diff --git a/CHANGELOG.md b/CHANGELOG.md index a2bb2e7e4..57848aa7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,417 @@ +# Version 24.38 - 2024-09-17 + +### Added 🆕 + +- chore: refs #7323 filter data by:jorgep +- chore: refs #7323 fix test by:jorgep +- chore: refs #7323 worker changes by:jorgep +- chore: refs #7323 worker changes wip by:jorgep +- chore: refs #7524 add select limit by:jorgep +- feat(AccessToken&ACL): refs #7547 upgrade security by:alexm +- feat: deleted code and redirect to Lilium by:Jon +- feat: refs #4515 New throw buy_checkItem by:guillermo +- feat: refs #6650 Added saleGroupLog by:guillermo +- feat: refs #6650 new itemShelvingLog by:guillermo +- feat: refs #6760 refs #actualiza campo nickname by:jgallego +- feat: refs #7277 fdescribe by:jgallego +- feat: refs #7277 fit by:jgallego +- feat: refs #7277 refundInvoices by:jgallego +- feat: refs #7277 test with warehouse by:jgallego +- feat: refs #7277 traducciones by:jgallego +- feat: refs #7277 transfer addressFk by:jgallego +- feat: refs #7532 Requested changes by:guillermo +- feat: refs #7564 Added proc by:guillermo +- feat: refs #7564 Added ticket_setVolumeItemCost by:guillermo +- feat: refs #7564 Added volume column by:guillermo +- feat: refs #7564 Fix version by:guillermo +- feat: refs #7564 Requested changes by:guillermo +- feat: refs #7615 setDeleted by:robert +- feat: refs #7650 Added no transfer lines to inventory entry and fixtures by:guillermo +- feat: refs #7650 Fix tests by:guillermo +- feat: refs #7747 Delete buyUltimate and buyUltimateFromInterval by:ivanm +- feat: refs #7759 Changed defined only of vn objects by:guillermo +- feat: refs #7759 Changed definer root to vn-admin by:guillermo +- feat: refs #7759 Changed name by:guillermo +- feat: refs #7759 Deleted version 11163-maroonEucalyptus by:guillermo +- feat: refs #7759 Revoke routine grants vn by:guillermo +- feat: refs #7811 Added comment by:guillermo +- feat: refs #7811 Added new params in datasources.json by:guillermo +- feat: refs #7898 Add column "floor" in vn.parking by:ivanm +- feat: refs #7898 Modify default by:ivanm +- feat: refs #7905 Added new method getBuysCsv by:guillermo +- feat: refs #7905 Added param toCsv by:guillermo +- feat: refs #7938 remove unnecessary insert in clientLog by:alexm +- feat: refs #7953 pullinfo (7953-devToTest_2438) by:alexm +- feat(salix): #7671 define isDestiny field in model by:Javier Segarra +- feat(salix): refs #7896 update version and changelog (origin/7896_down_devToTest_2436) by:Javier Segarra +- feat(salix): refs #7905 #7905 use getBuys toCSV flattened by:Javier Segarra +- feat(ssalix): refs #7671 #7671 checkDates by:Javier Segarra +- feat(ssalix): refs #7671 #7671 checkDates to present by:Javier Segarra +- feat: ticket 215005 Changed acl show transferClient by:guillermo + +### Changed 📦 + +- perf: refs #7671 improve showBadDates by:Javier Segarra +- perf(salix): refs #7671 #7671 imrpove and revert where changes by:Javier Segarra +- refactor: deleted e2e & added back descriptor and summary by:Jon + +### Fixed 🛠️ + +- chore: refs #7323 fix test by:jorgep +- feat: refs #7650 Added no transfer lines to inventory entry and fixtures by:guillermo +- fix by:guillermo +- fixes: refs #7760 collection problems by:Carlos Andrés +- fix merge dev (7407-workerMedical) by:alexm +- fix: refs #6727 No delete log tables data in clean procedures by:guillermo +- fix: refs #6897 back and tests by:carlossa +- fix: refs #6897 back by:carlossa +- fix: refs #6897 fix filter by:carlossa +- fix: refs #6897 fix json by:carlossa +- fix: refs #6897 travel filter by:carlossa +- fix: refs #6897 error test by:jgallego +- fix: refs #7323 fetch from right source by:jorgep +- fix: refs #7564 Deleted query by:guillermo +- fix: refs #7759 Added user 'vn'@'localhost' & grants by:guillermo +- fix: refs #7760 collection problems by:Carlos Andrés +- fix: refs #7760 tmp.ticketIPT by:Carlos Andrés +- fix: refs #7905 added comments to flatten.js by:guillermo +- fix: refs ##7905 Handle error by:guillermo +- fix(salix): refs #7905 #7905 use right fn to flatten data by:Javier Segarra +- perf(salix): refs #7671 #7671 imrpove and revert where changes by:Javier Segarra +- refs #6898 fix supplier remove by:carlossa +- refs #7407 fix acls fixtures by:carlossa +- test: fix connections e2e (7547-accessToken-security) by:alexm +- test: refs #7277 fix test proposal by:Javier Segarra +- test(salix): refs #7671 #7671 improve and revert where changes by:Javier Segarra + +# Version 24.36 - 2024-09-03 + +### Added 🆕 + +- chore: refs #7524 WIP limit call by:jorgep +- chore: refs #7524 modify ormConfig table col (origin/7524-warmfix-modifyColumn) by:jorgep +- feat(update-user): refs #7848 add twoFactor by:alexm +- feat: #3199 Requested changes by:guillermo +- feat: refs #3199 Added more scopes ticket_recalcByScope by:guillermo +- feat: refs #3199 Added one more scope ticket_recalcByScope by:guillermo +- feat: refs #3199 Created ticket_recalcItemTaxCountryByScope by:guillermo +- feat: refs #3199 Requested changes by:guillermo +- feat: refs #7346 add multiple feature by:jgallego +- feat: refs #7346 backTest checks new implementation by:jgallego +- feat: refs #7346 mas intuitivo by:jgallego +- feat: refs #7514 Changes to put srt log (origin/7514-srtLog) by:guillermo +- feat: refs #7524 add default limit (origin/7524-limitSelect) by:jorgep +- feat: refs #7524 add mock limit on find query by:jorgep +- feat: refs #7524 wip remote hooks by:jorgep +- feat: refs #7562 Requested changes by:guillermo +- feat: refs #7567 Changed time to call event by:guillermo +- feat: refs #7567 Requested changes by:guillermo +- feat: refs #7710 pr revision by:jgallego +- feat: refs #7710 test fixed (origin/7710-cloneWithTicketPackaging, 7710-cloneWithTicketPackaging) by:jgallego +- feat: refs #7712 Fix by:guillermo +- feat: refs #7712 Unify by:guillermo +- feat: refs #7712 sizeLimit (origin/7712-sizeLimit) by:guillermo +- feat: refs #7758 Add code mandateType and accountDetailType by:ivanm +- feat: refs #7758 Modify code lowerCamelCase and UNIQUE by:ivanm +- feat: refs #7758 accountDetailType fix deploy error by:ivanm +- feat: refs #7784 Changes in entry-order-pdf by:guillermo +- feat: refs #7784 Requested changes by:guillermo +- feat: refs #7799 Added Fk in vn.item.itemPackingTypeFk by:guillermo +- feat: refs #7800 Added company Fk by:guillermo +- feat: refs #7842 Added editorFk in vn.host by:guillermo +- feat: refs #7860 Update new packagings (origin/7860-newPackaging) by:guillermo +- feat: refs #7862 roadmap new fields by:ivanm +- feat: refs #7882 Added quadMindsConfig table by:guillermo + +### Changed 📦 + +- refactor: refs #7567 Fix and improvement by:guillermo +- refactor: refs #7567 Minor change by:guillermo +- refactor: refs #7756 Fix tests by:guillermo +- refactor: refs #7798 Drop bi.Greuges_comercial_detail by:guillermo +- refactor: refs #7848 adapt to lilium by:alexm + +### Fixed 🛠️ + +- feat: refs #7710 test fixed (origin/7710-cloneWithTicketPackaging, 7710-cloneWithTicketPackaging) by:jgallego +- feat: refs #7758 accountDetailType fix deploy error by:ivanm +- fix(salix): #7283 ItemFixedPrice duplicated (origin/7283_itemFixedPrice_duplicated) by:Javier Segarra +- fix: refs #7346 minor error (origin/7346, 7346) by:jgallego +- fix: refs #7355 remove and tests accounts (origin/7355-accountMigration2) by:carlossa +- fix: refs #7355 remove and tests accounts by:carlossa +- fix: refs #7524 default limit select by:jorgep +- fix: refs #7756 Foreign keys invoiceOut (origin/7756-fixRefFk) by:guillermo +- fix: refs #7756 id 0 by:guillermo +- fix: refs #7800 tpvMerchantEnable PRIMARY KEY (origin/7800-tpvMerchantEnable) by:guillermo +- fix: refs #7800 tpvMerchantEnable PRIMARY KEY by:guillermo +- fix: refs #7916 itemShelving_transfer (origin/test, test) by:guillermo +- fix: refs #pako Deleted duplicated version by:guillermo + +# Version 24.34 - 2024-08-20 + +### Added 🆕 + +- #6900 feat: clear empty by:jorgep +- #6900 feat: empty commit by:jorgep +- chore: refs #6900 beautify code by:jorgep +- chore: refs #6989 add config model by:jorgep +- feat workerActivity refs #6078 by:sergiodt +- feat: #6453 Refactor (origin/6453-orderConfirm) by:guillermo +- feat: #6453 Rollback always split by itemPackingType by:guillermo +- feat: deleted worker module code & redirect to Lilium by:Jon +- feat: refs #6453 Added new ticket search by:guillermo +- feat: refs #6453 Fixes by:guillermo +- feat: refs #6453 Minor changes by:guillermo +- feat: refs #6453 Requested changes by:guillermo +- feat: refs #6900 drop section by:jorgep +- feat: refs #7283 order by desc date by:jorgep +- feat: refs #7323 add locale by:jorgep +- feat: refs #7323 redirect to lilium by:jorgep +- feat: refs #7646 delete scannableCodeType by:robert +- feat: refs #7713 Created ACLLog by:guillermo +- feat: refs #7774 (origin/7774-ticket_cloneWeekly) by:robert +- feat: refs #7774 #7774 Changes ticket_cloneWeekly by:guillermo +- feat: refs #7774 ticket_cloneWeekly by:robert + +### Changed 📦 + +- refactor: refs #6453 Major changes by:guillermo +- refactor: refs #6453 Minor changes by:guillermo +- refactor: refs #6453 order_confirmWithUser by:guillermo +- refactor: refs #7646 #7646 Deleted scannable* variables productionConfig by:guillermo +- refactor: refs #7820 Deprecated silexACL by:guillermo + +### Fixed 🛠️ + +- #6900 fix: #6900 rectificative filter by:jorgep +- #6900 fix: empty commit by:jorgep +- fix(orders_filter): add sourceApp accepts by:alexm +- fix: refs #6130 commit lint by:pablone +- fix: refs #6453 order_confirmWithUser by:guillermo +- fix: refs #7283 sql by:jorgep +- fix: refs #7713 ACL Log by:guillermo +- test: fix claim descriptor redirect to lilium by:alexm +- test: fix ticket redirect to lilium by:alexm +- test: fix ticket sale e2e by:alexm + +# Version 24.32 - 2024-08-06 + +### Added 🆕 + +- chore: refs #7197 add supplierActivityFk filter by:jorgep +- feat checkExpeditionPrintOut refs #7751 by:sergiodt +- feat(defaulter_filter): add department by:alexm +- feat: redirect to lilium page not found by:alexm +- feat: refactor buyUltimate refs #7736 by:Carlos Andrés +- feat: refs #6403 add delete by:pablone +- feat: refs #7126 Added manaClaim calc by:guillermo +- feat: refs #7126 Refactor and added columns in bs.waste table & proc by:guillermo +- feat: refs #7197 filter by correcting by:jorgep +- feat: refs #7297 add new columns by:pablone +- feat: refs #7356 new parameters in sql for Weekly tickets front by:Jon +- feat: refs #7401 redirect lilium by:pablone +- feat: refs #7511 Fix tests by:guillermo +- feat: refs #7511 Rename to multiConfig tables by:guillermo +- feat: refs #7589 Added display (item_valuateInventory) by:guillermo +- feat: refs #7589 Added vItemTypeFk & vItemCategoryFk (item_valuateInventory) by:guillermo +- feat: refs #7681 Changes by:guillermo +- feat: refs #7681 Optimization and refactor by:guillermo +- feat: refs #7683 drop temporary table by:robert +- feat: refs #7683 productionControl by:robert +- feat: refs #7728 Added throw due date by:guillermo +- feat: refs #7740 Ticket before update added restriction by:guillermo +- feat(salix): #7648 Add field for endpoint as buyLabel report by:Javier Segarra +- feat(salix): #7648 remove white line by:Javier Segarra +- feat: tabla config dias margen vctos. refs #7728 by:Carlos Andrés + +### Changed 📦 + +- eat: refactor buyUltimate refs #7736 by:Carlos Andrés +- feat: refactor buyUltimate refs #7736 by:Carlos Andrés +- feat: refs #7681 Optimization and refactor by:guillermo +- refactor: refs #7126 Requested changes by:guillermo +- refactor: refs #7511 Minor change by:guillermo +- refactor: refs #7640 Multipleinventory available by:guillermo +- refactor: refs #7681 Changes by:guillermo +- refactor: refs #7681 Requested changes by:guillermo + +### Fixed 🛠️ + +- add prefix (hotFix_liliumRedirection) by:alexm +- fix(client_filter): add recovery by:alexm +- fix: defaulter filter correct sql (6943-fix_defaulter_filter) by:alexm +- fix(deletExpeditions): merge test → dev by:guillermo +- fix: refs #6403 fix mrw cancel shipment return type by:pablone +- fix: refs #7126 Added addressWaste type by:guillermo +- fix: refs #7126 Fix by:guillermo +- fix: refs #7126 Minor change by:guillermo +- fix: refs #7126 Primary key no unique data by:guillermo +- fix: refs #7126 Slow update by:guillermo +- fix: refs #7511 Minor change by:guillermo +- fix: refs #7546 Deleted insert util.binlogQueue by:guillermo +- fix: refs #7811 Variables pm2 by:guillermo +- fix: without path by:alexm + +# Version 24.28 - 2024-07-09 + +### Added 🆕 + +- feat boxPicking refs #7357 by:sergiodt +- feat boxPicking refs #7357 (origin/7357_dipole_review) by:sergiodt +- feat:concurrency issue refs #6861 by:Carlos Andrés +- feat expeditionPalletPrint refs #5210 by:sergiodt +- feat front-reservas refs #6861 (origin/6861-Reservas-front) by:sergiodt +- feat itemShelving_filterBuyer refs #7023 by:sergiodt +- feat itemShelvingLog refs #7168 by:sergiodt +- feat itemShelvingSale refs #6861 by:sergiodt +- feat: previas con reserva refs #6861 by:Carlos Andrés +- feat: previas con sitema de reservas refs #6861 by:Carlos Andrés +- feat: previas con sitema de reservas refs #6861 (origin/6861-Pasar-modo-trabajo-de-previa-a-reservas) by:Carlos Andrés +- feat refactor setParking REGEXP refs #7575 (origin/7575_setParking_regExp) by:sergiodt +- feat: refs #6238 add travelKgPercentage table and model (origin/6238-addPercentage) by:jorgep +- feat: refs #6286 check if is teamBoss (origin/6286-setRightWorkerTimeControlAcls) by:jorgep +- feat: refs #6701 Fix error by:guillermo +- feat: refs #6861 trigger by:sergiodt +- feat: refs #7027 mailError managed by:jgallego +- feat: refs #7168 Added vRecords param in proc by:guillermo +- feat: refs #7168 Minor change by:guillermo +- feat: refs #7216 logUnpaid (origin/7216-clientUnpaid) by:jgallego +- feat: refs #7216 triggers by:jgallego +- feat: refs #7296 by:robert +- feat: refs #7296 drop column expeditionTruckFk by:robert +- feat: refs #7490 Changes (origin/7490-duaInvoiceInBooking) by:guillermo +- feat: refs #7545 Deleted hasIncoterms client column (origin/7545-hasIncoterms) by:guillermo +- feat: refs #7555 remove account.password__ by:alexm +- feat: return sql check error by:alexm +- feat roadmap refs #7195 by:sergiodt +- #refs 5890 feat:add assignCollection by:sergiodt +- refs#5890 feat: delete trigger and modify getTickets by:sergiodt +- refs #5890 feat:itemShelving_add by:sergiodt +- refs #5890 feat:reserves by:sergiodt +- refs #5890 feat:trigger by:sergiodt +- refs #5890 feat: triggers by:sergiodt +- refs #6861 feat: getLock by:sergiodt +- refs #6861 feat: obsrevation by:sergiodt +- refs #6861 feat: previas a reservas by:sergiodt +- refs #6861 feat:reserve previos by:sergiodt +- refs #6861 feat: reservePrevious by:sergiodt +- refs #6861 feat:reserveWithReservation by:sergiodt +- refs #6861 feat:sectoCollection reserve by:sergiodt +- refs #6861 feat: skipTest by:sergiodt +- refs #6861 feat: trigger by:sergiodt + +### Changed 📦 + +- feat refactor setParking REGEXP refs #7575 (origin/7575_setParking_regExp) by:sergiodt +- refactor: refs #5447 changed models by:Jon +- refactor: refs #6238 drop useless round by:jorgep +- refactor: refs #6286 replace name by:jorgep +- refactor: refs #6701 Refactor claim_ratio_routine by:guillermo +- refactor: refs #7490 Added final update by:guillermo +- refactor: refs #7490 Deleted update duaInvoiceInBooking by:guillermo +- refactor: refs #7490 Minor changes by:guillermo +- refactor: refs #7519 Minor change by:guillermo + +### Fixed 🛠️ + +- acls, fixtures, models by:carlossa +- fix: refs #6238 delete unused SQL script by:jorgep +- fix: refs #6238 insert ignore by:jorgep +- fix: refs #6238 use scheme by:jorgep +- fix: refs #6286 replace id for reason by:jorgep +- fix: refs #6286 update WorkerTimeControl permissions by:jorgep +- fix(WorkerIncome): refs #7409 fix models by:alexm +- refs #5890 fix: dev by:sergiodt +- refs #6897 fix entry Salix by:carlossa +- refs #6897 fix es.yml by:carlossa +- refs #6897 fix redirection by:carlossa +- refs #6897 fix remove by:carlossa +- refs #7406 fix back by:carlossa +- refs #7406 fix pr by:carlossa +- refs #7409 fix acls by:carlossa +- refs #7409 fix back (origin/7409-workerIncome) by:carlossa +- refs #7409 fix pr by:carlossa + +# Version 24.24 - 2024-06-11 + +### Added 🆕 + +- 6281 feat:buyFk in itemShekving by:sergiodt +- 6281 feat:buyFk in itemShelving by:sergiodt +- feat: #6408 tests by:jgallego +- feat: packaging refs #4021 (origin/4021_packaging) by:sergiodt +- feat: refs #6021 add new field by:pablone +- feat: refs #6281 change fixtures by:robert +- feat: refs # 6408 test ok (origin/6408-rocketChat) by:jgallego +- feat: refs #6477 productionConfig add column by:robert +- feat: refs #6600 add column (origin/6600-createItemPhotoComment) by:jorgep +- feat: refs #6600 Add photoMotivation column to item table and create itemPhotoComment table by:jorgep +- feat: refs #6889 add back tests by:jorgep +- feat: refs #6889 fixtures & models by:jorgep +- feat : refs #6889 wip: check if is productionReviewer or owner by:jorgep +- feat: refs #6942 set false isBooed & ledger by:jorgep +- feat: refs #6942 toUnbook by:jorgep +- feat: refs #6942 xdiario fixtures by:jorgep +- feat: refs #7398 Change by:guillermo +- feat: refs #7438 Added volume to item_valuateInventory by:guillermo +- feat: refs #7438 Requested changes and little changes by:guillermo +- refs #6281 feat:buyFk in itemShelving by:sergiodt +- feat: refs #6449 item ID is displayed in the sale line by:jorgep + +### Changed 📦 + +- refactor: refs #6600 add space by:jorgep +- refactor: refs #6889 improve file loading logic by:jorgep +- refactor: refs #6889 sale tests e2e by:jorgep +- refactor: refs #6889 script sql (origin/6889-dropAddSaleByCode) by:jorgep +- refactor: refs #6889 use addSale by:jorgep +- refactor: refs #6942 toUnbook & drop buyer acls by:jorgep +- refactor: refs #7398 Refactor and change ekt_scan (origin/7398-ektScan) by:guillermo +- refactor: refs #7486 Optimized procs by:guillermo + +### Fixed 🛠️ + +- feat: refs #6281 change fixtures by:robert +- feat: refs #6889 fixtures & models by:jorgep +- feat: refs #6942 xdiario fixtures by:jorgep +- fix: checking process.env.NODE_ENV by:alexm +- fix: en translations by:alexm +- fix: move to boot (origin/7421-fix_checking_NODE_ENV, 7421-fix_checking_NODE_ENV) by:alexm +- fix: refs #6095 filter by refFk null by:pablone +- fix: refs #6600 rollback by:jorgep +- fix: refs #6889 allocate 'productionReviewer' role to revision dep. workers & check if is owner or reviewer by:jorgep +- fix: refs #6889 check if has collection or sectorCollection by:jorgep +- fix: refs #6889 e2e tests by:jorgep +- fix: refs #6889 fix back tests by:jorgep +- fix: refs #6889 modify fixtures by:jorgep +- fix: refs #6889 rollback by:jorgep +- fix: refs #6942 acls & back by:jorgep +- fix: refs #6942 add deleteById acl by:jorgep +- fix: refs #6942 add test & change column name by:jorgep +- fix: refs #6942 create invoiceIn acl by:jorgep +- fix: refs #6942 delete by:jorgep +- fix: refs #6942 drop quotes by:jorgep +- fix : refs #6942 remove grafana update priv by:jorgep +- fix: refs #6942 revoke update isBooked by:jorgep +- fix: refs #6942 toBook/toUnbook by:jorgep +- fix: refs #7442 Fix kubernetes deploy by:Juan Ferrer Toribio +- fix(salix): refs #7272 #7272 Add aclService in routes.js by:Javier Segarra +- fix(salix): refs #7272 #7272 Back validateToken endpoint by:Javier Segarra +- fix(salix): refs #7272 #7272 Bug when acl not loaded by:Javier Segarra +- fix(salix): refs #7272 #7272 Call validateToken by:Javier Segarra +- fix(salix): refs #7272 #7272 Errors when Token not exists by:Javier Segarra +- fix(salix): refs #7272 #7272 Front retry calls by:Javier Segarra +- fix(salix): refs #7272 #7272 i18n Error by:Javier Segarra +- fix(salix): refs #7272 #7272 Remove aclService from auth.js by:Javier Segarra +- fix: simplify by:alexm +- fix traduction & e2e by:carlossa +- refs #6820 fix back by:carlossa +- refs #6820 fix pr by:carlossa +- refs #6832 fix: ToItem (origin/6832_refactorBackToItem) by:Sergio De la torre +- refs #7292 fix tback by:carlossa +- refs #7296 fix pr errors, trad by:carlossa +- test(salix): refs #7272 #7272 fix renew-token.spec by:Javier Segarra + # Changelog diff --git a/Jenkinsfile b/Jenkinsfile index 6f0a642b4..19f47c5b0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,6 +24,7 @@ node { FROM_GIT = env.JOB_NAME.startsWith('gitea/') RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT RUN_BUILD = PROTECTED_BRANCH && FROM_GIT + // https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables echo "NODE_NAME: ${env.NODE_NAME}" echo "WORKSPACE: ${env.WORKSPACE}" @@ -59,7 +60,6 @@ pipeline { } environment { PROJECT_NAME = 'salix' - STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}" } stages { stage('Install') { @@ -103,7 +103,7 @@ pipeline { NODE_ENV = '' } steps { - sh 'node back/tests.js --ci --junit --network jenkins' + sh 'node back/tests.js --junit' } post { always { @@ -121,7 +121,7 @@ pipeline { steps { script { def packageJson = readJSON file: 'package.json' - env.VERSION = packageJson.version + env.VERSION = "${packageJson.version}-build${env.BUILD_ID}" } sh 'docker-compose build back' } @@ -159,7 +159,7 @@ pipeline { steps { script { def packageJson = readJSON file: 'package.json' - env.VERSION = packageJson.version + env.VERSION = "${packageJson.version}-build${env.BUILD_ID}" } sh 'gulp build' sh 'docker-compose build front' @@ -179,7 +179,7 @@ pipeline { steps { script { def packageJson = readJSON file: 'package.json' - env.VERSION = packageJson.version + env.VERSION = "${packageJson.version}-build${env.BUILD_ID}" } sh 'docker login --username $CREDENTIALS_USR --password $CREDENTIALS_PSW $REGISTRY' sh 'docker-compose push' @@ -203,19 +203,23 @@ pipeline { sh 'npx myt push $NODE_ENV --force --commit' } } - stage('Docker') { + stage('Kubernetes') { when { expression { FROM_GIT } } - environment { - DOCKER_HOST = "${env.SWARM_HOST}" - } steps { script { def packageJson = readJSON file: 'package.json' - env.VERSION = packageJson.version + env.VERSION = "${packageJson.version}-build${env.BUILD_ID}" + } + withKubeConfig([ + serverUrl: "$KUBERNETES_API", + credentialsId: 'kubernetes', + namespace: 'salix' + ]) { + sh 'kubectl set image deployment/salix-back-$BRANCH_NAME salix-back-$BRANCH_NAME=$REGISTRY/salix-back:$VERSION' + sh 'kubectl set image deployment/salix-front-$BRANCH_NAME salix-front-$BRANCH_NAME=$REGISTRY/salix-front:$VERSION' } - sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}" } } } diff --git a/README.md b/README.md index 53478f425..2ad83c2e4 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,16 @@ Required applications. * Node.js * Docker * Git +* MYT You will need to install globally the following items. ``` $ sudo npm install -g jest gulp-cli ``` +After installing MYT you will need the following item. +``` +$ apt install libkrb5-dev libssl-dev +``` ## Installing dependencies and launching @@ -23,7 +28,7 @@ Pull from repository. Run this commands on project root directory to install Node dependencies. ``` -$ npm install +$ pnpm install $ gulp install ``` diff --git a/back/methods/collection/assign.js b/back/methods/collection/assign.js index 0484eb5a8..f246043b8 100644 --- a/back/methods/collection/assign.js +++ b/back/methods/collection/assign.js @@ -20,9 +20,14 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const [, , [{collectionFk}]] = - await Self.rawSql('CALL vn.collection_assign(?, @vCollectionFk); SELECT @vCollectionFk collectionFk', - [userId], myOptions); + const randStr = Math.random().toString(36).substring(3); + const result = await Self.rawSql(` + CALL vn.collection_assign(?, @vCollectionFk); + SELECT @vCollectionFk ? + `, [userId, randStr], myOptions); + + // Por si entra en SELECT FOR UPDATE una o varias veces + const collectionFk = result.find(item => item[0]?.[randStr] !== undefined)?.[0]?.[randStr]; if (!collectionFk) throw new UserError('There are not picking tickets'); await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions); diff --git a/back/methods/collection/assignCollection.js b/back/methods/collection/assignCollection.js new file mode 100644 index 000000000..2a7ec9ad5 --- /dev/null +++ b/back/methods/collection/assignCollection.js @@ -0,0 +1,36 @@ +const UserError = require('vn-loopback/util/user-error'); +module.exports = Self => { + Self.remoteMethodCtx('assignCollection', { + description: 'Assign a collection', + accessType: 'WRITE', + http: { + path: `/assignCollection`, + verb: 'POST' + }, + returns: { + type: ['object'], + root: true + }, + }); + + Self.assignCollection = async(ctx, options) => { + const userId = ctx.req.accessToken.userId; + const myOptions = {userId}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const randStr = Math.random().toString(36).substring(3); + const result = await Self.rawSql(` + CALL vn.collection_getAssigned(?, @vCollectionFk); + SELECT @vCollectionFk ? + `, [userId, randStr], myOptions); + + const collectionFk = result.find(item => item[0]?.[randStr] !== undefined)?.[0]?.[randStr]; + + if (!collectionFk) throw new UserError('There are not picking tickets'); + await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions); + + return collectionFk; + }; +}; diff --git a/back/methods/collection/getSales.js b/back/methods/collection/getSales.js index fd5e3d085..a9e5f2e60 100644 --- a/back/methods/collection/getSales.js +++ b/back/methods/collection/getSales.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethodCtx('getSales', { - description: 'Get sales from ticket or collection', + description: 'Get sales from ticket, collection or sectorCollection', accessType: 'READ', accepts: [ { @@ -60,15 +60,17 @@ module.exports = Self => { if (print) await Self.rawSql('CALL vn.collection_printSticker(?,NULL)', [id], myOptions); for (let ticket of tickets) { - let observations = ticket.observaciones.split(' '); + if (ticket.observaciones) { + let observations = ticket.observaciones.split(' '); - for (let observation of observations) { - const salesPerson = ticket.salesPersonFk; - if (observation.startsWith('#') || observation.startsWith('@')) { - await models.Chat.send(ctx, - observation, - $t('ticketCommercial', {ticket: ticket.ticketFk, salesPerson}) - ); + for (let observation of observations) { + const salesPerson = ticket.salesPersonFk; + if (observation.startsWith('#') || observation.startsWith('@')) { + await models.Chat.send(ctx, + observation, + $t('ticketCommercial', {ticket: ticket.ticketFk, salesPerson}) + ); + } } } } diff --git a/back/methods/collection/getTickets.js b/back/methods/collection/getTickets.js index 50117b954..2a2b67524 100644 --- a/back/methods/collection/getTickets.js +++ b/back/methods/collection/getTickets.js @@ -37,6 +37,7 @@ module.exports = Self => { const promises = []; const [tickets] = await Self.rawSql(`CALL vn.collection_getTickets(?)`, [id], myOptions); + const sales = await Self.rawSql(` SELECT s.ticketFk, sgd.saleGroupFk, @@ -56,19 +57,20 @@ module.exports = Self => { ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY pickingOrder) currentItemShelving, COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) totalItemShelving, sh.code, - IFNULL(p2.code, p.code) parkingCode, - IFNULL(p2.pickingOrder, p.pickingOrder) pickingOrder, + p2.code parkingCode, + p2.pickingOrder pickingOrder, + p.code parkingCodePrevia, + p.pickingOrder pickingOrderPrevia, iss.id itemShelvingSaleFk, iss.isPicked FROM ticketCollection tc LEFT JOIN collection c ON c.id = tc.collectionFk - JOIN ticket t ON t.id = tc.ticketFk - JOIN sale s ON s.ticketFk = t.id + JOIN sale s ON s.ticketFk = tc.ticketFk LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id LEFT JOIN saleGroup sg ON sg.id = sgd.saleGroupFk LEFT JOIN parking p2 ON p2.id = sg.parkingFk JOIN item i ON i.id = s.itemFk - LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id + JOIN itemShelvingSale iss ON iss.saleFk = s.id LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk LEFT JOIN shelving sh ON sh.code = ish.shelvingFk LEFT JOIN parking p ON p.id = sh.parkingFk @@ -76,17 +78,57 @@ module.exports = Self => { LEFT JOIN origin o ON o.id = i.originFk WHERE tc.collectionFk = ? GROUP BY s.id, ish.id, p.code, p2.code - ORDER BY pickingOrder;`, [id], myOptions); - + UNION ALL + SELECT s.ticketFk, + sgd.saleGroupFk, + s.id saleFk, + s.itemFk, + i.longName, + i.size, + ic.color, + o.code origin, + ish.packing, + ish.grouping, + s.isAdded, + s.originalQuantity, + s.quantity, + iss.quantity, + SUM(iss.quantity) OVER (PARTITION BY s.id ORDER BY ish.id), + ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY p.pickingOrder), + COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) , + sh.code, + p2.code, + p2.pickingOrder, + p.code, + p.pickingOrder, + iss.id itemShelvingSaleFk, + iss.isPicked + FROM sectorCollection sc + JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id + JOIN saleGroup sg ON sg.id = ss.saleGroupFk + LEFT JOIN saleGroupDetail sgd ON sgd.saleGroupFk = sg.id + JOIN sale s ON s.id = sgd.saleFk + LEFT JOIN parking p2 ON p2.id = sg.parkingFk + JOIN item i ON i.id = s.itemFk + JOIN itemShelvingSale iss ON iss.saleFk = s.id + LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + LEFT JOIN shelving sh ON sh.code = ish.shelvingFk + LEFT JOIN parking p ON p.id = sh.parkingFk + LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk + LEFT JOIN origin o ON o.id = i.originFk + WHERE sc.id = ? + AND sgd.saleGroupFk + GROUP BY s.id, ish.id, p.code, p2.code`, [id, id], myOptions); if (print) await Self.rawSql(`CALL vn.collection_printSticker(?, ?)`, [id, null], myOptions); const collection = {collectionFk: id, tickets: []}; + if (tickets && tickets.length) { for (const ticket of tickets) { const ticketId = ticket.ticketFk; - if (ticket.observaciones != '') { - for (observation of ticket.observaciones.split(' ')) { + if (ticket.observation) { + for (observation of ticket.observation?.split(' ')) { if (['#', '@'].includes(observation.charAt(0))) { promises.push(Self.app.models.Chat.send(ctx, observation, $t('The ticket is in preparation', { @@ -100,11 +142,11 @@ module.exports = Self => { if (sales && sales.length) { const barcodes = await Self.rawSql(` SELECT s.id saleFk, b.code, c.id - FROM vn.sale s - LEFT JOIN vn.itemBarcode b ON b.itemFk = s.itemFk - LEFT JOIN vn.buy c ON c.itemFk = s.itemFk - LEFT JOIN vn.entry e ON e.id = c.entryFk - LEFT JOIN vn.travel tr ON tr.id = e.travelFk + FROM sale s + LEFT JOIN itemBarcode b ON b.itemFk = s.itemFk + LEFT JOIN buy c ON c.itemFk = s.itemFk + LEFT JOIN entry e ON e.id = c.entryFk + LEFT JOIN travel tr ON tr.id = e.travelFk WHERE s.ticketFk = ? AND tr.landed >= util.VN_CURDATE() - INTERVAL 1 YEAR`, [ticketId], myOptions); diff --git a/back/methods/collection/spec/assignCollection.spec.js b/back/methods/collection/spec/assignCollection.spec.js new file mode 100644 index 000000000..7cdcd6cb6 --- /dev/null +++ b/back/methods/collection/spec/assignCollection.spec.js @@ -0,0 +1,36 @@ +const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); + +describe('ticket assignCollection()', () => { + let ctx; + let options; + let tx; + beforeEach(async() => { + ctx = { + req: { + accessToken: {userId: 1106}, + headers: {origin: 'http://localhost'}, + __: value => value + }, + args: {} + }; + + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: ctx.req}); + + options = {transaction: tx}; + tx = await models.Sale.beginTransaction({}); + options.transaction = tx; + }); + + afterEach(async() => { + if (tx) await tx.rollback(); + }); + + it('should throw an error when there is not picking tickets', async() => { + try { + await models.Collection.assignCollection(ctx, options); + } catch (e) { + expect(e.message).toEqual('There are not picking tickets'); + } + }); +}); diff --git a/back/methods/collection/spec/getSales.spec.js b/back/methods/collection/spec/getSales.spec.js index e6205cc79..520657ec1 100644 --- a/back/methods/collection/spec/getSales.spec.js +++ b/back/methods/collection/spec/getSales.spec.js @@ -4,15 +4,7 @@ describe('collection getSales()', () => { const collectionOrTicketFk = 999999; const print = true; const source = 'CHECKER'; - - beforeAll(() => { - ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'http://localhost'}, - } - }; - }); + const ctx = beforeAll.getCtx(); it('should return a collection with tickets, placements and barcodes settled correctly', async() => { const tx = await models.Collection.beginTransaction({}); diff --git a/back/methods/collection/spec/getTickets.spec.js b/back/methods/collection/spec/getTickets.spec.js index e6b9e6a17..0e006706d 100644 --- a/back/methods/collection/spec/getTickets.spec.js +++ b/back/methods/collection/spec/getTickets.spec.js @@ -1,15 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('collection getTickets()', () => { - let ctx; - beforeAll(async() => { - ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'http://localhost'} - } - }; - }); + const ctx = beforeAll.getCtx(); it('should get tickets, sales and barcodes from collection', async() => { const tx = await models.Collection.beginTransaction({}); @@ -26,8 +18,8 @@ describe('collection getTickets()', () => { expect(collectionTickets.tickets[1].ticketFk).toEqual(2); expect(collectionTickets.tickets[2].ticketFk).toEqual(23); expect(collectionTickets.tickets[0].sales[0].ticketFk).toEqual(1); - expect(collectionTickets.tickets[0].sales[1].ticketFk).toEqual(1); - expect(collectionTickets.tickets[0].sales[2].ticketFk).toEqual(1); + expect(collectionTickets.tickets[1].sales.length).toEqual(0); + expect(collectionTickets.tickets[2].sales.length).toEqual(0); expect(collectionTickets.tickets[0].sales[0].Barcodes.length).toBeTruthy(); await tx.rollback(); diff --git a/back/methods/collection/spec/setSaleQuantity.spec.js b/back/methods/collection/spec/setSaleQuantity.spec.js index b563f5b19..00ddae0fe 100644 --- a/back/methods/collection/spec/setSaleQuantity.spec.js +++ b/back/methods/collection/spec/setSaleQuantity.spec.js @@ -1,20 +1,7 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('setSaleQuantity()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); it('should change quantity sale', async() => { const tx = await models.Ticket.beginTransaction({}); diff --git a/back/methods/dms/updateFile.js b/back/methods/dms/updateFile.js index cfc4c322f..68149ef62 100644 --- a/back/methods/dms/updateFile.js +++ b/back/methods/dms/updateFile.js @@ -38,7 +38,7 @@ module.exports = Self => { { arg: 'hasFile', type: 'Boolean', - description: 'True if has an attached file' + description: 'True if has the original in paper' }, { arg: 'hasFileAttached', diff --git a/back/methods/edi/updateData.js b/back/methods/edi/updateData.js index 6bebad1e4..d8395cbc4 100644 --- a/back/methods/edi/updateData.js +++ b/back/methods/edi/updateData.js @@ -24,7 +24,7 @@ module.exports = Self => { try { const options = {transaction: tx, userId: ctx.req.accessToken.userId}; - const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileConfig', null, options); + const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileMultiConfig', null, options); const updatableFiles = []; for (const file of files) { @@ -54,7 +54,7 @@ module.exports = Self => { const tables = await Self.rawSql(` SELECT fileName, toTable, file - FROM edi.tableConfig + FROM edi.tableMultiConfig WHERE file IN (?)`, [fileNames], options); for (const table of tables) { @@ -85,9 +85,9 @@ module.exports = Self => { for (const file of updatableFiles) { console.log(`Updating file ${file.name} checksum...`); await Self.rawSql(` - UPDATE edi.fileConfig - SET checksum = ? - WHERE name = ?`, + UPDATE edi.fileMultiConfig + SET checksum = ? + WHERE name = ?`, [file.checksum, file.name], options); } @@ -228,7 +228,7 @@ module.exports = Self => { await Self.rawSql(sqlTemplate, [filePath], options); await Self.rawSql(` - UPDATE edi.tableConfig + UPDATE edi.tableMultiConfig SET updated = ? WHERE fileName = ? `, [Date.vnNew(), baseName], options); diff --git a/back/methods/mrw-config/cancelShipment.ejs b/back/methods/mrw-config/cancelShipment.ejs index 9ef401bc8..bc0662981 100644 --- a/back/methods/mrw-config/cancelShipment.ejs +++ b/back/methods/mrw-config/cancelShipment.ejs @@ -2,7 +2,7 @@ <%= mrw.franchiseCode %> - <%= mrw.subscriberCode %> + <%= clientType %> <%= mrw.user %> <%= mrw.password %> diff --git a/back/methods/mrw-config/cancelShipment.js b/back/methods/mrw-config/cancelShipment.js index 86bbb7410..56d206529 100644 --- a/back/methods/mrw-config/cancelShipment.js +++ b/back/methods/mrw-config/cancelShipment.js @@ -13,7 +13,7 @@ module.exports = Self => { required: true }], returns: { - type: ['object'], + type: 'boolean', root: true }, http: { @@ -27,9 +27,9 @@ module.exports = Self => { const mrw = await models.MrwConfig.findOne(); const {externalId} = await models.Expedition.findById(expeditionFk); - + const clientType = await models.MrwConfig.getClientType(expeditionFk); const template = fs.readFileSync(__dirname + '/cancelShipment.ejs', 'utf-8'); - const renderedXml = ejs.render(template, {mrw, externalId}); + const renderedXml = ejs.render(template, {mrw, externalId, clientType}); const response = await axios.post(mrw.url, renderedXml, { headers: { 'Content-Type': 'application/soap+xml; charset=utf-8' @@ -39,6 +39,7 @@ module.exports = Self => { const xmlString = response.data; const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); - return xmlDoc.getElementsByTagName('Mensaje')[0].textContent; + const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent; + return result.toLowerCase().includes('se ha cancelado correctamente'); }; }; diff --git a/back/methods/mrw-config/createShipment.ejs b/back/methods/mrw-config/createShipment.ejs index bf8a07dab..52ccc859c 100644 --- a/back/methods/mrw-config/createShipment.ejs +++ b/back/methods/mrw-config/createShipment.ejs @@ -3,7 +3,7 @@ <%= mrw.franchiseCode %> - <%= mrw.subscriberCode %> + <%= clientType %> <%= mrw.user %> <%= mrw.password %> @@ -25,17 +25,25 @@ <%= expeditionData.fi %> <%= expeditionData.clientName %> - <%= expeditionData.phone %> + <%= expeditionData.mobile %> + <%= expeditionData.deliveryObservation %> <%= expeditionData.created %> - <%= expeditionData.expeditionDataId %> + <%= expeditionData.reference %> <%= expeditionData.serviceType %> 1 <%= expeditionData.weekDays %> - <%= expeditionData.kg %> + + + <%= mrw.defaultHeight %> + <%= mrw.defaultLength %> + <%= mrw.defaultWidth %> + <%= mrw.defaultWeight %> + + diff --git a/back/methods/mrw-config/createShipment.js b/back/methods/mrw-config/createShipment.js index 081a83382..2ebb80774 100644 --- a/back/methods/mrw-config/createShipment.js +++ b/back/methods/mrw-config/createShipment.js @@ -1,7 +1,3 @@ -const axios = require('axios'); -const {DOMParser} = require('xmldom'); -const fs = require('fs'); -const ejs = require('ejs'); const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { @@ -23,29 +19,27 @@ module.exports = Self => { } }); - Self.createShipment = async(expeditionFk, options) => { - const myOptions = {}; - let tx; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - + Self.createShipment = async expeditionFk => { const models = Self.app.models; - const mrw = await models.MrwConfig.findOne(null, myOptions); + const mrw = await Self.getConfig(); + const clientType = await models.MrwConfig.getClientType(expeditionFk); - if (!mrw) - throw new UserError(`Some mrwConfig parameters are not set`); + const today = Date.vnNew(); + const [hours, minutes] = mrw?.expeditionDeadLine ? mrw.expeditionDeadLine.split(':').map(Number) : [0, 0]; + + const deadLine = Date.vnNew(); + deadLine.setHours(hours, minutes, 0); + + if (today > deadLine && (!mrw.notified || mrw.notified.setHours(0, 0, 0, 0) !== today.setHours(0, 0, 0, 0))) { + await models.NotificationQueue.create({notificationFk: 'mrw-deadline'}); + await mrw.updateAttributes({notified: Date.vnNow()}); + } const query = `SELECT CASE co.code WHEN 'ES' THEN a.postalCode - WHEN 'PT' THEN LEFT(a.postalCode, 4) + WHEN 'PT' THEN LEFT(a.postalCode, mc.portugalPostCodeTrim) WHEN 'AD' THEN REPLACE(a.postalCode, 'AD', '00') END postalCode, a.city, @@ -53,62 +47,45 @@ module.exports = Self => { co.code countryCode, c.fi, c.name clientName, - c.phone, + IFNULL(a.mobile, c.mobile) mobile, DATE_FORMAT(t.shipped, '%d/%m/%Y') created, t.shipped, - e.id expeditionId, - LPAD(IF(mw.params IS NULL, ms.serviceType, mw.serviceType), 4 ,'0') serviceType, - IF(mw.weekdays, 'S', 'N') weekDays + CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference, + LPAD(IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth, '0') serviceType, + IF(mw.weekdays, 'S', 'N') weekDays, + ta.description deliveryObservation FROM expedition e JOIN ticket t ON e.ticketFk = t.id JOIN agencyMode am ON am.id = t.agencyModeFk JOIN mrwService ms ON ms.agencyModeCodeFk = am.code - LEFT JOIN mrwServiceWeekday mw ON mw.weekdays = DATE_FORMAT(t.shipped, '%a') + LEFT JOIN mrwServiceWeekday mw ON mw.agencyModeCodeFk = am.code + AND mw.weekDays & (1 << WEEKDAY(t.landed)) JOIN client c ON t.clientFk = c.id JOIN address a ON t.addressFk = a.id + LEFT JOIN ticketObservation ta ON ta.ticketFk = t.id + AND ta.observationTypeFk IN (SELECT id FROM observationType ot WHERE ot.code = 'agency') JOIN province p ON a.provinceFk = p.id JOIN country co ON co.id = p.countryFk + JOIN mrwConfig mc WHERE e.id = ? LIMIT 1`; - const [expeditionData] = await Self.rawSql(query, [expeditionFk], myOptions); + const [expeditionData] = await Self.rawSql(query, [expeditionFk]); - if (!expeditionData) - throw new UserError(`This expedition is not a MRW shipment`); - - const today = Date.vnNew(); - today.setHours(0, 0, 0, 0); - if (expeditionData?.shipped.setHours(0, 0, 0, 0) < today) + if (expeditionData?.shipped.setHours(0, 0, 0, 0) < today.setHours(0, 0, 0, 0)) throw new UserError(`This ticket has a shipped date earlier than today`); - const shipmentResponse = await sendXmlDoc('createShipment', {mrw, expeditionData}, 'application/soap+xml'); - const shipmentId = getTextByTag(shipmentResponse, 'NumeroEnvio'); + const shipmentResponse = await Self.sendXmlDoc( + __dirname + `/createShipment.ejs`, + {mrw, expeditionData, clientType}, + 'application/soap+xml' + ); + const shipmentId = Self.getTextByTag(shipmentResponse, 'NumeroEnvio'); - if (!shipmentId) - throw new UserError(getTextByTag(shipmentResponse, 'Mensaje')); + if (!shipmentId) throw new UserError(Self.getTextByTag(shipmentResponse, 'Mensaje')); - const getLabelResponse = await sendXmlDoc('getLabel', {mrw, shipmentId}, 'text/xml'); - const file = getTextByTag(getLabelResponse, 'EtiquetaFile'); - - if (tx) await tx.commit(); + const file = await models.MrwConfig.getLabel(shipmentId, clientType); return {shipmentId, file}; }; - - function getTextByTag(xmlDoc, tag) { - return xmlDoc?.getElementsByTagName(tag)[0]?.textContent; - } - - async function sendXmlDoc(xmlDock, params, contentType) { - const parser = new DOMParser(); - - const xmlTemplate = fs.readFileSync(__dirname + `/${xmlDock}.ejs`, 'utf-8'); - const renderedTemplate = ejs.render(xmlTemplate, params); - const data = await axios.post(params.mrw.url, renderedTemplate, { - headers: { - 'Content-Type': `${contentType}; charset=utf-8` - } - }); - return parser.parseFromString(data.data, 'text/xml'); - } }; diff --git a/back/methods/mrw-config/getLabel.ejs b/back/methods/mrw-config/getLabel.ejs index 09bdb3f6c..b0dae17c8 100644 --- a/back/methods/mrw-config/getLabel.ejs +++ b/back/methods/mrw-config/getLabel.ejs @@ -2,7 +2,7 @@ <%= mrw.franchiseCode %> - <%= mrw.subscriberCode %> + <%= clientType %> <%= mrw.user %> <%= mrw.password %> diff --git a/back/methods/mrw-config/getLabel.js b/back/methods/mrw-config/getLabel.js new file mode 100644 index 000000000..4af3276bb --- /dev/null +++ b/back/methods/mrw-config/getLabel.js @@ -0,0 +1,37 @@ +module.exports = Self => { + Self.remoteMethod('getLabel', { + description: 'Return a base64Binary label from de MRW WebService', + accessType: 'READ', + accepts: [{ + arg: 'shipmentId', + type: 'string', + required: true + }, + { + arg: 'clientType', + type: 'string', + required: true + }, + ], + returns: { + type: 'string', + root: true + }, + http: { + path: `/getLabel`, + verb: 'GET' + } + }); + + Self.getLabel = async(shipmentId, clientType) => { + const mrw = await Self.getConfig(); + + const getLabelResponse = await Self.sendXmlDoc( + __dirname + `/getLabel.ejs`, + {mrw, shipmentId, clientType}, + 'text/xml' + ); + + return Self.getTextByTag(getLabelResponse, 'EtiquetaFile'); + }; +}; diff --git a/back/methods/mrw-config/specs/createShipment.spec.js b/back/methods/mrw-config/specs/createShipment.spec.js index f05f9a81d..c8a5295f7 100644 --- a/back/methods/mrw-config/specs/createShipment.spec.js +++ b/back/methods/mrw-config/specs/createShipment.spec.js @@ -2,6 +2,7 @@ const models = require('vn-loopback/server/server').models; const axios = require('axios'); const fs = require('fs'); +const filter = {notificationFk: 'mrw-deadline'}; const mockBase64Binary = 'base64BinaryString'; const ticket1 = { 'id': '44', @@ -11,9 +12,8 @@ const ticket1 = { 'addressFk': 1, 'agencyModeFk': 999 }; - +let expedition; const expedition1 = { - 'id': 17, 'agencyModeFk': 999, 'ticketFk': 44, 'freightItemFk': 71, @@ -28,25 +28,49 @@ const expedition1 = { 'editorFk': 100 }; -let tx; -let options; - describe('MRWConfig createShipment()', () => { - beforeEach(async() => { - options = tx = undefined; - tx = await models.MrwConfig.beginTransaction({}); - options = {transaction: tx}; - + beforeAll(async() => { await models.Agency.create( - {'id': 999, 'name': 'mrw'}, - options + {'id': 999, 'name': 'mrw'} ); await models.AgencyMode.create( - {'id': 999, 'name': 'mrw', 'agencyFk': 999, 'code': 'mrw'}, - options + {'id': 999, 'name': 'mrw', 'agencyFk': 999, 'code': 'mrw'} + ); + await models.MrwService.create( + {'agencyModeCodeFk': 'mrw', 'clientType': '000001', 'serviceType': 105, 'kg': 10} + ); + + await createMrwConfig(); + + await models.Ticket.create(ticket1); + expedition = await models.Expedition.create(expedition1); + }); + + afterAll(async() => { + await cleanFixtures(); + await models.Ticket.destroyAll(ticket1); + await models.Expedition.destroyAll(ticket1); + }); + + beforeEach(async() => { + const mockPostResponses = [ + {data: fs.readFileSync(__dirname + '/mockGetLabel.xml', 'utf-8')}, + {data: fs.readFileSync(__dirname + '/mockCreateShipment.xml', 'utf-8')} + ]; + + spyOn(axios, 'post').and.callFake(() => Promise.resolve(mockPostResponses.pop())); + await cleanFixtures(); + }); + + async function cleanFixtures() { + await models.NotificationQueue.destroyAll(filter); + await models.MrwConfig.updateAll({id: 1}, {expeditionDeadLine: null, notified: null}); + } + + async function createMrwConfig() { await models.MrwConfig.create( { 'id': 1, @@ -54,68 +78,82 @@ describe('MRWConfig createShipment()', () => { 'user': 'user', 'password': 'password', 'franchiseCode': 'franchiseCode', - 'subscriberCode': 'subscriberCode' - }, options + 'subscriberCode': 'subscriberCode', + 'clientTypeWidth': 6 + } ); + } - await models.Application.rawSql( - `INSERT INTO vn.mrwService - SET agencyModeCodeFk = 'mrw', - clientType = 1, - serviceType = 1, - kg = 1`, null, options - ); - await models.Ticket.create(ticket1, options); - await models.Expedition.create(expedition1, options); - }); - - afterEach(async() => { - await tx.rollback(); - }); + async function getLastNotification() { + return models.NotificationQueue.findOne({ + order: 'id DESC', + where: filter + }); + } it('should create a shipment and return a base64Binary label', async() => { - const mockPostResponses = [ - {data: fs.readFileSync(__dirname + '/mockGetLabel.xml', 'utf-8')}, - {data: fs.readFileSync(__dirname + '/mockCreateShipment.xml', 'utf-8')} - ]; - - spyOn(axios, 'post').and.callFake(() => Promise.resolve(mockPostResponses.pop())); - - const {file} = await models.MrwConfig.createShipment(expedition1.id, options); + const {file} = await models.MrwConfig.createShipment(expedition.id); expect(file).toEqual(mockBase64Binary); }); it('should fail if mrwConfig has no data', async() => { let error; - await models.MrwConfig.createShipment(expedition1.id).catch(e => { + await models.MrwConfig.destroyAll(); + await models.MrwConfig.createShipment(expedition.id).catch(e => { error = e; }).finally(async() => { - expect(error.message).toEqual(`Some mrwConfig parameters are not set`); + expect(error.message).toEqual(`MRW service is not configured`); }); + await createMrwConfig(); expect(error).toBeDefined(); }); it('should fail if expeditionFk is not a MrwExpedition', async() => { let error; - await models.MrwConfig.createShipment(undefined, options).catch(e => { + await models.MrwConfig.createShipment(15).catch(e => { error = e; }).finally(async() => { - expect(error.message).toEqual(`This expedition is not a MRW shipment`); + expect(error.message).toEqual(`ClientType not available`); }); }); - it(' should fail if the creation date of this ticket is before the current date it', async() => { + it('should fail if the creation date of this ticket is before the current date', async() => { let error; const yesterday = Date.vnNew(); - yesterday.setDate(yesterday.getDate() - 1); - await models.Ticket.updateAll({id: ticket1.id}, {shipped: yesterday}, options); - await models.MrwConfig.createShipment(expedition1.id, options).catch(e => { + + await models.Ticket.updateAll({id: ticket1.id}, {shipped: yesterday}); + await models.MrwConfig.createShipment(expedition.id).catch(e => { error = e; }).finally(async() => { expect(error.message).toEqual(`This ticket has a shipped date earlier than today`); }); + await models.Ticket.updateAll({id: ticket1.id}, {shipped: Date.vnNew()}); + }); + + it('should send mail if you are past the dead line and is not notified today', async() => { + await models.MrwConfig.updateAll({id: 1}, {expeditionDeadLine: '10:00:00', notified: null}); + await models.MrwConfig.createShipment(expedition.id); + const notification = await getLastNotification(); + + expect(notification.notificationFk).toEqual(filter.notificationFk); + }); + + it('should send mail if you are past the dead line and it is notified from another day', async() => { + await models.MrwConfig.updateAll({id: 1}, {expeditionDeadLine: '10:00:00', notified: new Date()}); + await models.MrwConfig.createShipment(expedition.id); + const notification = await getLastNotification(); + + expect(notification.notificationFk).toEqual(filter.notificationFk); + }); + + it('should not send mail if you are past the dead line and it is notified', async() => { + await models.MrwConfig.updateAll({id: 1}, {expeditionDeadLine: '10:00:00', notified: Date.vnNew()}); + await models.MrwConfig.createShipment(expedition.id); + const notification = await getLastNotification(); + + expect(notification).toEqual(null); }); }); diff --git a/back/methods/postcode/filter.js b/back/methods/postcode/filter.js index 8b0f64d97..f350b1ea9 100644 --- a/back/methods/postcode/filter.js +++ b/back/methods/postcode/filter.js @@ -11,13 +11,6 @@ module.exports = Self => { arg: 'filter', type: 'object', description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', - http: {source: 'query'} - }, - { - arg: 'search', - type: 'string', - description: 'Value to filter', - http: {source: 'query'} }, ], returns: { @@ -29,13 +22,11 @@ module.exports = Self => { verb: 'GET', }, }); - Self.filter = async(ctx, filter, options) => { + Self.filter = async(filter = {}, options) => { const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); - filter = ctx?.filter ?? {}; - const conn = Self.dataSource.connector; const where = buildFilter(filter?.where, (param, value) => { switch (param) { @@ -50,31 +41,33 @@ module.exports = Self => { }; } }) ?? {}; - delete ctx.filter.where; + delete filter.where; const stmts = []; let stmt; stmt = new ParameterizedSQL(` - SELECT - pc.townFk, - t.provinceFk, - p.countryFk, - pc.code, - t.name as town, - p.name as province, - c.name country - FROM - postCode pc - JOIN town t on t.id = pc.townFk - JOIN province p on p.id = t.provinceFk - JOIN country c on c.id = p.countryFk + SELECT + pc.townFk, + t.provinceFk, + p.countryFk, + pc.code, + t.name as town, + p.name as province, + c.name country + FROM + postCode pc + JOIN town t on t.id = pc.townFk + JOIN province p on p.id = t.provinceFk + JOIN country c on c.id = p.countryFk `); - stmt.merge(conn.makeSuffix({where, ...ctx})); + stmt.merge(conn.makeSuffix({where})); + stmt.merge(conn.makeLimit(filter)); const itemsIndex = stmts.push(stmt) - 1; const sql = ParameterizedSQL.join(stmts, ';'); const result = await conn.executeStmt(sql, myOptions); + return itemsIndex === 0 ? result : result[itemsIndex]; }; }; diff --git a/back/methods/postcode/specs/filter.spec.js b/back/methods/postcode/specs/filter.spec.js index 60ac24809..7ebce495a 100644 --- a/back/methods/postcode/specs/filter.spec.js +++ b/back/methods/postcode/specs/filter.spec.js @@ -6,12 +6,9 @@ describe('Postcode filter()', () => { const options = {transaction: tx}; try { - const ctx = { - filter: { - }, + const results = await models.Postcode.filter({ limit: 1 - }; - const results = await models.Postcode.filter(ctx, options); + }, options); expect(results.length).toEqual(1); await tx.rollback(); @@ -26,16 +23,13 @@ describe('Postcode filter()', () => { const options = {transaction: tx}; try { - const ctx = { - filter: { - where: { - search: 46, - } - }, - }; - const results = await models.Postcode.filter(ctx, options); + const results = await models.Postcode.filter({ + where: { + search: 46, + } + }, options); - expect(results.length).toEqual(4); + expect(results.length).toEqual(5); await tx.rollback(); } catch (e) { await tx.rollback(); @@ -48,14 +42,9 @@ describe('Postcode filter()', () => { const options = {transaction: tx}; try { - const ctx = { - filter: { - where: { - search: 'Alz', - } - }, - }; - const results = await models.Postcode.filter(ctx, options); + const results = await models.Postcode.filter({where: { + search: 'Alz', + }}, options); expect(results.length).toEqual(1); await tx.rollback(); @@ -70,16 +59,11 @@ describe('Postcode filter()', () => { const options = {transaction: tx}; try { - const ctx = { - filter: { - where: { - search: 'one', - } - }, - }; - const results = await models.Postcode.filter(ctx, options); + const results = await models.Postcode.filter({where: { + search: 'one', + }}, options); - expect(results.length).toEqual(4); + expect(results.length).toEqual(5); await tx.rollback(); } catch (e) { await tx.rollback(); @@ -92,14 +76,11 @@ describe('Postcode filter()', () => { const options = {transaction: tx}; try { - const ctx = { - filter: { - where: { - search: 'Ec', - } - }, - }; - const results = await models.Postcode.filter(ctx, options); + const results = await models.Postcode.filter({ + where: { + search: 'Ec', + } + }, options); expect(results.length).toEqual(1); await tx.rollback(); diff --git a/back/methods/quadminds-api-config/sendOrders.js b/back/methods/quadminds-api-config/sendOrders.js new file mode 100644 index 000000000..760d622b6 --- /dev/null +++ b/back/methods/quadminds-api-config/sendOrders.js @@ -0,0 +1,88 @@ +const axios = require('axios'); +const UserError = require('vn-loopback/util/user-error'); +const moment = require('moment'); + +module.exports = Self => { + Self.remoteMethod('sendOrders', { + description: 'Sends a set of orders', + accessType: 'WRITE', + accepts: [{ + arg: 'tickets', + type: ['number'], + required: true + } + ], + returns: { + type: 'string', + root: true + }, + http: { + path: `/sendOrders`, + verb: 'POST' + } + }); + Self.sendOrders = async tickets => { + const config = await Self.app.models.QuadmindsApiConfig.findOne(); + if (!config) throw new UserError('Config params not set'); + + if (tickets.length > config.maxObjects) + throw new UserError(`Quadminds does not support more than ${config.maxObjects} tickets`); + + let poisData = []; + let isOk; + for (let offset = 0; !isOk; offset = offset + config.limit) { + const pois = await axios.get(`${config.url}pois/search?limit=${config.limit}&offset=${offset}`, { + headers: { + 'Accept': 'application/json', + 'X-Saas-Apikey': config.key + } + }); + pois.data.data.length ? poisData.push(...pois.data.data) : isOk = true; + } + + const poiMap = new Map(poisData.map(poi => [poi.code, poi._id])); + + let orders = await Self.rawSql(` + SELECT a.id poiCode, + t.id code, + t.shipped date, + 'PEDIDO' operation, + t.totalWithVat totalAmount, + t.totalWithoutVat totalAmountWithoutTaxes, + SUM(sv.volume) volume + FROM ticket t + JOIN address a ON a.id = t.addressFk + JOIN saleVolume sv ON sv.ticketFk = t.id + WHERE t.id IN (?) + GROUP BY t.id + `, [tickets]); + + // Transformo code en string ya que lo obtenermos como integer + orders = orders.map(order => { + return { + ...order, + poiId: poiMap.get(order.poiCode.toString()) || undefined, + code: order.code.toString(), + date: moment(order.date).format('YYYY-MM-DD'), + totalAmount: order.totalAmount || undefined, + totalAmountWithoutTaxes: order.totalAmountWithoutTaxes || undefined, + timeWindow: [{ + from: config.orderTimeFrom, + to: config.orderTimeTo + }], + orderMeasures: [{ + constraintId: 3, // Volumen + value: order.volume + }] + }; + }); + + await axios.post(`${config.url}orders`, orders, { + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'X-Saas-Apikey': config.key + } + }); + }; +}; diff --git a/back/methods/quadminds-api-config/sendPois.js b/back/methods/quadminds-api-config/sendPois.js new file mode 100644 index 000000000..cb5eef93e --- /dev/null +++ b/back/methods/quadminds-api-config/sendPois.js @@ -0,0 +1,87 @@ +const axios = require('axios'); +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethod('sendPois', { + description: 'Sends a set of pois', + accessType: 'WRITE', + accepts: [{ + arg: 'tickets', + type: ['number'], + required: true + } + ], + returns: { + type: 'string', + root: true + }, + http: { + path: `/sendPois`, + verb: 'POST' + } + }); + Self.sendPois = async tickets => { + const config = await Self.app.models.QuadmindsApiConfig.findOne(); + if (!config) throw new UserError('Config params not set'); + + if (tickets.length > config.maxObjects) + throw new UserError(`Quadminds does not support more than ${config.maxObjects} tickets`); + + let pois = await Self.rawSql(` + WITH deliveryNotes AS ( + SELECT t.id, t.routeFk, tn.description + FROM ticket t + JOIN ticketObservation tn ON tn.ticketFk = t.id + JOIN observationType ot ON ot.id = tn.observationTypeFk + WHERE ot.code = 'delivery' + ) + SELECT a.id code, + c.socialName name, + IF(ABS(a.latitude - ROUND(a.latitude)) < 0.000001, NULL, a.latitude) latitude, + IF(ABS(a.longitude - ROUND(a.longitude)) < 0.000001, NULL, a.longitude) longitude, + a.street, + a.city locality, + p.name state, + co.name country, + CONCAT_WS(', ', IFNULL(a.street, ''), IFNULL(a.city, ''), IFNULL(p.name, '')) longAddress, + CONCAT(IFNULL(a.mobile, c.mobile)) phoneNumber, + dn.description poiDeliveryComments, + c.email email + FROM ticket t + JOIN address a ON a.id = t.addressFk + JOIN province p ON p.id = a.provinceFk + JOIN country co ON co.id = p.countryFk + JOIN client c ON c.id = t.clientFk + LEFT JOIN deliveryNotes dn ON dn.id = t.id + WHERE t.id IN (?) + GROUP BY t.id + `, [tickets]); + + // Transformo code en string ya que lo obtenermos como integer + pois = pois.map(poi => { + return { + ...poi, + code: poi.code.toString(), + latitude: poi.latitude || undefined, + longitude: poi.longitude || undefined, + address: { + street: poi.street || undefined, + locality: poi.locality || undefined, + state: poi.state || undefined, + country: poi.country || undefined + }, + poiDeliveryComments: poi.poiDeliveryComments || undefined, + phoneNumber: poi.phoneNumber || undefined, + email: poi.email || undefined + }; + }); + + await axios.post(`${config.url}pois`, pois, { + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'X-Saas-Apikey': config.key + } + }); + }; +}; diff --git a/back/methods/starred-module/specs/getStarredModules.spec.js b/back/methods/starred-module/specs/getStarredModules.spec.js index bf9bd1d73..afe1dd9c2 100644 --- a/back/methods/starred-module/specs/getStarredModules.spec.js +++ b/back/methods/starred-module/specs/getStarredModules.spec.js @@ -1,22 +1,7 @@ const {models} = require('vn-loopback/server/server'); -const LoopBackContext = require('loopback-context'); describe('getStarredModules()', () => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - const ctx = {req: activeCtx}; - - beforeEach(() => { - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + const ctx = beforeAll.getCtx(); it(`should return the starred modules for a given user`, async() => { const newStarred = await models.StarredModule.create({workerFk: 9, moduleFk: 'customer', position: 1}); diff --git a/back/methods/starred-module/specs/setPosition.spec.js b/back/methods/starred-module/specs/setPosition.spec.js index a428fcf22..63addeffc 100644 --- a/back/methods/starred-module/specs/setPosition.spec.js +++ b/back/methods/starred-module/specs/setPosition.spec.js @@ -1,24 +1,8 @@ const {models} = require('vn-loopback/server/server'); -const LoopBackContext = require('loopback-context'); describe('setPosition()', () => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - const ctx = { - req: activeCtx - }; - - beforeEach(() => { - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + const ctx = beforeAll.getCtx(); + beforeAll.mockLoopBackContext(); it('should increase the orders module position by replacing it with clients and vice versa', async() => { const tx = await models.StarredModule.beginTransaction({}); diff --git a/back/methods/starred-module/specs/toggleStarredModule.spec.js b/back/methods/starred-module/specs/toggleStarredModule.spec.js index 848c1475a..d506abc33 100644 --- a/back/methods/starred-module/specs/toggleStarredModule.spec.js +++ b/back/methods/starred-module/specs/toggleStarredModule.spec.js @@ -1,24 +1,7 @@ const {models} = require('vn-loopback/server/server'); -const LoopBackContext = require('loopback-context'); describe('toggleStarredModule()', () => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - const ctx = { - req: activeCtx - }; - - beforeEach(() => { - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + const ctx = beforeAll.getCtx(); it('should create a new starred module and then remove it by calling the method again with same args', async() => { const starredModule = await models.StarredModule.toggleStarredModule(ctx, 'order'); @@ -26,7 +9,7 @@ describe('toggleStarredModule()', () => { expect(starredModules.length).toEqual(1); expect(starredModule.moduleFk).toEqual('order'); - expect(starredModule.workerFk).toEqual(activeCtx.accessToken.userId); + expect(starredModule.workerFk).toEqual(ctx.req.accessToken.userId); expect(starredModule.position).toEqual(starredModules.length); await models.StarredModule.toggleStarredModule(ctx, 'order'); diff --git a/back/methods/url/getUrl.js b/back/methods/url/getUrl.js index fa3f7fdad..5c6e5655f 100644 --- a/back/methods/url/getUrl.js +++ b/back/methods/url/getUrl.js @@ -22,7 +22,7 @@ module.exports = Self => { const url = await Self.app.models.Url.findOne({ where: { appName, - environment: process.env.NODE_ENV || 'development' + environment: process.env.NODE_ENV || 'dev' } }); return url?.url; diff --git a/back/methods/user-config/specs/getUserConfig.spec.js b/back/methods/user-config/specs/getUserConfig.spec.js index 8b510a706..bbfb98ef7 100644 --- a/back/methods/user-config/specs/getUserConfig.spec.js +++ b/back/methods/user-config/specs/getUserConfig.spec.js @@ -1,12 +1,12 @@ const models = require('vn-loopback/server/server').models; describe('userConfig getUserConfig()', () => { + const ctx = beforeAll.getCtx(); it(`should return the configuration data of a given user`, async() => { const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; try { - const ctx = {req: {accessToken: {userId: 9}}}; const result = await models.UserConfig.getUserConfig(ctx, options); expect(result.warehouseFk).toEqual(1); diff --git a/back/methods/viaexpress-config/renderer.js b/back/methods/viaexpress-config/renderer.js index c8533ea6b..5d83b5870 100644 --- a/back/methods/viaexpress-config/renderer.js +++ b/back/methods/viaexpress-config/renderer.js @@ -20,7 +20,7 @@ module.exports = Self => { } }); - Self.renderer = async (expeditionFk) => { + Self.renderer = async expeditionFk => { const models = Self.app.models; const viaexpressConfig = await models.ViaexpressConfig.findOne({ @@ -109,7 +109,7 @@ module.exports = Self => { const ticket = expedition.ticket(); const sender = ticket.company().client(); const shipped = ticket.shipped.toISOString(); - const isInterdia = (ticket.agencyModeFk === viaexpressConfig.agencyModeFk) + const isInterdia = (ticket.agencyModeFk === viaexpressConfig.agencyModeFk); const data = { viaexpressConfig, sender, diff --git a/back/methods/vn-token/killSession.js b/back/methods/vn-token/killSession.js new file mode 100644 index 000000000..23d02bfc2 --- /dev/null +++ b/back/methods/vn-token/killSession.js @@ -0,0 +1,29 @@ +module.exports = Self => { + Self.remoteMethodCtx('killSession', { + description: 'Kill session', + accepts: [{ + arg: 'userId', + type: 'integer', + description: 'The user id', + required: true, + }, { + arg: 'created', + type: 'date', + description: 'The created time', + required: true, + }], + accessType: 'WRITE', + http: { + path: `/killSession`, + verb: 'POST' + } + }); + + Self.killSession = async function(ctx, userId, created) { + await Self.app.models.VnUser.userSecurity(ctx, ctx.req.accessToken.userId); + const tokens = await Self.app.models.AccessToken.find({where: {userId, created}}); + if (!tokens?.length) return; + for (const token of tokens) + await Self.app.models.AccessToken.deleteById(token.id); + }; +}; diff --git a/back/methods/vn-user/acls.js b/back/methods/vn-user/acls.js new file mode 100644 index 000000000..7da75ed2c --- /dev/null +++ b/back/methods/vn-user/acls.js @@ -0,0 +1,72 @@ +module.exports = Self => { + Self.remoteMethodCtx('acls', { + description: 'Get all of the current user acls', + returns: { + type: 'Object', + root: true + }, + http: { + path: '/acls', + verb: 'GET' + } + }); + + const staticAcls = new Map(); + const app = require('vn-loopback/server/server'); + app.on('started', function() { + for (const model of app.models()) { + for (const acl of model.settings.acls) { + if (acl.principalType == 'ROLE' && acl.permission == 'ALLOW') { + const staticAcl = { + model: model.name, + property: '*', + accessType: acl.accessType, + permission: acl.permission, + principalType: acl.principalType, + principalId: acl.principalId, + }; + if (staticAcls.has(acl.principalId)) + staticAcls.get(acl.principalId).push(staticAcl); + else + staticAcls.set(acl.principalId, [staticAcl]); + } + } + } + }); + + Self.acls = async function(ctx) { + const models = Self.app.models; + const acls = []; + const userId = ctx.req.accessToken.userId; + if (userId) { + const roleMapping = await models.RoleMapping.find({ + where: { + principalId: userId + }, + include: [ + { + relation: 'role', + scope: { + fields: [ + 'name' + ] + } + } + ] + }); + const dynamicAcls = await models.ACL.find({ + where: { + principalId: { + inq: roleMapping.map(rm => rm.role().name) + } + } + }); + dynamicAcls.forEach(acl => acls.push(acl)); + staticAcls.get('$authenticated').forEach(acl => acls.push(acl)); + } else + staticAcls.get('$unauthenticated').forEach(acl => acls.push(acl)); + + staticAcls.get('$everyone').forEach(acl => acls.push(acl)); + return acls; + }; +}; diff --git a/back/methods/vn-user/renew-token.js b/back/methods/vn-user/renew-token.js index 8e5ffc095..100e913ee 100644 --- a/back/methods/vn-user/renew-token.js +++ b/back/methods/vn-user/renew-token.js @@ -16,41 +16,51 @@ module.exports = Self => { accessScopes: ['DEFAULT', 'read:multimedia']}); Self.renewToken = async function(ctx) { - const {accessToken: token} = ctx.req; - - // Check if current token is valid - - const {renewPeriod, courtesyTime} = await models.AccessTokenConfig.findOne({ - fields: ['renewPeriod', 'courtesyTime'] - }); - const now = Date.now(); - const differenceMilliseconds = now - token.created; - const differenceSeconds = Math.floor(differenceMilliseconds / 1000); - const isNotExceeded = differenceSeconds < renewPeriod - courtesyTime; - if (isNotExceeded) - return token; - - // Schedule to remove current token - setTimeout(async() => { - try { - 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.accessTokens.create(createTokenOptions); + let token; let isNotExceeded; + try { + token = ctx.req.accessToken; - return {id: accessToken.id, ttl: accessToken.ttl}; + const {courtesyTime} = await models.AccessTokenConfig.findOne({ + fields: ['courtesyTime'] + }); + isNotExceeded = await Self.validateToken(ctx); + if (isNotExceeded) + return token; + + // Schedule to remove current token + setTimeout(async() => { + try { + await Self.logout(token.id); + } catch (error) { + // FIXME: Crash if do throw new Error(error) + } + }, courtesyTime * 1000); + + // Get scopes + const {scopes} = token; + if (scopes) + createTokenOptions = {scopes: [scopes[0]]}; + // Create new accessToken + const user = await Self.findById(token.userId); + const accessToken = await user.accessTokens.create(createTokenOptions); + + return {id: accessToken.id, ttl: accessToken.ttl}; + } catch (error) { + const body = { + error: error.message, + userId: token?.userId ?? null, + token: token?.id, + scopes: token?.scopes, + createTokenOptions, + isNotExceeded + }; + await handleError(JSON.stringify(body)); + throw new Error(error); + } }; }; + +async function handleError(body) { + await models.Application.rawSql('CALL util.debugAdd(?,?);', ['renewToken', body]); +} diff --git a/back/methods/vn-user/sign-in.js b/back/methods/vn-user/sign-in.js index 782046641..775970d55 100644 --- a/back/methods/vn-user/sign-in.js +++ b/back/methods/vn-user/sign-in.js @@ -67,7 +67,9 @@ module.exports = Self => { if (vnUser.twoFactor === 'email') { const $ = Self.app.models; - const code = String(Math.floor(Math.random() * 999999)); + const min = 100000; + const max = 999999; + const code = String(Math.floor(Math.random() * (max - min + 1)) + min); const maxTTL = ((60 * 1000) * 5); // 5 min await $.AuthCode.upsertWithWhere({userFk: vnUser.id}, { userFk: vnUser.id, diff --git a/back/methods/vn-user/specs/acls.spec.js b/back/methods/vn-user/specs/acls.spec.js new file mode 100644 index 000000000..0349b39fb --- /dev/null +++ b/back/methods/vn-user/specs/acls.spec.js @@ -0,0 +1,27 @@ +const {models} = require('vn-loopback/server/server'); +const id = {administrative: 5, employee: 1, productionBoss: 50}; + +describe('VnUser acls()', () => { + it('should get its owns acls', async() => { + expect(await hasAcl('administrative', id.administrative)).toBeTruthy(); + expect(await hasAcl('productionBoss', id.productionBoss)).toBeTruthy(); + }); + + it('should not get administrative acls', async() => { + expect(await hasAcl('administrative', id.employee)).toBeFalsy(); + }); + + it('should get the $authenticated acls', async() => { + expect(await hasAcl('$authenticated', id.employee)).toBeTruthy(); + }); + + it('should get the $everyone acls', async() => { + expect(await hasAcl('$everyone', id.employee)).toBeTruthy(); + }); +}); + +const hasAcl = async(role, userId) => { + const ctx = {req: {accessToken: {userId}, headers: {origin: 'http://localhost'}}}; + const acls = await models.VnUser.acls(ctx); + return Object.values(acls).some(acl => acl.principalId === role); +}; diff --git a/back/methods/vn-user/specs/renew-token.spec.js b/back/methods/vn-user/specs/renew-token.spec.js index 70e7473d1..8941916ec 100644 --- a/back/methods/vn-user/specs/renew-token.spec.js +++ b/back/methods/vn-user/specs/renew-token.spec.js @@ -61,4 +61,21 @@ describe('Renew Token', () => { expect(error).toBeUndefined(); expect(response.id).toEqual(ctx.req.accessToken.id); }); + + it('throw error', async() => { + let error; + + try { + await models.VnUser.renewToken({req: {token: null}}); + } catch (e) { + error = e; + } + + expect(error).toBeDefined(); + + const query = 'SELECT * FROM util.debug WHERE variable = "renewToken"'; + const debugLog = await models.Application.rawSql(query); + + expect(debugLog.length).toEqual(1); + }); }); diff --git a/back/methods/vn-user/update-user.js b/back/methods/vn-user/update-user.js index ddaae8548..2bb390cf9 100644 --- a/back/methods/vn-user/update-user.js +++ b/back/methods/vn-user/update-user.js @@ -24,6 +24,10 @@ module.exports = Self => { arg: 'lang', type: 'string', description: 'The user lang' + }, { + arg: 'twoFactor', + type: 'any', + description: 'The user twoFactor' } ], http: { @@ -32,8 +36,8 @@ module.exports = Self => { } }); - Self.updateUser = async(ctx, id, name, nickname, email, lang) => { + Self.updateUser = async(ctx, id, name, nickname, email, lang, twoFactor) => { await Self.userSecurity(ctx, id); - await Self.upsertWithWhere({id}, {name, nickname, email, lang}); + await Self.upsertWithWhere({id}, {name, nickname, email, lang, twoFactor}); }; }; diff --git a/back/methods/vn-user/validate-auth.js b/back/methods/vn-user/validate-auth.js index beab43417..8fb8b4923 100644 --- a/back/methods/vn-user/validate-auth.js +++ b/back/methods/vn-user/validate-auth.js @@ -58,7 +58,7 @@ module.exports = Self => { fields: ['name', 'twoFactor'] }, myOptions); - if (user.name !== username) + if (user.name.toLowerCase() !== username.toLowerCase()) throw new UserError('Authentication failed'); await authCode.destroy(myOptions); diff --git a/back/methods/vn-user/validate-token.js b/back/methods/vn-user/validate-token.js new file mode 100644 index 000000000..3b75c7c34 --- /dev/null +++ b/back/methods/vn-user/validate-token.js @@ -0,0 +1,30 @@ +const {models} = require('vn-loopback/server/server'); +module.exports = Self => { + Self.remoteMethodCtx('validateToken', { + description: 'Validates the current logged user token', + accepts: [], + accessType: 'READ', + returns: { + type: 'Boolean', + root: true + }, + http: { + path: `/validateToken`, + verb: 'GET' + } + }); + + Self.validateToken = async function(ctx) { + const {accessToken: token} = ctx.req; + + // Check if current token is valid + const {renewPeriod, courtesyTime} = await models.AccessTokenConfig.findOne({ + fields: ['renewPeriod', 'courtesyTime'] + }); + const now = Date.now(); + const differenceMilliseconds = now - token.created; + const differenceSeconds = Math.floor(differenceMilliseconds / 1000); + const isNotExceeded = differenceSeconds < renewPeriod - courtesyTime; + return isNotExceeded; + }; +}; diff --git a/back/methods/workerActivity/add.js b/back/methods/workerActivity/add.js new file mode 100644 index 000000000..4592a0797 --- /dev/null +++ b/back/methods/workerActivity/add.js @@ -0,0 +1,50 @@ +module.exports = Self => { + Self.remoteMethodCtx('add', { + description: 'Add activity if the activity is different or is the same but have exceed time for break', + accessType: 'WRITE', + accepts: [ + { + arg: 'code', + type: 'string', + description: 'Code for activity' + }, + { + arg: 'model', + type: 'string', + description: 'Origin model from insert' + }, + + ], + http: { + path: `/add`, + verb: 'POST' + } + }); + + Self.add = async(ctx, code, model, options) => { + const userId = ctx.req.accessToken.userId; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + return await Self.rawSql(` + INSERT INTO workerActivity (workerFk, workerActivityTypeFk, model) + SELECT ?, ?, ? + FROM workerTimeControlParams wtcp + LEFT JOIN ( + SELECT wa.workerFk, + wa.created, + wat.code + FROM workerActivity wa + LEFT JOIN workerActivityType wat ON wat.code = wa.workerActivityTypeFk + WHERE wa.workerFk = ? + ORDER BY wa.created DESC + LIMIT 1 + ) sub ON TRUE + WHERE sub.workerFk IS NULL + OR sub.code <> ? + OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcp.dayBreak;` + , [userId, code, model, userId, code], myOptions); + }; +}; diff --git a/back/methods/workerActivity/specs/add.spec.js b/back/methods/workerActivity/specs/add.spec.js new file mode 100644 index 000000000..352d67723 --- /dev/null +++ b/back/methods/workerActivity/specs/add.spec.js @@ -0,0 +1,30 @@ +const {models} = require('vn-loopback'); + +describe('workerActivity insert()', () => { + const ctx = beforeAll.getCtx(1106); + + it('should insert in workerActivity', async() => { + const tx = await models.WorkerActivity.beginTransaction({}); + let count = 0; + const options = {transaction: tx}; + + try { + await models.WorkerActivityType.create( + {'code': 'STOP', 'description': 'STOP'}, options + ); + + await models.WorkerActivity.add(ctx, 'STOP', 'APP', options); + + count = await models.WorkerActivity.count( + {'workerFK': 1106}, options + ); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + + expect(count).toEqual(1); + }); +}); diff --git a/back/model-config.json b/back/model-config.json index b643ab54f..b6d304675 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -28,6 +28,9 @@ "Company": { "dataSource": "vn" }, + "Config": { + "dataSource": "vn" + }, "Continent": { "dataSource": "vn" }, @@ -64,6 +67,9 @@ "EmailUser": { "dataSource": "vn" }, + "Expedition_PrintOut": { + "dataSource": "vn" + }, "Image": { "dataSource": "vn" }, @@ -112,9 +118,15 @@ "NotificationSubscription": { "dataSource": "vn" }, + "OrmConfig": { + "dataSource": "vn" + }, "Province": { "dataSource": "vn" }, + "QuadmindsApiConfig": { + "dataSource": "vn" + }, "Autonomy": { "dataSource": "vn" }, @@ -163,9 +175,15 @@ "PrintConfig": { "dataSource": "vn" }, + "QueueMember": { + "dataSource": "vn" + }, "ViaexpressConfig": { "dataSource": "vn" }, + "VnToken": { + "dataSource": "vn" + }, "VnUser": { "dataSource": "vn" }, @@ -189,5 +207,8 @@ }, "RouteConfig": { "dataSource": "vn" + }, + "MrwService": { + "dataSource": "vn" } -} +} \ No newline at end of file diff --git a/back/models/collection.js b/back/models/collection.js index f2c2f1566..f91ac7afa 100644 --- a/back/models/collection.js +++ b/back/models/collection.js @@ -3,6 +3,7 @@ module.exports = Self => { require('../methods/collection/setSaleQuantity')(Self); require('../methods/collection/previousLabel')(Self); require('../methods/collection/getTickets')(Self); + require('../methods/collection/assignCollection')(Self); require('../methods/collection/assign')(Self); require('../methods/collection/getSales')(Self); }; diff --git a/back/models/collection.json b/back/models/collection.json index cb8dc3d7c..8a8afeb89 100644 --- a/back/models/collection.json +++ b/back/models/collection.json @@ -1,6 +1,16 @@ { "name": "Collection", "base": "VnModel", + "properties": { + "id": { + "id": true, + "type": "number", + "required": true + }, + "workerFk": { + "type": "number" + } + }, "options": { "mysql": { "table": "collection" diff --git a/back/models/config.json b/back/models/config.json new file mode 100644 index 000000000..e5ba1f134 --- /dev/null +++ b/back/models/config.json @@ -0,0 +1,22 @@ +{ + "name": "Config", + "base": "VnModel", + "options": { + "mysql": { + "table": "config" + } + }, + "properties": { + "inventoried": { + "type": "date" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$authenticated", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/back/models/country.json b/back/models/country.json index a4c74d330..5b9d842a8 100644 --- a/back/models/country.json +++ b/back/models/country.json @@ -25,6 +25,9 @@ }, "isSocialNameUnique": { "type": "boolean" + }, + "continentFk": { + "type": "number" } }, "relations": { @@ -32,6 +35,11 @@ "type": "belongsTo", "model": "Currency", "foreignKey": "currencyFk" + }, + "continent": { + "type": "belongsTo", + "model": "Continent", + "foreignKey": "continentFk" } }, "acls": [ diff --git a/back/models/default-view-config.json b/back/models/default-view-config.json index 88164692d..e7d856c17 100644 --- a/back/models/default-view-config.json +++ b/back/models/default-view-config.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "salix.defaultViewConfig" + "table": "salix.defaultViewMultiConfig" } }, "properties": { diff --git a/back/models/expedition_PrintOut.json b/back/models/expedition_PrintOut.json new file mode 100644 index 000000000..dd49b0234 --- /dev/null +++ b/back/models/expedition_PrintOut.json @@ -0,0 +1,22 @@ +{ + "name": "Expedition_PrintOut", + "base": "VnModel", + "options": { + "mysql": { + "table": "dipole.expedition_PrintOut" + } + }, + "properties": { + "expeditionFk": { + "type": "number", + "id": true, + "description": "id expeditionFk" + }, + "itemFk": { + "type": "number" + }, + "isChecked": { + "type": "boolean" + } + } +} \ No newline at end of file diff --git a/back/models/mrw-config.js b/back/models/mrw-config.js index f764b91cc..8bb24dbe5 100644 --- a/back/models/mrw-config.js +++ b/back/models/mrw-config.js @@ -1,4 +1,60 @@ module.exports = Self => { require('../methods/mrw-config/createShipment')(Self); + require('../methods/mrw-config/getLabel')(Self); require('../methods/mrw-config/cancelShipment')(Self); + + const fs = require('fs'); + const ejs = require('ejs'); + const UserError = require('vn-loopback/util/user-error'); + const {DOMParser} = require('xmldom'); + const axios = require('axios'); + + Self.getConfig = async function() { + const mrw = await Self.app.models.MrwConfig.findOne(null); + if (!mrw) throw new UserError(`MRW service is not configured`); + return mrw; + }; + + Self.getTextByTag = function(xmlDoc, tag) { + return xmlDoc?.getElementsByTagName(tag)[0]?.textContent; + }; + + Self.sendXmlDoc = async function(path, params, contentType) { + const parser = new DOMParser(); + + const xmlTemplate = fs.readFileSync(path, 'utf-8'); + const renderedTemplate = ejs.render(xmlTemplate, params); + const data = await axios.post(params.mrw.url, renderedTemplate, { + headers: { + 'Content-Type': `${contentType}; charset=utf-8` + } + }); + return parser.parseFromString(data.data, 'text/xml'); + }; + + Self.getClientType = async function(expeditionFk) { + if (!expeditionFk) throw new UserError(`No expeditionFk defined`); + + const {clientTypeWidth} = await Self.getConfig(); + const result = await Self.app.models.Expedition.findById(expeditionFk, + {include: [{ + relation: 'ticket', + scope: { + include: { + relation: 'agencyMode', + scope: { + include: { + relation: 'mrwService', + } + } + } + } + }]} + ); + const clientType = result?.ticket()?.agencyMode()?.mrwService()?.clientType; + if (!clientType || !clientTypeWidth) throw new UserError(`ClientType not available`); + + return clientType.toString().padStart(clientTypeWidth, '0'); + }; }; + diff --git a/back/models/mrw-config.json b/back/models/mrw-config.json index 50cf7e8fc..60c0ca2a2 100644 --- a/back/models/mrw-config.json +++ b/back/models/mrw-config.json @@ -27,6 +27,27 @@ }, "subscriberCode": { "type": "string" + }, + "defaultHeight": { + "type": "number" + }, + "defaultLength": { + "type": "number" + }, + "defaultWidth": { + "type": "number" + }, + "defaultWeight": { + "type": "number" + }, + "expeditionDeadLine": { + "type": "string" + }, + "notified":{ + "type": "date" + }, + "clientTypeWidth": { + "type": "number" } } } diff --git a/back/models/mrw-service.json b/back/models/mrw-service.json new file mode 100644 index 000000000..1ad72d060 --- /dev/null +++ b/back/models/mrw-service.json @@ -0,0 +1,33 @@ +{ + "name": "MrwService", + "base": "VnModel", + "options": { + "mysql": { + "table": "mrwService" + } + }, + "properties": { + "agencyModeCodeFk": { + "id": true, + "type": "string", + "required": true + }, + "clientType": { + "type": "number", + "required": true + }, + "serviceType": { + "type": "number" + }, + "kg": { + "type": "number" + } + }, + "relations": { + "agency": { + "type": "hasOne", + "model": "AgencyMode", + "foreignKey": "code" + } + } +} diff --git a/back/models/ormConfig.json b/back/models/ormConfig.json new file mode 100644 index 000000000..ef4c2b181 --- /dev/null +++ b/back/models/ormConfig.json @@ -0,0 +1,26 @@ +{ + "name": "OrmConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "ormConfig" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "selectLimit": { + "type": "number" + } + }, + "acls": [ + { + "accessType": "*", + "principalType": "ROLE", + "principalId": "$authenticated", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/back/models/postcode.json b/back/models/postcode.json index eadc2c86c..bad6be5d7 100644 --- a/back/models/postcode.json +++ b/back/models/postcode.json @@ -9,7 +9,8 @@ "properties": { "code": { "id": true, - "type": "string" + "type": "string", + "required": true } }, "relations": { @@ -47,4 +48,4 @@ } } } -} \ No newline at end of file +} diff --git a/back/models/production-config.json b/back/models/production-config.json index 3800dbbf2..2fc6d71ff 100644 --- a/back/models/production-config.json +++ b/back/models/production-config.json @@ -3,17 +3,23 @@ "base": "VnModel", "options": { "mysql": { - "table": "productionConfig" + "table": "productionConfig" } - }, + }, "properties": { "id": { "type": "number", "required": true, "id": true }, + "sectorFromCode": { + "type": "string" + }, + "sectorToCode": { + "type": "string" + }, "backupPrinterNotificationDelay": { "type": "string" } } -} +} \ No newline at end of file diff --git a/back/models/quadminds-api-config.js b/back/models/quadminds-api-config.js new file mode 100644 index 000000000..c2773fa0b --- /dev/null +++ b/back/models/quadminds-api-config.js @@ -0,0 +1,4 @@ +module.exports = Self => { + require('../methods/quadminds-api-config/sendPois')(Self); + require('../methods/quadminds-api-config/sendOrders')(Self); +}; diff --git a/back/models/quadminds-api-config.json b/back/models/quadminds-api-config.json new file mode 100644 index 000000000..4001badf3 --- /dev/null +++ b/back/models/quadminds-api-config.json @@ -0,0 +1,34 @@ +{ + "name": "QuadmindsApiConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "quadmindsApiConfig" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "required": true + }, + "url": { + "type": "string" + }, + "key": { + "type": "string" + }, + "maxObjects": { + "type": "number" + }, + "limit": { + "type": "number" + }, + "orderTimeFrom": { + "type": "string" + }, + "orderTimeTo": { + "type": "string" + } + } +} diff --git a/back/models/queue-member.json b/back/models/queue-member.json new file mode 100644 index 000000000..93ca2ebd7 --- /dev/null +++ b/back/models/queue-member.json @@ -0,0 +1,38 @@ +{ + "name": "QueueMember", + "base": "VnModel", + "options": { + "mysql": { + "table": "pbx.queueMember" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "queue": { + "type": "string" + }, + "extension": { + "type": "string" + } + }, + "relations": { + "queueRelation": { + "type": "belongsTo", + "model": "Queue", + "foreignKey": "queue", + "primaryKey": "name" + } + }, + "acls": [ + { + "property": "*", + "accessType": "READ", + "principalType": "ROLE", + "principalId": "employee", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/back/models/specs/mailAliasAccount.spec.js b/back/models/specs/mailAliasAccount.spec.js index 8f0278a50..0f4cbdbb1 100644 --- a/back/models/specs/mailAliasAccount.spec.js +++ b/back/models/specs/mailAliasAccount.spec.js @@ -1,12 +1,13 @@ const models = require('vn-loopback/server/server').models; describe('loopback model MailAliasAccount', () => { + const ctx = beforeAll.getCtx(); it('should add a mail Alias', async() => { const tx = await models.MailAliasAccount.beginTransaction({}); let error; try { - const options = {transaction: tx, accessToken: {userId: 9}}; + const options = {transaction: tx, ctx}; await models.MailAliasAccount.create({mailAlias: 2, account: 5}, options); await tx.rollback(); @@ -23,7 +24,7 @@ describe('loopback model MailAliasAccount', () => { let error; try { - const options = {transaction: tx, accessToken: {userId: 9}}; + const options = {transaction: tx, ctx}; await models.MailAliasAccount.create({mailAlias: 3, account: 5}, options); await tx.rollback(); diff --git a/back/models/town.json b/back/models/town.json index 4ad729791..e5d39314b 100644 --- a/back/models/town.json +++ b/back/models/town.json @@ -12,7 +12,8 @@ "type": "number" }, "name": { - "type": "string" + "type": "string", + "required": true } }, "relations": { @@ -54,4 +55,4 @@ "fields": ["id", "name", "provinceFk"] } } -} \ No newline at end of file +} diff --git a/back/models/user-config.json b/back/models/user-config.json index 5c5df1b9e..f8e563dc3 100644 --- a/back/models/user-config.json +++ b/back/models/user-config.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "userConfig" + "table": "userMultiConfig" } }, "properties": { diff --git a/back/models/vn-token.js b/back/models/vn-token.js new file mode 100644 index 000000000..03d45dae2 --- /dev/null +++ b/back/models/vn-token.js @@ -0,0 +1,5 @@ +const vnModel = require('vn-loopback/common/models/vn-model'); +module.exports = function(Self) { + vnModel(Self); + require('../methods/vn-token/killSession')(Self); +}; diff --git a/back/models/vn-token.json b/back/models/vn-token.json new file mode 100644 index 000000000..fab8965d6 --- /dev/null +++ b/back/models/vn-token.json @@ -0,0 +1,22 @@ +{ + "name": "VnToken", + "base": "AccessToken", + "options": { + "mysql": { + "table": "salix.AccessToken" + } + }, + "properties": { + "created": { + "type": "date" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "userId" + } + }, + "hidden": ["id"] +} diff --git a/back/models/vn-user.js b/back/models/vn-user.js index b59f13ffa..531561e04 100644 --- a/back/models/vn-user.js +++ b/back/models/vn-user.js @@ -15,6 +15,8 @@ module.exports = function(Self) { require('../methods/vn-user/renew-token')(Self); require('../methods/vn-user/share-token')(Self); require('../methods/vn-user/update-user')(Self); + require('../methods/vn-user/validate-token')(Self); + require('../methods/vn-user/acls')(Self); Self.definition.settings.acls = Self.definition.settings.acls.filter(acl => acl.property !== 'create'); @@ -99,9 +101,10 @@ module.exports = function(Self) { const headers = httpRequest.headers; const origin = headers.origin; - const defaultHash = '/reset-password?access_token=$token$'; + const defaultHash = '!/reset-password?access_token=$token$'; const recoverHashes = { - hedera: 'verificationToken=$token$' + hedera: '!verificationToken=$token$', + lilium: '/resetPassword?access_token=$token$' }; const app = info.options?.app; @@ -113,7 +116,7 @@ module.exports = function(Self) { const params = { recipient: info.email, lang: user.lang, - url: origin + '/#!' + recoverHash + url: origin + '/#' + recoverHash }; const options = Object.assign({}, info.options); diff --git a/back/models/vn-user.json b/back/models/vn-user.json index 5f6ac3f47..8c49c8db9 100644 --- a/back/models/vn-user.json +++ b/back/models/vn-user.json @@ -113,6 +113,13 @@ "principalId": "$everyone", "permission": "ALLOW" }, + { + "property": "validateToken", + "accessType": "EXECUTE", + "principalType": "ROLE", + "principalId": "$authenticated", + "permission": "ALLOW" + }, { "property": "privileges", "accessType": "*", @@ -133,6 +140,13 @@ "principalType": "ROLE", "principalId": "$authenticated", "permission": "ALLOW" + }, + { + "property": "acls", + "accessType": "*", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" } ], "scopes": { @@ -151,7 +165,8 @@ "hasGrant", "realm", "email", - "emailVerified" + "emailVerified", + "twoFactor" ] } } diff --git a/back/models/warehouse.json b/back/models/warehouse.json index dcbf7f2d2..9267900a5 100644 --- a/back/models/warehouse.json +++ b/back/models/warehouse.json @@ -9,21 +9,39 @@ }, "properties": { "id": { - "id": true, - "type": "number", - "forceId": false + "id": true, + "type": "number", + "forceId": false }, "name": { - "type": "string" + "type": "string" }, "code": { - "type": "string" + "type": "string" }, "isInventory": { - "type": "number" + "type": "number" }, - "isManaged":{ - "type": "boolean" + "isManaged": { + "type": "boolean" + }, + "isDestiny": { + "type": "boolean" + }, + "countryFk": { + "type": "number" + } + }, + "relations": { + "country": { + "type": "belongsTo", + "model": "Country", + "foreignKey": "countryFk" + }, + "address": { + "type": "belongsTo", + "model": "Address", + "foreignKey": "addressFk" } }, "acls": [ @@ -34,5 +52,11 @@ "permission": "ALLOW" } ], - "scope" : {"where": {"isForTicket": {"neq": 0}}} + "scope": { + "where": { + "isForTicket": { + "neq": 0 + } + } + } } diff --git a/back/models/workerActivity.js b/back/models/workerActivity.js new file mode 100644 index 000000000..b3bb2c160 --- /dev/null +++ b/back/models/workerActivity.js @@ -0,0 +1,3 @@ +module.exports = Self => { + require('../methods/workerActivity/add')(Self); +}; diff --git a/back/models/workerActivity.json b/back/models/workerActivity.json index e3b994f77..ecd92bbce 100644 --- a/back/models/workerActivity.json +++ b/back/models/workerActivity.json @@ -22,18 +22,18 @@ }, "description": { "type": "string" + } + }, + "relations": { + "workerFk": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" }, - "relations": { - "workerFk": { - "type": "belongsTo", - "model": "Worker", - "foreignKey": "workerFk" - }, - "workerActivityTypeFk": { - "type": "belongsTo", - "model": "WorkerActivityType", - "foreignKey": "workerActivityTypeFk" - } + "workerActivityTypeFk": { + "type": "belongsTo", + "model": "WorkerActivityType", + "foreignKey": "workerActivityTypeFk" } } } \ No newline at end of file diff --git a/back/nodemonConfig.json b/back/nodemonConfig.json index 5138bc30e..9552460bd 100644 --- a/back/nodemonConfig.json +++ b/back/nodemonConfig.json @@ -22,4 +22,4 @@ "modules/worker/front/**/*", "modules/zone/front/**/*" ] -} \ No newline at end of file +} diff --git a/back/process.yml b/back/process.yml index a29323240..94072b57d 100644 --- a/back/process.yml +++ b/back/process.yml @@ -2,6 +2,6 @@ apps: - script: ./loopback/server/server.js name: salix-back instances: 1 - max_restarts: 3 - restart_delay: 15000 + max_restarts: 0 + autorestart: false node_args: --tls-min-v1.0 --openssl-legacy-provider diff --git a/back/tests-helper.js b/back/tests-helper.js index b88fa1fd6..96f75f064 100644 --- a/back/tests-helper.js +++ b/back/tests-helper.js @@ -10,13 +10,13 @@ async function init() { host: process.env.DB_HOST, port: process.env.DB_PORT }); - const bootOptions = {dataSources}; await new Promise((resolve, reject) => { app.boot(bootOptions, err => err ? reject(err) : resolve()); }); // FIXME: Workaround to wait for loopback to be ready + app.emit('started'); await app.models.Application.status(); } @@ -32,3 +32,4 @@ module.exports = { if (require.main === module) init(); + diff --git a/back/tests.js b/back/tests.js index 50698eb92..2527367c2 100644 --- a/back/tests.js +++ b/back/tests.js @@ -84,7 +84,7 @@ async function test() { 'loopback/**/*[sS]pec.js', 'modules/*/back/**/*.[sS]pec.js' ], - helpers: [] + helpers: [`back/vn-jasmine.js`], }; if (PARALLEL) { @@ -114,7 +114,6 @@ async function test() { if (opts.ci) runner.jasmine.DEFAULT_TIMEOUT_INTERVAL = SPEC_TIMEOUT; - // runner.loadConfigFile('back/jasmine.json'); runner.loadConfig(config); process.env.SPEC_IS_RUNNING = true; await runner.execute(); diff --git a/back/vn-jasmine.js b/back/vn-jasmine.js new file mode 100644 index 000000000..2b981c6d9 --- /dev/null +++ b/back/vn-jasmine.js @@ -0,0 +1,48 @@ + +const LoopBackContext = require('loopback-context'); +const getAccessToken = (userId = 9) => { + return {accessToken: {userId}}; +}; +const DEFAULT_HEADERS = {headers: {origin: 'http://localhost'}}; +const default_before_all = userId => { + return { + req: { + ...getAccessToken(userId), + ...DEFAULT_HEADERS, + ...{__: value => value} + + }, + args: {} + }; +}; +const default_loopback_ctx = userId => { + return { + ...getAccessToken(userId), + ...default_before_all(userId), + http: { + ...default_before_all(userId) + }, + args: {} + }; +}; + +function vnBeforeAll() { + Object.assign(beforeAll, {getCtx: default_before_all, mockLoopBackContext}); +} + +const mockLoopBackContext = userId => { + const activeCtx = default_loopback_ctx(userId); + beforeAll(() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + return activeCtx; +}; +module.exports = { + mockLoopBackContext +}; + +(function init() { + vnBeforeAll(); +})(); diff --git a/db/.pullinfo.json b/db/.pullinfo.json index 0defed845..5b75584d1 100644 --- a/db/.pullinfo.json +++ b/db/.pullinfo.json @@ -9,7 +9,7 @@ }, "vn": { "view": { - "expeditionPallet_Print": "06613719475fcdba8309607c38cc78efc2e348cca7bc96b48dc3ae3c12426f54" + "expeditionPallet_Print": "99f75145ac2e7b612a6d71e74b6e55f194a465780fd9875a15eb01e6596b447e" } } } diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index f49e3f0f9..ca254055b 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -1,9 +1,10 @@ USE `util`; +/*M!999999\- enable the sandbox mode */ /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -INSERT INTO `version` VALUES ('vn-database','11031','12f36dc825b6660062e2c86fde9c6b451cb58f0d','2024-05-14 08:25:58','11048'); +INSERT INTO `version` VALUES ('vn-database','11278','fe10f03459a153fc213bf64e352804c043f94590','2024-10-03 07:47:47','11281'); INSERT INTO `versionLog` VALUES ('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL); @@ -644,6 +645,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','10849','15-invoiceInLog.sql','je INSERT INTO `versionLog` VALUES ('vn-database','10849','16-travelLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10849','17-packingSiteDeviceLog.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:45:55',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10851','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-01-30 13:31:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10852','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:37',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10853','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:46:05',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10853','00-secondScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-02-15 09:46:06',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10854','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-01-30 16:20:34',NULL,NULL); @@ -759,9 +761,11 @@ INSERT INTO `versionLog` VALUES ('vn-database','10953','06-srt.sql','jenkins@db- INSERT INTO `versionLog` VALUES ('vn-database','10953','07-util.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:55',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10953','08-vn.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:56',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10953','08-vn2.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10955','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:16',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10956','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10957','00-aclTicketClone.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10959','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-18 13:32:25',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10960','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:12',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10962','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-25 08:27:35',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10964','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10967','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL); @@ -774,7 +778,10 @@ INSERT INTO `versionLog` VALUES ('vn-database','10975','00-action.sql','jenkins@ INSERT INTO `versionLog` VALUES ('vn-database','10975','01-expeditionFk.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-03 12:04:52',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10976','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:57',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10977','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:57',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10978','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:33',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10983','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:37',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10984','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10986','00-addSummaryId.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:12',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10988','00-pbx_prefix.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-04-11 17:00:16',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10990','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10991','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL); @@ -788,28 +795,251 @@ INSERT INTO `versionLog` VALUES ('vn-database','10996','00-dropOrderRecalc.sql', INSERT INTO `versionLog` VALUES ('vn-database','10996','01-dropTicketRecalc.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10996','02-dropTravelRecalc.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10997','00-groupingMode.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11000','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:16',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11001','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11002','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11003','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11006','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:16',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11007','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11008','00-alter.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11010','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11012','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11013','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11014','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11015','00-photoMotivation.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11016','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-27 13:16:09',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11018','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11019','00-locker.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11019','01-aclLocker.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11021','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-30 09:07:56',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11022','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11026','00-entryAlter.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11026','01-entryUpdate.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11026','02-entryInternal.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11030','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11031','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11033','00-rollbackAcls.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-07 12:45:45',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11034','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11037','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11038','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11040','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:31',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11042','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11044','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:31',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11045','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-10 14:53:29',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11046','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:46',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11050','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11050','01-elementFilter.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11051','00-sipConfig_callLimit.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-14 14:31:10',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11054','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:46',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11055','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:46',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11057','00-part.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:46',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11057','01-part.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:47',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11057','02-part.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:47',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11057','03-part.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:48',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11058','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:48',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11059','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11060','00-createRoleReviewer.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11061','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:48',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11063','00-roadmapAddress.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11063','01-roadmapStop.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11063','02-roadmapStopGrants.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11064','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11065','00-modifyInvoiceInPrivileges.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11065','01-modifyInvoiceInAcls.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11068','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11069','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11070','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11071','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:48',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11073','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11074','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11075','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-28 12:54:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11078','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11079','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-31 08:22:10',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11080','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-31 12:01:58',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11081','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11082','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11083','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-03 10:46:36',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11084','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11086','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-27 10:02:02',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11087','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11088','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:44:48',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11089','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:39:16',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11090','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11092','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-07 08:21:23',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11093','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:39:16',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11096','00-addBuyerAcl.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 12:48:51',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11099','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11100','00-modifyTimeControlAcls.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11101','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11102','00-createTravelKgPercentage.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11103','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11104','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11105','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-20 15:36:07',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11106','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:39:49',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:44:48',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','01-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:44:48',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','02-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:44:48',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','03-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:44:48',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','04-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:44:49',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','05-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:44:49',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','06-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:45:04',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','07-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:45:41',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','08-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:45:41',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','09-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:45:47',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','10-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:45:48',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','11-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:45:59',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','12-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:46:00',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','14-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:46:00',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','15-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:46:06',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','17-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:46:06',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','18-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:46:06',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','19-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:46:19',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','20-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:46:19',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','21-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:34',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','22-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:34',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','23-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11107','24-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11108','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 07:38:39',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11109','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-18 19:09:56',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11110','00-clientUnpaid.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11111','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11112','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 07:38:40',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11113','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11114','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:39:49',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11115','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11116','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11117','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11118','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-19 12:28:49',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11119','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11120','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11121','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11124','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 07:38:40',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11124','01-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 07:38:40',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11126','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11128','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11129','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11130','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11131','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11134','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-05 11:02:07',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11135','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:16',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11136','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:16',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11137','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:33',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11138','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:34',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11139','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-08 10:58:01',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11140','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:34',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11141','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:39:07',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11142','00-invoiceOutSerialColumn.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:39:07',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11142','01-invoiceOutSerialUpdate.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:39:07',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11145','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 13:55:46',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11146','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11149','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11150','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11152','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-16 09:06:11',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11154','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11155','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11156','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11157','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-16 13:11:00',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11158','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-17 17:06:30',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11159','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-18 17:23:32',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11160','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-18 13:46:16',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11161','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11164','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-23 11:03:16',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11165','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-20 08:34:43',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11166','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-20 08:34:43',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11168','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-25 08:58:34',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11169','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-25 12:38:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11170','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-09 07:12:38',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11171','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:39:07',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11172','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:39:07',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11172','01-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:39:07',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11172','02-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:39:07',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11172','03-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:39:07',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11172','04-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:39:07',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11172','05-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:39:08',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11172','06-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:39:08',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11172','07-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:40:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11172','08-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:54:58',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11172','09-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:55:00',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11172','10-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:55:16',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11172','11-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:57:20',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11172','12-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:57:20',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11172','13-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:57:20',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11172','14-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:57:25',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11172','15-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:57:44',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11175','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:57:44',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11177','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-30 12:42:28',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11178','00-aclSetWeight.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11179','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-20 08:34:43',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11180','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-20 08:34:43',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11182','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-08-09 08:19:36',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11183','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 07:38:42',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11185','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:57:44',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11187','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:57:44',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11189','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:00',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11190','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:00',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11191','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:00',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11191','01-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11191','02-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11192','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11193','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11193','01-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11193','02-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11194','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11195','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11196','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-18 07:28:14',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11197','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11201','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-27 13:04:26',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11204','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11205','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-04 13:54:55',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11206','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 07:38:42',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11207','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 07:38:42',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11209','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-03 08:58:01',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11210','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11210','01-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11210','02-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:40',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11210','03-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:41',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11211','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 07:38:42',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11213','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-06 06:31:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11215','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 07:38:42',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11216','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:41',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11217','00-hederaMessages.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-09 12:21:45',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11219','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:41',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11221','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:41',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11222','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:41',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11223','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:41',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11224','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:41',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11225','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:41',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11225','01-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:41',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11225','02-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:41',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11227','00-addWorkerTimeControlMailAcl.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:41',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11229','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-16 08:24:17',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11234','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:42',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11235','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11236','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11236','01-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11237','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11239','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-17 12:57:06',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11240','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11241','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-20 09:08:25',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11246','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-18 12:39:53',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11247','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-19 12:10:08',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11248','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-23 11:12:17',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11249','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11253','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-20 14:41:27',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11255','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11256','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-09-23 12:18:24',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11262','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11263','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-09-27 12:05:32',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11278','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-03 07:47:43',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11279','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-10-02 08:05:24',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11280','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-02 08:46:50',NULL,NULL); /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; USE `account`; +/*M!999999\- enable the sandbox mode */ /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; @@ -887,7 +1117,7 @@ INSERT INTO `role` VALUES (109,'salesTeamBoss','Jefe de equipo de comerciales',1 INSERT INTO `role` VALUES (110,'palletizer','Paletizadores',1,'2022-12-02 13:56:22','2022-12-02 13:56:30',NULL); INSERT INTO `role` VALUES (111,'entryEditor','Entry editor',1,'2023-01-13 12:21:55','2023-01-13 12:21:55',NULL); INSERT INTO `role` VALUES (112,'maintenance','Personal de mantenimiento',1,'2023-01-19 07:23:35','2023-01-19 07:23:35',NULL); -INSERT INTO `role` VALUES (114,'maintenanceBos','Jefe de mantenimiento',1,'2023-01-19 07:31:16','2023-05-17 13:07:21',NULL); +INSERT INTO `role` VALUES (114,'maintenanceBoss','Jefe de mantenimiento',1,'2023-01-19 07:31:16','2024-06-14 08:56:41',19295); INSERT INTO `role` VALUES (115,'itManagement','TI management',1,'2023-03-29 09:27:55','2023-03-29 09:28:04',NULL); INSERT INTO `role` VALUES (119,'palletizerBoss','Jefe de paletizadores',1,'2023-06-07 13:51:54','2023-06-07 13:51:54',NULL); INSERT INTO `role` VALUES (120,'developerBoss','Jefe de proyecto de desarrollo',1,'2023-06-19 09:07:21','2023-06-19 09:07:21',21709); @@ -899,6 +1129,8 @@ INSERT INTO `role` VALUES (125,'claimViewer','Trabajadores que consulta las recl INSERT INTO `role` VALUES (126,'greenhouseBoss','Jefe de invernadero',1,'2023-11-16 14:32:13','2023-11-16 14:32:13',NULL); INSERT INTO `role` VALUES (127,'timeControl','Tablet para fichar',1,'2024-01-09 16:36:56','2024-01-09 16:36:56',NULL); INSERT INTO `role` VALUES (129,'buyerAssistant','Comprador que tienes mas permisos para ayudar al buyerBoss en algunas tareas',1,'2024-02-06 06:59:12','2024-02-06 06:59:12',783); +INSERT INTO `role` VALUES (130,'reviewer','Revisor de producción',1,'2024-06-11 00:00:00','2024-06-11 00:00:00',10578); +INSERT INTO `role` VALUES (131,'supplier','Privilegios básicos de un proveedor',1,'2024-07-05 10:18:58','2024-07-05 10:18:58',19295); INSERT INTO `roleInherit` VALUES (1,1,2,NULL); INSERT INTO `roleInherit` VALUES (2,1,3,NULL); @@ -925,7 +1157,6 @@ INSERT INTO `roleInherit` VALUES (27,21,53,NULL); INSERT INTO `roleInherit` VALUES (28,22,13,NULL); INSERT INTO `roleInherit` VALUES (29,22,21,NULL); INSERT INTO `roleInherit` VALUES (30,30,5,NULL); -INSERT INTO `roleInherit` VALUES (31,30,20,NULL); INSERT INTO `roleInherit` VALUES (32,30,22,NULL); INSERT INTO `roleInherit` VALUES (33,30,53,NULL); INSERT INTO `roleInherit` VALUES (34,30,64,NULL); @@ -935,7 +1166,6 @@ INSERT INTO `roleInherit` VALUES (37,34,1,NULL); INSERT INTO `roleInherit` VALUES (38,34,13,NULL); INSERT INTO `roleInherit` VALUES (39,34,33,NULL); INSERT INTO `roleInherit` VALUES (40,35,1,NULL); -INSERT INTO `roleInherit` VALUES (42,36,47,NULL); INSERT INTO `roleInherit` VALUES (43,37,1,NULL); INSERT INTO `roleInherit` VALUES (44,38,37,NULL); INSERT INTO `roleInherit` VALUES (45,38,64,NULL); @@ -1090,7 +1320,6 @@ INSERT INTO `roleInherit` VALUES (249,109,18,NULL); INSERT INTO `roleInherit` VALUES (250,109,13,NULL); INSERT INTO `roleInherit` VALUES (251,51,21,NULL); INSERT INTO `roleInherit` VALUES (253,48,49,NULL); -INSERT INTO `roleInherit` VALUES (254,110,1,NULL); INSERT INTO `roleInherit` VALUES (255,110,76,NULL); INSERT INTO `roleInherit` VALUES (256,48,69,NULL); INSERT INTO `roleInherit` VALUES (257,47,111,NULL); @@ -1158,13 +1387,26 @@ INSERT INTO `roleInherit` VALUES (353,110,49,NULL); INSERT INTO `roleInherit` VALUES (354,103,119,NULL); INSERT INTO `roleInherit` VALUES (355,127,11,NULL); INSERT INTO `roleInherit` VALUES (356,123,125,NULL); -INSERT INTO `roleInherit` VALUES (357,36,35,NULL); INSERT INTO `roleInherit` VALUES (358,36,49,NULL); INSERT INTO `roleInherit` VALUES (359,129,35,NULL); INSERT INTO `roleInherit` VALUES (360,101,129,NULL); INSERT INTO `roleInherit` VALUES (361,50,112,NULL); INSERT INTO `roleInherit` VALUES (362,122,15,NULL); INSERT INTO `roleInherit` VALUES (364,35,18,NULL); +INSERT INTO `roleInherit` VALUES (365,123,119,NULL); +INSERT INTO `roleInherit` VALUES (366,30,37,NULL); +INSERT INTO `roleInherit` VALUES (367,30,73,NULL); +INSERT INTO `roleInherit` VALUES (368,130,49,10578); +INSERT INTO `roleInherit` VALUES (369,50,130,10578); +INSERT INTO `roleInherit` VALUES (370,72,130,10578); +INSERT INTO `roleInherit` VALUES (371,36,35,NULL); +INSERT INTO `roleInherit` VALUES (372,126,13,19295); +INSERT INTO `roleInherit` VALUES (373,131,2,19295); +INSERT INTO `roleInherit` VALUES (375,120,131,1437); +INSERT INTO `roleInherit` VALUES (376,124,21,19336); +INSERT INTO `roleInherit` VALUES (377,47,49,19295); +INSERT INTO `roleInherit` VALUES (378,101,15,19294); +INSERT INTO `roleInherit` VALUES (379,103,121,19294); INSERT INTO `userPassword` VALUES (1,7,1,0,2,1); @@ -1177,716 +1419,800 @@ INSERT INTO `mailConfig` VALUES (1,'verdnatura.es'); /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; USE `salix`; +/*M!999999\- enable the sandbox mode */ /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -INSERT INTO `ACL` VALUES (3,'Address','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (5,'AgencyService','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (9,'ClientObservation','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (11,'ContactChannel','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (13,'Employee','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (14,'PayMethod','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (16,'FakeProduction','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (17,'Warehouse','* ','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (20,'TicketState','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (24,'Delivery','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (25,'Zone','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (26,'ClientCredit','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (27,'ClientCreditLimit','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (30,'GreugeType','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (31,'Mandate','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (32,'MandateType','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (33,'Company','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (34,'Greuge','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (35,'AddressObservation','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (36,'ObservationType','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (37,'Greuge','*','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (38,'AgencyMode','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'); -INSERT INTO `ACL` VALUES (44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'); -INSERT INTO `ACL` VALUES (51,'ItemTag','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (53,'Item','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (54,'Item','*','WRITE','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (55,'Recovery','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (58,'CreditClassification','*','*','ALLOW','ROLE','insurance'); -INSERT INTO `ACL` VALUES (60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'); -INSERT INTO `ACL` VALUES (61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (63,'TicketObservation','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (65,'Sale','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (66,'TicketTracking','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (68,'TicketPackaging','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (69,'Packaging','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'); -INSERT INTO `ACL` VALUES (72,'SaleComponent','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (73,'Expedition','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryAssistant'); -INSERT INTO `ACL` VALUES (75,'Expedition','*','WRITE','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (77,'WorkerMana','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (79,'Ticket','state','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (80,'Sale','deleteSales','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (83,'Sale','updatePrice','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (85,'SaleTracking','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (86,'Order','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (87,'OrderRow','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (88,'ClientContact','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (90,'Sale','reserve','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (97,'ClaimEnd','*','WRITE','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (102,'Claim','createFromSales','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'); -INSERT INTO `ACL` VALUES (105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'); -INSERT INTO `ACL` VALUES (106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'); -INSERT INTO `ACL` VALUES (108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'); -INSERT INTO `ACL` VALUES (109,'UserConfig','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (110,'Accounting','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (111,'ClientLog','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (112,'Defaulter','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (113,'ClientRisk','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (114,'Receipt','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (116,'BankEntity','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (117,'ClientSample','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'); -INSERT INTO `ACL` VALUES (119,'Travel','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (120,'Travel','*','WRITE','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (121,'Item','regularize','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (122,'TicketRequest','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (127,'TicketLog','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (129,'TicketService','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (130,'Expedition','*','WRITE','ALLOW','ROLE','packager'); -INSERT INTO `ACL` VALUES (131,'CreditInsurance','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (132,'CreditClassification','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'); -INSERT INTO `ACL` VALUES (135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (141,'Zone','*','*','ALLOW','ROLE','logisticBoss'); -INSERT INTO `ACL` VALUES (142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryAssistant'); -INSERT INTO `ACL` VALUES (143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryAssistant'); -INSERT INTO `ACL` VALUES (144,'Stowaway','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (147,'UserConfigView','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (148,'UserConfigView','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (149,'Sip','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (150,'Sip','*','WRITE','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (151,'Department','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (152,'Department','*','WRITE','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (154,'Route','*','WRITE','ALLOW','ROLE','delivery'); -INSERT INTO `ACL` VALUES (155,'Calendar','*','READ','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (157,'Calendar','absences','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'); -INSERT INTO `ACL` VALUES (160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (161,'TicketConfig','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'); -INSERT INTO `ACL` VALUES (163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'); -INSERT INTO `ACL` VALUES (165,'TicketDms','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (172,'Sms','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (173,'Sms','send','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (176,'Device','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (177,'Device','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (179,'ItemLog','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (180,'RouteLog','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (186,'ClientDms','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryAssistant'); -INSERT INTO `ACL` VALUES (191,'Agency','getLanded','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (192,'Agency','getShipped','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (194,'Postcode','*','WRITE','ALLOW','ROLE','deliveryAssistant'); -INSERT INTO `ACL` VALUES (195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (197,'Dms','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (199,'ClaimDms','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (203,'UserPhone','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (205,'WorkerDms','*','READ','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (206,'Chat','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (207,'Chat','sendMessage','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (211,'TravelLog','*','READ','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (212,'Thermograph','*','*','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (213,'TravelThermograph','*','WRITE','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (214,'Entry','*','*','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (216,'TravelThermograph','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (218,'Intrastat','*','*','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (221,'UserConfig','getUserConfig','READ','ALLOW','ROLE','account'); -INSERT INTO `ACL` VALUES (226,'ClientObservation','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (227,'Address','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (228,'AddressObservation','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (230,'ClientCredit','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (231,'ClientContact','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (232,'ClientSample','*','READ','ALLOW','ROLE','trainee'); -INSERT INTO `ACL` VALUES (233,'EntryLog','*','READ','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (234,'WorkerLog','find','READ','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (235,'CustomsAgent','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (236,'Buy','*','*','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (237,'WorkerDms','filter','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (238,'Town','*','WRITE','ALLOW','ROLE','deliveryAssistant'); -INSERT INTO `ACL` VALUES (239,'Province','*','WRITE','ALLOW','ROLE','deliveryAssistant'); -INSERT INTO `ACL` VALUES (241,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (248,'RoleMapping','*','READ','ALLOW','ROLE','account'); -INSERT INTO `ACL` VALUES (249,'UserPassword','*','READ','ALLOW','ROLE','account'); -INSERT INTO `ACL` VALUES (250,'Town','*','WRITE','ALLOW','ROLE','deliveryAssistant'); -INSERT INTO `ACL` VALUES (251,'Province','*','WRITE','ALLOW','ROLE','deliveryAssistant'); -INSERT INTO `ACL` VALUES (252,'Supplier','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (253,'Supplier','*','WRITE','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (254,'SupplierLog','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (256,'Image','*','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (257,'FixedPrice','*','*','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (258,'PayDem','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (259,'Client','createReceipt','*','ALLOW','ROLE','salesAssistant'); -INSERT INTO `ACL` VALUES (260,'PrintServerQueue','*','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (261,'SupplierAccount','*','*','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (262,'Entry','*','*','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (263,'InvoiceIn','*','*','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (264,'StarredModule','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (265,'ItemBotanical','*','WRITE','ALLOW','ROLE','logisticBoss'); -INSERT INTO `ACL` VALUES (266,'ZoneLog','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (267,'Genus','*','WRITE','ALLOW','ROLE','logisticBoss'); -INSERT INTO `ACL` VALUES (268,'Specie','*','WRITE','ALLOW','ROLE','logisticBoss'); -INSERT INTO `ACL` VALUES (269,'InvoiceOut','createPdf','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (270,'SupplierAddress','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (271,'SalesMonitor','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (272,'InvoiceInLog','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (273,'InvoiceInTax','*','*','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (274,'InvoiceInLog','*','READ','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (275,'InvoiceOut','createManualInvoice','WRITE','ALLOW','ROLE','invoicing'); -INSERT INTO `ACL` VALUES (276,'InvoiceOut','globalInvoicing','WRITE','ALLOW','ROLE','invoicing'); -INSERT INTO `ACL` VALUES (278,'RoleInherit','*','WRITE','ALLOW','ROLE','grant'); -INSERT INTO `ACL` VALUES (279,'MailAlias','*','READ','ALLOW','ROLE','marketing'); -INSERT INTO `ACL` VALUES (283,'EntryObservation','*','*','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (284,'LdapConfig','*','*','ALLOW','ROLE','sysadmin'); -INSERT INTO `ACL` VALUES (285,'SambaConfig','*','*','ALLOW','ROLE','sysadmin'); -INSERT INTO `ACL` VALUES (286,'ACL','*','*','ALLOW','ROLE','developer'); -INSERT INTO `ACL` VALUES (287,'AccessToken','*','*','ALLOW','ROLE','developer'); -INSERT INTO `ACL` VALUES (293,'RoleInherit','*','*','ALLOW','ROLE','it'); -INSERT INTO `ACL` VALUES (294,'RoleRole','*','*','ALLOW','ROLE','it'); -INSERT INTO `ACL` VALUES (295,'AccountConfig','*','*','ALLOW','ROLE','sysadmin'); -INSERT INTO `ACL` VALUES (296,'Collection','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (297,'Sale','clone','WRITE','ALLOW','ROLE','invoicing'); -INSERT INTO `ACL` VALUES (298,'InvoiceInDueDay','*','*','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (299,'Collection','setSaleQuantity','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (302,'AgencyTerm','*','*','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (303,'ClaimLog','*','READ','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (304,'Edi','updateData','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (305,'EducationLevel','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (306,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (307,'SupplierAgencyTerm','*','*','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (308,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (309,'Zone','getZoneClosing','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (310,'ExpeditionState','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (311,'Expense','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (312,'Expense','*','WRITE','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (314,'SupplierActivity','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (315,'SupplierActivity','*','WRITE','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (316,'Dms','deleteTrashFiles','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (317,'ClientUnpaid','*','*','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (318,'MdbVersion','*','*','ALLOW','ROLE','developer'); -INSERT INTO `ACL` VALUES (319,'ItemType','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (320,'ItemType','*','WRITE','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (321,'InvoiceOut','refund','WRITE','ALLOW','ROLE','invoicing'); -INSERT INTO `ACL` VALUES (322,'InvoiceOut','refund','WRITE','ALLOW','ROLE','salesAssistant'); -INSERT INTO `ACL` VALUES (323,'InvoiceOut','refund','WRITE','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (324,'Ticket','refund','WRITE','ALLOW','ROLE','invoicing'); -INSERT INTO `ACL` VALUES (325,'Ticket','refund','WRITE','ALLOW','ROLE','salesAssistant'); -INSERT INTO `ACL` VALUES (326,'Ticket','refund','WRITE','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (327,'Sale','clone','WRITE','ALLOW','ROLE','salesAssistant'); -INSERT INTO `ACL` VALUES (328,'Sale','clone','WRITE','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (329,'TicketRefund','*','WRITE','ALLOW','ROLE','invoicing'); -INSERT INTO `ACL` VALUES (330,'ClaimObservation','*','WRITE','ALLOW','ROLE','salesPerson'); -INSERT INTO `ACL` VALUES (331,'ClaimObservation','*','READ','ALLOW','ROLE','salesPerson'); -INSERT INTO `ACL` VALUES (332,'Client','setPassword','WRITE','ALLOW','ROLE','salesPerson'); -INSERT INTO `ACL` VALUES (333,'Client','updateUser','WRITE','ALLOW','ROLE','salesPerson'); -INSERT INTO `ACL` VALUES (334,'ShelvingLog','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (335,'ZoneExclusionGeo','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (336,'ZoneExclusionGeo','*','WRITE','ALLOW','ROLE','deliveryAssistant'); -INSERT INTO `ACL` VALUES (337,'Parking','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (338,'Shelving','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (339,'OsTicket','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (340,'OsTicketConfig','*','*','ALLOW','ROLE','it'); -INSERT INTO `ACL` VALUES (341,'ClientConsumptionQueue','*','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (342,'Ticket','deliveryNotePdf','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (343,'Ticket','deliveryNoteEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (344,'Ticket','deliveryNoteCsvPdf','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (345,'Ticket','deliveryNoteCsvEmail','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (346,'Client','campaignMetricsPdf','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (347,'Client','campaignMetricsEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (348,'Client','clientWelcomeHtml','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (349,'Client','clientWelcomeEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (350,'Client','creditRequestPdf','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (351,'Client','creditRequestHtml','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (352,'Client','creditRequestEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (353,'Client','printerSetupHtml','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (354,'Client','printerSetupEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (355,'Client','sepaCoreEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (356,'Client','letterDebtorPdf','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (357,'Client','letterDebtorStHtml','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (358,'Client','letterDebtorStEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (359,'Client','letterDebtorNdHtml','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (360,'Client','letterDebtorNdEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (361,'Client','clientDebtStatementPdf','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (362,'Client','clientDebtStatementHtml','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (363,'Client','clientDebtStatementEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (364,'Client','incotermsAuthorizationPdf','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (365,'Client','incotermsAuthorizationHtml','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (366,'Client','incotermsAuthorizationEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (367,'Client','consumptionSendQueued','WRITE','ALLOW','ROLE','system'); -INSERT INTO `ACL` VALUES (368,'InvoiceOut','invoiceEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (369,'InvoiceOut','exportationPdf','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (370,'InvoiceOut','sendQueued','WRITE','ALLOW','ROLE','system'); -INSERT INTO `ACL` VALUES (371,'Ticket','invoiceCsvPdf','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (372,'Ticket','invoiceCsvEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (373,'Supplier','campaignMetricsPdf','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (374,'Supplier','campaignMetricsEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (375,'Travel','extraCommunityPdf','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (376,'Travel','extraCommunityEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (377,'Entry','entryOrderPdf','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (378,'OsTicket','osTicketReportEmail','WRITE','ALLOW','ROLE','system'); -INSERT INTO `ACL` VALUES (379,'Item','buyerWasteEmail','WRITE','ALLOW','ROLE','system'); -INSERT INTO `ACL` VALUES (380,'Claim','claimPickupPdf','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (381,'Claim','claimPickupEmail','WRITE','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (382,'Item','labelPdf','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (383,'Sector','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (384,'Sector','*','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (385,'Route','driverRoutePdf','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (386,'Route','driverRouteEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (387,'Ticket','deliveryNotePdf','READ','ALLOW','ROLE','customer'); -INSERT INTO `ACL` VALUES (388,'Supplier','newSupplier','WRITE','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (389,'ClaimRma','*','READ','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (390,'ClaimRma','*','WRITE','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (391,'Notification','*','WRITE','ALLOW','ROLE','system'); -INSERT INTO `ACL` VALUES (392,'Boxing','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (393,'Url','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (394,'Url','*','WRITE','ALLOW','ROLE','it'); -INSERT INTO `ACL` VALUES (395,'ItemShelving','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (396,'ItemShelving','*','WRITE','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (397,'ItemShelvingPlacementSupplyStock','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (398,'NotificationQueue','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (399,'InvoiceOut','clientsToInvoice','WRITE','ALLOW','ROLE','invoicing'); -INSERT INTO `ACL` VALUES (400,'InvoiceOut','invoiceClient','WRITE','ALLOW','ROLE','invoicing'); -INSERT INTO `ACL` VALUES (401,'Sale','editTracked','WRITE','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (402,'Sale','editFloramondo','WRITE','ALLOW','ROLE','salesAssistant'); -INSERT INTO `ACL` VALUES (403,'Receipt','balanceCompensationEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (404,'Receipt','balanceCompensationPdf','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (405,'Ticket','getTicketsFuture','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (406,'Ticket','merge','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (407,'Sale','editFloramondo','WRITE','ALLOW','ROLE','logistic'); -INSERT INTO `ACL` VALUES (408,'ZipConfig','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (409,'Item','*','WRITE','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (410,'Sale','editCloned','WRITE','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (411,'Sale','editCloned','WRITE','ALLOW','ROLE','salesAssistant'); -INSERT INTO `ACL` VALUES (414,'MdbVersion','*','READ','ALLOW','ROLE','$everyone'); -INSERT INTO `ACL` VALUES (416,'TicketLog','getChanges','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (417,'Ticket','getTicketsAdvance','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (418,'EntryLog','*','READ','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (419,'Sale','editTracked','WRITE','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (420,'MdbBranch','*','READ','ALLOW','ROLE','$everyone'); -INSERT INTO `ACL` VALUES (421,'ItemShelvingSale','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (422,'Docuware','checkFile','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (423,'Docuware','download','READ','ALLOW','ROLE','salesPerson'); -INSERT INTO `ACL` VALUES (424,'Docuware','upload','WRITE','ALLOW','ROLE','productionAssi'); -INSERT INTO `ACL` VALUES (425,'Docuware','deliveryNoteEmail','WRITE','ALLOW','ROLE','salesPerson'); -INSERT INTO `ACL` VALUES (426,'TpvTransaction','confirm','WRITE','ALLOW','ROLE','$everyone'); -INSERT INTO `ACL` VALUES (427,'TpvTransaction','start','WRITE','ALLOW','ROLE','$authenticated'); -INSERT INTO `ACL` VALUES (428,'TpvTransaction','end','WRITE','ALLOW','ROLE','$authenticated'); -INSERT INTO `ACL` VALUES (429,'ItemConfig','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (431,'Tag','onSubmit','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (432,'Worker','updateAttributes','WRITE','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (433,'Worker','createAbsence','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (434,'Worker','updateAbsence','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (435,'Worker','deleteAbsence','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (436,'Worker','new','WRITE','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (438,'Client','getClientOrSupplierReference','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (439,'NotificationSubscription','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (440,'NotificationAcl','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (441,'MdbApp','*','READ','ALLOW','ROLE','$everyone'); -INSERT INTO `ACL` VALUES (442,'MdbApp','*','*','ALLOW','ROLE','developer'); -INSERT INTO `ACL` VALUES (443,'ItemConfig','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (444,'DeviceProduction','*','*','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (445,'DeviceProductionModels','*','*','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (446,'DeviceProductionState','*','*','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (447,'DeviceProductionUser','*','*','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (448,'DeviceProduction','*','*','ALLOW','ROLE','productionAssi'); -INSERT INTO `ACL` VALUES (449,'DeviceProductionModels','*','*','ALLOW','ROLE','productionAssi'); -INSERT INTO `ACL` VALUES (450,'DeviceProductionState','*','*','ALLOW','ROLE','productionAssi'); -INSERT INTO `ACL` VALUES (451,'DeviceProductionUser','*','*','ALLOW','ROLE','productionAssi'); -INSERT INTO `ACL` VALUES (452,'Worker','deallocatePDA','*','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (453,'Worker','allocatePDA','*','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (454,'Worker','deallocatePDA','*','ALLOW','ROLE','productionAssi'); -INSERT INTO `ACL` VALUES (455,'Worker','allocatePDA','*','ALLOW','ROLE','productionAssi'); -INSERT INTO `ACL` VALUES (456,'Zone','*','*','ALLOW','ROLE','deliveryAssistant'); -INSERT INTO `ACL` VALUES (458,'Operator','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (459,'Operator','*','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (460,'InvoiceIn','getSerial','READ','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (461,'Ticket','saveSign','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (462,'InvoiceOut','negativeBases','READ','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (463,'InvoiceOut','negativeBasesCsv','READ','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (464,'WorkerObservation','*','*','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (465,'ClientInforma','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (466,'ClientInforma','*','WRITE','ALLOW','ROLE','financial'); -INSERT INTO `ACL` VALUES (467,'Receipt','receiptEmail','*','ALLOW','ROLE','salesAssistant'); -INSERT INTO `ACL` VALUES (468,'Client','setRating','WRITE','ALLOW','ROLE','financial'); -INSERT INTO `ACL` VALUES (470,'Client','addressesPropagateRe','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (471,'Client','canBeInvoiced','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (472,'Client','canCreateTicket','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (473,'Client','consumption','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (474,'Client','createAddress','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (475,'Client','createWithUser','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (476,'Client','extendedListFilter','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (477,'Client','getAverageInvoiced','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (478,'Client','getCard','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (479,'Client','getDebt','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (480,'Client','getMana','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (481,'Client','transactions','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (482,'Client','hasCustomerRole','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (483,'Client','isValidClient','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (484,'Client','lastActiveTickets','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (485,'Client','sendSms','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (486,'Client','setPassword','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (487,'Client','summary','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (488,'Client','updateAddress','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (489,'Client','updateFiscalData','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (491,'Client','uploadFile','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (492,'Client','campaignMetricsPdf','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (493,'Client','campaignMetricsEmail','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (494,'Client','clientWelcomeHtml','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (495,'Client','clientWelcomeEmail','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (496,'Client','printerSetupHtml','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (497,'Client','printerSetupEmail','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (498,'Client','sepaCoreEmail','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (499,'Client','letterDebtorPdf','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (500,'Client','letterDebtorStHtml','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (501,'Client','letterDebtorStEmail','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (502,'Client','letterDebtorNdHtml','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (503,'Client','letterDebtorNdEmail','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (504,'Client','clientDebtStatementPdf','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (505,'Client','clientDebtStatementHtml','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (506,'Client','clientDebtStatementEmail','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (507,'Client','creditRequestPdf','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (508,'Client','creditRequestHtml','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (509,'Client','creditRequestEmail','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (510,'Client','incotermsAuthorizationPdf','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (511,'Client','incotermsAuthorizationHtml','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (512,'Client','incotermsAuthorizationEmail','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (513,'Client','consumptionSendQueued','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (514,'Client','filter','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (515,'Client','getClientOrSupplierReference','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (516,'Client','upsert','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (518,'Client','replaceById','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (519,'Client','updateAttributes','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (520,'Client','updateAttributes','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (521,'Client','deleteById','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (522,'Client','replaceOrCreate','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (523,'Client','updateAll','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (524,'Client','upsertWithWhere','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (525,'Defaulter','observationEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (527,'VnUser','acl','READ','ALLOW','ROLE','account'); -INSERT INTO `ACL` VALUES (528,'VnUser','getCurrentUserData','READ','ALLOW','ROLE','account'); -INSERT INTO `ACL` VALUES (530,'Account','exists','READ','ALLOW','ROLE','account'); -INSERT INTO `ACL` VALUES (531,'Account','exists','READ','ALLOW','ROLE','account'); -INSERT INTO `ACL` VALUES (532,'UserLog','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (533,'RoleLog','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (534,'WagonType','*','*','ALLOW','ROLE','productionAssi'); -INSERT INTO `ACL` VALUES (535,'WagonTypeColor','*','*','ALLOW','ROLE','productionAssi'); -INSERT INTO `ACL` VALUES (536,'WagonTypeTray','*','*','ALLOW','ROLE','productionAssi'); -INSERT INTO `ACL` VALUES (537,'WagonConfig','*','*','ALLOW','ROLE','productionAssi'); -INSERT INTO `ACL` VALUES (538,'CollectionWagon','*','*','ALLOW','ROLE','productionAssi'); -INSERT INTO `ACL` VALUES (539,'CollectionWagonTicket','*','*','ALLOW','ROLE','productionAssi'); -INSERT INTO `ACL` VALUES (540,'Wagon','*','*','ALLOW','ROLE','productionAssi'); -INSERT INTO `ACL` VALUES (541,'WagonType','createWagonType','*','ALLOW','ROLE','productionAssi'); -INSERT INTO `ACL` VALUES (542,'WagonType','deleteWagonType','*','ALLOW','ROLE','productionAssi'); -INSERT INTO `ACL` VALUES (543,'WagonType','editWagonType','*','ALLOW','ROLE','productionAssi'); -INSERT INTO `ACL` VALUES (544,'Docuware','deliveryNoteEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (545,'Agency','find','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (546,'Agency','seeExpired','READ','ALLOW','ROLE','coolerAssist'); -INSERT INTO `ACL` VALUES (547,'WorkerLog','models','READ','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (548,'Ticket','editDiscount','WRITE','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (549,'Ticket','editDiscount','WRITE','ALLOW','ROLE','salesPerson'); -INSERT INTO `ACL` VALUES (550,'Ticket','isRoleAdvanced','*','ALLOW','ROLE','salesAssistant'); -INSERT INTO `ACL` VALUES (551,'Ticket','isRoleAdvanced','*','ALLOW','ROLE','deliveryAssistant'); -INSERT INTO `ACL` VALUES (552,'Ticket','isRoleAdvanced','*','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (553,'Ticket','isRoleAdvanced','*','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (554,'Ticket','deleteTicketWithPartPrepared','WRITE','ALLOW','ROLE','salesAssistant'); -INSERT INTO `ACL` VALUES (555,'Ticket','editZone','WRITE','ALLOW','ROLE','deliveryAssistant'); -INSERT INTO `ACL` VALUES (556,'State','editableStates','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (557,'State','seeEditableStates','READ','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (558,'State','seeEditableStates','READ','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (559,'State','isSomeEditable','READ','ALLOW','ROLE','salesPerson'); -INSERT INTO `ACL` VALUES (560,'State','isAllEditable','READ','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (561,'State','isAllEditable','READ','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (562,'Agency','seeExpired','READ','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (563,'Agency','seeExpired','READ','ALLOW','ROLE','productionBoss'); -INSERT INTO `ACL` VALUES (564,'Claim','createAfterDeadline','WRITE','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (565,'Client','editAddressLogifloraAllowed','WRITE','ALLOW','ROLE','salesAssistant'); -INSERT INTO `ACL` VALUES (566,'Client','editFiscalDataWithoutTaxDataCheck','WRITE','ALLOW','ROLE','salesAssistant'); -INSERT INTO `ACL` VALUES (567,'Client','editVerifiedDataWithoutTaxDataCheck','WRITE','ALLOW','ROLE','salesAssistant'); -INSERT INTO `ACL` VALUES (568,'Client','editCredit','WRITE','ALLOW','ROLE','financialBoss'); -INSERT INTO `ACL` VALUES (569,'Client','zeroCreditEditor','WRITE','ALLOW','ROLE','financialBoss'); -INSERT INTO `ACL` VALUES (570,'InvoiceOut','canCreatePdf','WRITE','ALLOW','ROLE','invoicing'); -INSERT INTO `ACL` VALUES (571,'Supplier','editPayMethodCheck','WRITE','ALLOW','ROLE','financial'); -INSERT INTO `ACL` VALUES (572,'Worker','isTeamBoss','WRITE','ALLOW','ROLE','teamBoss'); -INSERT INTO `ACL` VALUES (573,'Worker','forceIsSubordinate','READ','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (574,'Claim','editState','WRITE','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (577,'Claim','findOne','READ','ALLOW','ROLE','salesPerson'); -INSERT INTO `ACL` VALUES (579,'Claim','updateClaim','WRITE','ALLOW','ROLE','salesPerson'); -INSERT INTO `ACL` VALUES (580,'Claim','regularizeClaim','WRITE','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (581,'Claim','updateClaimDestination','WRITE','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (582,'Claim','downloadFile','READ','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (583,'Claim','deleteById','WRITE','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (585,'Claim','logs','READ','ALLOW','ROLE','claimManager'); -INSERT INTO `ACL` VALUES (586,'Ticket','find','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (587,'Ticket','findById','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (588,'Ticket','findOne','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (589,'Ticket','getVolume','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (590,'Ticket','getTotalVolume','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (591,'Ticket','summary','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (592,'Ticket','priceDifference','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (593,'Ticket','componentUpdate','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (594,'Ticket','new','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (595,'Ticket','isEditable','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (596,'Ticket','setDeleted','WRITE','ALLOW','ROLE','salesPerson'); -INSERT INTO `ACL` VALUES (597,'Ticket','restore','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (598,'Ticket','getSales','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (599,'Ticket','getSalesPersonMana','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (600,'Ticket','filter','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (601,'Ticket','makeInvoice','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (602,'Ticket','updateEditableTicket','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (603,'Ticket','updateDiscount','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (604,'Ticket','transferSales','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (605,'Ticket','sendSms','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (606,'Ticket','isLocked','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (607,'Ticket','freightCost','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (608,'Ticket','getComponentsSum','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (609,'Ticket','updateAttributes','WRITE','ALLOW','ROLE','delivery'); -INSERT INTO `ACL` VALUES (610,'Ticket','deliveryNoteCsv','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (611,'State','find','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (612,'State','findById','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (613,'State','findOne','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (614,'Worker','find','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (615,'Worker','findById','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (616,'Worker','findOne','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (617,'Worker','filter','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (618,'Worker','getWorkedHours','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (619,'Worker','active','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (620,'Worker','activeWithRole','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (621,'Worker','uploadFile','WRITE','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (622,'Worker','contracts','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (623,'Worker','holidays','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (624,'Worker','activeContract','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (625,'Worker','activeWithInheritedRole','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (626,'Ticket','collectionLabel','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (628,'Ticket','expeditionPalletLabel','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (629,'Ticket','editDiscount','WRITE','ALLOW','ROLE','artificialBoss'); -INSERT INTO `ACL` VALUES (630,'Claim','claimPickupEmail','WRITE','ALLOW','ROLE','salesTeamBoss'); -INSERT INTO `ACL` VALUES (635,'Ticket','updateAttributes','WRITE','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (636,'Claim','claimPickupEmail','WRITE','ALLOW','ROLE','salesPerson'); -INSERT INTO `ACL` VALUES (637,'Claim','downloadFile','READ','ALLOW','ROLE','salesPerson'); -INSERT INTO `ACL` VALUES (638,'Agency','seeExpired','READ','ALLOW','ROLE','artificialBoss'); -INSERT INTO `ACL` VALUES (639,'Agency','seeExpired','READ','ALLOW','ROLE','logisticAssistant'); -INSERT INTO `ACL` VALUES (654,'Ticket','editZone','WRITE','ALLOW','ROLE','logisticAssistant'); -INSERT INTO `ACL` VALUES (655,'Entry','addFromPackaging','WRITE','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (656,'Entry','addFromBuy','WRITE','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (657,'Supplier','getItemsPackaging','READ','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (658,'Ticket','closeAll','WRITE','ALLOW','ROLE','system'); -INSERT INTO `ACL` VALUES (659,'Account','*','*','ALLOW','ROLE','developerBoss'); -INSERT INTO `ACL` VALUES (664,'MailForward','*','*','ALLOW','ROLE','itManagement'); -INSERT INTO `ACL` VALUES (667,'VnUser','*','*','ALLOW','ROLE','itManagement'); -INSERT INTO `ACL` VALUES (668,'VnUser','__get__preview','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (669,'VnUser','preview','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (670,'VnUser','create','*','ALLOW','ROLE','itManagement'); -INSERT INTO `ACL` VALUES (672,'PackingSiteAdvanced','*','*','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (673,'InvoiceOut','makePdfAndNotify','WRITE','ALLOW','ROLE','invoicing'); -INSERT INTO `ACL` VALUES (674,'InvoiceOutConfig','*','READ','ALLOW','ROLE','invoicing'); -INSERT INTO `ACL` VALUES (676,'Ticket','invoiceTickets','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (680,'MailAliasAccount','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (683,'MailAliasAccount','canEditAlias','WRITE','ALLOW','ROLE','developerBoss'); -INSERT INTO `ACL` VALUES (684,'WorkerDisableExcluded','*','READ','ALLOW','ROLE','itManagement'); -INSERT INTO `ACL` VALUES (685,'WorkerDisableExcluded','*','WRITE','ALLOW','ROLE','itManagement'); -INSERT INTO `ACL` VALUES (686,'MailForward','*','*','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (687,'ClientSms','find','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (688,'ClientSms','create','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (689,'Vehicle','sorted','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (690,'Roadmap','*','*','ALLOW','ROLE','palletizerBoss'); -INSERT INTO `ACL` VALUES (691,'Roadmap','*','*','ALLOW','ROLE','productionBoss'); -INSERT INTO `ACL` VALUES (692,'ExpeditionTruck','*','*','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (693,'ExpeditionTruck','*','*','ALLOW','ROLE','productionBoss'); -INSERT INTO `ACL` VALUES (695,'ViaexpressConfig','internationalExpedition','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (696,'ViaexpressConfig','renderer','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (697,'Ticket','transferClient','WRITE','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (698,'Ticket','canEditWeekly','WRITE','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (699,'TicketSms','find','READ','ALLOW','ROLE','salesPerson'); -INSERT INTO `ACL` VALUES (701,'Docuware','upload','WRITE','ALLOW','ROLE','deliveryAssistant'); -INSERT INTO `ACL` VALUES (702,'Ticket','docuwareDownload','READ','ALLOW','ROLE','salesPerson'); -INSERT INTO `ACL` VALUES (703,'Worker','search','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (704,'ExpeditionState','addExpeditionState','WRITE','ALLOW','ROLE','delivery'); -INSERT INTO `ACL` VALUES (705,'SaleGroupDetail','deleteById','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (706,'Ticket','setDeleted','WRITE','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (707,'DeviceLog','create','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (708,'Collection','getTickets','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (709,'Client','findOne','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (710,'Client','findById','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (711,'Client','find','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (712,'Client','exists','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (713,'Client','__get__addresses','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (714,'ExpeditionMistakeType','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (715,'WorkerMistakeType','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (716,'ExpeditionMistake','*','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (717,'WorkerMistake','*','WRITE','ALLOW','ROLE','coolerAssist'); -INSERT INTO `ACL` VALUES (718,'MistakesTypes','*','WRITE','ALLOW','ROLE','coolerAssist'); -INSERT INTO `ACL` VALUES (719,'MistakeType','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (720,'MachineWorker','*','READ','ALLOW','ROLE','coolerAssist'); -INSERT INTO `ACL` VALUES (721,'Printer','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (722,'SaleMistake','*','WRITE','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (723,'Item','setVisibleDiscard','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (724,'Address','getAddress','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (725,'Account','findOne','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (726,'Account','findById','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (727,'Account','find','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (728,'Account','exists','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (729,'Sale','clone','WRITE','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (730,'Ticket','setDeleted','WRITE','ALLOW','ROLE','deliveryAssistant'); -INSERT INTO `ACL` VALUES (732,'Sale','isInPreparing','*','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (733,'Train','*','READ','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (734,'WorkerDepartment','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (735,'VnUser','higherPrivileges','*','ALLOW','ROLE','itManagement'); -INSERT INTO `ACL` VALUES (736,'VnUser','mediumPrivileges','*','ALLOW','ROLE','hr'); -INSERT INTO `ACL` VALUES (737,'VnUser','updateUser','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (738,'TicketCollection','*','WRITE','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (739,'Worker','setPassword','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (740,'Url','getByUser','READ','ALLOW','ROLE','$everyone'); -INSERT INTO `ACL` VALUES (741,'Claim','__get__lines','READ','ALLOW','ROLE','claimViewer'); -INSERT INTO `ACL` VALUES (742,'AddressShortage','*','READ','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (743,'Claim','filter','READ','ALLOW','ROLE','claimViewer'); -INSERT INTO `ACL` VALUES (744,'Claim','find','READ','ALLOW','ROLE','claimViewer'); -INSERT INTO `ACL` VALUES (745,'Claim','findById','READ','ALLOW','ROLE','claimViewer'); -INSERT INTO `ACL` VALUES (746,'Claim','getSummary','READ','ALLOW','ROLE','claimViewer'); -INSERT INTO `ACL` VALUES (747,'CplusRectificationType','*','READ','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (748,'SiiTypeInvoiceOut','*','READ','ALLOW','ROLE','salesPerson'); -INSERT INTO `ACL` VALUES (749,'InvoiceCorrectionType','*','READ','ALLOW','ROLE','salesPerson'); -INSERT INTO `ACL` VALUES (750,'InvoiceOut','transferInvoice','WRITE','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (751,'Application','executeProc','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (752,'Application','executeFunc','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (753,'NotificationSubscription','getList','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (754,'Route','find','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (755,'Route','findById','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (756,'Route','findOne','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (757,'Route','getRoutesByWorker','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (758,'Route','canViewAllRoute','READ','ALLOW','ROLE','deliveryAssistant'); -INSERT INTO `ACL` VALUES (759,'Route','cmr','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (760,'Route','downloadCmrsZip','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (761,'Route','downloadZip','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (762,'Route','filter','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (763,'Route','getByWorker','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (764,'Route','getDeliveryPoint','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (765,'Route','getExternalCmrs','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (766,'Route','getSuggestedTickets','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (767,'Route','getTickets','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (768,'Route','guessPriority','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (769,'Route','insertTicket','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (770,'Route','getDeliveryPoint','READ','ALLOW','ROLE','deliveryBoss'); -INSERT INTO `ACL` VALUES (771,'Route','summary','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (772,'Route','getExpeditionSummary','READ','ALLOW','ROLE','delivery'); -INSERT INTO `ACL` VALUES (773,'WorkerTimeControl','login','READ','ALLOW','ROLE','timeControl'); -INSERT INTO `ACL` VALUES (774,'WorkerTimeControl','getClockIn','READ','ALLOW','ROLE','timeControl'); -INSERT INTO `ACL` VALUES (775,'WorkerTimeControl','clockIn','WRITE','ALLOW','ROLE','timeControl'); -INSERT INTO `ACL` VALUES (776,'WorkerTimeControl','addTimeEntry','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (777,'WorkerTimeControl','deleteTimeEntry','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (778,'WorkerTimeControl','updateTimeEntry','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (779,'WorkerTimeControl','sendMail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (780,'WorkerTimeControl','updateWorkerTimeControlMail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (781,'WorkerTimeControl','weeklyHourRecordEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (782,'WorkerTimeControl','getMailStates','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (783,'WorkerTimeControl','resendWeeklyHourEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (784,'VnRole','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (785,'VnRole','*','WRITE','ALLOW','ROLE','it'); -INSERT INTO `ACL` VALUES (786,'State','isAllEditable','READ','ALLOW','ROLE','delivery'); -INSERT INTO `ACL` VALUES (787,'Ticket','makePdfList','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (788,'Ticket','invoiceTicketsAndPdf','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (789,'InvoiceIn','*','*','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (790,'InvoiceIn','getSerial','READ','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (791,'InvoiceIn','corrective','WRITE','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (792,'InvoiceInCorrection','*','*','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (793,'Supplier','updateAllFiscalData','WRITE','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (794,'Supplier','updateFiscalData','WRITE','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (795,'Ticket','myLastModified','*','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (796,'MrwConfig','cancelShipment','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (797,'MrwConfig','createShipment','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (798,'MailAliasAccount','*','*','ALLOW','ROLE','itManagement'); -INSERT INTO `ACL` VALUES (799,'Ticket','saveCmr','*','ALLOW','ROLE','developer'); -INSERT INTO `ACL` VALUES (800,'EntryDms','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (801,'MailAliasAccount','create','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (802,'MailAliasAccount','deleteById','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (804,'DeviceProduction','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (805,'Collection','assign','WRITE','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (806,'ExpeditionPallet','getPallet','READ','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (807,'MachineWorker','updateInTime','WRITE','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (808,'MobileAppVersionControl','getVersion','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (809,'SaleTracking','delete','WRITE','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (810,'SaleTracking','updateTracking','WRITE','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (811,'SaleTracking','setPicked','WRITE','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (813,'Sale','getFromSectorCollection','READ','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (814,'ItemBarcode','delete','WRITE','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (815,'WorkerActivityType','*','READ','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (816,'WorkerActivity','*','*','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (817,'ParkingLog','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (818,'ExpeditionPallet','*','*','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (819,'Ticket','addSaleByCode','WRITE','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (820,'TicketCollection','*','READ','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (821,'Ticket','clone','WRITE','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (822,'SupplierDms','*','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (823,'MailAlias','*','*','ALLOW','ROLE','developerBoss'); -INSERT INTO `ACL` VALUES (824,'ItemShelving','hasItemOlder','READ','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (825,'Application','getEnumValues','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (826,'Ticket','editZone','WRITE','ALLOW','ROLE','salesAssistant'); -INSERT INTO `ACL` VALUES (827,'TicketWeekly','deleteById','WRITE','ALLOW','ROLE','buyerBoss'); -INSERT INTO `ACL` VALUES (828,'TicketWeekly','upsert','WRITE','ALLOW','ROLE','buyer'); -INSERT INTO `ACL` VALUES (830,'InvoiceIn','*','READ','ALLOW','ROLE','deliveryBoss'); -INSERT INTO `ACL` VALUES (831,'InvoiceIn','exchangeRateUpdate','*','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (832,'AgencyLog','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (833,'AgencyWorkCenter','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (834,'AgencyMode','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (835,'Agency','*','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (836,'Agency','*','WRITE','ALLOW','ROLE','deliveryAssistant'); -INSERT INTO `ACL` VALUES (837,'AgencyWorkCenter','*','WRITE','ALLOW','ROLE','deliveryAssistant'); +INSERT INTO `ACL` VALUES (3,'Address','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (5,'AgencyService','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (9,'ClientObservation','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (11,'ContactChannel','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (13,'Employee','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (14,'PayMethod','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (16,'FakeProduction','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (17,'Warehouse','* ','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (20,'TicketState','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (24,'Delivery','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (25,'Zone','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (26,'ClientCredit','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (27,'ClientCreditLimit','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (30,'GreugeType','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (31,'Mandate','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (32,'MandateType','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (33,'Company','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (34,'Greuge','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (35,'AddressObservation','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (36,'ObservationType','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (37,'Greuge','*','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (38,'AgencyMode','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (41,'ItemBotanical','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher',NULL); +INSERT INTO `ACL` VALUES (44,'ItemPlacement','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (45,'ItemBarcode','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher',NULL); +INSERT INTO `ACL` VALUES (51,'ItemTag','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (53,'Item','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (54,'Item','*','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (55,'Recovery','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (56,'Recovery','*','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (58,'CreditClassification','*','*','ALLOW','ROLE','insurance',NULL); +INSERT INTO `ACL` VALUES (60,'CreditInsurance','*','*','ALLOW','ROLE','insurance',NULL); +INSERT INTO `ACL` VALUES (61,'InvoiceOut','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (63,'TicketObservation','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (65,'Sale','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (66,'TicketTracking','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (68,'TicketPackaging','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (69,'Packaging','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (70,'Packaging','*','WRITE','ALLOW','ROLE','logistic',NULL); +INSERT INTO `ACL` VALUES (72,'SaleComponent','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (73,'Expedition','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryAssistant',NULL); +INSERT INTO `ACL` VALUES (75,'Expedition','*','WRITE','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (77,'WorkerMana','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (78,'TicketTracking','*','WRITE','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (79,'Ticket','state','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (80,'Sale','deleteSales','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (81,'Sale','moveToTicket','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (82,'Sale','updateQuantity','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (83,'Sale','updatePrice','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (84,'Sale','updateDiscount','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (85,'SaleTracking','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (86,'Order','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (87,'OrderRow','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (88,'ClientContact','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (90,'Sale','reserve','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (91,'TicketWeekly','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (94,'Agency','landsThatDay','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (96,'ClaimEnd','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (97,'ClaimEnd','*','WRITE','ALLOW','ROLE','claimManager',NULL); +INSERT INTO `ACL` VALUES (98,'ClaimBeginning','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','claimManager',NULL); +INSERT INTO `ACL` VALUES (102,'Claim','createFromSales','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss',NULL); +INSERT INTO `ACL` VALUES (105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss',NULL); +INSERT INTO `ACL` VALUES (106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss',NULL); +INSERT INTO `ACL` VALUES (108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss',NULL); +INSERT INTO `ACL` VALUES (109,'UserConfig','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (110,'Accounting','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (111,'ClientLog','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (112,'Defaulter','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (113,'ClientRisk','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (114,'Receipt','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (115,'Receipt','*','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (116,'BankEntity','*','READ','ALLOW','ROLE','employee',10578); +INSERT INTO `ACL` VALUES (117,'ClientSample','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson',NULL); +INSERT INTO `ACL` VALUES (119,'Travel','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (120,'Travel','*','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (121,'Item','regularize','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (122,'TicketRequest','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (127,'TicketLog','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (129,'TicketService','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (130,'Expedition','*','WRITE','ALLOW','ROLE','packager',NULL); +INSERT INTO `ACL` VALUES (131,'CreditInsurance','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (132,'CreditClassification','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss',NULL); +INSERT INTO `ACL` VALUES (135,'ZoneGeo','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (138,'LabourHoliday','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (141,'Zone','*','*','ALLOW','ROLE','logisticBoss',NULL); +INSERT INTO `ACL` VALUES (142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryAssistant',NULL); +INSERT INTO `ACL` VALUES (143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryAssistant',NULL); +INSERT INTO `ACL` VALUES (144,'Stowaway','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (147,'UserConfigView','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (148,'UserConfigView','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (149,'Sip','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (150,'Sip','*','WRITE','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (151,'Department','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (152,'Department','*','WRITE','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (154,'Route','*','WRITE','ALLOW','ROLE','delivery',NULL); +INSERT INTO `ACL` VALUES (155,'Calendar','*','READ','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (156,'WorkerLabour','*','READ','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (157,'Calendar','absences','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory',NULL); +INSERT INTO `ACL` VALUES (160,'TicketServiceType','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (161,'TicketConfig','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','adminBoss',783); +INSERT INTO `ACL` VALUES (163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing',NULL); +INSERT INTO `ACL` VALUES (165,'TicketDms','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (172,'Sms','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (173,'Sms','send','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (176,'Device','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (177,'Device','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (179,'ItemLog','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (180,'RouteLog','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (183,'Dms','downloadFile','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (186,'ClientDms','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryAssistant',NULL); +INSERT INTO `ACL` VALUES (191,'Agency','getLanded','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (192,'Agency','getShipped','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (194,'Postcode','*','WRITE','ALLOW','ROLE','deliveryAssistant',NULL); +INSERT INTO `ACL` VALUES (195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (197,'Dms','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (199,'ClaimDms','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','claimManager',NULL); +INSERT INTO `ACL` VALUES (203,'UserPhone','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (205,'WorkerDms','*','READ','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (206,'Chat','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (207,'Chat','sendMessage','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (211,'TravelLog','*','READ','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (212,'Thermograph','*','*','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (213,'TravelThermograph','*','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (214,'Entry','*','*','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (216,'TravelThermograph','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (218,'Intrastat','*','*','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (221,'UserConfig','getUserConfig','READ','ALLOW','ROLE','guest',NULL); +INSERT INTO `ACL` VALUES (226,'ClientObservation','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (227,'Address','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (228,'AddressObservation','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (230,'ClientCredit','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (231,'ClientContact','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (232,'ClientSample','*','READ','ALLOW','ROLE','trainee',NULL); +INSERT INTO `ACL` VALUES (233,'EntryLog','*','READ','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (234,'WorkerLog','find','READ','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (235,'CustomsAgent','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (236,'Buy','*','*','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (237,'WorkerDms','filter','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (241,'SupplierContact','*','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (248,'RoleMapping','*','READ','ALLOW','ROLE','account',NULL); +INSERT INTO `ACL` VALUES (249,'UserPassword','*','READ','ALLOW','ROLE','account',NULL); +INSERT INTO `ACL` VALUES (250,'Town','*','WRITE','ALLOW','ROLE','deliveryAssistant',NULL); +INSERT INTO `ACL` VALUES (251,'Province','*','WRITE','ALLOW','ROLE','deliveryAssistant',NULL); +INSERT INTO `ACL` VALUES (252,'Supplier','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (253,'Supplier','*','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (254,'SupplierLog','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (256,'Image','*','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (257,'FixedPrice','*','*','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (258,'PayDem','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (259,'Client','createReceipt','*','ALLOW','ROLE','salesAssistant',NULL); +INSERT INTO `ACL` VALUES (260,'PrintServerQueue','*','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (261,'SupplierAccount','*','WRITE','ALLOW','ROLE','administrative',783); +INSERT INTO `ACL` VALUES (262,'Entry','*','*','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (263,'InvoiceIn','*','READ','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (264,'StarredModule','*','*','ALLOW','ROLE','$authenticated',NULL); +INSERT INTO `ACL` VALUES (265,'ItemBotanical','*','WRITE','ALLOW','ROLE','logisticBoss',NULL); +INSERT INTO `ACL` VALUES (266,'ZoneLog','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (267,'Genus','*','WRITE','ALLOW','ROLE','logisticBoss',NULL); +INSERT INTO `ACL` VALUES (268,'Specie','*','WRITE','ALLOW','ROLE','logisticBoss',NULL); +INSERT INTO `ACL` VALUES (269,'InvoiceOut','createPdf','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (270,'SupplierAddress','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (271,'SalesMonitor','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (272,'InvoiceInLog','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (273,'InvoiceInTax','*','*','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (274,'InvoiceInLog','*','READ','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (275,'InvoiceOut','createManualInvoice','WRITE','ALLOW','ROLE','invoicing',NULL); +INSERT INTO `ACL` VALUES (276,'InvoiceOut','globalInvoicing','WRITE','ALLOW','ROLE','invoicing',NULL); +INSERT INTO `ACL` VALUES (278,'RoleInherit','*','WRITE','ALLOW','ROLE','grant',NULL); +INSERT INTO `ACL` VALUES (279,'MailAlias','*','READ','ALLOW','ROLE','marketing',NULL); +INSERT INTO `ACL` VALUES (283,'EntryObservation','*','*','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (284,'LdapConfig','*','*','ALLOW','ROLE','sysadmin',NULL); +INSERT INTO `ACL` VALUES (285,'SambaConfig','*','*','ALLOW','ROLE','sysadmin',NULL); +INSERT INTO `ACL` VALUES (286,'ACL','*','READ','ALLOW','ROLE','developer',10578); +INSERT INTO `ACL` VALUES (287,'AccessToken','*','*','ALLOW','ROLE','developerBoss',10578); +INSERT INTO `ACL` VALUES (293,'RoleInherit','*','*','ALLOW','ROLE','it',NULL); +INSERT INTO `ACL` VALUES (294,'RoleRole','*','*','ALLOW','ROLE','it',NULL); +INSERT INTO `ACL` VALUES (295,'AccountConfig','*','*','ALLOW','ROLE','sysadmin',NULL); +INSERT INTO `ACL` VALUES (296,'Collection','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (297,'Sale','clone','WRITE','ALLOW','ROLE','invoicing',NULL); +INSERT INTO `ACL` VALUES (298,'InvoiceInDueDay','*','*','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (299,'Collection','setSaleQuantity','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (302,'AgencyTerm','*','*','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (303,'ClaimLog','*','READ','ALLOW','ROLE','employee',19294); +INSERT INTO `ACL` VALUES (304,'Edi','updateData','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (305,'EducationLevel','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (306,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (307,'SupplierAgencyTerm','*','*','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (308,'InvoiceInIntrastat','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (309,'Zone','getZoneClosing','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (310,'ExpeditionState','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (311,'Expense','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (312,'Expense','*','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (314,'SupplierActivity','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (315,'SupplierActivity','*','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (316,'Dms','deleteTrashFiles','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (317,'ClientUnpaid','*','*','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (318,'MdbVersion','*','*','ALLOW','ROLE','developer',NULL); +INSERT INTO `ACL` VALUES (319,'ItemType','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (320,'ItemType','*','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (321,'InvoiceOut','refund','WRITE','ALLOW','ROLE','invoicing',NULL); +INSERT INTO `ACL` VALUES (322,'InvoiceOut','refund','WRITE','ALLOW','ROLE','salesAssistant',NULL); +INSERT INTO `ACL` VALUES (323,'InvoiceOut','refund','WRITE','ALLOW','ROLE','claimManager',NULL); +INSERT INTO `ACL` VALUES (324,'Ticket','cloneAll','WRITE','ALLOW','ROLE','invoicing',10578); +INSERT INTO `ACL` VALUES (326,'Ticket','cloneAll','WRITE','ALLOW','ROLE','claimManager',10578); +INSERT INTO `ACL` VALUES (327,'Sale','clone','WRITE','ALLOW','ROLE','salesAssistant',NULL); +INSERT INTO `ACL` VALUES (328,'Sale','clone','WRITE','ALLOW','ROLE','claimManager',NULL); +INSERT INTO `ACL` VALUES (329,'TicketRefund','*','WRITE','ALLOW','ROLE','invoicing',NULL); +INSERT INTO `ACL` VALUES (330,'ClaimObservation','*','WRITE','ALLOW','ROLE','salesPerson',NULL); +INSERT INTO `ACL` VALUES (331,'ClaimObservation','*','READ','ALLOW','ROLE','salesPerson',NULL); +INSERT INTO `ACL` VALUES (332,'Client','setPassword','WRITE','ALLOW','ROLE','salesPerson',NULL); +INSERT INTO `ACL` VALUES (333,'Client','updateUser','WRITE','ALLOW','ROLE','salesPerson',NULL); +INSERT INTO `ACL` VALUES (334,'ShelvingLog','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (335,'ZoneExclusionGeo','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (336,'ZoneExclusionGeo','*','WRITE','ALLOW','ROLE','deliveryAssistant',NULL); +INSERT INTO `ACL` VALUES (337,'Parking','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (338,'Shelving','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (339,'OsTicket','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (340,'OsTicketConfig','*','*','ALLOW','ROLE','it',NULL); +INSERT INTO `ACL` VALUES (341,'ClientConsumptionQueue','*','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (343,'Ticket','deliveryNoteEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (344,'Ticket','deliveryNoteCsvPdf','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (345,'Ticket','deliveryNoteCsvEmail','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (346,'Client','campaignMetricsPdf','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (347,'Client','campaignMetricsEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (348,'Client','clientWelcomeHtml','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (349,'Client','clientWelcomeEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (350,'Client','creditRequestPdf','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (351,'Client','creditRequestHtml','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (352,'Client','creditRequestEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (353,'Client','printerSetupHtml','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (354,'Client','printerSetupEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (355,'Client','sepaCoreEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (356,'Client','letterDebtorPdf','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (357,'Client','letterDebtorStHtml','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (358,'Client','letterDebtorStEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (359,'Client','letterDebtorNdHtml','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (360,'Client','letterDebtorNdEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (361,'Client','clientDebtStatementPdf','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (362,'Client','clientDebtStatementHtml','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (363,'Client','clientDebtStatementEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (364,'Client','incotermsAuthorizationPdf','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (365,'Client','incotermsAuthorizationHtml','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (366,'Client','incotermsAuthorizationEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (367,'Client','consumptionSendQueued','WRITE','ALLOW','ROLE','system',NULL); +INSERT INTO `ACL` VALUES (368,'InvoiceOut','invoiceEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (369,'InvoiceOut','exportationPdf','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (370,'InvoiceOut','sendQueued','WRITE','ALLOW','ROLE','system',NULL); +INSERT INTO `ACL` VALUES (371,'Ticket','invoiceCsvPdf','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (372,'Ticket','invoiceCsvEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (373,'Supplier','campaignMetricsPdf','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (374,'Supplier','campaignMetricsEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (375,'Travel','extraCommunityPdf','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (376,'Travel','extraCommunityEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (377,'Entry','entryOrderPdf','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (378,'OsTicket','osTicketReportEmail','WRITE','ALLOW','ROLE','system',NULL); +INSERT INTO `ACL` VALUES (379,'Item','buyerWasteEmail','WRITE','ALLOW','ROLE','system',NULL); +INSERT INTO `ACL` VALUES (380,'Claim','claimPickupPdf','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (381,'Claim','claimPickupEmail','WRITE','ALLOW','ROLE','claimManager',NULL); +INSERT INTO `ACL` VALUES (382,'Item','labelPdf','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (383,'Sector','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (384,'Sector','*','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (385,'Route','driverRoutePdf','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (386,'Route','driverRouteEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (387,'Ticket','deliveryNotePdf','READ','ALLOW','ROLE','$owner',NULL); +INSERT INTO `ACL` VALUES (388,'Supplier','newSupplier','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (389,'ClaimRma','*','READ','ALLOW','ROLE','claimManager',NULL); +INSERT INTO `ACL` VALUES (390,'ClaimRma','*','WRITE','ALLOW','ROLE','claimManager',NULL); +INSERT INTO `ACL` VALUES (391,'Notification','*','WRITE','ALLOW','ROLE','system',NULL); +INSERT INTO `ACL` VALUES (392,'Boxing','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (393,'Url','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (394,'Url','*','WRITE','ALLOW','ROLE','it',NULL); +INSERT INTO `ACL` VALUES (395,'ItemShelving','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (396,'ItemShelving','*','WRITE','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (397,'ItemShelvingPlacementSupplyStock','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (398,'NotificationQueue','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (399,'InvoiceOut','clientsToInvoice','WRITE','ALLOW','ROLE','invoicing',NULL); +INSERT INTO `ACL` VALUES (400,'InvoiceOut','invoiceClient','WRITE','ALLOW','ROLE','invoicing',NULL); +INSERT INTO `ACL` VALUES (401,'Sale','editTracked','WRITE','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (402,'Sale','editFloramondo','WRITE','ALLOW','ROLE','salesAssistant',NULL); +INSERT INTO `ACL` VALUES (403,'Receipt','balanceCompensationEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (404,'Receipt','balanceCompensationPdf','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (405,'Ticket','getTicketsFuture','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (406,'Ticket','merge','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (407,'Sale','editFloramondo','WRITE','ALLOW','ROLE','logistic',NULL); +INSERT INTO `ACL` VALUES (408,'ZipConfig','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (409,'Item','*','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (410,'Sale','editCloned','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (411,'Sale','editCloned','WRITE','ALLOW','ROLE','salesAssistant',NULL); +INSERT INTO `ACL` VALUES (414,'MdbVersion','*','READ','ALLOW','ROLE','$everyone',NULL); +INSERT INTO `ACL` VALUES (416,'TicketLog','getChanges','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (417,'Ticket','getTicketsAdvance','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (418,'EntryLog','*','READ','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (419,'Sale','editTracked','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (420,'MdbBranch','*','READ','ALLOW','ROLE','$everyone',NULL); +INSERT INTO `ACL` VALUES (421,'ItemShelvingSale','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (422,'Docuware','checkFile','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (423,'Docuware','download','READ','ALLOW','ROLE','salesPerson',NULL); +INSERT INTO `ACL` VALUES (424,'Docuware','upload','WRITE','ALLOW','ROLE','productionAssi',NULL); +INSERT INTO `ACL` VALUES (425,'Docuware','deliveryNoteEmail','WRITE','ALLOW','ROLE','salesPerson',NULL); +INSERT INTO `ACL` VALUES (426,'TpvTransaction','confirm','WRITE','ALLOW','ROLE','$everyone',NULL); +INSERT INTO `ACL` VALUES (427,'TpvTransaction','start','WRITE','ALLOW','ROLE','$authenticated',NULL); +INSERT INTO `ACL` VALUES (428,'TpvTransaction','end','WRITE','ALLOW','ROLE','$authenticated',NULL); +INSERT INTO `ACL` VALUES (429,'ItemConfig','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (431,'Tag','onSubmit','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (432,'Worker','updateAttributes','WRITE','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (433,'Worker','createAbsence','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (434,'Worker','updateAbsence','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (435,'Worker','deleteAbsence','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (436,'Worker','new','WRITE','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (438,'Client','getClientOrSupplierReference','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (439,'NotificationSubscription','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (440,'NotificationAcl','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (441,'MdbApp','*','READ','ALLOW','ROLE','$everyone',NULL); +INSERT INTO `ACL` VALUES (442,'MdbApp','*','*','ALLOW','ROLE','developer',NULL); +INSERT INTO `ACL` VALUES (443,'ItemConfig','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (444,'DeviceProduction','*','*','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (445,'DeviceProductionModels','*','*','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (446,'DeviceProductionState','*','*','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (447,'DeviceProductionUser','*','*','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (448,'DeviceProduction','*','*','ALLOW','ROLE','productionAssi',NULL); +INSERT INTO `ACL` VALUES (449,'DeviceProductionModels','*','*','ALLOW','ROLE','productionAssi',NULL); +INSERT INTO `ACL` VALUES (450,'DeviceProductionState','*','*','ALLOW','ROLE','productionAssi',NULL); +INSERT INTO `ACL` VALUES (451,'DeviceProductionUser','*','*','ALLOW','ROLE','productionAssi',NULL); +INSERT INTO `ACL` VALUES (452,'Worker','deallocatePDA','*','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (453,'Worker','allocatePDA','*','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (454,'Worker','deallocatePDA','*','ALLOW','ROLE','productionAssi',NULL); +INSERT INTO `ACL` VALUES (455,'Worker','allocatePDA','*','ALLOW','ROLE','productionAssi',NULL); +INSERT INTO `ACL` VALUES (456,'Zone','*','*','ALLOW','ROLE','deliveryAssistant',NULL); +INSERT INTO `ACL` VALUES (458,'Operator','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (459,'Operator','*','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (460,'InvoiceIn','getSerial','READ','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (461,'Ticket','saveSign','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (462,'InvoiceOut','negativeBases','READ','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (463,'InvoiceOut','negativeBasesCsv','READ','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (464,'WorkerObservation','*','*','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (465,'ClientInforma','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (466,'ClientInforma','*','WRITE','ALLOW','ROLE','financial',NULL); +INSERT INTO `ACL` VALUES (467,'Receipt','receiptEmail','*','ALLOW','ROLE','salesAssistant',NULL); +INSERT INTO `ACL` VALUES (468,'Client','setRating','WRITE','ALLOW','ROLE','financial',NULL); +INSERT INTO `ACL` VALUES (470,'Client','addressesPropagateRe','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (471,'Client','canBeInvoiced','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (472,'Client','canCreateTicket','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (473,'Client','consumption','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (474,'Client','createAddress','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (475,'Client','createWithUser','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (476,'Client','extendedListFilter','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (477,'Client','getAverageInvoiced','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (478,'Client','getCard','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (479,'Client','getDebt','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (480,'Client','getMana','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (481,'Client','transactions','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (482,'Client','hasCustomerRole','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (483,'Client','isValidClient','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (484,'Client','lastActiveTickets','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (485,'Client','sendSms','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (486,'Client','setPassword','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (487,'Client','summary','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (488,'Client','updateAddress','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (489,'Client','updateFiscalData','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (491,'Client','uploadFile','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (492,'Client','campaignMetricsPdf','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (493,'Client','campaignMetricsEmail','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (494,'Client','clientWelcomeHtml','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (495,'Client','clientWelcomeEmail','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (496,'Client','printerSetupHtml','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (497,'Client','printerSetupEmail','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (498,'Client','sepaCoreEmail','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (499,'Client','letterDebtorPdf','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (500,'Client','letterDebtorStHtml','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (501,'Client','letterDebtorStEmail','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (502,'Client','letterDebtorNdHtml','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (503,'Client','letterDebtorNdEmail','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (504,'Client','clientDebtStatementPdf','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (505,'Client','clientDebtStatementHtml','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (506,'Client','clientDebtStatementEmail','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (507,'Client','creditRequestPdf','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (508,'Client','creditRequestHtml','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (509,'Client','creditRequestEmail','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (510,'Client','incotermsAuthorizationPdf','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (511,'Client','incotermsAuthorizationHtml','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (512,'Client','incotermsAuthorizationEmail','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (513,'Client','consumptionSendQueued','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (514,'Client','filter','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (515,'Client','getClientOrSupplierReference','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (516,'Client','upsert','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (518,'Client','replaceById','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (519,'Client','updateAttributes','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (520,'Client','updateAttributes','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (521,'Client','deleteById','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (522,'Client','replaceOrCreate','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (523,'Client','updateAll','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (524,'Client','upsertWithWhere','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (525,'Defaulter','observationEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (527,'VnUser','acl','READ','ALLOW','ROLE','guest',NULL); +INSERT INTO `ACL` VALUES (528,'VnUser','getCurrentUserData','READ','ALLOW','ROLE','account',NULL); +INSERT INTO `ACL` VALUES (530,'Account','exists','READ','ALLOW','ROLE','account',NULL); +INSERT INTO `ACL` VALUES (531,'Account','exists','READ','ALLOW','ROLE','account',NULL); +INSERT INTO `ACL` VALUES (532,'UserLog','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (533,'RoleLog','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (534,'WagonType','*','*','ALLOW','ROLE','productionAssi',NULL); +INSERT INTO `ACL` VALUES (535,'WagonTypeColor','*','*','ALLOW','ROLE','productionAssi',NULL); +INSERT INTO `ACL` VALUES (536,'WagonTypeTray','*','*','ALLOW','ROLE','productionAssi',NULL); +INSERT INTO `ACL` VALUES (537,'WagonConfig','*','*','ALLOW','ROLE','productionAssi',NULL); +INSERT INTO `ACL` VALUES (538,'CollectionWagon','*','*','ALLOW','ROLE','productionAssi',NULL); +INSERT INTO `ACL` VALUES (539,'CollectionWagonTicket','*','*','ALLOW','ROLE','productionAssi',NULL); +INSERT INTO `ACL` VALUES (540,'Wagon','*','*','ALLOW','ROLE','productionAssi',NULL); +INSERT INTO `ACL` VALUES (541,'WagonType','createWagonType','*','ALLOW','ROLE','productionAssi',NULL); +INSERT INTO `ACL` VALUES (542,'WagonType','deleteWagonType','*','ALLOW','ROLE','productionAssi',NULL); +INSERT INTO `ACL` VALUES (543,'WagonType','editWagonType','*','ALLOW','ROLE','productionAssi',NULL); +INSERT INTO `ACL` VALUES (544,'Docuware','deliveryNoteEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (545,'Agency','find','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (546,'Agency','seeExpired','READ','ALLOW','ROLE','coolerAssist',NULL); +INSERT INTO `ACL` VALUES (547,'WorkerLog','models','READ','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (548,'Ticket','editDiscount','WRITE','ALLOW','ROLE','claimManager',NULL); +INSERT INTO `ACL` VALUES (549,'Ticket','editDiscount','WRITE','ALLOW','ROLE','salesPerson',NULL); +INSERT INTO `ACL` VALUES (550,'Ticket','isRoleAdvanced','*','ALLOW','ROLE','salesAssistant',NULL); +INSERT INTO `ACL` VALUES (551,'Ticket','isRoleAdvanced','*','ALLOW','ROLE','deliveryAssistant',NULL); +INSERT INTO `ACL` VALUES (552,'Ticket','isRoleAdvanced','*','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (553,'Ticket','isRoleAdvanced','*','ALLOW','ROLE','claimManager',NULL); +INSERT INTO `ACL` VALUES (554,'Ticket','deleteTicketWithPartPrepared','WRITE','ALLOW','ROLE','salesAssistant',NULL); +INSERT INTO `ACL` VALUES (555,'Ticket','editZone','WRITE','ALLOW','ROLE','deliveryAssistant',NULL); +INSERT INTO `ACL` VALUES (556,'State','editableStates','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (557,'State','seeEditableStates','READ','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (558,'State','seeEditableStates','READ','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (559,'State','isSomeEditable','READ','ALLOW','ROLE','salesPerson',NULL); +INSERT INTO `ACL` VALUES (560,'State','isAllEditable','READ','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (561,'State','isAllEditable','READ','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (562,'Agency','seeExpired','READ','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (563,'Agency','seeExpired','READ','ALLOW','ROLE','productionBoss',NULL); +INSERT INTO `ACL` VALUES (564,'Claim','createAfterDeadline','WRITE','ALLOW','ROLE','claimManager',NULL); +INSERT INTO `ACL` VALUES (565,'Client','editAddressLogifloraAllowed','WRITE','ALLOW','ROLE','salesAssistant',NULL); +INSERT INTO `ACL` VALUES (566,'Client','editFiscalDataWithoutTaxDataCheck','WRITE','ALLOW','ROLE','salesAssistant',NULL); +INSERT INTO `ACL` VALUES (567,'Client','editVerifiedDataWithoutTaxDataCheck','WRITE','ALLOW','ROLE','salesAssistant',NULL); +INSERT INTO `ACL` VALUES (568,'Client','editCredit','WRITE','ALLOW','ROLE','financialBoss',NULL); +INSERT INTO `ACL` VALUES (569,'Client','zeroCreditEditor','WRITE','ALLOW','ROLE','financialBoss',NULL); +INSERT INTO `ACL` VALUES (570,'InvoiceOut','canCreatePdf','WRITE','ALLOW','ROLE','invoicing',NULL); +INSERT INTO `ACL` VALUES (571,'Supplier','editPayMethodCheck','WRITE','ALLOW','ROLE','financial',NULL); +INSERT INTO `ACL` VALUES (572,'Worker','isTeamBoss','WRITE','ALLOW','ROLE','teamBoss',NULL); +INSERT INTO `ACL` VALUES (573,'Worker','forceIsSubordinate','READ','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (574,'Claim','editPickup','WRITE','ALLOW','ROLE','claimManager',NULL); +INSERT INTO `ACL` VALUES (577,'Claim','findOne','READ','ALLOW','ROLE','salesPerson',NULL); +INSERT INTO `ACL` VALUES (579,'Claim','updateClaim','WRITE','ALLOW','ROLE','salesPerson',NULL); +INSERT INTO `ACL` VALUES (580,'Claim','regularizeClaim','WRITE','ALLOW','ROLE','claimManager',NULL); +INSERT INTO `ACL` VALUES (581,'Claim','updateClaimDestination','WRITE','ALLOW','ROLE','claimManager',NULL); +INSERT INTO `ACL` VALUES (582,'Claim','downloadFile','READ','ALLOW','ROLE','claimManager',NULL); +INSERT INTO `ACL` VALUES (583,'Claim','deleteById','WRITE','ALLOW','ROLE','claimManager',NULL); +INSERT INTO `ACL` VALUES (585,'Claim','logs','READ','ALLOW','ROLE','claimManager',NULL); +INSERT INTO `ACL` VALUES (586,'Ticket','find','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (587,'Ticket','findById','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (588,'Ticket','findOne','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (589,'Ticket','getVolume','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (590,'Ticket','getTotalVolume','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (591,'Ticket','summary','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (592,'Ticket','priceDifference','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (593,'Ticket','componentUpdate','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (594,'Ticket','new','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (595,'Ticket','isEditable','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (596,'Ticket','setDeleted','WRITE','ALLOW','ROLE','salesPerson',NULL); +INSERT INTO `ACL` VALUES (597,'Ticket','restore','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (598,'Ticket','getSales','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (599,'Ticket','getSalesPersonMana','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (600,'Ticket','filter','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (601,'Ticket','makeInvoice','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (602,'Ticket','updateEditableTicket','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (603,'Ticket','updateDiscount','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (604,'Ticket','transferSales','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (605,'Ticket','sendSms','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (606,'Ticket','isLocked','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (607,'Ticket','freightCost','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (608,'Ticket','getComponentsSum','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (609,'Ticket','updateAttributes','WRITE','ALLOW','ROLE','delivery',NULL); +INSERT INTO `ACL` VALUES (610,'Ticket','deliveryNoteCsv','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (611,'State','find','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (612,'State','findById','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (613,'State','findOne','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (614,'Worker','find','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (616,'Worker','findOne','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (617,'Worker','filter','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (618,'Worker','getWorkedHours','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (619,'Worker','active','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (620,'Worker','activeWithRole','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (621,'Worker','uploadFile','WRITE','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (622,'Worker','contracts','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (623,'Worker','holidays','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (624,'Worker','activeContract','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (625,'Worker','activeWithInheritedRole','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (626,'Ticket','collectionLabel','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (628,'Ticket','expeditionPalletLabel','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (629,'Ticket','editDiscount','WRITE','ALLOW','ROLE','artificialBoss',NULL); +INSERT INTO `ACL` VALUES (630,'Claim','claimPickupEmail','WRITE','ALLOW','ROLE','salesTeamBoss',NULL); +INSERT INTO `ACL` VALUES (635,'Ticket','updateAttributes','WRITE','ALLOW','ROLE','administrative',19295); +INSERT INTO `ACL` VALUES (636,'Claim','claimPickupEmail','WRITE','ALLOW','ROLE','salesPerson',NULL); +INSERT INTO `ACL` VALUES (637,'Claim','downloadFile','READ','ALLOW','ROLE','salesPerson',NULL); +INSERT INTO `ACL` VALUES (638,'Agency','seeExpired','READ','ALLOW','ROLE','artificialBoss',NULL); +INSERT INTO `ACL` VALUES (639,'Agency','seeExpired','READ','ALLOW','ROLE','logisticAssistant',NULL); +INSERT INTO `ACL` VALUES (654,'Ticket','editZone','WRITE','ALLOW','ROLE','logisticAssistant',NULL); +INSERT INTO `ACL` VALUES (655,'Entry','addFromPackaging','WRITE','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (656,'Entry','addFromBuy','WRITE','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (657,'Supplier','getItemsPackaging','READ','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (658,'Ticket','closeAll','WRITE','ALLOW','ROLE','system',19295); +INSERT INTO `ACL` VALUES (659,'Account','*','*','ALLOW','ROLE','developerBoss',NULL); +INSERT INTO `ACL` VALUES (664,'MailForward','*','*','ALLOW','ROLE','itManagement',NULL); +INSERT INTO `ACL` VALUES (667,'VnUser','*','*','ALLOW','ROLE','itManagement',NULL); +INSERT INTO `ACL` VALUES (668,'VnUser','__get__preview','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (669,'VnUser','preview','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (670,'VnUser','create','*','ALLOW','ROLE','itManagement',NULL); +INSERT INTO `ACL` VALUES (672,'PackingSiteAdvanced','*','*','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (673,'InvoiceOut','makePdfAndNotify','WRITE','ALLOW','ROLE','invoicing',NULL); +INSERT INTO `ACL` VALUES (674,'InvoiceOutConfig','*','READ','ALLOW','ROLE','invoicing',NULL); +INSERT INTO `ACL` VALUES (676,'Ticket','invoiceTickets','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (680,'MailAliasAccount','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (683,'MailAliasAccount','canEditAlias','WRITE','ALLOW','ROLE','developerBoss',NULL); +INSERT INTO `ACL` VALUES (684,'WorkerDisableExcluded','*','READ','ALLOW','ROLE','itManagement',NULL); +INSERT INTO `ACL` VALUES (685,'WorkerDisableExcluded','*','WRITE','ALLOW','ROLE','itManagement',NULL); +INSERT INTO `ACL` VALUES (686,'MailForward','*','*','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (687,'ClientSms','find','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (688,'ClientSms','create','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (689,'Vehicle','sorted','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (695,'ViaexpressConfig','internationalExpedition','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (696,'ViaexpressConfig','renderer','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (697,'Ticket','transferClient','WRITE','ALLOW','ROLE','claimManager',19295); +INSERT INTO `ACL` VALUES (698,'Ticket','canEditWeekly','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (699,'TicketSms','find','READ','ALLOW','ROLE','salesPerson',NULL); +INSERT INTO `ACL` VALUES (701,'Docuware','upload','WRITE','ALLOW','ROLE','deliveryAssistant',NULL); +INSERT INTO `ACL` VALUES (702,'Ticket','docuwareDownload','READ','ALLOW','ROLE','salesPerson',NULL); +INSERT INTO `ACL` VALUES (703,'Worker','search','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (704,'ExpeditionState','addExpeditionState','WRITE','ALLOW','ROLE','production',19294); +INSERT INTO `ACL` VALUES (705,'SaleGroupDetail','deleteById','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (706,'Ticket','setDeleted','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (707,'DeviceLog','create','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (708,'Collection','getTickets','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (709,'Client','findOne','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (710,'Client','findById','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (711,'Client','find','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (712,'Client','exists','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (713,'Client','__get__addresses','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (714,'ExpeditionMistakeType','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (715,'WorkerMistakeType','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (716,'ExpeditionMistake','*','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (717,'WorkerMistake','*','WRITE','ALLOW','ROLE','coolerAssist',NULL); +INSERT INTO `ACL` VALUES (718,'MistakesTypes','*','WRITE','ALLOW','ROLE','coolerAssist',NULL); +INSERT INTO `ACL` VALUES (719,'MistakeType','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (720,'MachineWorker','*','READ','ALLOW','ROLE','coolerAssist',NULL); +INSERT INTO `ACL` VALUES (721,'Printer','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (722,'SaleMistake','*','WRITE','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (723,'Item','setVisibleDiscard','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (724,'Address','getAddress','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (725,'Account','findOne','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (726,'Account','findById','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (727,'Account','find','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (728,'Account','exists','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (729,'Sale','clone','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (730,'Ticket','setDeleted','WRITE','ALLOW','ROLE','deliveryAssistant',NULL); +INSERT INTO `ACL` VALUES (732,'Sale','isInPreparing','*','ALLOW','ROLE','reviewer',NULL); +INSERT INTO `ACL` VALUES (733,'Train','*','READ','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (734,'WorkerDepartment','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (735,'VnUser','higherPrivileges','*','ALLOW','ROLE','itManagement',NULL); +INSERT INTO `ACL` VALUES (736,'VnUser','mediumPrivileges','*','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (737,'VnUser','updateUser','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (738,'TicketCollection','*','WRITE','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (739,'Worker','setPassword','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (740,'Url','getByUser','READ','ALLOW','ROLE','$everyone',NULL); +INSERT INTO `ACL` VALUES (741,'Claim','__get__lines','READ','ALLOW','ROLE','claimViewer',NULL); +INSERT INTO `ACL` VALUES (742,'AddressShortage','*','READ','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (743,'Claim','filter','READ','ALLOW','ROLE','claimViewer',NULL); +INSERT INTO `ACL` VALUES (744,'Claim','find','READ','ALLOW','ROLE','claimViewer',NULL); +INSERT INTO `ACL` VALUES (745,'Claim','findById','READ','ALLOW','ROLE','claimViewer',NULL); +INSERT INTO `ACL` VALUES (746,'Claim','getSummary','READ','ALLOW','ROLE','claimViewer',NULL); +INSERT INTO `ACL` VALUES (747,'CplusRectificationType','*','READ','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (748,'SiiTypeInvoiceOut','*','READ','ALLOW','ROLE','salesPerson',NULL); +INSERT INTO `ACL` VALUES (749,'InvoiceCorrectionType','*','READ','ALLOW','ROLE','salesPerson',NULL); +INSERT INTO `ACL` VALUES (750,'InvoiceOut','transferInvoice','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (751,'Application','executeProc','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (752,'Application','executeFunc','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (753,'NotificationSubscription','getList','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (754,'Route','find','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (755,'Route','findById','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (756,'Route','findOne','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (757,'Route','getRoutesByWorker','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (758,'Route','canViewAllRoute','READ','ALLOW','ROLE','deliveryAssistant',NULL); +INSERT INTO `ACL` VALUES (759,'Route','cmr','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (760,'Route','downloadCmrsZip','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (761,'Route','downloadZip','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (762,'Route','filter','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (763,'Route','getByWorker','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (764,'Route','getDeliveryPoint','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (765,'Route','cmrs','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (766,'Route','getSuggestedTickets','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (767,'Route','getTickets','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (768,'Route','guessPriority','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (769,'Route','insertTicket','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (770,'Route','getDeliveryPoint','READ','ALLOW','ROLE','deliveryBoss',NULL); +INSERT INTO `ACL` VALUES (771,'Route','summary','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (772,'Route','getExpeditionSummary','READ','ALLOW','ROLE','delivery',NULL); +INSERT INTO `ACL` VALUES (773,'WorkerTimeControl','login','READ','ALLOW','ROLE','timeControl',NULL); +INSERT INTO `ACL` VALUES (774,'WorkerTimeControl','getClockIn','READ','ALLOW','ROLE','timeControl',NULL); +INSERT INTO `ACL` VALUES (775,'WorkerTimeControl','clockIn','WRITE','ALLOW','ROLE','timeControl',NULL); +INSERT INTO `ACL` VALUES (776,'WorkerTimeControl','addTimeEntry','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (777,'WorkerTimeControl','deleteTimeEntry','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (778,'WorkerTimeControl','updateTimeEntry','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (779,'WorkerTimeControl','sendMail','WRITE','ALLOW','ROLE','developer',NULL); +INSERT INTO `ACL` VALUES (780,'WorkerTimeControl','updateMailState','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (781,'WorkerTimeControl','weeklyHourRecordEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (782,'WorkerTimeControl','getMailStates','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (783,'WorkerTimeControl','resendWeeklyHourEmail','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (784,'VnRole','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (785,'VnRole','*','WRITE','ALLOW','ROLE','it',NULL); +INSERT INTO `ACL` VALUES (786,'State','isAllEditable','READ','ALLOW','ROLE','delivery',NULL); +INSERT INTO `ACL` VALUES (787,'Ticket','makePdfList','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (788,'Ticket','invoiceTicketsAndPdf','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (789,'InvoiceIn','*','READ','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (790,'InvoiceIn','getSerial','READ','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (791,'InvoiceIn','corrective','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (792,'InvoiceInCorrection','*','*','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (793,'Supplier','updateAllFiscalData','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (794,'Supplier','updateFiscalData','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (795,'Ticket','myLastModified','*','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (796,'MrwConfig','cancelShipment','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (797,'MrwConfig','createShipment','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (798,'MailAliasAccount','*','*','ALLOW','ROLE','itManagement',NULL); +INSERT INTO `ACL` VALUES (799,'Ticket','saveCmr','*','ALLOW','ROLE','developer',NULL); +INSERT INTO `ACL` VALUES (800,'EntryDms','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (801,'MailAliasAccount','create','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (802,'MailAliasAccount','deleteById','WRITE','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (804,'DeviceProduction','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (805,'Collection','assign','WRITE','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (806,'ExpeditionPallet','getPallet','READ','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (807,'MachineWorker','updateInTime','WRITE','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (808,'MobileAppVersionControl','getVersion','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (809,'SaleTracking','delete','WRITE','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (810,'SaleTracking','updateTracking','WRITE','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (811,'SaleTracking','setPicked','WRITE','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (813,'Sale','getFromSectorCollection','READ','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (814,'ItemBarcode','delete','WRITE','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (815,'WorkerActivityType','*','READ','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (816,'WorkerActivity','*','*','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (817,'ParkingLog','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (818,'ExpeditionPallet','*','*','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (819,'Ticket','addSaleByCode','WRITE','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (820,'TicketCollection','*','READ','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (822,'SupplierDms','*','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (823,'MailAlias','*','*','ALLOW','ROLE','developerBoss',NULL); +INSERT INTO `ACL` VALUES (824,'ItemShelving','hasItemOlder','READ','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (825,'Application','getEnumValues','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (826,'Ticket','editZone','WRITE','ALLOW','ROLE','salesAssistant',NULL); +INSERT INTO `ACL` VALUES (827,'TicketWeekly','deleteById','WRITE','ALLOW','ROLE','buyerBoss',NULL); +INSERT INTO `ACL` VALUES (828,'TicketWeekly','upsert','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (830,'InvoiceIn','*','READ','ALLOW','ROLE','deliveryBoss',NULL); +INSERT INTO `ACL` VALUES (831,'InvoiceIn','exchangeRateUpdate','*','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (832,'AgencyLog','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (833,'AgencyWorkCenter','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (835,'Agency','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (836,'Agency','*','WRITE','ALLOW','ROLE','deliveryAssistant',NULL); +INSERT INTO `ACL` VALUES (837,'AgencyWorkCenter','*','WRITE','ALLOW','ROLE','deliveryAssistant',NULL); +INSERT INTO `ACL` VALUES (838,'Worker','getAvailablePda','READ','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (839,'Locker','__get__codes','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (840,'Locker','*','*','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (841,'Locker','*','*','ALLOW','ROLE','productionBoss',NULL); +INSERT INTO `ACL` VALUES (842,'Worker','__get__locker','READ','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (843,'Worker','__get__locker','READ','ALLOW','ROLE','productionBoss',NULL); +INSERT INTO `ACL` VALUES (846,'Ticket','cloneAll','WRITE','ALLOW','ROLE','logistic',10578); +INSERT INTO `ACL` VALUES (847,'RouteConfig','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (848,'InvoiceIn','updateInvoiceIn','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (849,'InvoiceIn','clone','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (850,'InvoiceIn','corrective','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (851,'InvoiceIn','exchangeRateUpdate','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (852,'InvoiceIn','invoiceInEmail','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (853,'InvoiceIn','toBook','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (854,'InvoiceIn','toUnbook','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (855,'InvoiceIn','deleteById','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (856,'InvoiceIn','updateInvoiceIn','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (857,'InvoiceIn','clone','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (858,'InvoiceIn','corrective','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (859,'InvoiceIn','exchangeRateUpdate','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (860,'InvoiceIn','invoiceInEmail','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (861,'InvoiceIn','toBook','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (862,'InvoiceIn','deleteById','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (863,'InvoiceIn','create','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (864,'InvoiceIn','create','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (865,'Ticket','deliveryNotePdf','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (866,'InvoiceOut','download','READ','ALLOW','ROLE','$owner',NULL); +INSERT INTO `ACL` VALUES (867,'InvoiceIn','*','READ','ALLOW','ROLE','maintenanceBoss',NULL); +INSERT INTO `ACL` VALUES (868,'InvoiceIn','*','READ','ALLOW','ROLE','maintenanceBos',NULL); +INSERT INTO `ACL` VALUES (869,'Ticket','editZone','WRITE','ALLOW','ROLE','buyer',NULL); +INSERT INTO `ACL` VALUES (870,'Entry','find','READ','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (871,'RoadmapAddress','*','WRITE','ALLOW','ROLE','palletizerBoss',NULL); +INSERT INTO `ACL` VALUES (872,'RoadmapAddress','*','READ','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (873,'Roadmap','*','WRITE','ALLOW','ROLE','palletizerBoss',NULL); +INSERT INTO `ACL` VALUES (874,'Roadmap','*','READ','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (875,'RoadmapStop','*','WRITE','ALLOW','ROLE','palletizerBoss',NULL); +INSERT INTO `ACL` VALUES (876,'RoadmapStop','*','READ','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (877,'TravelKgPercentage','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (878,'MrwConfig','getLabel','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (879,'AgencyMode','*','*','ALLOW','ROLE','deliveryAssistant',NULL); +INSERT INTO `ACL` VALUES (880,'Collection','assignCollection','WRITE','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (881,'TrainingCourse','*','*','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (882,'TrainingCourseType','*','*','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (883,'TrainingCenter','*','*','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (884,'Worker','__get__trainingCourse','*','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (885,'WorkerTimeControl','addTimeEntry','WRITE','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (886,'WorkerTimeControl','deleteTimeEntry','WRITE','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (887,'WorkerTimeControl','updateTimeEntry','WRITE','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (888,'WorkerTimeControl','weeklyHourRecordEmail','WRITE','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (889,'WorkerTimeControl','sendMail','WRITE','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (890,'WorkerTimeControl','updateMailState','WRITE','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (891,'TravelKgPercentage','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (892,'WorkerIncome','*','*','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (893,'PayrollComponent','*','*','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (894,'Worker','__get__incomes','*','ALLOW','ROLE','hr',NULL); +INSERT INTO `ACL` VALUES (895,'ItemShelvingLog','*','READ','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (897,'WorkerLog','*','READ','ALLOW','ROLE','employee',NULL); +INSERT INTO `ACL` VALUES (901,'WorkerTimeControl','sendMail','WRITE','ALLOW','ROLE','system',NULL); +INSERT INTO `ACL` VALUES (902,'Entry','filter','READ','ALLOW','ROLE','supplier',NULL); +INSERT INTO `ACL` VALUES (903,'Entry','getBuys','READ','ALLOW','ROLE','supplier',NULL); +INSERT INTO `ACL` VALUES (904,'Entry','buyLabel','READ','ALLOW','ROLE','supplier',NULL); +INSERT INTO `ACL` VALUES (905,'AddressWaste','*','READ','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (906,'Entry','print','READ','ALLOW','ROLE','supplier',NULL); +INSERT INTO `ACL` VALUES (907,'Expedition_PrintOut','*','*','ALLOW','ROLE','production',NULL); +INSERT INTO `ACL` VALUES (908,'Docuware','upload','WRITE','ALLOW','ROLE','hrBuyer',13657); +INSERT INTO `ACL` VALUES (909,'Entry','getBuysCsv','READ','ALLOW','ROLE','supplier',19295); +INSERT INTO `ACL` VALUES (910,'MedicalReview','*','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (911,'MedicalCenter','*','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (912,'Worker','__get__medicalReview','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (913,'VnToken','*','READ','ALLOW','ROLE','developer',10578); +INSERT INTO `ACL` VALUES (914,'VnToken','killSession','*','ALLOW','ROLE','developer',10578); +INSERT INTO `ACL` VALUES (915,'ACL','*','WRITE','ALLOW','ROLE','developerBoss',10578); +INSERT INTO `ACL` VALUES (916,'Entry','getBuysCsv','READ','ALLOW','ROLE','supplier',10578); +INSERT INTO `ACL` VALUES (917,'InvoiceOut','refundAndInvoice','WRITE','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (918,'Worker','__get__descriptor','READ','ALLOW','ROLE','employee',10578); +INSERT INTO `ACL` VALUES (919,'Worker','findById','READ','ALLOW','ROLE','employee',10578); +INSERT INTO `ACL` VALUES (920,'QuadmindsApiConfig','*','*','ALLOW','ROLE','delivery',19295); +INSERT INTO `ACL` VALUES (922,'SaleGroup','*','WRITE','ALLOW','ROLE','production',19294); +INSERT INTO `ACL` VALUES (923,'Worker','__get__advancedSummary','READ','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (924,'Worker','__get__summary','READ','ALLOW','ROLE','employee',10578); +INSERT INTO `ACL` VALUES (925,'Postcode','*','WRITE','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (926,'Province','*','WRITE','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (927,'Town','*','WRITE','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (928,'ExpeditionStateType','*','READ','ALLOW','ROLE','employee',19294); +INSERT INTO `ACL` VALUES (929,'ExpeditionState','addExpeditionState','WRITE','ALLOW','ROLE','delivery',19294); +INSERT INTO `ACL` VALUES (930,'SupplierAccount','*','READ','ALLOW','ROLE','buyer',783); +INSERT INTO `ACL` VALUES (931,'StockBought','*','READ','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (932,'StockBought','*','WRITE','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (933,'Buyer','*','READ','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (934,'Ticket','setWeight','WRITE','ALLOW','ROLE','salesPerson',10578); +INSERT INTO `ACL` VALUES (935,'BankEntity','*','WRITE','ALLOW','ROLE','financial',10578); +INSERT INTO `ACL` VALUES (936,'Device','handleUser','*','ALLOW','ROLE','employee',10578); +INSERT INTO `ACL` VALUES (937,'WorkerTimeControlMail','count','READ','ALLOW','ROLE','employee',10578); +INSERT INTO `ACL` VALUES (938,'Worker','__get__mail','READ','ALLOW','ROLE','hr',10578); INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee'); INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee'); @@ -1971,24 +2297,27 @@ INSERT INTO `module` VALUES ('wagon'); INSERT INTO `module` VALUES ('worker'); INSERT INTO `module` VALUES ('zone'); -INSERT INTO `defaultViewConfig` VALUES ('itemsIndex','{\"intrastat\":false,\"stemMultiplier\":false,\"landed\":false,\"producer\":false}'); -INSERT INTO `defaultViewConfig` VALUES ('latestBuys','{\"intrastat\":false,\"description\":false,\"density\":false,\"isActive\":false,\n \"freightValue\":false,\"packageValue\":false,\"isIgnored\":false,\"price2\":false,\"ektFk\":false,\"weight\":false,\n \"size\":false,\"comissionValue\":false,\"landing\":false}'); -INSERT INTO `defaultViewConfig` VALUES ('ticketsMonitor','{\"id\":false}'); -INSERT INTO `defaultViewConfig` VALUES ('clientsDetail','{\"id\":true,\"phone\":true,\"city\":true,\"socialName\":true,\"salesPersonFk\":true,\"email\":true,\"name\":false,\"fi\":false,\"credit\":false,\"creditInsurance\":false,\"mobile\":false,\"street\":false,\"countryFk\":false,\"provinceFk\":false,\"postcode\":false,\"created\":false,\"businessTypeFk\":false,\"payMethodFk\":false,\"sageTaxTypeFk\":false,\"sageTransactionTypeFk\":false,\"isActive\":false,\"isVies\":false,\"isTaxDataChecked\":false,\"isEqualizated\":false,\"isFreezed\":false,\"hasToInvoice\":false,\"hasToInvoiceByAddress\":false,\"isToBeMailed\":false,\"hasLcr\":false,\"hasCoreVnl\":false,\"hasSepaVnl\":false}'); +INSERT INTO `defaultViewMultiConfig` VALUES ('itemsIndex','{\"intrastat\":false,\"stemMultiplier\":false,\"landed\":false,\"producer\":false}'); +INSERT INTO `defaultViewMultiConfig` VALUES ('latestBuys','{\"intrastat\":false,\"description\":false,\"density\":false,\"isActive\":false,\n \"freightValue\":false,\"packageValue\":false,\"isIgnored\":false,\"price2\":false,\"ektFk\":false,\"weight\":false,\n \"size\":false,\"comissionValue\":false,\"landing\":false}'); +INSERT INTO `defaultViewMultiConfig` VALUES ('ticketsMonitor','{\"id\":false}'); +INSERT INTO `defaultViewMultiConfig` VALUES ('clientsDetail','{\"id\":true,\"phone\":true,\"city\":true,\"socialName\":true,\"salesPersonFk\":true,\"email\":true,\"name\":false,\"fi\":false,\"credit\":false,\"creditInsurance\":false,\"mobile\":false,\"street\":false,\"countryFk\":false,\"provinceFk\":false,\"postcode\":false,\"created\":false,\"businessTypeFk\":false,\"payMethodFk\":false,\"sageTaxTypeFk\":false,\"sageTransactionTypeFk\":false,\"isActive\":false,\"isVies\":false,\"isTaxDataChecked\":false,\"isEqualizated\":false,\"isFreezed\":false,\"hasToInvoice\":false,\"hasToInvoiceByAddress\":false,\"isToBeMailed\":false,\"hasLcr\":false,\"hasCoreVnl\":false,\"hasSepaVnl\":false}'); +INSERT INTO `defaultViewMultiConfig` VALUES ('routesList','{\"ID\":true,\"worker\":true,\"agency\":true,\"vehicle\":true,\"date\":true,\"volume\":true,\"description\":true,\"started\":true,\"finished\":true,\"actions\":true}'); /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; USE `vn`; +/*M!999999\- enable the sandbox mode */ /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; INSERT INTO `alertLevel` VALUES ('FREE',0,1); -INSERT INTO `alertLevel` VALUES ('ON_PREPARATION',1,1); -INSERT INTO `alertLevel` VALUES ('PACKED',2,0); -INSERT INTO `alertLevel` VALUES ('DELIVERED',3,0); +INSERT INTO `alertLevel` VALUES ('ON_PREVIOUS',1,1); +INSERT INTO `alertLevel` VALUES ('ON_PREPARATION',2,1); +INSERT INTO `alertLevel` VALUES ('PACKED',3,0); +INSERT INTO `alertLevel` VALUES ('DELIVERED',4,0); INSERT INTO `bookingPlanner` VALUES (5,'2017-07-01 00:00:00','4770000002','WORLD',7,4,1); INSERT INTO `bookingPlanner` VALUES (6,'2017-07-01 00:00:00','4770000010','NATIONAL',3,1,1); @@ -2179,26 +2508,25 @@ INSERT INTO `component` VALUES (39,'maná auto',7,NULL,NULL,1,'autoMana',0); INSERT INTO `component` VALUES (40,'cambios Santos 2016',4,NULL,NULL,1,NULL,0); INSERT INTO `component` VALUES (41,'bonificacion porte',6,NULL,NULL,1,'freightCharge',0); INSERT INTO `component` VALUES (42,'promocion Francia',4,NULL,NULL,1,'frenchOffer',0); -INSERT INTO `component` VALUES (43,'promocion Floramondo',4,NULL,NULL,1,'floramondoPromo',0); INSERT INTO `component` VALUES (44,'rappel cadena',2,NULL,NULL,1,'rappel',0); INSERT INTO `component` VALUES (45,'maná reclamacion',7,4,NULL,0,'manaClaim',0); INSERT INTO `component` VALUES (46,'recargo a particular',2,NULL,0.25,0,'individual',0); -INSERT INTO `component` VALUES (47,'promocion Italia',4,NULL,NULL,1,'italianOffer',0); INSERT INTO `component` VALUES (48,'fusión de lineas',4,NULL,NULL,1,'lineFusion',0); INSERT INTO `component` VALUES (49,'sustitución',4,NULL,NULL,1,'substitution',0); +INSERT INTO `component` VALUES (50,'bonus',4,NULL,NULL,1,'bonus',0); -INSERT INTO `componentType` VALUES (1,'coste',1,0,'COST'); -INSERT INTO `componentType` VALUES (2,'com ventas',1,1,NULL); -INSERT INTO `componentType` VALUES (3,'com compras',1,1,NULL); -INSERT INTO `componentType` VALUES (4,'empresa',1,1,'MARGIN'); -INSERT INTO `componentType` VALUES (5,'cliente',0,0,NULL); -INSERT INTO `componentType` VALUES (6,'agencia',0,0,'FREIGHT'); -INSERT INTO `componentType` VALUES (7,'cartera_comercial',0,0,'MANA'); -INSERT INTO `componentType` VALUES (8,'cartera_producto',0,1,NULL); -INSERT INTO `componentType` VALUES (9,'maniobra',1,0,NULL); -INSERT INTO `componentType` VALUES (10,'cartera_comprador',0,1,NULL); -INSERT INTO `componentType` VALUES (11,'errores',0,1,NULL); -INSERT INTO `componentType` VALUES (12,'otros',0,1,NULL); +INSERT INTO `componentType` VALUES (1,'cost','coste',1,0); +INSERT INTO `componentType` VALUES (2,NULL,'com ventas',1,1); +INSERT INTO `componentType` VALUES (3,NULL,'com compras',1,1); +INSERT INTO `componentType` VALUES (4,'margin','empresa',1,1); +INSERT INTO `componentType` VALUES (5,NULL,'cliente',0,0); +INSERT INTO `componentType` VALUES (6,'freight','agencia',0,0); +INSERT INTO `componentType` VALUES (7,'mana','cartera_comercial',0,0); +INSERT INTO `componentType` VALUES (8,NULL,'cartera_producto',0,1); +INSERT INTO `componentType` VALUES (9,NULL,'maniobra',1,0); +INSERT INTO `componentType` VALUES (10,NULL,'cartera_comprador',0,1); +INSERT INTO `componentType` VALUES (11,NULL,'errores',0,1); +INSERT INTO `componentType` VALUES (12,'other','otros',0,1); INSERT INTO `continent` VALUES (1,'Asia','AS'); INSERT INTO `continent` VALUES (2,'América','AM'); @@ -2206,61 +2534,63 @@ INSERT INTO `continent` VALUES (3,'África','AF'); INSERT INTO `continent` VALUES (4,'Europa','EU'); INSERT INTO `continent` VALUES (5,'Oceanía','OC'); -INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,110,763,0,0,0,0,26,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (22,'shopping','COMPRAS',2,3,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (23,'CMA','CAMARA',13,14,NULL,72,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (31,'it','INFORMATICA',4,5,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (34,'accounting','CONTABILIDAD',6,7,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (35,'finance','FINANZAS',8,9,NULL,0,0,0,1,0,1,'/1/',NULL,1,'begonya@verdnatura.es',1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (36,'labor','LABORAL',10,11,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',12,35,NULL,72,1,1,1,11,1,'/1/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (38,'picking','SACADO',15,16,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (39,'packing','ENCAJADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',36,37,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (43,'VT','VENTAS',38,69,NULL,0,0,0,1,15,1,'/1/',NULL,1,'',1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (44,'management','GERENCIA',70,71,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',72,73,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (46,'delivery','REPARTO',74,75,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',76,77,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',78,79,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',80,81,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (53,'marketing','MARKETING Y COMUNICACIÓN',39,40,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',82,83,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (55,NULL,'TALLER NATURAL',19,20,14548,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1118,NULL,NULL,NULL); -INSERT INTO `department` VALUES (56,NULL,'TALLER ARTIFICIAL',21,22,8470,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1927,NULL,NULL,NULL); -INSERT INTO `department` VALUES (58,'CMP','CAMPOS',84,87,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',88,89,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (60,'claims','RECLAMACIONES',41,42,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,1,1,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (61,NULL,'VNH',90,93,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',94,95,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (68,NULL,'COMPLEMENTOS',23,24,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',96,97,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (80,'vallesTeam','EQUIPO ESPAÑA 5',43,44,4250,72,0,0,2,0,43,'/1/43/','jvp_equipo',1,'equipojvalles@verdnatura.es',0,0,0,0,NULL,NULL,'5300',NULL); -INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',98,99,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (89,NULL,'COORDINACION',100,101,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (90,NULL,'TRAILER',91,92,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (91,'artificial','ARTIFICIAL',25,26,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (92,NULL,'EQUIPO SILVERIO',45,46,1203,0,0,0,2,0,43,'/1/43/','sdc_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (94,'spainTeam2','EQUIPO ESPAÑA 2',47,48,3797,0,0,0,2,0,43,'/1/43/','es2_equipo',0,'es2@verdnatura.es',0,0,0,0,NULL,NULL,'5100',NULL); -INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',49,50,24065,0,0,0,2,0,43,'/1/43/','es1_equipo',0,'es1@verdnatura.es',0,0,0,0,NULL,NULL,'5000',NULL); -INSERT INTO `department` VALUES (96,NULL,'EQUIPO C LOPEZ',51,52,4661,0,0,0,2,0,43,'/1/43/','cla_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (115,NULL,'EQUIPO CLAUDI',53,54,3810,0,0,0,2,0,43,'/1/43/','csr_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (123,NULL,'EQUIPO ELENA BASCUÑANA',55,56,7102,0,0,0,2,0,43,'/1/43/','ebt_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',102,103,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (125,'miriamMarTeam','EQUIPO ESPAÑA 3',57,58,1118,0,0,0,2,0,43,'/1/43/','mir_equipo',0,'equipomirgir@verdnatura.es',0,0,0,0,NULL,NULL,'5200',NULL); -INSERT INTO `department` VALUES (126,NULL,'PRESERVADO',27,28,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (128,NULL,'PALETIZADO',29,30,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (130,NULL,'REVISION',31,32,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',85,86,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',59,60,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (133,'franceTeam','EQUIPO FRANCIA',61,62,1731,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL); -INSERT INTO `department` VALUES (134,'portugalTeam','EQUIPO PORTUGAL',63,64,6264,0,0,0,2,0,43,'/1/43/','pt_equipo',1,'portugal@verdnatura.es',0,0,0,0,NULL,NULL,'3500',NULL); -INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',104,105,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',106,107,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (137,'sorter','SORTER',108,109,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (139,'soriaTeam','EQUIPO ESPAÑA 4',65,66,3803,0,0,0,2,0,43,'/1/43/','jss_equipo',1,'equipojsoria@verdnatura.es',0,0,0,0,NULL,NULL,'5400',NULL); -INSERT INTO `department` VALUES (140,'hollandTeam','EQUIPO HOLANDA',67,68,NULL,0,0,0,2,0,43,'/1/43/','nl_equipo',1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (141,NULL,'PREVIA',33,34,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,114,763,0,0,0,0,26,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (22,'shopping','COMPRAS',2,5,NULL,72,0,0,1,1,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (23,'CMA','CAMARA',15,16,NULL,72,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,'PREVIOUS'); +INSERT INTO `department` VALUES (31,'it','INFORMATICA',6,7,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (34,'accounting','CONTABILIDAD',8,9,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (35,'finance','FINANZAS',10,11,NULL,0,0,0,1,0,1,'/1/',NULL,1,'begonya@verdnatura.es',1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (36,'labor','LABORAL',12,13,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',14,37,NULL,72,1,1,1,11,1,'/1/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (38,'picking','SACADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'ON_PREPARATION'); +INSERT INTO `department` VALUES (39,'packing','ENCAJADO',19,20,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'PACKING'); +INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',38,39,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (43,'VT','VENTAS',40,73,NULL,0,0,0,1,16,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (44,'management','GERENCIA',74,75,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',76,77,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (46,'delivery','REPARTO',78,79,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,'DELIVERY'); +INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',80,81,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'STORAGE'); +INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',82,83,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',84,85,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (53,'marketing','MARKETING Y COMUNICACIÓN',41,42,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',86,87,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (55,NULL,'TALLER NATURAL',21,22,14548,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1118,NULL,NULL,NULL); +INSERT INTO `department` VALUES (56,NULL,'TALLER ARTIFICIAL',23,24,8470,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1927,NULL,NULL,NULL); +INSERT INTO `department` VALUES (58,'CMP','CAMPOS',88,91,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'FIELD'); +INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',92,93,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (60,'claims','RECLAMACIONES',43,44,NULL,72,0,0,2,0,43,'/1/43/',NULL,0,NULL,1,1,0,0,NULL,NULL,NULL,'CLAIM'); +INSERT INTO `department` VALUES (61,NULL,'VNH',94,97,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',98,99,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (68,NULL,'COMPLEMENTOS',25,26,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',100,101,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (80,'spainTeam5','EQUIPO ESPAÑA 5',45,46,4250,0,0,0,2,0,43,'/1/43/','es5_equipo',1,'es5@verdnatura.es',0,0,0,0,NULL,NULL,'5300',NULL); +INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',102,103,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (89,NULL,'COORDINACION',104,105,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (90,NULL,'TRAILER',95,96,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (91,'artificial','ARTIFICIAL',27,28,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'PREVIOUS'); +INSERT INTO `department` VALUES (92,NULL,'EQUIPO SILVERIO',47,48,1203,0,0,0,2,0,43,'/1/43/','sdc_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (94,'spainTeam2','EQUIPO ESPAÑA 2',49,50,3797,0,0,0,2,0,43,'/1/43/','es2_equipo',1,'es2@verdnatura.es',0,0,0,0,NULL,NULL,'5100',NULL); +INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',51,52,24065,0,0,0,2,0,43,'/1/43/','es1_equipo',1,'es1@verdnatura.es',0,0,0,0,NULL,NULL,'5000',NULL); +INSERT INTO `department` VALUES (96,NULL,'EQUIPO C LOPEZ',53,54,4661,0,0,0,2,0,43,'/1/43/','cla_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (115,NULL,'EQUIPO CLAUDI',55,56,3810,0,0,0,2,0,43,'/1/43/','csr_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (123,NULL,'EQUIPO ELENA BASCUÑANA',57,58,7102,0,0,0,2,0,43,'/1/43/','ebt_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',106,107,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (125,'spainTeam3','EQUIPO ESPAÑA 3',59,60,1118,0,0,0,2,0,43,'/1/43/','es3_equipo',1,'es3@verdnatura.es',0,0,0,0,NULL,NULL,'5200',NULL); +INSERT INTO `department` VALUES (126,NULL,'PRESERVADO',29,30,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (128,NULL,'PALETIZADO',31,32,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'PALLETIZING'); +INSERT INTO `department` VALUES (130,NULL,'REVISION',33,34,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'ON_CHECKING'); +INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',89,90,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',61,62,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (133,'franceTeam','EQUIPO FRANCIA',63,64,1731,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL); +INSERT INTO `department` VALUES (134,'portugalTeam','EQUIPO PORTUGAL',65,66,6264,0,0,0,2,0,43,'/1/43/','pt_equipo',1,'portugal@verdnatura.es',0,0,0,0,NULL,NULL,'3500',NULL); +INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',108,109,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',110,111,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (137,'sorter','SORTER',112,113,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (139,'spainTeam4','EQUIPO ESPAÑA 4',67,68,3803,0,0,0,2,0,43,'/1/43/','es4_equipo',1,'es4@verdnatura.es',0,0,0,0,NULL,NULL,'5400',NULL); +INSERT INTO `department` VALUES (140,'hollandTeam','EQUIPO HOLANDA',69,70,NULL,0,0,0,2,0,43,'/1/43/','nl_equipo',1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (141,NULL,'PREVIA',35,36,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'PREVIOUS'); +INSERT INTO `department` VALUES (146,NULL,'VERDNACOLOMBIA',3,4,NULL,72,0,0,2,0,22,'/1/22/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (147,'spainTeamAsia','EQUIPO ESPAÑA ASIA',71,72,40214,0,0,0,2,0,43,'/1/43/','esA_equipo',0,'esA@verdnatura.es',0,0,0,0,NULL,NULL,'5500',NULL); INSERT INTO `docuware` VALUES (1,'deliveryNote','Albaranes cliente','find','find','N__ALBAR_N',NULL); INSERT INTO `docuware` VALUES (2,'deliveryNote','Albaranes cliente','store','Archivar','N__ALBAR_N',NULL); @@ -2315,7 +2645,7 @@ INSERT INTO `sample` VALUES (16,'letter-debtor-nd','Aviso reiterado por saldo de INSERT INTO `sample` VALUES (17,'client-lcr','Email de solicitud de datos bancarios LCR',0,1,1,0,NULL); INSERT INTO `sample` VALUES (18,'client-debt-statement','Extracto del cliente',1,0,1,1,'Clients'); INSERT INTO `sample` VALUES (19,'credit-request','Solicitud de crédito',1,1,1,0,'Clients'); -INSERT INTO `sample` VALUES (20,'incoterms-authorization','Autorización de incoterms',1,1,1,0,'Clients'); +INSERT INTO `sample` VALUES (20,'incoterms-authorization','Entregas intracomunitarias recogidas por el cliente',1,1,1,0,'Clients'); INSERT INTO `siiTrascendencyInvoiceIn` VALUES (1,'Operación de régimen general'); INSERT INTO `siiTrascendencyInvoiceIn` VALUES (2,'Operaciones por las que los empresarios satisfacen compensaciones REAGYP'); @@ -2352,212 +2682,50 @@ INSERT INTO `siiTypeInvoiceOut` VALUES (7,'R3','Factura rectificativa (Art. 80.4 INSERT INTO `siiTypeInvoiceOut` VALUES (8,'R4','Factura rectificativa (Resto)'); INSERT INTO `siiTypeInvoiceOut` VALUES (9,'R5','Factura rectificativa en facturas simplificadas'); -INSERT INTO `silexACL` VALUES (1,'workerTimeControl','clockIn','$everyone'); -INSERT INTO `silexACL` VALUES (2,'workerTimeControl','getClockIn','$everyone'); -INSERT INTO `silexACL` VALUES (3,'workerTimeControl','login','$everyone'); -INSERT INTO `silexACL` VALUES (4,'security','device_checkLogin','employee'); -INSERT INTO `silexACL` VALUES (5,'security','getVersion','employee'); -INSERT INTO `silexACL` VALUES (6,'security','login','employee'); -INSERT INTO `silexACL` VALUES (7,'delivery','addNote','employee'); -INSERT INTO `silexACL` VALUES (8,'delivery','expeditionState_add','employee'); -INSERT INTO `silexACL` VALUES (9,'delivery','expeditionState_addByExpedition','employee'); -INSERT INTO `silexACL` VALUES (10,'delivery','expeditionState_addByExpeditionMulti','employee'); -INSERT INTO `silexACL` VALUES (11,'delivery','expeditionState_addByRoute','employee'); -INSERT INTO `silexACL` VALUES (12,'delivery','expedition_getLog','employee'); -INSERT INTO `silexACL` VALUES (13,'delivery','getExpeditionFromRoute','employee'); -INSERT INTO `silexACL` VALUES (14,'delivery','getInfo','employee'); -INSERT INTO `silexACL` VALUES (15,'delivery','getInfoCompany','employee'); -INSERT INTO `silexACL` VALUES (16,'delivery','getInfoFreelance','employee'); -INSERT INTO `silexACL` VALUES (17,'delivery','getWorkers','employee'); -INSERT INTO `silexACL` VALUES (18,'delivery','get_routes','employee'); -INSERT INTO `silexACL` VALUES (19,'delivery','get_tickets','employee'); -INSERT INTO `silexACL` VALUES (20,'delivery','get_version','employee'); -INSERT INTO `silexACL` VALUES (21,'delivery','saveLoadersWorkers','employee'); -INSERT INTO `silexACL` VALUES (22,'delivery','save_sign','employee'); -INSERT INTO `silexACL` VALUES (23,'delivery','setRouteOk','employee'); -INSERT INTO `silexACL` VALUES (24,'delivery','updateExpeditionChecked','employee'); -INSERT INTO `silexACL` VALUES (25,'delivery','update_routes','employee'); -INSERT INTO `silexACL` VALUES (26,'almacennew','barcodes_edit','employee'); -INSERT INTO `silexACL` VALUES (27,'almacennew','barcodeToItem','employee'); -INSERT INTO `silexACL` VALUES (28,'almacennew','buffer_setTypeByName','employee'); -INSERT INTO `silexACL` VALUES (29,'almacennew','buy_updateGrouping','employee'); -INSERT INTO `silexACL` VALUES (30,'almacennew','buy_updatePacking','employee'); -INSERT INTO `silexACL` VALUES (31,'almacennew','checkRouteExpeditionScanPut','employee'); -INSERT INTO `silexACL` VALUES (32,'almacennew','clearShelvingList','employee'); -INSERT INTO `silexACL` VALUES (33,'almacennew','collectionAddItem','employee'); -INSERT INTO `silexACL` VALUES (34,'almacennew','collectionGet','employee'); -INSERT INTO `silexACL` VALUES (35,'almacennew','collectionIncreaseQuantity','employee'); -INSERT INTO `silexACL` VALUES (36,'almacennew','collectionMissingTrash','employee'); -INSERT INTO `silexACL` VALUES (37,'almacennew','collectionNew','employee'); -INSERT INTO `silexACL` VALUES (38,'almacennew','collectionStickerPrint','employee'); -INSERT INTO `silexACL` VALUES (39,'almacennew','collection_getTickets','employee'); -INSERT INTO `silexACL` VALUES (40,'almacennew','collection_printSticker','employee'); -INSERT INTO `silexACL` VALUES (41,'almacennew','department_getHasMistake','employee'); -INSERT INTO `silexACL` VALUES (42,'almacennew','deviceLog_add','employee'); -INSERT INTO `silexACL` VALUES (43,'almacennew','deviceProductionUser_getWorker','employee'); -INSERT INTO `silexACL` VALUES (44,'almacennew','deviceProduction_getnameDevice','employee'); -INSERT INTO `silexACL` VALUES (45,'almacennew','expeditionLoading_add','employee'); -INSERT INTO `silexACL` VALUES (46,'almacennew','expeditionPalletDel','employee'); -INSERT INTO `silexACL` VALUES (47,'almacennew','expeditionPalletList','employee'); -INSERT INTO `silexACL` VALUES (48,'almacennew','expeditionPalletPrintSet','employee'); -INSERT INTO `silexACL` VALUES (49,'almacennew','expeditionPalletView','employee'); -INSERT INTO `silexACL` VALUES (50,'almacennew','expeditionScanAdd','employee'); -INSERT INTO `silexACL` VALUES (51,'almacennew','expeditionScanDel','employee'); -INSERT INTO `silexACL` VALUES (52,'almacennew','expeditionScanList','employee'); -INSERT INTO `silexACL` VALUES (53,'almacennew','expeditionScanPut','employee'); -INSERT INTO `silexACL` VALUES (54,'almacennew','expeditionState_addByPallet','employee'); -INSERT INTO `silexACL` VALUES (55,'almacennew','expeditionTruckAdd','employee'); -INSERT INTO `silexACL` VALUES (56,'almacennew','expeditionTruckList','employee'); -INSERT INTO `silexACL` VALUES (57,'almacennew','expedition_getState','employee'); -INSERT INTO `silexACL` VALUES (58,'almacennew','expedition_scan','employee'); -INSERT INTO `silexACL` VALUES (59,'almacennew','faultsReview','employee'); -INSERT INTO `silexACL` VALUES (60,'almacennew','faultsReview_isChecked','employee'); -INSERT INTO `silexACL` VALUES (61,'almacennew','getItemUbication','employee'); -INSERT INTO `silexACL` VALUES (62,'almacennew','get_ItemPackingType','employee'); -INSERT INTO `silexACL` VALUES (63,'almacennew','itemDiary','employee'); -INSERT INTO `silexACL` VALUES (64,'almacennew','itemPlacementSupplyAiming','employee'); -INSERT INTO `silexACL` VALUES (65,'almacennew','itemPlacementSupplyCloseOrder','employee'); -INSERT INTO `silexACL` VALUES (66,'almacennew','itemPlacementSupplyGetOrder','employee'); -INSERT INTO `silexACL` VALUES (68,'almacennew','itemShelvingBuyerGet','employee'); -INSERT INTO `silexACL` VALUES (69,'almacennew','itemShelvingBuyerTask','employee'); -INSERT INTO `silexACL` VALUES (70,'almacennew','itemShelvingDelete','employee'); -INSERT INTO `silexACL` VALUES (71,'almacennew','itemShelvingList','employee'); -INSERT INTO `silexACL` VALUES (72,'almacennew','itemShelvingLog_get','employee'); -INSERT INTO `silexACL` VALUES (73,'almacennew','itemShelvingMake','employee'); -INSERT INTO `silexACL` VALUES (74,'almacennew','itemShelvingMakeEdit','employee'); -INSERT INTO `silexACL` VALUES (75,'almacennew','itemShelvingMake_multi','employee'); -INSERT INTO `silexACL` VALUES (76,'almacennew','itemShelvingPlacementSupplyAdd','employee'); -INSERT INTO `silexACL` VALUES (77,'almacennew','itemShelvingSaleSupplyAdd','employee'); -INSERT INTO `silexACL` VALUES (78,'almacennew','itemShelvingStarsUpdate','employee'); -INSERT INTO `silexACL` VALUES (79,'almacennew','itemShelvingTransfer','employee'); -INSERT INTO `silexACL` VALUES (80,'almacennew','itemShelving_addByClaim','employee'); -INSERT INTO `silexACL` VALUES (81,'almacennew','itemShelving_filterBuyer','employee'); -INSERT INTO `silexACL` VALUES (82,'almacennew','itemShelving_getSaleDate','employee'); -INSERT INTO `silexACL` VALUES (83,'almacennew','itemTrash','employee'); -INSERT INTO `silexACL` VALUES (84,'almacennew','item_card','employee'); -INSERT INTO `silexACL` VALUES (85,'almacennew','item_getSimilar','employee'); -INSERT INTO `silexACL` VALUES (86,'almacennew','item_placement_save','employee'); -INSERT INTO `silexACL` VALUES (87,'almacennew','item_saveReference','employee'); -INSERT INTO `silexACL` VALUES (88,'almacennew','item_updatePackingShelve','employee'); -INSERT INTO `silexACL` VALUES (89,'almacennew','machineWorker_add','employee'); -INSERT INTO `silexACL` VALUES (90,'almacennew','machineWorker_getHistorical','employee'); -INSERT INTO `silexACL` VALUES (91,'almacennew','machineWorker_update','employee'); -INSERT INTO `silexACL` VALUES (92,'almacennew','machineWorker_Worker','employee'); -INSERT INTO `silexACL` VALUES (93,'almacennew','machine_checkPlate','employee'); -INSERT INTO `silexACL` VALUES (94,'almacennew','machine_getWorkerPlate','employee'); -INSERT INTO `silexACL` VALUES (95,'almacennew','mistakeType','employee'); -INSERT INTO `silexACL` VALUES (96,'almacennew','printer_get','employee'); -INSERT INTO `silexACL` VALUES (97,'almacennew','qr_getCall','developer'); -INSERT INTO `silexACL` VALUES (98,'almacennew','saleMistakeAdd','employee'); -INSERT INTO `silexACL` VALUES (99,'almacennew','saleMove','employee'); -INSERT INTO `silexACL` VALUES (100,'almacennew','saleParking_add','employee'); -INSERT INTO `silexACL` VALUES (101,'almacennew','saleTrackingDel','employee'); -INSERT INTO `silexACL` VALUES (102,'almacennew','saleTrackingReplace','employee'); -INSERT INTO `silexACL` VALUES (103,'almacennew','saleTracking_add','employee'); -INSERT INTO `silexACL` VALUES (104,'almacennew','saleTracking_addPrevOK','employee'); -INSERT INTO `silexACL` VALUES (105,'almacennew','saleTracking_updateIsChecked','employee'); -INSERT INTO `silexACL` VALUES (106,'almacennew','sectorCollectionSaleGroup_add','employee'); -INSERT INTO `silexACL` VALUES (107,'almacennew','sectorCollection_get','employee'); -INSERT INTO `silexACL` VALUES (108,'almacennew','sectorCollection_getSale','employee'); -INSERT INTO `silexACL` VALUES (109,'almacennew','sectorCollection_new','employee'); -INSERT INTO `silexACL` VALUES (110,'almacennew','sector_get','employee'); -INSERT INTO `silexACL` VALUES (111,'almacennew','shelvingChange','employee'); -INSERT INTO `silexACL` VALUES (112,'almacennew','shelvingLog_get','employee'); -INSERT INTO `silexACL` VALUES (113,'almacennew','shelvingPark','employee'); -INSERT INTO `silexACL` VALUES (114,'almacennew','shelvingParking_get','employee'); -INSERT INTO `silexACL` VALUES (115,'almacennew','shelvingPriorityUpdate','employee'); -INSERT INTO `silexACL` VALUES (116,'almacennew','sip_getExtension','employee'); -INSERT INTO `silexACL` VALUES (117,'almacennew','ticketCollection_setUsedShelves','employee'); -INSERT INTO `silexACL` VALUES (118,'almacennew','ticketOrCollection_checkFullyControlled','employee'); -INSERT INTO `silexACL` VALUES (119,'almacennew','ticketToPrePrepare','employee'); -INSERT INTO `silexACL` VALUES (120,'almacennew','ticket_checkFullyControlled','employee'); -INSERT INTO `silexACL` VALUES (121,'almacennew','ticket_setState','employee'); -INSERT INTO `silexACL` VALUES (122,'almacennew','update_ItemPackingType','employee'); -INSERT INTO `silexACL` VALUES (123,'almacennew','workerMachinery_isRegistered','employee'); -INSERT INTO `silexACL` VALUES (124,'almacennew','workerMistakeType_get','employee'); -INSERT INTO `silexACL` VALUES (125,'almacennew','workerMistake_Add','coolerBoss'); -INSERT INTO `silexACL` VALUES (126,'almacennew','workerShelving_add','employee'); -INSERT INTO `silexACL` VALUES (127,'almacennew','workerShelving_delete','employee'); -INSERT INTO `silexACL` VALUES (128,'almacennew','worker_getFromHasMistake','employee'); -INSERT INTO `silexACL` VALUES (129,'almacennew','worker_getId','employee'); -INSERT INTO `silexACL` VALUES (130,'almacennew','worker_getPrinter','employee'); -INSERT INTO `silexACL` VALUES (131,'almacennew','worker_getSector','employee'); -INSERT INTO `silexACL` VALUES (132,'almacennew','worker_updatePrinter','employee'); -INSERT INTO `silexACL` VALUES (133,'almacennew','worker_updateSector','employee'); -INSERT INTO `silexACL` VALUES (134,'almacennew','itemShelving_updateFromSale','employee'); -INSERT INTO `silexACL` VALUES (135,'almacennew','collection_getUncheckedTicket','employee'); -INSERT INTO `silexACL` VALUES (136,'almacennew','itemShelving_return','employee'); -INSERT INTO `silexACL` VALUES (137,'almacennew','itemShelving_merge','employee'); -INSERT INTO `silexACL` VALUES (139,'delivery','get_expeditionsSummary','employee'); -INSERT INTO `silexACL` VALUES (140,'almacennew','cmrExpeditionPallet_add','employee'); -INSERT INTO `silexACL` VALUES (141,'delivery','route_getExpeditionSummary','employee'); -INSERT INTO `silexACL` VALUES (142,'almacennew','item_saveStems','employee'); -INSERT INTO `silexACL` VALUES (143,'almacennew','debug_add','employee'); -INSERT INTO `silexACL` VALUES (144,'almacennew','operator_getNumberOfWagons','employee'); -INSERT INTO `silexACL` VALUES (145,'almacennew','operator_add','employee'); -INSERT INTO `silexACL` VALUES (146,'almacennew','expeditionPallet_get','employee'); -INSERT INTO `silexACL` VALUES (147,'almacennew','worker_isF11Allowed','employee'); -INSERT INTO `silexACL` VALUES (148,'almacennew','train_get','employee'); -INSERT INTO `silexACL` VALUES (149,'almacennew','saleTracking_mark','employee'); -INSERT INTO `silexACL` VALUES (150,'almacennew','operator_updateItemPackingType','employee'); -INSERT INTO `silexACL` VALUES (151,'almacennew','operator_updateTrain','employee'); -INSERT INTO `silexACL` VALUES (152,'almacennew','operator_getTrain','employee'); -INSERT INTO `silexACL` VALUES (153,'almacennew','operator_getItemPackingType','employee'); -INSERT INTO `silexACL` VALUES (154,'almacennew','collection_assign','employee'); -INSERT INTO `silexACL` VALUES (155,'almacennew','itemPacking_get','employee'); -INSERT INTO `silexACL` VALUES (156,'almacennew','shelvingLog_add','employee'); -INSERT INTO `silexACL` VALUES (157,'almacennew','collection_get','employee'); -INSERT INTO `silexACL` VALUES (158,'delivery','get_routesFromExpedition','employee'); -INSERT INTO `silexACL` VALUES (160,'almacennew','expeditionMistakeType_get','employee'); -INSERT INTO `silexACL` VALUES (161,'almacennew','expeditionMistake_add','employee'); -INSERT INTO `silexACL` VALUES (162,'almacennew','itemShelving_addList','employee'); -INSERT INTO `silexACL` VALUES (163,'almacennew','cmrPallet_add','employee'); -INSERT INTO `silexACL` VALUES (164,'almacennew','ticket_isOutClosureZone','employee'); -INSERT INTO `silexACL` VALUES (165,'almacennew','itemShelving_selfConsumption','employee'); -INSERT INTO `silexACL` VALUES (166,'almacennew','ticket_printLabelPrevious','employee'); -INSERT INTO `silexACL` VALUES (167,'almacennew','travel_updatePacking','employee'); -INSERT INTO `silexACL` VALUES (168,'app','status','$everyone'); - -INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4,1,'alert'); -INSERT INTO `state` VALUES (2,'Libre',2,0,'FREE',NULL,2,0,0,0,0,0,0,4,1,'notice'); -INSERT INTO `state` VALUES (3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3,0,'success'); -INSERT INTO `state` VALUES (4,'Impreso',4,0,'PRINTED',2,29,1,0,1,0,0,1,2,0,'success'); -INSERT INTO `state` VALUES (5,'Preparación',6,1,'ON_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'); -INSERT INTO `state` VALUES (6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0,'warning'); -INSERT INTO `state` VALUES (7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,0,0,4,1,'alert'); -INSERT INTO `state` VALUES (8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1,0,'warning'); -INSERT INTO `state` VALUES (9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,1,0,NULL); -INSERT INTO `state` VALUES (10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0,0,NULL); -INSERT INTO `state` VALUES (11,'Facturado',0,3,'INVOICED',NULL,11,0,1,0,0,0,0,0,0,NULL); -INSERT INTO `state` VALUES (12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4,1,'alert'); -INSERT INTO `state` VALUES (13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0,NULL); -INSERT INTO `state` VALUES (14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1,0,'warning'); -INSERT INTO `state` VALUES (15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0,NULL); -INSERT INTO `state` VALUES (16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0,NULL); -INSERT INTO `state` VALUES (20,'Asignado',4,0,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2,0,'success'); -INSERT INTO `state` VALUES (21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0,'success'); -INSERT INTO `state` VALUES (22,'Pte. Ampliar',2,0,'EXPANDABLE',NULL,22,0,0,0,0,0,0,4,1,'alert'); -INSERT INTO `state` VALUES (23,'URGENTE',5,1,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1,'success'); -INSERT INTO `state` VALUES (24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3,1,'success'); -INSERT INTO `state` VALUES (25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,0,0,3,0,'alert'); -INSERT INTO `state` VALUES (26,'Prep Previa',5,0,'PREVIOUS_PREPARATION',1,28,1,0,0,1,0,0,2,0,'warning'); -INSERT INTO `state` VALUES (27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0,'success'); -INSERT INTO `state` VALUES (28,'Previa OK',3,0,'OK PREVIOUS',3,28,1,0,1,1,1,1,3,0,'warning'); -INSERT INTO `state` VALUES (29,'Previa Impreso',4,0,'PRINTED PREVIOUS',2,29,1,0,1,0,0,1,2,0,'success'); -INSERT INTO `state` VALUES (30,'Embarcado',4,1,'BOARD',5,30,0,0,0,2,0,0,3,0,'success'); -INSERT INTO `state` VALUES (31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,2,0,'success'); -INSERT INTO `state` VALUES (32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0,'warning'); -INSERT INTO `state` VALUES (33,'Auto_Impreso',4,0,'PRINTED_AUTO',2,29,1,0,1,0,0,1,2,0,'success'); -INSERT INTO `state` VALUES (34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1,'alert'); -INSERT INTO `state` VALUES (35,'Semi-Encajado',9,2,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0,NULL); -INSERT INTO `state` VALUES (36,'Previa Revisando',3,0,'PREVIOUS_CONTROL',2,37,1,0,0,4,0,1,2,0,'warning'); -INSERT INTO `state` VALUES (37,'Previa Revisado',3,0,'PREVIOUS_CONTROLLED',2,29,1,0,1,0,0,1,2,0,'warning'); -INSERT INTO `state` VALUES (38,'Prep Cámara',6,1,'COOLER_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'); -INSERT INTO `state` VALUES (41,'Prep Parcial',6,1,'PARTIAL_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'); +INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',1,0,0,0,0,0,0,4,1,'alert'); +INSERT INTO `state` VALUES (2,'Libre',2,0,'FREE',2,0,0,0,0,0,0,4,1,'notice'); +INSERT INTO `state` VALUES (3,'OK',3,0,'OK',28,1,0,1,0,1,1,3,0,'success'); +INSERT INTO `state` VALUES (4,'Impreso',4,0,'PRINTED',29,1,0,1,0,0,1,2,0,'success'); +INSERT INTO `state` VALUES (5,'Preparación',6,2,'ON_PREPARATION',14,0,0,0,2,0,0,2,0,'warning'); +INSERT INTO `state` VALUES (6,'En Revisión',7,2,'ON_CHECKING',6,0,1,0,3,0,0,1,0,'warning'); +INSERT INTO `state` VALUES (7,'Sin Acabar',1,0,'NOT_READY',7,0,0,0,0,0,0,4,1,'alert'); +INSERT INTO `state` VALUES (8,'Revisado',8,2,'CHECKED',8,0,1,0,3,0,0,1,0,'warning'); +INSERT INTO `state` VALUES (9,'Encajando',9,3,'PACKING',9,0,1,0,0,0,0,1,0,NULL); +INSERT INTO `state` VALUES (10,'Encajado',10,3,'PACKED',10,0,1,0,0,0,0,0,0,NULL); +INSERT INTO `state` VALUES (11,'Facturado',0,4,'INVOICED',11,0,1,0,0,0,0,0,0,NULL); +INSERT INTO `state` VALUES (12,'Bloqueado',0,0,'BLOCKED',12,0,0,0,0,0,0,4,1,'alert'); +INSERT INTO `state` VALUES (13,'En Reparto',11,4,'ON_DELIVERY',13,0,1,0,0,0,0,0,0,NULL); +INSERT INTO `state` VALUES (14,'Preparado',6,2,'PREPARED',14,0,1,0,2,0,0,1,0,'warning'); +INSERT INTO `state` VALUES (15,'Pte Recogida',12,4,'WAITING_FOR_PICKUP',15,0,1,0,0,0,0,0,0,NULL); +INSERT INTO `state` VALUES (16,'Entregado',13,4,'DELIVERED',16,0,1,0,0,0,0,0,0,NULL); +INSERT INTO `state` VALUES (20,'Asignado',4,0,'PICKER_DESIGNED',20,1,0,0,0,0,0,2,0,'success'); +INSERT INTO `state` VALUES (21,'Retornado',4,2,'PRINTED_BACK',21,0,0,0,0,0,0,2,0,'success'); +INSERT INTO `state` VALUES (22,'Pte. Ampliar',2,0,'EXPANDABLE',22,0,0,0,0,0,0,4,1,'alert'); +INSERT INTO `state` VALUES (23,'URGENTE',5,2,'LAST_CALL',23,1,0,1,0,0,0,4,1,'success'); +INSERT INTO `state` VALUES (24,'Encadenado',4,0,'CHAINED',24,0,0,0,0,0,0,3,1,'success'); +INSERT INTO `state` VALUES (25,'Embarcando',3,0,'BOARDING',25,1,0,0,0,0,0,3,0,'alert'); +INSERT INTO `state` VALUES (26,'Prep Previa',5,0,'PREVIOUS_PREPARATION',28,1,0,0,1,0,0,2,0,'warning'); +INSERT INTO `state` VALUES (27,'Prep Asistida',5,2,'ASSISTED_PREPARATION',27,0,0,0,0,0,0,2,0,'success'); +INSERT INTO `state` VALUES (28,'Previa OK',3,0,'OK PREVIOUS',28,1,0,1,1,1,1,3,0,'warning'); +INSERT INTO `state` VALUES (29,'Previa Impreso',4,0,'PRINTED PREVIOUS',29,1,0,1,0,0,1,2,0,'success'); +INSERT INTO `state` VALUES (30,'Embarcado',4,2,'BOARD',30,0,0,0,2,0,0,3,0,'success'); +INSERT INTO `state` VALUES (31,'Polizon Impreso',4,2,'PRINTED STOWAWAY',29,1,0,1,0,0,1,2,0,'success'); +INSERT INTO `state` VALUES (32,'Polizon OK',3,2,'OK STOWAWAY',31,1,0,0,1,1,1,3,0,'warning'); +INSERT INTO `state` VALUES (33,'Auto_Impreso',4,0,'PRINTED_AUTO',29,1,0,1,0,0,1,2,0,'success'); +INSERT INTO `state` VALUES (34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',34,0,0,0,0,0,0,4,1,'alert'); +INSERT INTO `state` VALUES (35,'Semi-Encajado',9,3,'HALF_PACKED',10,0,1,0,0,0,0,1,0,NULL); +INSERT INTO `state` VALUES (36,'Previa Revisando',3,0,'PREVIOUS_CONTROL',37,1,0,0,4,0,1,2,0,'warning'); +INSERT INTO `state` VALUES (37,'Previa Revisado',3,0,'PREVIOUS_CONTROLLED',29,1,0,1,0,0,1,2,0,'warning'); +INSERT INTO `state` VALUES (38,'Prep Cámara',6,2,'COOLER_PREPARATION',14,0,0,0,2,0,0,2,0,'warning'); +INSERT INTO `state` VALUES (41,'Prep Parcial',6,2,'PARTIAL_PREPARATION',14,0,0,0,2,0,0,2,0,'warning'); +INSERT INTO `state` VALUES (42,'Entregado en parte',13,3,'PARTIAL_DELIVERED',16,0,1,0,0,0,0,0,0,NULL); +INSERT INTO `state` VALUES (43,'Preparación por caja',6,2,'BOX_PICKING',42,0,0,0,2,0,0,2,0,'warning'); INSERT INTO `ticketUpdateAction` VALUES (1,'Cambiar los precios en el ticket','renewPrices'); INSERT INTO `ticketUpdateAction` VALUES (2,'Convertir en maná','mana'); +INSERT INTO `ticketCanAdvanceConfig` VALUES (1,5); + INSERT INTO `volumeConfig` VALUES (2.67,1.60,0.8,150,0.30,120,57,2.0,50,200,10,167.0); INSERT INTO `workCenter` VALUES (1,'Silla',20,859,1,'Av espioca 100',552703,NULL); @@ -2570,6 +2738,7 @@ INSERT INTO `workCenter` VALUES (7,'Tenerife',NULL,NULL,NULL,NULL,NULL,NULL); INSERT INTO `workCenter` VALUES (8,'Silla-Agrario',26,NULL,NULL,NULL,NULL,NULL); INSERT INTO `workCenter` VALUES (9,'Algemesi',20,1354,60,'Fenollars, 2',523549,NULL); INSERT INTO `workCenter` VALUES (10,'Rubi',88,NULL,84,'Av. de la Llana, 131',549722,NULL); +INSERT INTO `workCenter` VALUES (11,'Colombia',NULL,NULL,NULL,NULL,NULL,NULL); INSERT INTO `workerTimeControlError` VALUES (1,'IS_NOT_ALLOWED_FUTURE','No se permite fichar a futuro'); INSERT INTO `workerTimeControlError` VALUES (2,'INACTIVE_BUSINESS','No hay un contrato en vigor'); @@ -2586,6 +2755,7 @@ INSERT INTO `workerTimeControlError` VALUES (9,'UNDEFINED_ERROR','Error sin defi /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; USE `cache`; +/*M!999999\- enable the sandbox mode */ /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; @@ -2610,6 +2780,7 @@ INSERT INTO `cache` VALUES (14,'lastBuy','23:59:00'); /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; USE `hedera`; +/*M!999999\- enable the sandbox mode */ /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; @@ -2644,7 +2815,7 @@ INSERT INTO `language` VALUES ('mn','Португалий','Mongolian',1); INSERT INTO `language` VALUES ('pt','Português','Portuguese',1); INSERT INTO `link` VALUES (16,'Printing server','Manage the CUPS printing server','http://printnatura.verdnatura.es','printer'); -INSERT INTO `link` VALUES (20,'Webmail','Verdnatura webmail','https://webmail.verdnatura.es/','mail'); +INSERT INTO `link` VALUES (20,'Webmail','Verdnatura webmail','https://mail.verdnatura.es/','mail'); INSERT INTO `link` VALUES (23,'Verdnatura Beta','Trial version of the web page','https://test-shop.verdnatura.es/','vn'); INSERT INTO `link` VALUES (25,'Shared folder','Shared folder','https://cdn.verdnatura.es/share','backup'); INSERT INTO `link` VALUES (29,'phpMyAdmin','Manage MySQL database','https://pma.verdnatura.es/','pma'); @@ -2653,16 +2824,16 @@ INSERT INTO `link` VALUES (33,'Gitea','Version control system','https://gitea.ve INSERT INTO `link` VALUES (34,'Wiknatura','Verdnatura wiki page','https://wiki.verdnatura.es/','wiki'); INSERT INTO `link` VALUES (35,'phpLDAPadmin','Manage the LDAP database','https://pla.verdnatura.es/','pla'); INSERT INTO `link` VALUES (36,'Applications','Access applications repository','https://cdn.verdnatura.es/vn-access','access'); -INSERT INTO `link` VALUES (37,'Jenkins','CI and CD system','https://jenkins.verdnatura.es','jenkins'); -INSERT INTO `link` VALUES (38,'osTicket','User service center','https://cau.verdnatura.es','osticket'); -INSERT INTO `link` VALUES (39,'Redmine','Flexible project management','https://redmine.verdnatura.es','redmine'); -INSERT INTO `link` VALUES (40,'Grafana','Analytics & monitoring solution','https://grafana.verdnatura.es','grafana'); -INSERT INTO `link` VALUES (41,'Rocket.Chat','Communications platform','https://chat.verdnatura.es','rocketchat'); -INSERT INTO `link` VALUES (42,'Salix','ERP software','https://salix.verdnatura.es','salix'); -INSERT INTO `link` VALUES (43,'Docker','Container management','https://docker.verdnatura.es','docker'); -INSERT INTO `link` VALUES (44,'Proxmox','Virtual environment','https://mox.verdnatura.es','proxmox'); -INSERT INTO `link` VALUES (45,'Shinobi','Network video recorder','https://shinobi.verdnatura.es','shinobi'); -INSERT INTO `link` VALUES (46,'DokuWiki','Internal documentation','https://doku.verdnatura.es','dokuwiki'); +INSERT INTO `link` VALUES (37,'Jenkins','CI and CD system','https://jenkins.verdnatura.es/','jenkins'); +INSERT INTO `link` VALUES (38,'osTicket','User service center','https://cau.verdnatura.es/','osticket'); +INSERT INTO `link` VALUES (39,'Redmine','Flexible project management','https://redmine.verdnatura.es/','redmine'); +INSERT INTO `link` VALUES (40,'Grafana','Analytics & monitoring solution','https://grafana.verdnatura.es/','grafana'); +INSERT INTO `link` VALUES (41,'Rocket.Chat','Communications platform','https://chat.verdnatura.es/','rocketchat'); +INSERT INTO `link` VALUES (42,'Salix','ERP software','https://salix.verdnatura.es/','salix'); +INSERT INTO `link` VALUES (43,'Kubernetes','Container management','https://kube.verdnatura.es/','docker'); +INSERT INTO `link` VALUES (44,'Proxmox','Virtual environment','https://pve.verdnatura.es/','proxmox'); +INSERT INTO `link` VALUES (45,'Shinobi','Network video recorder','https://shinobi.verdnatura.es/','shinobi'); +INSERT INTO `link` VALUES (46,'xWiki','Internal documentation','https://xwiki.verdnatura.es/','dokuwiki'); INSERT INTO `location` VALUES (2,'39.2095886','-0.4173501','Valencia','Calle Fenollar, 2','46680','Algemesi','Valencia','963 242 100','es'); INSERT INTO `location` VALUES (3,'40.4564969','-3.4875829','Madrid','Avenida de la Constitución, 3 - Nave E','28850','Torrejón de Ardoz','Madrid','963 242 100',NULL); @@ -2712,6 +2883,8 @@ INSERT INTO `message` VALUES (18,'orderNotOwnedByUser','The order belongs to ano INSERT INTO `message` VALUES (19,'orderConfirmed','The order has already been confirmed and cannot be modified'); INSERT INTO `message` VALUES (20,'clientNotVerified','Incomplete tax data, please contact your sales representative'); INSERT INTO `message` VALUES (21,'quantityLessThanMin','The quantity cannot be less than the minimum'); +INSERT INTO `message` VALUES (22,'ORDER_ROW_UNAVAILABLE','The ordered quantity exceeds the available'); +INSERT INTO `message` VALUES (23,'AMOUNT_NOT_MATCH_GROUPING','The quantity ordered does not match the grouping'); INSERT INTO `metatag` VALUES (2,'title','Verdnatura Levante SL, mayorista de flores, plantas y complementos para floristería y decoración'); INSERT INTO `metatag` VALUES (3,'description','Verdnatura Levante SL, mayorista de flores, plantas y complementos para floristería y decoración. Envío a toda España, pedidos por internet o por teléfono.'); @@ -2878,6 +3051,7 @@ INSERT INTO `tpvResponse` VALUES (9999,'Operación que ha sido redirigida al emi /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; USE `sage`; +/*M!999999\- enable the sandbox mode */ /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; diff --git a/db/dump/.dump/privileges.sql b/db/dump/.dump/privileges.sql index 5b1b600b1..66e553763 100644 --- a/db/dump/.dump/privileges.sql +++ b/db/dump/.dump/privileges.sql @@ -1,2071 +1,2217 @@ USE `mysql`; +/*M!999999\- enable the sandbox mode */ /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; /*!40000 ALTER TABLE `db` DISABLE KEYS */; -INSERT IGNORE INTO `db` VALUES ('','tmp','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','postgresql','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','util','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','vn2008','android','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','tmp','android','Y','Y','Y','Y','N','Y','N','N','N','N','Y','N','N','N','N','N','N','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','cache','salix','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','hedera','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','nst','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','postgresql','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','hedera','android','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','android','android','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','sage','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','pbx','android','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','vn','android','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','cache','android','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','vn2008','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','bi','android','Y','Y','Y','Y','N','Y','N','N','N','N','Y','Y','N','Y','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','vn2008','hedera-web','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','srt','android','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','psico','android','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','account','android','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','edi','hedera-web','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','stock','hedera-web','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','hedera','hedera-web','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','salix','hedera-web','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','account','hedera-web','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','edi','android','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','util','hedera-web','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','vn','hedera-web','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','Consumos','android','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','vncontrol','android','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','salix','salix','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','N'); -INSERT IGNORE INTO `db` VALUES ('','vn','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','Y','N','N'); -INSERT IGNORE INTO `db` VALUES ('','pbx','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','edi','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','bs','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','managedesktop','salix','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','account','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','Y','N','N'); -INSERT IGNORE INTO `db` VALUES ('','mysql','salix','Y','N','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','psico','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','geo','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','floranet','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','tmp','guest','Y','Y','Y','Y','N','Y','N','N','N','N','Y','N','N','N','N','N','N','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','util','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','dipole','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','bi','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','sage','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','bs','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','util','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','stock','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','salix','sysadmin','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','pbx','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','.mysqlworkbench','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','hedera','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','account','sysadmin','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','cache','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','vn2008','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','vn','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','srt','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','sage','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','srt','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','psico','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','postgresql','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','edi','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','vn2008','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','vn','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','edi','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','dipole','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','cache','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','bs','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','bi','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','util','grafana','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','mysql','developerBoss','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','rfid','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); -INSERT IGNORE INTO `db` VALUES ('','floranet','floranet','Y','N','N','N','N','N','N','N','N','N','Y','Y','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','tmp','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','postgresql','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','util','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','vn2008','android','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','tmp','android','Y','Y','Y','Y','N','Y','N','N','N','N','Y','N','N','N','N','N','N','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','cache','salix','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','hedera','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','nst','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','postgresql','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','hedera','android','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','android','android','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','sage','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','pbx','android','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','vn','android','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','cache','android','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','vn2008','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','bi','android','Y','Y','Y','Y','N','Y','N','N','N','N','Y','Y','N','Y','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','vn2008','hedera-web','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','srt','android','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','psico','android','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','account','android','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','edi','hedera-web','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','stock','hedera-web','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','hedera','hedera-web','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','salix','hedera-web','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','account','hedera-web','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','edi','android','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','util','hedera-web','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','vn','hedera-web','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','Consumos','android','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','vncontrol','android','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','salix','salix','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','N'); +INSERT IGNORE INTO `db` VALUES ('','vn','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','Y','N','N'); +INSERT IGNORE INTO `db` VALUES ('','pbx','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','edi','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','bs','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','managedesktop','salix','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','account','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','Y','N','N'); +INSERT IGNORE INTO `db` VALUES ('','mysql','salix','Y','N','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','psico','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','geo','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','floranet','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','tmp','guest','Y','Y','Y','Y','N','Y','N','N','N','N','Y','N','N','N','N','N','N','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','util','salix','Y','Y','Y','Y','N','N','N','N','N','N','Y','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','dipole','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','bi','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','sage','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','bs','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','util','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','stock','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','salix','sysadmin','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','pbx','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','.mysqlworkbench','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','hedera','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','account','sysadmin','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','cache','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','vn2008','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','vn','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','srt','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','sage','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','srt','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','psico','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','postgresql','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','edi','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','vn2008','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','vn','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','edi','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','dipole','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','cache','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','bs','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','bi','developer','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','util','grafana','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','mysql','developerBoss','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','rfid','developerBoss','Y','Y','Y','Y','N','N','Y','N','N','N','N','N','N','N','N','N','Y','N','N','N'); +INSERT IGNORE INTO `db` VALUES ('','floranet','floranet','Y','N','N','N','N','N','N','N','N','N','Y','Y','N','N','N','N','Y','N','N','N'); /*!40000 ALTER TABLE `db` ENABLE KEYS */; /*!40000 ALTER TABLE `tables_priv` DISABLE KEYS */; -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','itemTypeL10n','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','country','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','itemType','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myAddress','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select','Insert,Update'); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','visitUser','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','producer','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','tagL10n','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','config','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','','Select'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','originL10n','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','origin','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','entryEditor','entry','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert','Update'); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','social','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','image','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','guest','tblContadores','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','','Select'); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','logistic','item_track','alexm@db-proxy2.static.verdnatura.es','2022-08-03 23:44:43','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','administrative','value','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','administrative','type','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','type','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','value','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developerBoss','general_log','juan@10.5.1.1','0000-00-00 00:00:00','Select,Drop',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','dipole','employee','expedition_PrintOut','alexm@%','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','logistic','marketPlace','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionAssi','definitivo','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','manager','item_group','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','administrative','item_feature','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','item_feature','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','itemTag','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','itemCategoryL10n','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financialBoss','credit','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','guest','Tipos','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','producer','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','mdbVersion','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','province','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','mistakeType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','warehouse','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','account','itemTaxCountry','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','province','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myTpvTransaction','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myTicketState','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myTicketRow','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myTicket','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myOrderTicket','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myOrderRow','juan@db-proxy2.static.verdnatura.es','2022-08-03 23:44:43','Select,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myOrder','juan@db-proxy2.static.verdnatura.es','2022-08-03 23:44:43','Select,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myInvoice','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myClient','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select','Update'); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myBasketItem','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myBasketDefaults','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','account','userPassword','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','mainAccountBank','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','itemCategory','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','psico','hr','answer','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ticketDms','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','employee','ekt','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','sage','administrative','taxType','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','psico','hr','fellow','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','address_type','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','user','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','','Select'); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','userPassword','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','roleRole','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','roleInherit','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','role','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','mailConfig','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','mailAliasAccount','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','mailAlias','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','accountConfig','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','account','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','tpvMerchant','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','','Select'); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','account','myUser','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','','Update'); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','language','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','imageConfig','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','','Select'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','guest','Paises','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','','Select'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','guest','Tintas','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','','Select'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','item','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','agencyMode','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','','Select'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','inkL10n','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','ink','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','deliveryMethod','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','guest','reinos','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','collectionHotbed','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','hr','mailForward','juan@db-proxy1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','location','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','hr','mailAliasAccount','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','tag','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','news','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buy_edi_k012','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','buy_edi_k012','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','myMenu','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','myBasket','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','message','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','guest','myUser','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','guest','myRole','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','employee','followme','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','hr','account','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','salix','android','AccessToken','jenkins@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerBoss','itemTag','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','itemTag','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','buy_edi_k03','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','psico','hr','examQuestion','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','psico','hr','exam','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','manager','exchange','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','employee','supplier','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','dipole','employee','printer','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','manager','item_groupToOffer','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','dipole','coolerAssist','expedition_PrintOut','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','logistic','putOrder','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','logistic','supplyResponse','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','collectionWagonTicket','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','employee','blacklist','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','employee','cdr','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','employee','queue','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','employee','queueMember','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','employee','queuePhone','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','employee','schedule','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','employee','sip','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','','Select'); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','browser','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','config','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','','Select'); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','order','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select,Insert,Update,Delete','References'); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','orderRowComponent','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','imageCollection','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','orderRow','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','link','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','shelf','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','shelfConfig','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','order_row','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','order_component','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','visitAccess','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','visitAgent','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','visit','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','userSession','z-developer@172.16.255.16','2022-08-03 23:44:43','','Select'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','collectionWagon','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','marketing','news','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','newsTag','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','sage','employee','TiposIva','z-sysadmin@172.16.255.30','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','sage','employee','TiposRetencion','z-sysadmin@172.16.255.30','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','sage','employee','TiposTransacciones','z-sysadmin@172.16.255.30','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','bank_account_type','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','salesPerson','item_groupToOffer','carlosap@172.16.5.232','2022-08-03 23:44:43','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myTicketService','root@10.2.3.180','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','sage','administrative','movConta','carlosap@172.16.5.232','2022-08-03 23:44:43','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','mailConfig','jgallego@81.202.38.190','2022-08-03 23:44:43','','Select'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financial','account_conciliacion','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','accion_dits','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','config','juan@%','0000-00-00 00:00:00','','Select'); -INSERT IGNORE INTO `tables_priv` VALUES ('','util','account','config','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','transitoryDuaUnified','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','clientDied','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','hr','userPassword','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','hr','roleRole','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','hr','roleInherit','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','hr','role','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','hr','mailConfig','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','hr','mailAlias','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','tables_priv','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','event','$itBoss@10.0.2.68','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','proxies_priv','$itBoss@10.0.2.68','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','procs_priv','$itBoss@10.5.1.5','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','db','$itBoss@10.0.2.68','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','columns_priv','$itBoss@10.0.2.68','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','time','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','slow_log','$itBoss@10.0.2.68','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','user','$itBoss@10.0.2.68','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','proc','$itBoss@10.0.2.68','2022-08-03 23:44:43','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financial','account_detail','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','account_detail_type','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','entryEditor','Compres','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Agencias','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','awb_component','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','developer','emailUser','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerBoss','agencia_descuadre','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','airline','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','airline','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','agency_warehouse','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','albaran','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vncontrol','salesPerson','inter','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','albaran_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','albaran_state','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Articles','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','awb','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','awb','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','awb_component','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','awb_component','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','awb_component_template','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','awb_component_type','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','awb_gestdoc','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','awb_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','awb_recibida','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','awb_role','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','awb_unit','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financialBoss','balance_nest_tree','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vncontrol','deliveryBoss','inter','juan@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Bancos','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','barcodes','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','barcodes','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vncontrol','buyer','inter','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vncontrol','employee','inter','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','awb_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','awb','alexm@%','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','agency','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','buySource','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','buy_edi','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','buy_edi_k04','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buy_edi_k03','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buy_edi_k04','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesAssistant','Clientes','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','v_empresa','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','v_empresa','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','chanel','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','v_empresa','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Clientes','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','V_edi_item_track','alexm@%','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionPlus','v_botanic_export','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','manager','v_botanic_export','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionPlus','v_Articles_botanical','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Colores','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Clientes','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','recibida_vencimiento','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','claimManager','jerarquia','juan@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerBusinessAgreement','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','tarifa_componentes','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','tarifa_componentes_series','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','claimManager','Entradas','alexm@%','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','cl_main','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','cl_main','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','state','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','producer','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','officeBoss','ticket_observation','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Cajas','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','cmrConfig','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hrBoss','awb_recibida','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hrBoss','awb','juan@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Compres','alexm@%','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','buy_edi','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','salix','developer','ACL','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Vehiculos_consumo','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','palletizer','cmr','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerBoss','Colores','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','state','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Consignatarios','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','artificialBoss','travel','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','price_fixed','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','printQueue','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','preservedBoss','travel','alexm@%','0000-00-00 00:00:00','Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','travel','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','Cubos','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerAssistant','itemType','jgallego@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Cubos','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','Cubos','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','artificialBoss','state','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','travel','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Bancos_poliza','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','cmr','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','duaDismissed','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','edi_article','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','time','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','operator','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','payment','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','edi_supplier','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','edi_supplier','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','travel','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Tramos','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Trabajadores','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','empresa','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','sectorType','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Tintas','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','claimManager','Movimientos','juan@%','0000-00-00 00:00:00','Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Entradas','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','ticket_observation','juan@%','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Entradas_dits','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','sale','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Entradas_orden','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','ticket_observation','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Entradas_turno','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','entrySource','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','Tickets_turno','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Tickets_turno','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expeditionScan','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Tickets_state','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','tickets_gestdoc','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hrBoss','tickets_gestdoc','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','tickets_gestdoc','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Tickets','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Entradas','root@localhost','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Entradas','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Entradas','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerBoss','Tintas','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','filtros','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Entradas_kop','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','flight','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','warehouse_pickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','zones','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','claimManager','warehouse_pickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','businessReasonEnd','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','businessCalendar','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','business','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','budgetNotes','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','specialLabels','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','budgetDms','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','budget','juan@10.5.1.2','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','offerList','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','bookingPlanner','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','budgetInvoiceIn','juan@10.5.1.2','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','beach','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','business','alexm@%','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Movimientos_revisar','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Movimientos_mark','alexm@%','0000-00-00 00:00:00','Select,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Movimientos_componentes','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','Movimientos_componentes','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','Movimientos','juan@%','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','handmadeBoss','Movimientos','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionAssi','Movimientos','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Movimientos','alexm@%','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Movimientos','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Monedas','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','calendarHolidays','juan@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','mandato','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financial','mandato','alexm@%','0000-00-00 00:00:00','Select,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','iva_group','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','greugeType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceInIntrastat','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','greuge','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Intrastat','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Intrastat','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','integra2_province','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Grupos','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','dms','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','continent','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','artificialBoss','Movimientos_componentes','alexm@%','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Movimientos_componentes','alexm@%','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','Movimientos_mark','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','Movimientos_revisar','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','handmadeBoss','Reservas','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerBoss','bankEntity','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Ordenes','alexm@%','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','awb','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Origen','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','pago','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','awb','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Paises','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','salesAssistant','clientDied','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','warehouse_pickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','payroll_categorias','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','payroll_centros','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','payroll_conceptos','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','claimManager','Tintas','juan@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','alertLevel','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','bankEntity','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','payroll_employee','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','sale','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','bankEntity','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','agencyMode','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Recibos','alexm@%','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','saleCloned','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','pay_met','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Permisos','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','shelving','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemShelvingStock','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','palletizer','cmrConfig','carlosap@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Proveedores','alexm@%','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','PreciosEspeciales','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionAssi','agencia_descuadre','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','price_fixed','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','iva_tipo','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','iva_codigo','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financial','pago','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Proveedores','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Proveedores_cargueras','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Proveedores_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expedition','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Proveedores_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','claimManager','recibida','juan@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','recibida','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','adminOfficer','recibida_iva','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','recibida_intrastat','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','recibida_iva','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','recibida_vencimiento','alexm@%','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','Recibos','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','officeBoss','bankEntity','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','agency','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','bankEntity','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','versiones','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','reference_rate','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','saleComponent','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financial','Remesas','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionAssi','Reservas','alexm@%','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','cmr','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Rutas','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','address','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','address','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','accountingType','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemShelvingStock_byWarehouse','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Movimientos','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionAssi','Series','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','adminOfficer','Series','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financial','Recibos','alexm@%','0000-00-00 00:00:00','Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','price_fixed','alexm@%','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','accountingConfig','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','buyer','salesByItemTypeDay','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesAssistant','state','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','bufferState','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','coolerAssist','state','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','absenceType','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','artificialBoss','Entradas_Auto','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionAssi','Vehiculos_consumo','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','tblContadores','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','buyMark','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','calendar','juan@10.5.1.2','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','calendarHolidays','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','claim','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','claimEnd','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','claimRatio','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Cubos','alexm@%','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','cplusRectificationType','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','cplusInvoiceType477','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','duaInvoiceIn','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','country','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','duaInvoiceIn','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financial','mandato_tipo','juan@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','propertyNotes','juan@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','province','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','receipt','jgallego@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','receipt','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','visitUser','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','referenceRate','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','report','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','cache','productionBoss','available','guillermo@10.5.1.2','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','time','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','role','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','config__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','role','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','comparativeFilterType','guillermo@10.5.1.4','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','comparativeFilter','guillermo@10.5.1.4','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','route','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','company','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expeditionStateType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','collectionHotbed','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','collectionColors','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','collection','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','cmr_list','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','collection','alexm@%','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','cmr','alexm@%','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','clientYoke','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','roles_mapping','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketLastState','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionBoss','calendar','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','adminOfficer','pago','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','clientPhoneBook','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','saleGroupDetail','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','clientObservation','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','clientObservation','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','productionConfig','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionBoss','sale','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','packingSite','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionPlus','province','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionPlus','province','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','grafana','sip','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','','Select'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','clientCredit','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','artificialBoss','saleTracking','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','saleTracking','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','saleTracking','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','saleTracking','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','client','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','client','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','saleVolume','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','Proveedores_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','awb_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerAssistant','Cubos','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','routesMonitor','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','Update'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminBoss','sale','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','sale','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Delete','Update'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','sale','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Delete','Update'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','sale','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','zoneClosure','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','saleComponent','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','saleComponent','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','marketingBoss','saleGoal','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','saleGroup','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','saleGroupDetail','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','account_detail','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','awb_component_type','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vncontrol','employee','accion','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','volumeConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','currency','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerBoss','tag','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','currency','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','creditClassification','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','creditInsurance','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','currency','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerTimeControl','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','defaulter','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','deliveryMethod','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','deliveryMethod','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','v_compres','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','deviceProductionUser','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','department','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','deviceProductionConfig','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','deviceProduction','alexm@%','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','deviceProduction','alexm@%','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionBoss','absenceType','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','deviceProductionConfig','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','deviceProductionUser','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','disabilityGrade','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','duaInvoiceIn','alexm@%','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','dmsType','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','duaEntry','alexm@%','0000-00-00 00:00:00','Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','duaEntry','alexm@%','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','dua','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','duaIntrastat','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','duaInvoiceIn','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','duaTax','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Tickets_turno','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','cl_main','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','agency','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','ektEntryAssign','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionBoss','itemShelving','root@localhost','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','propertyDms','juan@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerTimeControlConfig','juan@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','entry','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select','Update'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','businessType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','entryLog','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','projectState','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','entrySplit__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','entryType','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','projectNotes','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','project','juan@10.5.1.1','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','productionConfig','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','productionConfig','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','creditInsurance','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','cache','productionBoss','visible','guillermo@10.5.1.2','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','errorProduction__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','invoiceOut','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','coolerAssist','Tickets','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','packingSite','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','salix','developer','accessTokenConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','printQueueArgs','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','printQueue','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','printer','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','expedition','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','sector','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppeLocation','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','wks','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','entryObservation','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','itemShelvingList','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','cmrConfig','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','expeditionTruck','alexm@%','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','alertLevel','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','expeditionSticker','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','artificialBoss','entryObservation','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','dock','alexm@%','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','expeditionTruck','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','expeditionPallet','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','expense','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','expeditionScan','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','entryObservation','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppeGroup','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','floramondoNotOfferDay__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','fuelType','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppeDMS','alexm@%','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','genericAllocation','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppeComponent','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppe','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','glsExpedition__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','postCode','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','pgcMaster','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemBarcode','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','host','alexm@%','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticket','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceIn','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','invoiceIn','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','invoiceIn','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','inventoryFailure','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','intrastat','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','inventoryFailure','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','inventoryFailureCause','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','invoiceCorrection','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceCorrectionDataSource','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','invoiceCorrectionType','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','invoiceIn','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceInDueDay','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','invoiceInDueDay','alexm@%','0000-00-00 00:00:00','Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','invoiceInIntrastat__','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','invoiceInTax','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceInSage','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','invoiceInTax','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceInTax','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','invoiceOut','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','invoiceOut','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceOutExpense','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','item','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Update'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','invoiceOutSerial','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','invoiceOutTax','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','item','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','itemBarcode','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','itemBotanical','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemBotanicalWithGenus','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemCategory','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','pgcEqu','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','pgc','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','itemCost','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','itemConfig','alexm@%','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemConversor__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','itemCost','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','personalProtectionEquipment','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','payMethod','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','payment','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','payDem','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','itemPlacementSupplyList','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','itemPlacementSupplyList','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','itemPlacementSupply','alexm@%','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemPackingType','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','itemPlacementSupply','alexm@%','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','itemPlacementSupplyList','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemPlacement__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','payDem','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','invoiceOut','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemRepo__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemSearch','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemShelving','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','itemShelvingLog','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketWeekly','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','itemShelvingLog','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','airport','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemShelvingSale','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hrBoss','Tickets','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimEnd','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','itemTaxCountry','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workCenter','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','itemTaxCountry','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','itemTaxCountry','alexm@%','0000-00-00 00:00:00','Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','parking','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','packingSiteLog','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','dua','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','packingSite','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','packagingWithoutFreight','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemVerdecora__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','packagingWithFreight','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','packagingGifts','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','packagingConfig','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','packaging','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','packageEquivalentItem','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','packageEquivalent','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','packageChecked','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','packageChecked','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','packageChecked','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','operator','alexm@%','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','operator','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','mail','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','Recibos','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','operator','alexm@%','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','mandate','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','occupationCode','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','observationType','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','salix','developer','defaultViewConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','medicalCenter','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','medicalReview','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','noticeSubscription','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','noticeSubscription','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','noticeCategory','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','noticeCategory','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','mrwServiceWeekday','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','mrw','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','mrwService','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppePlan','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','accountingConfig','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','buy','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','buy','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','saleGoal','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','packingSiteLog','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hrBoss','Entradas','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','saleComponent','alexm@%','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','arcRead','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','clientProtected','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','invoiceOut','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','dua','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','duaEntry','alexm@%','0000-00-00 00:00:00','Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','expeditionTruck','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','moving','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','machineDetail','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','machineDms','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','vehicle','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','awb','alexm@%','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','machine','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','buy','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Entradas_dits','alexm@%','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerTimeControlMail','alexm@%','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bi','coolerBoss','rotacion','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','PreciosEspeciales','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','movingState','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','bufferType','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','bufferState','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','buffer','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','bufferGroup','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','lastRFID','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','person__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','config','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','expedition','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','travel','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','itemPicker','buy','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Entradas_Auto','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','machine','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financialBoss','referenceCurrent','alexm@%','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','vehicleState','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','vehicleEvent','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','cooler','Tintas','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','itemBotanical','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','cooler','Entradas','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','developer','signInLog','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketTracking','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','deviceProductionState','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','deviceProductionState','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vncontrol','hr','inter','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','printServerQueue2__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','printServerQueue__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','artificialBoss','buy','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','Movimientos','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','buy','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','receipt','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerBoss','producer','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','link','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','link','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','delivery','vehicle','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','upperStickers','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','province','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','XDiario','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','till','alexm@%','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financial','recovery','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','photocell','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','supplyResponse','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','cache','customer','last_buy','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','client','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','invoiceInTax','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','workerTeam','juan@10.5.1.2','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','profile_type','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','profile_media','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','recovery','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','buffer','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','professional_category','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','media_type','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','media','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','labour_agreement','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','returnBuckets__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','journey','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','income_employee','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','incometype_employee','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hrBoss','income_employee','alexm@%','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','buyer','salesByWeek','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','routeGate__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','calendar_labour_type','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bi','adminBoss','XDiario_ALL','alexm@%','0000-00-00 00:00:00','Select,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','rate','carlosap@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','expeditionState','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','salesPerson','clientAnnualConsumption','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bi','buyer','tarifa_componentes_series','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bi','buyer','tarifa_componentes','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bi','productionAssi','rutasBoard','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bi','logistic','rotacion','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bi','salesPerson','tarifa_componentes','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bi','salesPerson','tarifa_componentes_series','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','expeditionLog','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','salesPerson','clientNewBorn','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','saleItemShelving__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesBoss','workerTeam','juan@10.5.1.2','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','expedition','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemShelvingStock','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','saleParking__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','property','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','config','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','vehicleEvent','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','buyer','lastIndicators','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','saleComponent','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','itemBotanical','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','item','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','marketingBoss','salesPersonGoal','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hrBoss','journey','alexm@%','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','workerTimeControl','alexm@%','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','currentWorkersStats','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','ticketStateToday','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','shelving','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','shelving','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','shelving','alexm@%','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','supplierAccount','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerBoss','supplierAccount','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','supplierAccount','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','customer','supplier','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','state','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','state','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','stockBuyed','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','stowaway','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','supplier','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','supplierAccount','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','supplierAgencyTerm','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','supplierAgencyTerm','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','supplierExpense','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','marketingBoss','ticketService','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ticketService','jgallego@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','sendingServiceWeekday','jenkins@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','ticketRequest','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','ticketParking','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','taxCode','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminBoss','taxArea','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','taxClass','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','taxCode','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','taxCode','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','salesPersonEvolution','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','calendar_employee','juan@10.5.1.2','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','ticket','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticket','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','Update'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketCollection','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ticketDocumentation','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketDms','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','ektEntryAssign','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','intrastat','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','supplierAgencyTerm','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','entryConfig','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','franceExpressConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','ticketLog','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','ticketCollection','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','ticketDms','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketObservation','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','ticketPackaging','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketPackaging','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','ticketParking','alexm@%','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketPackingList','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketParking','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketPreviousPreparingList','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ticketRefund','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketRequest','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminBoss','ticketService','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminBoss','ticketServiceType','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketState','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','ticketStateToday','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bi','employee','claims_ratio','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','greugeType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','time','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketWeekly','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminBoss','till','juan@%','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','account','town','juan@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','time','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerMana','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bi','salesPerson','defaulters','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','customer','travel','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','train','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','train','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','trainingCenter','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','trainingCourse','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','trainingCourseType','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','travel','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','travelClonedWeekly','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bi','employee','facturacion_media_anual','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','travelObservation','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','bankPolicy','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','travelThermograph','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','tillConfig','juan@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','till','juan@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','till','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','vehicleState','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','vehicleInvoiceIn','alexm@%','0000-00-00 00:00:00','Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','vehicleEvent','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','vehicleDms','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','vehicle','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','vehicle','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Agencias','alexm@%','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','vehicleDms','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketState','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','vehicleInvoiceIn','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financialBoss','vehicleNotes','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','vehicleState','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','volumeConfig','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','ticketTrackingState','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','warehouse','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','role','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workCenter','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientCredit','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','worker','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','workerAppTester','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','propertyGroup','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','worker','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerBusinessType','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','workerDepartment','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','workerDepartment','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerDepartment','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerConfig__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','inventoryDiscrepancyDetail','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','sendingConfig','jenkins@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','entryConfig','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketPackagingStartingStock','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','ticketPackagingStartingStock','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerIrpf','juan@%','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerJourney','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerLabour','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','workerMana','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','workerMana','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','ticketPackaging','alexm@%','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','ticketPackagingStartingStock','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','entryConfig','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','officeBoss','ticketPackagingStartingStock','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerRelatives','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','ticketPackagingStartingStock','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','supplierPackaging','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerDocument','alexm@%','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceCorrection','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ink','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','zone','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','XDiario','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','XDiario','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','workerTimeControlMail','alexm@%','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerTimeControl','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bi','financial','Greuge_Evolution','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bi','officeBoss','Greuge_Evolution','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bi','claimManager','rotacion','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','sale','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','zonePromo__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','accountingConfig','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','accountingType','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','agencyMode','alexm@%','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','cache','employee','visible','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','productionConfig','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','cache','employee','available','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','logistic','ekt','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','ticketCollection','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientChain','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','VMPSettings','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimResponsible','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','packingSiteLog','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hrBoss','recibida','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','util','grafana','debug','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','myOrder','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','mdbVersion','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientLog','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','calendar','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','campaign','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketService','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','report','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','buyer','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','defaulter','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','componentType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientManaCache','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','invoiceIn','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','deliveryInformation','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','bufferType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','grafana','role','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','supplyOffer','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketStateToday','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','routeComplement','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','saleVolume','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','component','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','train','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','ticketPalletized','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','autonomy','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expeditionMistakeType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketParking','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemShelving','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','state','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','taxClass','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','salesByWeek','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','invoiceInDueDay','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','sectorProductivity','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','salesByclientSalesPerson','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','marketPlace','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','routeAction','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deviceProduction','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','invoiceOut','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','printer','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','mdbBranch','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','workerProductivity','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','config','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','userSession','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','receipt','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','buy','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','calendarHolidays','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','parking','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','role','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','errorLogApp','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','continent','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','lastRFID','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','farmingInvoiceIn','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','agencyMode','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','absenceType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','saleGroupDetail','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerMistakeType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','mdbVersionTree','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expeditionTruck','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','routeConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimReason','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','log','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','failureLog','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','clientNewBorn','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','farming','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','order','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','packingSpeed','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expense','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerLabour','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','orderRow','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','movingLog','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','warehouse','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','sector','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','salesPersonGoal','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','movingState','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimResult','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','routesMonitor','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expeditionPallet','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','ventas','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','intrastat','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','printQueueArgs','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bi','grafana','Greuge_Evolution','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','host','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','country','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','waste','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketTracking','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemCategory','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','saleTracking','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','producer','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','cache','grafana','stock','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','account','grafana','user','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','','Select'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deliveryMethod','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketCollection','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','lastHourProduction','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','warehouseAlias','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','zoneClosure','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','origin','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','referenceCurrent','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','thermograph','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','dms','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','dmsType','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','greenhouseBoss','property','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketLastState','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','myAddress','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','tag','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemTag','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','handmadeBoss','Tipos','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','saleBuy','carlosap@10.5.1.6','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','orderTicket','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','negativeOrigin','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','route','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemPackingType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','expedition','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','zoneEstimatedDelivery','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','payMethod','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemCost','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','worker','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','travel','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','entry','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','department','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bi','grafana','rutasBoard','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','address','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerDistributionCategory','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','client','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','zone','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','packingSite','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemTaxCountry','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','workerLabourDataByMonth','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketPackaging','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','bufferFreeLength','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','salesByItemTypeDay','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','collection','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','project','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','inventoryDiscrepancy','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','ektSubAddress','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','item_track','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','putOrder','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','parking','juan@10.5.1.2','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenance','machine','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','calendarType','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','glsExpedition','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','clientType','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expeditionMistake','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deviceProductionLog','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','integra2Province','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','vehicleState','juan@10.5.1.1','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','machineDetail','juan@10.5.1.1','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','machineDms','juan@10.5.1.1','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerJourney','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','productionError','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','professionalCategory','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','mdbApp','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','glsConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','clientContact','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','collectionVolumetry','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','administrative','item','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerIncome','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerBoss','tagAbbreviation','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','chronopostConfig','jenkins@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','chronopostSenderAddress','jenkins@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','chronopostServiceWeekday','jenkins@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','chronopostExpedition','root@localhost','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','sectorCollection','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','sendingService','jenkins@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','adminOfficer','tickets_gestdoc','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','flight','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','routeAction','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','bankErrorCode','jgallego@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','farming','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','farmingDms','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','farmingNotes','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','farmingInvoiceIn','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionBoss','routesMonitor','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','','Update'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','routeCommission','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expeditionState','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerBoss','warehouse','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimBeginning','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','invoicing','vehiclePlateRegex','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','businessSchedule','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','clientRisk','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','businessCalendar','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','employee','item','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','vehicleNotes','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','vehicleDms','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','palletizerBoss','expeditionTruck','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','palletizerBoss','zoneEvent','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','palletizerBoss','routesMonitor','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','propertyNotes','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','propertyDms','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','payment','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','payment','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','taxType','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','autonomy','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionPlus','autonomy','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','routePalletized','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticBoss','warehouse','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','m3','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','Cajas','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','tagAbbreviation','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemImageQueue','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','marketing','parking','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','sectorCollection','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','supplier','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','defaulter','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceInTaxBookingAccount','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','business','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','dock','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','item','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','clientAnnualConsumption','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','parking','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','bankEntityConfig','carlosap@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','shelving','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','duaEntry','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','salix','developer','fieldAcl','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','salix','developer','module','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','salix','developer','printConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','salix','developer','url','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','salix','developer','userConfigView','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimRedelivery','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientRisk','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','supplierDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','buyer','sale','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','chain','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','routesMonitor','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','warehouse_pickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','cl_main','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','company','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','routeAction','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','ticket_observation','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','Tickets_turno','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','jerarquia','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','Impresoras','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','autoRadioLogCall','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','autoRadioConfig','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','Recibos','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','Rutas','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','Movimientos','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','state','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','route','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','routeComplement','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','deliveryMethod','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','Tickets','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','expeditionRoute_Monitor','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','expeditionScan','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','expeditionPallet','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','province','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','expeditionTruck','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','v_botanic_export','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','itemCost','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','deliveryAssistant','m3','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','ticketDms','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','time','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','v_Articles_botanical','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','workCenter','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','workerDepartment','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','zoneEvent','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bi','deliveryAssistant','rotacion','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','agency','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','agencyMode','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','vehicle','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','vehicleEvent','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','postCode','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','','Update'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','town','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','','Update'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claim','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','supplierAccount','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerDepartment','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','grafana','cdr','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerTimeControlConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerMistake','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','putOrder','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','saleMistake','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deviceProductionUser','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','contactChannel','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deviceLog','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','vehicle','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','packaging','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','workerProductivityConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','antenna','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','cmr','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','accounting','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','creditClassification','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketLog','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','moving','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimDevelopment','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','expeditionLog','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','compradores_evolution','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','currency','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimObservation','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','salesPreviousPreparated','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimState','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','company','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','buffer','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','greuge','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','item','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select,Update'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','itemShelving','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','negativeOrigin','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','Vehiculos_consumo','carlosap@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','entryOrder','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBos','project','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','ink','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','supplierDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','supplierDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','remittance','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','vehicleConsumption','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','vehicleConsumption','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','accountReconciliation','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','accountDetail','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','accountDetail','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','accountDetailType','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','airline','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','airline','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','airport','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','deliveryNote','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','deliveryNoteDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','deliveryNoteState','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','awbComponent','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','awbComponent','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','awbComponent','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','awbComponentTemplate','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','awbComponentType','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','awbComponentType','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','awbDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','awbDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','awbDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','awbDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','awbInvoiceIn','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','awbInvoiceIn','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','awbRole','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','awbUnit','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financialBoss','balanceNestTree','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','ektK1','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','administrative','ektK1','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','ektK2','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','administrative','ektK2','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','ektK3','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','administrative','ektK3','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','ektK4','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','edi','administrative','ektK4','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','dmsStorageBox','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','company','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','warehousePickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','warehousePickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','warehousePickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','warehousePickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','component','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','config','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','componentType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBos','machineDms','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','itemShelvingSale','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','tagAbbreviation','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','ticketTracking','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','item','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Update'); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','ticketDms','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','agencyExtraCharge','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','sale_freightComponent','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','accounting','jgallego@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','accounting','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerActivity','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBos','machineDetail','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','vehicleState','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','expeditionState','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','specialPrice','jgallego@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimRatio','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketConfig','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','zoneIncluded','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','zoneGeo','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','quality','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','category','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','edi_bucket','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','ektEntryAssign','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','edi_bucket_type','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','calendarType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','timeSlots','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','supplierFreight','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','payrollWorker','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','payrollWorkCenter','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','payrollComponent','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','professionalCategory','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','ticketObservation','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deliveryNoteState','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deliveryNote','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','invoiceOutExpense','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','delivery','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','entry','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Cubos_Retorno','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimDestination','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','entryConfig','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','farmingDeliveryNote','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','sage','grafana','TiposIva','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','bs','buyer','waste','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientObservation','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceInConfig','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerActivity','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','itemTypeL10n','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','country','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','itemType','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myAddress','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select','Insert,Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','visitUser','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','producer','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','tagL10n','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','config','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','','Select'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','originL10n','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','origin','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','entryEditor','entry','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert','Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','social','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','image','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','guest','tblContadores','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','','Select'); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','logistic','item_track','alexm@db-proxy2.static.verdnatura.es','2022-08-03 23:44:43','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','administrative','value','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','administrative','type','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','type','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','value','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developerBoss','general_log','juan@10.5.1.1','0000-00-00 00:00:00','Select,Drop',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','dipole','employee','expedition_PrintOut','alexm@%','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','logistic','marketPlace','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionAssi','definitivo','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','manager','item_group','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','administrative','item_feature','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','item_feature','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','itemTag','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','itemCategoryL10n','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financialBoss','credit','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','guest','Tipos','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','producer','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','mdbVersion','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','province','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','mistakeType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','warehouse','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','account','itemTaxCountry','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','province','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myTpvTransaction','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myTicketState','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myTicketRow','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myTicket','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myOrderTicket','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myOrderRow','juan@db-proxy2.static.verdnatura.es','2022-08-03 23:44:43','Select,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myOrder','juan@db-proxy2.static.verdnatura.es','2022-08-03 23:44:43','Select,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myInvoice','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myClient','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select','Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myBasketItem','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myBasketDefaults','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','account','userPassword','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','mainAccountBank','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','itemCategory','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','psico','hr','answer','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ticketDms','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','employee','ekt','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','sage','administrative','taxType','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','psico','hr','fellow','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','address_type','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','user','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','','Select'); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','userPassword','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','roleRole','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','roleInherit','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','role','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','mailConfig','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','mailAliasAccount','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','mailAlias','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','accountConfig','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','employee','account','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','tpvMerchant','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','','Select'); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','account','myUser','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','','Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','language','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','imageConfig','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','','Select'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','guest','Paises','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','','Select'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','guest','Tintas','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','','Select'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','item','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','agencyMode','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','','Select'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','inkL10n','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','ink','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','deliveryMethod','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','guest','reinos','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','collectionHotbed','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','hr','mailForward','juan@db-proxy1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','location','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','hr','mailAliasAccount','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','tag','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','news','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buy_edi_k012','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','buy_edi_k012','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','myMenu','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','myBasket','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','message','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','guest','myUser','root@pc-juan.dyn.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','guest','myRole','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','employee','followme','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','hr','account','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','salix','android','AccessToken','jenkins@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerBoss','itemTag','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','itemTag','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','buy_edi_k03','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','psico','hr','examQuestion','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','psico','hr','exam','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','manager','exchange','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','employee','supplier','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','dipole','employee','printer','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','manager','item_groupToOffer','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','dipole','coolerAssist','expedition_PrintOut','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','logistic','putOrder','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','logistic','supplyResponse','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','collectionWagonTicket','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','employee','blacklist','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','employee','cdr','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','employee','queue','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','employee','queueMember','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','employee','queuePhone','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','employee','schedule','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','employee','sip','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','','Select'); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','browser','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','config','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','','Select'); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','order','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select,Insert,Update,Delete','References'); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','orderRowComponent','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','imageCollection','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','orderRow','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','link','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','shelf','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','shelfConfig','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','order_row','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','order_component','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','visitAccess','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','visitAgent','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','visit','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','userSession','z-developer@172.16.255.16','2022-08-03 23:44:43','','Select'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','collectionWagon','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','marketing','news','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','newsTag','z-developer@www1.static.verdnatura.es','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','sage','employee','TiposIva','z-sysadmin@172.16.255.30','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','sage','employee','TiposRetencion','z-sysadmin@172.16.255.30','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','sage','employee','TiposTransacciones','z-sysadmin@172.16.255.30','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','bank_account_type','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','salesPerson','item_groupToOffer','carlosap@172.16.5.232','2022-08-03 23:44:43','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','account','myTicketService','root@10.2.3.180','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','sage','administrative','movConta','carlosap@172.16.5.232','2022-08-03 23:44:43','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','mailConfig','jgallego@81.202.38.190','2022-08-03 23:44:43','','Select'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financial','account_conciliacion','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','accion_dits','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','config','juan@%','0000-00-00 00:00:00','','Select'); +INSERT IGNORE INTO `tables_priv` VALUES ('','util','account','config','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','transitoryDuaUnified','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','clientDied','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','hr','userPassword','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','hr','roleRole','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','hr','roleInherit','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','hr','role','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','hr','mailConfig','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','hr','mailAlias','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','tables_priv','$itBoss@10.0.2.69','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','event','$itBoss@10.0.2.68','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','proxies_priv','$itBoss@10.0.2.68','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','procs_priv','$itBoss@10.5.1.5','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','db','$itBoss@10.0.2.68','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','columns_priv','$itBoss@10.0.2.68','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','time','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','slow_log','$itBoss@10.0.2.68','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','user','$itBoss@10.0.2.68','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','proc','$itBoss@10.0.2.68','2022-08-03 23:44:43','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financial','account_detail','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','account_detail_type','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','entryEditor','Compres','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Agencias','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','awb_component','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','developer','emailUser','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerBoss','agencia_descuadre','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','airline','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','airline','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','agency_warehouse','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','albaran','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vncontrol','salesPerson','inter','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','albaran_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','albaran_state','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Articles','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','awb','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','awb','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','awb_component','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','awb_component','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','awb_component_template','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','awb_component_type','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','awb_gestdoc','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','awb_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','awb_recibida','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','awb_role','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','awb_unit','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financialBoss','balance_nest_tree','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vncontrol','deliveryBoss','inter','juan@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Bancos','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','barcodes','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','barcodes','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vncontrol','buyer','inter','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vncontrol','employee','inter','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','awb_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','awb','alexm@%','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','agency','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','buy_edi_k04','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buy_edi_k03','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buy_edi_k04','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesAssistant','Clientes','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','v_empresa','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','v_empresa','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','chanel','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','v_empresa','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Clientes','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','V_edi_item_track','alexm@%','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionPlus','v_botanic_export','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','manager','v_botanic_export','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionPlus','v_Articles_botanical','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Colores','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Clientes','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','recibida_vencimiento','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','claimManager','jerarquia','juan@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerBusinessAgreement','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','tarifa_componentes','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','tarifa_componentes_series','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','cl_main','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','cl_main','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','state','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','producer','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','officeBoss','ticket_observation','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Cajas','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','cmrConfig','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hrBoss','awb_recibida','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hrBoss','awb','juan@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','buy_edi','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','salix','developer','ACL','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Vehiculos_consumo','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','palletizer','cmr','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerBoss','Colores','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','state','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Consignatarios','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','artificialBoss','travel','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','price_fixed','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','printQueue','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','preservedBoss','travel','alexm@%','0000-00-00 00:00:00','Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','travel','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','Cubos','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerAssistant','itemType','jgallego@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Cubos','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','Cubos','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','artificialBoss','state','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','travel','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Bancos_poliza','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','cmr','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','duaDismissed','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','edi_article','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','time','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','operator','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','payment','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','edi_supplier','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','edi_supplier','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','travel','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Tramos','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Trabajadores','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','empresa','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','sectorType','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Tintas','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','claimManager','Movimientos','juan@%','0000-00-00 00:00:00','Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Compres','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','ticket_observation','juan@%','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Entradas_dits','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','sale','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Entradas_orden','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','ticket_observation','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Entradas_turno','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','entrySource','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','Tickets_turno','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Tickets_turno','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expeditionScan','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Tickets_state','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','tickets_gestdoc','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hrBoss','tickets_gestdoc','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','tickets_gestdoc','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Tickets','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Entradas','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerBoss','Tintas','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','filtros','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Entradas_kop','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','flight','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','warehouse_pickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','zones','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','claimManager','warehouse_pickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Entradas','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','buy','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','buySource','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','budgetNotes','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','specialLabels','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','budgetDms','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','budget','juan@10.5.1.2','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','offerList','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','bookingPlanner','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','budgetInvoiceIn','juan@10.5.1.2','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','beach','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','business','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Movimientos_revisar','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Movimientos_mark','alexm@%','0000-00-00 00:00:00','Select,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Movimientos_componentes','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','Movimientos_componentes','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','Movimientos','juan@%','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','handmadeBoss','Movimientos','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionAssi','Movimientos','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Movimientos','alexm@%','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Movimientos','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Monedas','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','calendarHolidays','juan@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','mandato','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financial','mandato','alexm@%','0000-00-00 00:00:00','Select,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','iva_group','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','greugeType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceInIntrastat','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','greuge','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Intrastat','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Intrastat','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','integra2_province','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Grupos','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','dms','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','continent','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','artificialBoss','Movimientos_componentes','alexm@%','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Movimientos_componentes','alexm@%','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','Movimientos_mark','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','Movimientos_revisar','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','handmadeBoss','Reservas','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerBoss','bankEntity','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Ordenes','alexm@%','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Origen','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','pago','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','awb','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Paises','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','salesAssistant','clientDied','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','warehouse_pickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','payroll_categorias','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','payroll_centros','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','payroll_conceptos','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','claimManager','Tintas','juan@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','alertLevel','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','bankEntity','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','payroll_employee','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','sale','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','bankEntity','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','agencyMode','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Recibos','alexm@%','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','saleCloned','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','pay_met','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Permisos','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','shelving','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemShelvingStock','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','palletizer','cmrConfig','carlosap@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Proveedores','alexm@%','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','PreciosEspeciales','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionAssi','agencia_descuadre','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','price_fixed','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','iva_tipo','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','iva_codigo','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financial','pago','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Proveedores','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Proveedores_cargueras','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Proveedores_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expedition','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Proveedores_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','claimManager','recibida','juan@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','recibida','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','adminOfficer','recibida_iva','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','recibida_intrastat','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','recibida_iva','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','recibida_vencimiento','alexm@%','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesPerson','Recibos','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','officeBoss','bankEntity','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','agency','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','bankEntity','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','versiones','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','reference_rate','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','saleComponent','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financial','Remesas','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionAssi','Reservas','alexm@%','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','cmr','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Rutas','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','address','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','grafana','queue','root@localhost','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','address','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','accountingType','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemShelvingStock_byWarehouse','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','Movimientos','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionAssi','Series','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','adminOfficer','Series','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financial','Recibos','alexm@%','0000-00-00 00:00:00','Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','price_fixed','alexm@%','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','accountingConfig','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','buyer','salesByItemTypeDay','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','salesAssistant','state','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','bufferState','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','coolerAssist','state','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','absenceType','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','artificialBoss','Entradas_Auto','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionAssi','Vehiculos_consumo','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','tblContadores','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','calendar','juan@10.5.1.2','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','calendarHolidays','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','claim','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','claimEnd','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','claimRatio','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Cubos','alexm@%','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','cplusRectificationType','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','cplusInvoiceType477','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','duaInvoiceIn','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','country','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','duaInvoiceIn','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financial','mandato_tipo','juan@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','propertyNotes','juan@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','province','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','receipt','jgallego@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','receipt','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','visitUser','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','referenceRate','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','report','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','cache','productionBoss','available','guillermo@10.5.1.2','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','time','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','role','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','config__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','role','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','comparativeFilterType','guillermo@10.5.1.4','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','comparativeFilter','guillermo@10.5.1.4','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','route','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','company','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expeditionStateType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','collectionHotbed','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','collectionColors','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','collection','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','cmr_list','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','collection','alexm@%','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','cmr','alexm@%','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','clientYoke','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','mysql','developer','roles_mapping','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketLastState','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionBoss','calendar','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','adminOfficer','pago','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','clientPhoneBook','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','saleGroupDetail','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','clientObservation','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','clientObservation','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','productionConfig','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionBoss','sale','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','packingSite','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionPlus','province','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionPlus','province','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','grafana','sip','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','','Select'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','clientCredit','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','artificialBoss','saleTracking','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','saleTracking','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','saleTracking','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','saleTracking','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','client','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','client','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','saleVolume','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','Proveedores_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','awb_gestdoc','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerAssistant','Cubos','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','routesMonitor','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select','Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminBoss','sale','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','sale','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Delete','Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','sale','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Delete','Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','sale','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','zoneClosure','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','saleComponent','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','saleComponent','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','marketingBoss','saleGoal','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','saleGroup','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','saleGroupDetail','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','account_detail','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','awb_component_type','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vncontrol','employee','accion','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','volumeConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','currency','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerBoss','tag','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','currency','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','creditClassification','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','creditInsurance','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','currency','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerTimeControl','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','defaulter','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','deliveryMethod','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','deliveryMethod','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','v_compres','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','deviceProductionUser','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','department','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','deviceProductionConfig','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','deviceProduction','alexm@%','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','deviceProduction','alexm@%','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionBoss','absenceType','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','deviceProductionConfig','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','deviceProductionUser','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','disabilityGrade','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','duaInvoiceIn','alexm@%','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','dmsType','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','duaEntry','alexm@%','0000-00-00 00:00:00','Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','duaEntry','alexm@%','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','dua','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','duaIntrastat','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','duaInvoiceIn','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','duaTax','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Tickets_turno','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','cl_main','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','agency','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','ektEntryAssign','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionBoss','itemShelving','root@localhost','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','propertyDms','juan@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerTimeControlConfig','juan@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','entry','guillermo@10.5.1.3','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','businessType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','entryLog','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','projectState','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','entrySplit__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','entryType','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','projectNotes','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','project','juan@10.5.1.1','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','productionConfig','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','productionConfig','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','creditInsurance','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','cache','productionBoss','visible','guillermo@10.5.1.2','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','errorProduction__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','invoiceOut','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','coolerAssist','Tickets','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','packingSite','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','salix','developer','accessTokenConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','printQueueArgs','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','printQueue','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','printer','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','expedition','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','sector','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppeLocation','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','wks','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','entryObservation','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','itemShelvingList','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','cmrConfig','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','expeditionTruck','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','alertLevel','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','expeditionSticker','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','artificialBoss','entryObservation','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','dock','alexm@%','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','expeditionTruck','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','expeditionPallet','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','expense','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','expeditionScan','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','entryObservation','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppeGroup','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','floramondoNotOfferDay__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','fuelType','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppeDMS','alexm@%','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppeComponent','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppe','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','glsExpedition__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','postCode','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','pgcMaster','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemBarcode','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','host','alexm@%','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticket','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceIn','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','invoiceIn','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','invoiceIn','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert','Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','inventoryFailure','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','intrastat','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','inventoryFailure','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','inventoryFailureCause','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','invoiceCorrection','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceCorrectionDataSource','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','invoiceCorrectionType','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','invoiceIn','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert','Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceInDueDay','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','invoiceInDueDay','alexm@%','0000-00-00 00:00:00','Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','invoiceInIntrastat__','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','invoiceInTax','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceInSage','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','invoiceInTax','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceInTax','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','invoiceOut','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','invoiceOut','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceOutExpense','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','item','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','invoiceOutSerial','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','invoiceOutTax','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','item','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','itemBarcode','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','itemBotanical','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemBotanicalWithGenus','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemCategory','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','pgcEqu','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','pgc','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','itemCost','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','itemConfig','alexm@%','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemConversor__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','itemCost','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','personalProtectionEquipment','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','payMethod','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','payment','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','payDem','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','itemPlacementSupplyList','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','itemPlacementSupplyList','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','itemPlacementSupply','alexm@%','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemPackingType','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','itemPlacementSupply','alexm@%','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','itemPlacementSupplyList','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemPlacement__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','payDem','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','invoiceOut','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemRepo__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemSearch','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemShelving','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','itemShelvingLog','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketWeekly','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','itemShelvingLog','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','airport','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemShelvingSale','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hrBoss','Tickets','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimEnd','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','itemTaxCountry','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workCenter','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','itemTaxCountry','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','itemTaxCountry','alexm@%','0000-00-00 00:00:00','Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','parking','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','packingSiteLog','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','dua','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','packingSite','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','packagingWithoutFreight','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemVerdecora__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','packagingWithFreight','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','packagingGifts','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','packagingConfig','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','packaging','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','packageEquivalentItem','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','packageEquivalent','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','packageChecked','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','packageChecked','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','packageChecked','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','operator','alexm@%','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','operator','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','mail','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','Recibos','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','operator','alexm@%','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','mandate','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','occupationCode','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','observationType','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','salix','developer','defaultViewConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','medicalCenter','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','medicalReview','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','noticeSubscription','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','noticeSubscription','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','noticeCategory','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','noticeCategory','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','mrwServiceWeekday','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','mrw','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','mrwService','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppePlan','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','accountingConfig','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','buy','carlosap@10.5.1.8','0000-00-00 00:00:00','Select,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','buy','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','saleGoal','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','packingSiteLog','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','saleComponent','alexm@%','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','arcRead','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','clientProtected','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','invoiceOut','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','dua','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','duaEntry','alexm@%','0000-00-00 00:00:00','Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','expeditionTruck','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','moving','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','machineDetail','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','machineDms','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','vehicle','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','awb','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','machine','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Entradas_dits','alexm@%','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerTimeControlMail','alexm@%','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bi','coolerBoss','rotacion','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','PreciosEspeciales','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','movingState','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','bufferType','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','bufferState','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','buffer','guillermo@10.5.1.3','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','bufferGroup','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','lastRFID','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','person__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','config','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenance','expedition','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','travel','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','itemPicker','buy','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','logistic','Entradas_Auto','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','machine','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financialBoss','referenceCurrent','alexm@%','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','vehicleState','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','vehicleEvent','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','cooler','Tintas','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','itemBotanical','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','productionConfigLog','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','developer','signInLog','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketTracking','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','deviceProductionState','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','deviceProductionState','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vncontrol','hr','inter','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','printServerQueue2__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','printServerQueue__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','artificialBoss','buy','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','Movimientos','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','buy','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','itemMinimumQuantity','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','receipt','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerBoss','producer','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','link','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','link','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','delivery','vehicle','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','upperStickers','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','province','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','XDiario','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','till','alexm@%','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','financial','recovery','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','photocell','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','supplyResponse','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','cache','customer','last_buy','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','client','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','invoiceInTax','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','workerTeam','juan@10.5.1.2','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','profile_type','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','profile_media','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','recovery','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','buffer','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','professional_category','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','media_type','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','media','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','labour_agreement','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','returnBuckets__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','journey','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','income_employee','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','incometype_employee','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hrBoss','income_employee','alexm@%','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','buyer','salesByWeek','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','routeGate__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','calendar_labour_type','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bi','adminBoss','XDiario_ALL','alexm@%','0000-00-00 00:00:00','Select,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','rate','carlosap@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','expeditionState','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','salesPerson','clientAnnualConsumption','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bi','buyer','tarifa_componentes_series','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bi','buyer','tarifa_componentes','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bi','productionAssi','rutasBoard','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bi','logistic','rotacion','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bi','salesPerson','tarifa_componentes','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bi','salesPerson','tarifa_componentes_series','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','expeditionLog','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','salesPerson','clientNewBorn','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','saleItemShelving__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesBoss','workerTeam','juan@10.5.1.2','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','expedition','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemShelvingStock','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','saleParking__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','property','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','config','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','vehicleEvent','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','buyer','lastIndicators','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','saleComponent','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','itemBotanical','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','item','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','marketingBoss','salesPersonGoal','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hrBoss','journey','alexm@%','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','workerTimeControl','alexm@%','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','currentWorkersStats','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','ticketStateToday','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','shelving','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','shelving','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','shelving','alexm@%','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','supplierAccount','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerBoss','supplierAccount','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','supplierAccount','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','customer','supplier','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','state','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','state','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','stockBuyed','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','stowaway','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','supplier','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','supplierAccount','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','supplierAgencyTerm','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','supplierAgencyTerm','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','supplierExpense','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','marketingBoss','ticketService','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ticketService','jgallego@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','sendingServiceWeekday','jenkins@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','ticketRequest','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','ticketParking','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','taxCode','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminBoss','taxArea','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','taxClass','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','taxCode','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','taxCode','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','salesPersonEvolution','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','calendar_employee','juan@10.5.1.2','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','ticket','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticket','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketCollection','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ticketDocumentation','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketDms','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','ektEntryAssign','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','intrastat','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','supplierAgencyTerm','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','entryConfig','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','franceExpressConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','ticketLog','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','ticketCollection','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','ticketDms','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketObservation','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','ticketPackaging','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketPackaging','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','ticketParking','alexm@%','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketPackingList','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketParking','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketPreviousPreparingList','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ticketRefund','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketRequest','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminBoss','ticketService','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminBoss','ticketServiceType','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketState','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','ticketStateToday','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','greugeType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','time','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketWeekly','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminBoss','till','juan@%','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','account','town','juan@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','time','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerMana','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bi','salesPerson','defaulters','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','customer','travel','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','train','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','train','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','trainingCenter','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','trainingCourse','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','trainingCourseType','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','travel','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','travelClonedWeekly','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bi','employee','facturacion_media_anual','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','travelObservation','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','bankPolicy','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','travelThermograph','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','tillConfig','juan@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','till','juan@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','till','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','vehicleState','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','sectorCollectionSaleGroup','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','vehicleEvent','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','vehicle','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','vehicle','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Agencias','alexm@%','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','expeditionStateType','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketState','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','vehicleInvoiceIn','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','vehicleState','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','volumeConfig','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','ticketTrackingState','alexm@%','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','warehouse','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','role','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workCenter','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientCredit','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','worker','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','workerAppTester','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','propertyGroup','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','worker','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerBusinessType','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','workerDepartment','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','workerDepartment','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerDepartment','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerConfig__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','inventoryDiscrepancyDetail','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','sendingConfig','jenkins@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','entryConfig','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketPackagingStartingStock','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','ticketPackagingStartingStock','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerIrpf','juan@%','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerJourney','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerLabour','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','workerMana','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','workerMana','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','ticketPackaging','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','ticketPackagingStartingStock','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','entryConfig','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','officeBoss','ticketPackagingStartingStock','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerRelatives','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','ticketPackagingStartingStock','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','supplierPackaging','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerDocument','alexm@%','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceCorrection','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ink','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','zone','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','XDiario','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','XDiario','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','workerTimeControlMail','alexm@%','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerTimeControl','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bi','financial','Greuge_Evolution','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bi','officeBoss','Greuge_Evolution','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bi','claimManager','rotacion','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','sale','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','zonePromo__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','accountingConfig','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','accountingType','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','agencyMode','alexm@%','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','cache','employee','visible','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','productionConfig','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','cache','employee','available','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','logistic','ekt','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','ticketCollection','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientChain','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','VMPSettings','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimResponsible','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','packingSiteLog','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hrBoss','recibida','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','util','grafana','debug','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','myOrder','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','mdbVersion','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientLog','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','calendar','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','campaign','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketService','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','report','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','buyer','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','defaulter','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','componentType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientManaCache','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','invoiceIn','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','deliveryInformation','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','bufferType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','grafana','role','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','supplyOffer','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketStateToday','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','routeComplement','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','saleVolume','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','component','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','train','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','ticketPalletized','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','autonomy','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expeditionMistakeType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketParking','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemShelving','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','state','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','taxClass','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','salesByWeek','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','invoiceInDueDay','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','sectorProductivity','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','salesByclientSalesPerson','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','marketPlace','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','routeAction','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deviceProduction','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','invoiceOut','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','printer','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','mdbBranch','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','workerProductivity','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','config','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','userSession','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','receipt','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','buy','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','calendarHolidays','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','parking','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','role','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','errorLogApp','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','continent','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','lastRFID','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','farmingInvoiceIn','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','agencyMode','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','absenceType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','saleGroupDetail','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerMistakeType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','mdbVersionTree','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expeditionTruck','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','routeConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimReason','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','log','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','failureLog','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','clientNewBorn','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','farming','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','order','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','packingSpeed','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expense','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerLabour','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','orderRow','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','movingLog','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','warehouse','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','sector','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','salesPersonGoal','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','movingState','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimResult','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','routesMonitor','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expeditionPallet','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','ventas','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','intrastat','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','printQueueArgs','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bi','grafana','Greuge_Evolution','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','host','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','country','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','waste','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketTracking','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemCategory','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','saleTracking','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','producer','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','cache','grafana','stock','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','account','grafana','user','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','','Select'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deliveryMethod','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketCollection','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','lastHourProduction','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','warehouseAlias','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','zoneClosure','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','origin','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','referenceCurrent','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','thermograph','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','dms','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','dmsType','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','greenhouseBoss','property','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketLastState','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','guest','myAddress','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','tag','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemTag','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','handmadeBoss','Tipos','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','saleBuy','carlosap@10.5.1.6','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','orderTicket','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','negativeOrigin','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','route','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemPackingType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','expedition','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','zoneEstimatedDelivery','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','payMethod','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemCost','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','worker','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','travel','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','entry','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','department','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bi','grafana','rutasBoard','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','address','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerDistributionCategory','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','client','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','zone','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','packingSite','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemTaxCountry','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','workerLabourDataByMonth','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketPackaging','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','bufferFreeLength','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','salesByItemTypeDay','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','collection','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','project','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','inventoryDiscrepancy','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','ektSubAddress','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','item_track','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','putOrder','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','parking','juan@10.5.1.2','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenance','machine','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','calendarType','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','glsExpedition','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','clientType','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expeditionMistake','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deviceProductionLog','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','integra2Province','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','vehicleState','juan@10.5.1.1','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','machineDetail','juan@10.5.1.1','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','machineDms','juan@10.5.1.1','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerJourney','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','productionError','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','professionalCategory','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','mdbApp','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','glsConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','clientContact','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','collectionVolumetry','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','administrative','item','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerIncome','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerBoss','tagAbbreviation','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','chronopostConfig','jenkins@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','chronopostSenderAddress','jenkins@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','chronopostServiceWeekday','jenkins@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','chronopostExpedition','root@localhost','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','sectorCollection','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','sendingService','jenkins@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','adminOfficer','tickets_gestdoc','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','flight','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','routeAction','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','bankErrorCode','jgallego@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','farming','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','farmingDms','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','farmingNotes','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','farmingInvoiceIn','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionBoss','routesMonitor','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','','Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','routeCommission','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','expeditionState','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerBoss','warehouse','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimBeginning','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','invoicing','vehiclePlateRegex','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','businessSchedule','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','clientRisk','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','businessCalendar','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','employee','item','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','vehicleNotes','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','vehicleDms','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','invoiceInConfig','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','palletizerBoss','zoneEvent','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','palletizerBoss','routesMonitor','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','propertyNotes','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','propertyDms','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','payment','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','payment','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','taxType','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','guest','autonomy','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionPlus','autonomy','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','routePalletized','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticBoss','warehouse','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','m3','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','Cajas','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','tagAbbreviation','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemImageQueue','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','marketing','parking','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','sectorCollection','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','supplier','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','defaulter','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceInTaxBookingAccount','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','business','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','dock','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','item','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','clientAnnualConsumption','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','parking','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','bankEntityConfig','carlosap@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','shelving','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','duaEntry','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','salix','developer','fieldAcl','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','salix','developer','module','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','salix','developer','printConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','salix','developer','url','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','salix','developer','userConfigView','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimRedelivery','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientRisk','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','supplierDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','buyer','sale','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','chain','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','routesMonitor','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','warehouse_pickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','cl_main','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','company','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','routeAction','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','ticket_observation','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','Tickets_turno','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','jerarquia','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','Impresoras','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','autoRadioLogCall','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','autoRadioConfig','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','Recibos','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','Rutas','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','Movimientos','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','state','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','route','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','routeComplement','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','deliveryMethod','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','Tickets','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','expeditionRoute_Monitor','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','expeditionScan','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','expeditionPallet','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','province','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','visitAccess','root@localhost','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','v_botanic_export','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','itemCost','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','deliveryAssistant','m3','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','ticketDms','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','time','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','v_Articles_botanical','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','workCenter','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','workerDepartment','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','zoneEvent','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bi','deliveryAssistant','rotacion','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','agency','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','agencyMode','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','vehicle','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','vehicleEvent','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','postCode','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','','Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','town','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','','Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claim','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','supplierAccount','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerDepartment','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','grafana','cdr','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerTimeControlConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerMistake','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','putOrder','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','saleMistake','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deviceProductionUser','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','contactChannel','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deviceLog','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','vehicle','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','packaging','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','workerProductivityConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','antenna','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','cmr','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','accounting','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','creditClassification','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketLog','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','moving','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimDevelopment','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','expeditionLog','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','compradores_evolution','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','currency','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimObservation','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','salesPreviousPreparated','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimState','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','company','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','buffer','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','greuge','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','item','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select,Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','itemShelving','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','agencyIncoming','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','addressObservation','carlosap@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','negativeOrigin','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','Vehiculos_consumo','carlosap@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','entryOrder','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBoss','machineDms','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','ink','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','supplierDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','supplierDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','visitAgent','root@localhost','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','remittance','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','vehicleConsumption','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','vehicleConsumption','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','accountReconciliation','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','accountDetail','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','accountDetail','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','accountDetailType','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','airline','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','airline','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','airport','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','deliveryNote','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','deliveryNoteDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','deliveryNoteState','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','awbComponent','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','awbComponent','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','awbComponent','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','awbComponentTemplate','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','awbComponentType','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','awbComponentType','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','awbDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','awbDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','awbDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','awbDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','awbInvoiceIn','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','awbInvoiceIn','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','awbRole','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','awbUnit','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financialBoss','balanceNestTree','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','ektK1','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','administrative','ektK1','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','ektK2','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','administrative','ektK2','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','ektK3','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','administrative','ektK3','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','buyer','ektK4','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','administrative','ektK4','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','dmsStorageBox','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','company','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','warehousePickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','warehousePickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','warehousePickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','warehousePickup','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','component','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','config','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','componentType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','priceFixed','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','itemShelvingSale','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','tagAbbreviation','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','ticketTracking','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','item','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','ticketDms','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','agencyExtraCharge','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','sale_freightComponent','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','accounting','jgallego@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','accounting','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerActivity','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketRequest','guillermo@10.5.1.3','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','Vehiculos_consumo','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','budgetState','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','vehicleState','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','expeditionState','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','specialPrice','jgallego@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimRatio','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketConfig','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','zoneIncluded','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','zoneGeo','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','quality','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','category','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','edi_bucket','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','ektEntryAssign','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','edi_bucket_type','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','calendarType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','timeSlots','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','supplierFreight','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','payrollWorker','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','payrollWorkCenter','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','payrollComponent','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','professionalCategory','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','ticketObservation','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deliveryNoteState','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deliveryNote','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','inventoryConfig','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','comparative','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','invoiceOutExpense','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','delivery','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','entry','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','Cubos_Retorno','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimDestination','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','entryConfig','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','farmingDeliveryNote','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','sage','grafana','TiposIva','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bs','buyer','waste','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientObservation','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','visit','root@localhost','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerActivity','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicy','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicyDetail','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicyReview','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','roadmapStop','guillermo@10.5.1.3','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','roadmapStop','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','agencyWorkCenter','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','roadmapStop','guillermo@10.5.1.3','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','greenhouseBoss','business','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','teamBoss','business','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketServiceType','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','business','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','supplierAgencyTerm','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemMinimumQuantity','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientRate','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','entryEditor','Entradas','guillermo@10.5.1.3','0000-00-00 00:00:00','Insert','Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','clientInforma','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','solunionCAP','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','clientUnpaid','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','pay_dem','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','invoiceOut','guillermo@10.5.1.3','0000-00-00 00:00:00','Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financialBoss','invoiceOut','guillermo@10.5.1.3','0000-00-00 00:00:00','Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financialBoss','accountDetail','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','accountDetail','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBoss','project','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBoss','machineDetail','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','antenna','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','bufferPool','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','enteringLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','expeditionLoading','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','failureLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','movingLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','sorterLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','genericAllocation','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','businessReasonEnd','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buy_edi','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buySource','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','bi','salesPerson','claims_ratio','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','shelfMultiConfig','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientConfig','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','albaran','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','albaran_gestdoc','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','albaran_state','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','deliveryNote','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','deliveryNoteDms','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','deliveryNoteState','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','buy','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','entryType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionBoss','claimDestination','juan@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','entryLog','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','dipole','grafana','expedition_PrintOut','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketObservation','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','recovery','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','observationType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientInforma','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','accountingType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','bankPolicyDetail','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','bankPolicyReview','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','bankPolicy','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','edi','hedera-web','imapMultiConfig','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','salesAssistant','orderConfig','root@localhost','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemEntryOut','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemEntryIn','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemShelvingSale','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','packaging','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerBoss','rate','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','vehicleDms','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','vehicleInvoiceIn','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','vehicleNotes','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','saleGroup','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','bufferLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financialBoss','supplierAccount','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','tillSerial','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','stockBuyed','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','alertLevel','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerActivityType','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','priceDelta','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','parkingLog','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','travelLog','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); /*!40000 ALTER TABLE `tables_priv` ENABLE KEYS */; /*!40000 ALTER TABLE `columns_priv` DISABLE KEYS */; -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','mailConfig','port','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','mailConfig','secure','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','mailConfig','host','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','account','employee','user','active','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','account','employee','user','role','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','account','employee','user','nickname','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','account','employee','user','name','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','account','employee','user','id','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','userSession','created','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','userSession','lastUpdate','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','userSession','userVisitFk','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','order','id','2022-08-03 23:44:43','References'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','config','testRestUri','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','config','restUri','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','config','defaultLang','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','pbx','employee','sip','extension','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','config','id','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','pbx','employee','sip','user_id','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','tpvMerchant','description','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','tpvMerchant','companyFk','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','tpvMerchant','id','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','account','account','myUser','nickname','2022-08-03 23:44:43','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','account','account','myUser','email','2022-08-03 23:44:43','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','account','account','myUser','lang','2022-08-03 23:44:43','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myAddress','isActive','2022-08-03 23:44:43','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myAddress','id','2022-08-03 23:44:43','Insert'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myAddress','provinceFk','2022-08-03 23:44:43','Insert,Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myAddress','nickname','2022-08-03 23:44:43','Insert,Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myAddress','street','2022-08-03 23:44:43','Insert,Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myAddress','clientFk','2022-08-03 23:44:43','Insert'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myAddress','city','2022-08-03 23:44:43','Insert,Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myAddress','postalCode','2022-08-03 23:44:43','Insert,Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myClient','defaultAddressFk','2022-08-03 23:44:43','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myClient','isToBeMailed','2022-08-03 23:44:43','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','guest','imageConfig','url','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','guest','Paises','Id','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','guest','Paises','Pais','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','guest','Tintas','Id_Tinta','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','guest','Tintas','name','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','guest','tblContadores','dbproduccion','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','guest','config','pdfsDir','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','guest','config','testDomain','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','guest','config','productionDomain','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','guest','config','defaultForm','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','guest','agencyMode','id','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','guest','agencyMode','deliveryMethodFk','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','guest','agencyMode','web','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','guest','agencyMode','agencyFk','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','guest','agencyMode','description','2022-08-03 23:44:43','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','guest','config','dbproduccion','0000-00-00 00:00:00','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','account','grafana','user','role','0000-00-00 00:00:00','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','account','grafana','user','email','0000-00-00 00:00:00','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','pbx','grafana','sip','user_id','0000-00-00 00:00:00','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','pbx','grafana','sip','extension','0000-00-00 00:00:00','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','account','grafana','user','name','0000-00-00 00:00:00','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','account','grafana','user','active','0000-00-00 00:00:00','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','id','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','supplierFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','dated','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','invoiceNumber','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','isExcludedFromAvailable','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','notes','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','isConfirmed','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','isOrdered','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','isRaid','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','commission','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','created','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','evaNotes','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','travelFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','currencyFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','companyFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','gestDocFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','invoiceInFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','isBlocked','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','loadPriority','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','kop','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','sub','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','pro','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','auction','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','invoiceAmount','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','buyerFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','typeFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','reference','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','observationEditorFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','entry','clonedFrom','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','routeFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','name','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','beachFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','ticketPacked','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','ticketFree','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','ticketProduction','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','packages','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','note','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','dated','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','dockFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','m3','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','priority','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','etd','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','m3boxes','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','bufferFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','isPickingAllowed','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','productionBoss','routesMonitor','expeditionTruckFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','account','grafana','user','id','0000-00-00 00:00:00','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','account','grafana','user','nickname','0000-00-00 00:00:00','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','id','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','itemFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','ticketFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','concept','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','quantity','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','originalQuantity','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','discount','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','reserved','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','isPicked','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','isPriceFixed','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','created','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','isAdded','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','total','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','editorFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','id','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','itemFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','ticketFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','concept','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','quantity','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','originalQuantity','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','discount','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','reserved','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','isPicked','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','isPriceFixed','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','created','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','isAdded','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','total','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','editorFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','deliveryAssistant','postCode','code','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','deliveryAssistant','postCode','townFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','deliveryAssistant','town','provinceFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','id','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','equivalent','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','stems','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','minPrice','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','isToPrint','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','family','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','box','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','category','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','doPhoto','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','image','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','inkFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','intrastatFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','hasMinPrice','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','created','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','comment','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','typeFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','generic','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','producerFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','description','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','density','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','relevancy','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','expenseFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','isActive','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','subName','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','tag5','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','value5','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','tag6','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','value6','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','tag7','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','value7','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','tag8','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','value8','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','tag9','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','value9','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','tag10','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','value10','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','minimum','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','upToDown','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','supplyResponseFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','hasKgPrice','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','isFloramondo','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','isFragile','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','numberOfItemsPerCask','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','embalageCode','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','quality','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','stemMultiplier','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','itemPackingTypeFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','packingOut','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','genericFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','packingShelve','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','isLaid','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','lastUsed','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','weightByPiece','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','editorFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','recycledPlastic','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','nonRecycledPlastic','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','minQuantity','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','item','size','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','item','originFk','0000-00-00 00:00:00','Select,Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','item','longName','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','item','name','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','id','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','warehouseFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','shipped','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','nickname','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','refFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','addressFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','workerFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','observations','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','isSigned','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','isLabeled','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','isPrinted','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','packages','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','location','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','hour','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','created','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','isBlocked','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','solution','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','routeFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','priority','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','hasPriority','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','companyFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','agencyModeFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','landed','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','isBoxed','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','isDeleted','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','zoneFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','zonePrice','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','zoneBonus','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','totalWithVat','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','totalWithoutVat','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','weight','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','clonedFrom','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','cmrFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','editorFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','config','truckLength','0000-00-00 00:00:00','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','production','item','isBoxPickingMode','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','id','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','supplierFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','dated','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','invoiceNumber','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','isExcludedFromAvailable','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','isConfirmed','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','isOrdered','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','isRaid','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','commission','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','created','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','evaNotes','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','travelFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','currencyFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','companyFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','gestDocFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','invoiceInFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','loadPriority','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','kop','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','sub','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','pro','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','auction','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','invoiceAmount','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','buyerFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','typeFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','reference','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','observationEditorFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','clonedFrom','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','editorFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','lockerUserFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','locked','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','mailConfig','port','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','mailConfig','secure','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','mailConfig','host','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','account','employee','user','active','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','account','employee','user','role','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','account','employee','user','nickname','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','account','employee','user','name','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','account','employee','user','id','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','userSession','created','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','userSession','lastUpdate','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','userSession','userVisitFk','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','order','id','2022-08-03 23:44:43','References'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','config','testRestUri','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','config','restUri','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','config','defaultLang','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','pbx','employee','sip','extension','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','employee','config','id','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','pbx','employee','sip','user_id','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','tpvMerchant','description','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','tpvMerchant','companyFk','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','tpvMerchant','id','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','account','account','myUser','nickname','2022-08-03 23:44:43','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','account','account','myUser','email','2022-08-03 23:44:43','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','account','account','myUser','lang','2022-08-03 23:44:43','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myAddress','isActive','2022-08-03 23:44:43','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myAddress','id','2022-08-03 23:44:43','Insert'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myAddress','provinceFk','2022-08-03 23:44:43','Insert,Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myAddress','nickname','2022-08-03 23:44:43','Insert,Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myAddress','street','2022-08-03 23:44:43','Insert,Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myAddress','clientFk','2022-08-03 23:44:43','Insert'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myAddress','city','2022-08-03 23:44:43','Insert,Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myAddress','postalCode','2022-08-03 23:44:43','Insert,Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myClient','defaultAddressFk','2022-08-03 23:44:43','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','account','myClient','isToBeMailed','2022-08-03 23:44:43','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','guest','imageConfig','url','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','guest','Paises','Id','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','guest','Paises','Pais','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','guest','Tintas','Id_Tinta','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','guest','Tintas','name','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','guest','tblContadores','dbproduccion','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','guest','config','pdfsDir','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','guest','config','testDomain','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','guest','config','productionDomain','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','hedera','guest','config','defaultForm','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','guest','agencyMode','id','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','guest','agencyMode','deliveryMethodFk','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','guest','agencyMode','web','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','guest','agencyMode','agencyFk','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','guest','agencyMode','description','2022-08-03 23:44:43','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','guest','config','dbproduccion','0000-00-00 00:00:00','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','account','grafana','user','role','0000-00-00 00:00:00','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','account','grafana','user','email','0000-00-00 00:00:00','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','pbx','grafana','sip','user_id','0000-00-00 00:00:00','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','pbx','grafana','sip','extension','0000-00-00 00:00:00','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','account','grafana','user','name','0000-00-00 00:00:00','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','account','grafana','user','active','0000-00-00 00:00:00','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','business','workerFk','0000-00-00 00:00:00','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','business','id','0000-00-00 00:00:00','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','business','departmentFk','0000-00-00 00:00:00','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','business','companyCodeFk','0000-00-00 00:00:00','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','routeFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','name','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','beachFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','ticketPacked','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','ticketFree','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','ticketProduction','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','packages','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','note','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','dated','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','dockFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','m3','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','priority','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','etd','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','m3boxes','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','bufferFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','isPickingAllowed','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','productionBoss','routesMonitor','expeditionTruckFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','account','grafana','user','id','0000-00-00 00:00:00','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','account','grafana','user','nickname','0000-00-00 00:00:00','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','id','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','itemFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','ticketFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','concept','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','quantity','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','originalQuantity','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','discount','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','reserved','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','isPicked','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','isPriceFixed','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','created','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','isAdded','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','total','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','sale','editorFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','id','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','itemFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','ticketFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','concept','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','quantity','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','originalQuantity','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','discount','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','reserved','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','isPicked','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','isPriceFixed','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','created','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','isAdded','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','total','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','salesAssistant','sale','editorFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','deliveryAssistant','postCode','code','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','deliveryAssistant','postCode','townFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','deliveryAssistant','town','provinceFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','id','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','equivalent','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','stems','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','minPrice','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','isToPrint','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','family','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','box','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','category','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','doPhoto','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','image','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','inkFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','intrastatFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','hasMinPrice','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','created','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','comment','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','typeFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','generic','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','producerFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','description','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','density','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','relevancy','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','expenseFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','isActive','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','subName','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','tag5','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','value5','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','tag6','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','value6','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','tag7','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','value7','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','tag8','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','value8','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','tag9','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','value9','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','tag10','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','value10','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','minimum','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','upToDown','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','supplyResponseFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','hasKgPrice','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','isFloramondo','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','isFragile','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','numberOfItemsPerCask','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','embalageCode','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','quality','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','stemMultiplier','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','itemPackingTypeFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','packingOut','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','genericFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','packingShelve','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','isLaid','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','lastUsed','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','weightByPiece','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','editorFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','recycledPlastic','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','nonRecycledPlastic','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','minQuantity','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','Id_Entrada','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','item','originFk','0000-00-00 00:00:00','Select,Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','Id_Proveedor','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','Fecha','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','id','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','warehouseFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','shipped','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','nickname','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','refFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','addressFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','workerFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','observations','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','isSigned','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','isLabeled','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','isPrinted','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','packages','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','location','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','hour','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','created','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','isBlocked','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','solution','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','routeFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','priority','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','hasPriority','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','companyFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','agencyModeFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','landed','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','isBoxed','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','isDeleted','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','zoneFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','zonePrice','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','zoneBonus','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','totalWithVat','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','totalWithoutVat','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','weight','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','clonedFrom','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','cmrFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','editorFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','config','truckLength','0000-00-00 00:00:00','Select'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','production','item','isBoxPickingMode','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','id','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','supplierFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','dated','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','invoiceNumber','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','isExcludedFromAvailable','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','isConfirmed','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','isOrdered','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','isRaid','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','commission','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','created','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','evaNotes','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','travelFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','currencyFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','companyFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','gestDocFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','invoiceInFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','loadPriority','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','kop','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','sub','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','pro','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','auction','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','invoiceAmount','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','buyerFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','typeFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','reference','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','observationEditorFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','clonedFrom','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','editorFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','lockerUserFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','entryEditor','entry','locked','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','Referencia','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','Inventario','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','Confirmada','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','Pedida','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','Redada','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','comision','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','odbc_date','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','Notas_Eva','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','travel_id','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','Id_Moneda','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','empresa_id','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','gestdoc_id','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','recibida_id','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','loadPriority','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','kop','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','sub','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','pro','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','invoiceAmount','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','buyerFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','typeFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn2008','entryEditor','Entradas','reference','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','id','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','serialNumber','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','serial','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','supplierFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','issued','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','supplierRef','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','currencyFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','created','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','companyFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','docFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','booked','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','operated','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','siiTypeInvoiceInFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','cplusRectificationTypeFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','cplusSubjectOpFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','cplusTaxBreakFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','siiTrascendencyInvoiceInFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','bookEntried','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','isVatDeductible','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','withholdingSageFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','expenseFkDeductible','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','hrBoss','invoiceIn','editorFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','id','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','serialNumber','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','serial','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','supplierFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','issued','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','supplierRef','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','currencyFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','created','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','companyFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','docFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','booked','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','operated','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','siiTypeInvoiceInFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','cplusRectificationTypeFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','cplusSubjectOpFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','cplusTaxBreakFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','siiTrascendencyInvoiceInFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','bookEntried','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','isVatDeductible','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','withholdingSageFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','expenseFkDeductible','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','invoiceIn','editorFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','id','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','serialNumber','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','serial','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','supplierFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','issued','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','supplierRef','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','currencyFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','created','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','companyFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','docFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','booked','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','operated','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','siiTypeInvoiceInFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','cplusRectificationTypeFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','cplusSubjectOpFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','cplusTaxBreakFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','siiTrascendencyInvoiceInFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','bookEntried','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','isVatDeductible','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','withholdingSageFk','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','expenseFkDeductible','0000-00-00 00:00:00','Update'); +INSERT IGNORE INTO `columns_priv` VALUES ('','vn','logistic','invoiceIn','editorFk','0000-00-00 00:00:00','Update'); /*!40000 ALTER TABLE `columns_priv` ENABLE KEYS */; /*!40000 ALTER TABLE `procs_priv` DISABLE KEYS */; -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','guest','myorder_getavailable','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','guest','myOrder_calcCatalogFull','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myOrder_checkConfig','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myOrder_calcCatalogFromItem','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myOrder_getTax','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','android','log_add','PROCEDURE','jenkins@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','employee','item_listAllocation','PROCEDURE','z-developer@www1.static.verdnatura.es','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','mytpvtransaction_end','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myticket_list','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myTicket_getServices','PROCEDURE','root@10.2.3.180','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myticket_getrows','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myticket_getpackages','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myTicket_get','PROCEDURE','z-sysadmin@172.16.255.34','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myorder_confirm','PROCEDURE','juan@10.5.1.2','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myorder_additem','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','guest','myOrder_configureForGuest','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myOrder_create','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana','zone_getaddresses','PROCEDURE','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','catalog_calcfrommyaddress','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','ext','buy_scan','PROCEDURE','juan@swarm-worker2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myUser_loginWithKey','PROCEDURE','jenkins@172.16.255.34','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myUser_login','PROCEDURE','jenkins@172.16.255.34','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myUser_hasRole','FUNCTION','jenkins@172.16.255.34','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myUser_getName','FUNCTION','jenkins@172.16.255.34','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myUser_getId','FUNCTION','jenkins@172.16.255.34','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','palletizerBoss','midnight','FUNCTION','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','account','account','myUser_logout','PROCEDURE','jenkins@172.16.255.34','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','entryEditor','getinventoryDate','FUNCTION','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana','zone_upcomingdeliveries','PROCEDURE','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','android','vn_now','FUNCTION','jenkins@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','entryEditor','entry_unlock','PROCEDURE','guillermo@10.5.1.4','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','account','zone_getAgency','PROCEDURE','juan@77.228.249.89','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','account','invoiceout_getpath','FUNCTION','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','employee','order_confirm','PROCEDURE','z-developer@www1.static.verdnatura.es','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myTpvTransaction_start','PROCEDURE','juan@77.227.99.220','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myticket_logaccess','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myorder_newwithdate','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myorder_newwithaddress','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myclient_getdebt','FUNCTION','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myOrder_configure','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myUser_hasRoleId','FUNCTION','jenkins@172.16.255.34','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myUser_checkLogin','FUNCTION','jenkins@172.16.255.34','Execute','2022-08-03 23:44:43'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','lang','FUNCTION','juan@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','grafana','firstdayofmonth','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','addAccountReconciliation','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','buy_getVolumeByEntry','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_getVolumeByEntry','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','entry_moveNotPrinted','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_getVolume','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','stockbuyedbyworker','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_getsplit','PROCEDURE','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','subordinategetlist','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_afterUpsert','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','grafana','dayend','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','srt','production','buffer_settypebyname','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buyUltimate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','buyUltimate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','barcodeToItem','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','ticket_splititempackingtype','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','entry_getCommission','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','deliveryAssistant','expeditionstate_addbypallet','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','mail_insert','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','entry_fixMisfit','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','VN_CURDATE','FUNCTION','juan@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','marketingBoss','clientTaxArea','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','clientTaxArea','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','client_checkBalance','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','absoluteInventoryHistory','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesPerson','client_getSalesPersonByTicket','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','pbx','developer','clientFromPhone','FUNCTION','juan@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','production','log_addWithUser','PROCEDURE','juan@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','adminBoss','balanceNestTree_addChild','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','adminBoss','balanceNestTree_delete','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','adminBoss','balanceNestTree_move','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','company_getSuppliersDebt','PROCEDURE','jgallego@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','multipleInventoryHistory','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','bi','salesAssistant','defaultersFromDate','PROCEDURE','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','buy_updatepacking','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','buy_updategrouping','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','item_comparative','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','entryEditor','item_getVolume','FUNCTION','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','clientgetmana','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_scan','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','client_getSalesPersonByTicket','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','client_create','PROCEDURE','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','entryEditor','entry_isintrastat','FUNCTION','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','manager','collection_make','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','android','debugadd','PROCEDURE','jenkins@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','copyComponentsFromSaleList','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaEntryValueUpdate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaInvoiceInBooking','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelvinglog_get','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expedition_getstate','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','srt','production','expedition_scan','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','productionBoss','saleSplit','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana','client_getDebt','FUNCTION','guillermo@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','client_getDebt','PROCEDURE','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','tx_commit','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','cooler','buyultimate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','grafana','firstdayofyear','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','claimManager','dayend','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','employee','log_add','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','srt','employee','moving_between','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','bi','financial','defaultersfromdate','PROCEDURE','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','getuser','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','hasanynegativebase','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','marketingBoss','hasanynegativebase','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','hassomenegativebase','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','administrative','accountshorttostandard','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana','lastdayofweek','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','creditInsurance_GetRisk','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','marketingBoss','invoicefromclient','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','invoicefromclient','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','invoicefromticket','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','invoiceindueday_calculate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','invoiceindueday_calculate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','entry_splitbyshelving','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','invoiceintaxmakebydua','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','invoiceintax_getfromentries','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','invoiceintax_getfromentries','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','marketingBoss','invoiceoutbooking','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','invoiceoutbooking','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','clienttaxarea','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_add','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','invoicefromclient','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','hasanynegativebase','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','invoiceserial','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','invoiceserial','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','VN_CURTIME','FUNCTION','juan@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaTaxBooking','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','adminBoss','invoiceout_newfromclient','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','invoiceout_newfromticket','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','marketingBoss','invoiceserial','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','clientgetmana','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','packingsite_startcollection','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','invoiceoutbooking','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','ticket_gettax','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','productionAssi','midnight','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','dipole','employee','expedition_add','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','ticketstateupdate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','coolerBoss','itempacking','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesPerson','ticket_clone','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','cache','employee','available_refresh','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','ticket_clone','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','coolerBoss','ticket_clone','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','payment_add','PROCEDURE','jgallego@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','timebusiness_calculatebyuser','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','itemsale_byweek','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','itemsale_byweek','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','timecontrol_calculatebyuser','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','ticket_clone','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','timecontrol_calculateall','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','manager','midnight','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','timebusiness_calculateall','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','cache','buyer','last_buy_refresh','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','supplierpackaging_reportsource','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','cache','buyer','stock_refresh','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','itemshelvingproblem','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','itemshelvingradar','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','cache','employee','visible_refresh','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','grafana','quarterfirstday','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','workertimecontrol_sendmailbydepartment','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','agency','item_getStock','PROCEDURE','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','employee','debugadd','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','buyer','dayend','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','invoiceindueday_calculate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','invoiceintax_getfromentries','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_get','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','zone_getstate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','worker_gethierarchy','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','workertimecontrol_weekcheckbreak','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','ticket_split','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','agency','agencyVolume','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','saletracking_new','PROCEDURE','alexm@pc325.algemesi.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','ticketnotinvoicedbyclient','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','coolerBoss','workerjourney_replace','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','artificialBoss','workerjourney_replace','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','workerjourney_replace','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','item_getinfo','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','item_getlack','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','workerjourney_replace','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','item_getpackage','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','workerdisable','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','client_getDebt','FUNCTION','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','developer','ticket_add','PROCEDURE','jenkins@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','workercalendar_calculateyear','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','workercalendar_calculatebusiness','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','ticketparking_findskipped','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','ticketcollection_getnopacked','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','supplier_checkbalance','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','item_valuateinventory','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','ledger_docompensation','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','ledger_next','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','invoicein_booking','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','supplierpackaging_reportsource','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','logshow','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyerBoss','supplierpackaging_reportsource','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financialBoss','supplierexpenses','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana','firstdayofweek','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','stockbuyed_add','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','mail_insert','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaParcialMake','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','palletizerBoss','packingsite_startcollection','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','sale_calculatecomponent','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesPerson','manaspellersrequery','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','adminBoss','packageinvoicing','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','packinglistswitch','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','previoussticker_get','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','productioncontrol','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','productionsectorlist','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','routemonitor_calculate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','account','developer','user_haspriv','FUNCTION','jgallego@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','salegroup_add','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','salepreparinglist','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','zone_getLanded','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','saletracking_del','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','manager','ekt_getEntry','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaTax_doRecalc','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','ticketGetTotal','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','adminBoss','tickettoinvoicebyaddress','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','ticket_canmerge','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','tickettotalvolume','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','tickettotalvolumeboxes','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','subordinategetlist','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','entry_clone','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myuser_haspriv','FUNCTION','jgallego@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','coolerAssist','ticket_canmerge','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','ticket_cloneweekly','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','ticket_closebyticket','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','ticket_getfromfloramondo','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','ticket_get','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','artificialBoss','ticket_getfromfloramondo','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','ticket_getfromfloramondo','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','ticket_getsplitlist','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','adminBoss','ticket_gettax','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','entryEditor','entry_lock','PROCEDURE','guillermo@10.5.1.4','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','account','developerBoss','role_syncPrivileges','PROCEDURE','juan@10.5.1.1','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','ticket_recalccomponents','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','entryDelivered','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','coolerBoss','ticket_splitpackingcomplete','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myuser_hasroutinepriv','FUNCTION','jgallego@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','productionAssi','timebusiness_calculateall','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','timecontrol_geterror','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','travel_weeklyclone','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_recalcPricesByBuy','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','handmadeBoss','confection_controlSource','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','bi','productionAssi','rutasanalyze','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','productionPlus','workerCreateExternal','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','productionAssi','confection_controlSource','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','VN_NOW','FUNCTION','juan@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','VN_UNIX_TIMESTAMP','FUNCTION','juan@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','VN_UTC_DATE','FUNCTION','juan@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','VN_UTC_TIME','FUNCTION','juan@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','VN_UTC_TIMESTAMP','FUNCTION','juan@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_getsaledate','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','ticket_setState','PROCEDURE','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','invoicing','invoiceout_new','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','sale_replaceItem','PROCEDURE','jgallego@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','ledger_next','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','deliveryAssistant','workerjourney_replace','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','account','developerBoss','role_sync','PROCEDURE','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','deliveryAssistant','ticket_weightdeclaration','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','clientPackagingOverstock','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','clientPackagingOverstockReturn','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_filterbuyer','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','deliveryAssistant','dayend','FUNCTION','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','deliveryAssistant','routeproposal','FUNCTION','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','account','developer','user_hasroutinepriv','FUNCTION','jgallego@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','account','grafana','user_hasRole','FUNCTION','jgallego@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','time_generate','PROCEDURE','jenkins@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_addbyclaim','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelvingtransfer','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_addlist','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_selfconsumption','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','item_getsimilar','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelvingsale_add','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','collection_printsticker','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','deviceproductionuser_getworker','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','ticket_printlabelprevious','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','ticket_isoutclosurezone','FUNCTION','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','workermachinery_isregistered','FUNCTION','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','ticketstatetoday_setstate','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','device_checklogin','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','worker_getfromhasmistake','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','sectorcollection_new','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','sectorcollection_get','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','setparking','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','shelvingparking_get','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','machine_getworkerplate','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','saletracking_addprevok','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','sectorcollectionsalegroup_add','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','saletracking_updateischecked','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','saletracking_addpreparedsalegroup','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','travel_updatepacking','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','freelance_getinfo','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','company_getfiscaldata','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expedition_getfromroute','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','machineworker_gethistorical','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemplacementsupplyaiming','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionstate_addbypallet','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','srt','production','expeditionloading_add','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionpallet_list','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionpallet_printlabel','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionpallet_view','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionscan_add','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionscan_list','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionscan_put','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','cmrpallet_add','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemtrash','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','item_getbalance','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expedition_checkroute','FUNCTION','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','addnotefromdelivery','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','client_getSalesPerson','FUNCTION','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','buy_updatepacking','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','buy_updategrouping','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','srt','delivery','buffer_settypebyname','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expedition_getstate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','srt','delivery','expedition_scan','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_get','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelvinglog_get','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_getsaledate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_filterbuyer','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_addbyclaim','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelvingtransfer','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_addlist','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_selfconsumption','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','item_getsimilar','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelvingsale_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','collection_printsticker','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','deviceproductionuser_getworker','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','ticket_printlabelprevious','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','ticket_isoutclosurezone','FUNCTION','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','workermachinery_isregistered','FUNCTION','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','ticketstatetoday_setstate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','device_checklogin','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','worker_getfromhasmistake','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','sectorcollection_new','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','sectorcollection_get','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','setparking','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','shelvingparking_get','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','machine_getworkerplate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','saletracking_addprevok','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','sectorcollectionsalegroup_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','saletracking_updateischecked','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','saletracking_addpreparedsalegroup','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','travel_updatepacking','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','freelance_getinfo','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','company_getfiscaldata','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expedition_getfromroute','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','machineworker_gethistorical','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemplacementsupplyaiming','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionstate_addbypallet','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','srt','delivery','expeditionloading_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionpallet_list','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionpallet_printlabel','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionpallet_view','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionscan_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionscan_list','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionscan_put','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','cmrpallet_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemtrash','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','item_getbalance','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expedition_checkroute','FUNCTION','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','addnotefromdelivery','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelving_getinfo','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemShelving_getinfo','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','collection_get','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','item_comparative','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','sale_getBoxPickingList','PROCEDURE','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','worker_isInDepartment','FUNCTION','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','tx_rollback','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','tx_start','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_recalcPrices','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_recalcPricesByAwb','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_recalcPricesByEntry','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','hr','accountNumberToIban','FUNCTION','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','financial','accountNumberToIban','FUNCTION','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','supplier_statement','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','supplier_statement','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hrBoss','supplier_statement','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','adminBoss','XDiario_check','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','travel_getDetailFromContinent','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','entry_getTransfer','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','entry_getTransfer','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','intrastat_estimateNet','FUNCTION','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','artificialBoss','confection_controlSource','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','remittance_calc','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','util','developer','connection_kill','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','client_getRisk','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana','item_ValuateInventory','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financialBoss','balance_create','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hrBoss','balance_create','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','buy_recalcPricesByEntry','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_recalcPricesByEntry','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','entryEditor','buy_recalcPricesByBuy','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','buy_recalcPricesByBuy','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_recalcPricesByBuy','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','guest','myorder_getavailable','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','guest','myOrder_calcCatalogFull','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myOrder_checkConfig','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myOrder_calcCatalogFromItem','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myOrder_getTax','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','android','log_add','PROCEDURE','jenkins@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','employee','item_listAllocation','PROCEDURE','z-developer@www1.static.verdnatura.es','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','mytpvtransaction_end','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myticket_list','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myTicket_getServices','PROCEDURE','root@10.2.3.180','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myticket_getrows','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myticket_getpackages','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myTicket_get','PROCEDURE','z-sysadmin@172.16.255.34','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myorder_confirm','PROCEDURE','juan@10.5.1.2','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myorder_additem','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','guest','myOrder_configureForGuest','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myOrder_create','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana','zone_getaddresses','PROCEDURE','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','catalog_calcfrommyaddress','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','ext','buy_scan','PROCEDURE','juan@swarm-worker2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myUser_loginWithKey','PROCEDURE','jenkins@172.16.255.34','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myUser_login','PROCEDURE','jenkins@172.16.255.34','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myUser_hasRole','FUNCTION','jenkins@172.16.255.34','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myUser_getName','FUNCTION','jenkins@172.16.255.34','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myUser_getId','FUNCTION','jenkins@172.16.255.34','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','palletizerBoss','midnight','FUNCTION','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','account','account','myUser_logout','PROCEDURE','jenkins@172.16.255.34','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','entryEditor','getinventoryDate','FUNCTION','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana','zone_upcomingdeliveries','PROCEDURE','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','android','vn_now','FUNCTION','jenkins@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','entryEditor','entry_unlock','PROCEDURE','guillermo@10.5.1.4','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','account','zone_getAgency','PROCEDURE','juan@77.228.249.89','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','account','invoiceout_getpath','FUNCTION','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','employee','order_confirm','PROCEDURE','z-developer@www1.static.verdnatura.es','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myTpvTransaction_start','PROCEDURE','juan@77.227.99.220','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myticket_logaccess','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myorder_newwithdate','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myorder_newwithaddress','PROCEDURE','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myclient_getdebt','FUNCTION','root@pc-juan.dyn.verdnatura.es','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','hedera','account','myOrder_configure','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myUser_hasRoleId','FUNCTION','jenkins@172.16.255.34','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myUser_checkLogin','FUNCTION','jenkins@172.16.255.34','Execute','2022-08-03 23:44:43'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','lang','FUNCTION','juan@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','grafana','firstdayofmonth','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','addAccountReconciliation','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','buy_getVolumeByEntry','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_getVolumeByEntry','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','entry_moveNotPrinted','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_getVolume','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','stockbuyedbyworker','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_getsplit','PROCEDURE','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','subordinategetlist','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_afterUpsert','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','grafana','dayend','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','srt','production','buffer_settypebyname','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','barcodeToItem','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','ticket_splititempackingtype','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','entry_getCommission','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','deliveryAssistant','expeditionstate_addbypallet','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','ledger_nextTx','PROCEDURE','guillermo@10.5.1.3','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','mail_insert','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','entry_fixMisfit','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','entry_updateComission','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','VN_CURDATE','FUNCTION','juan@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','marketingBoss','clientTaxArea','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','clientTaxArea','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','client_checkBalance','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','absoluteInventoryHistory','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesPerson','client_getSalesPersonByTicket','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','pbx','developer','clientFromPhone','FUNCTION','juan@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','production','log_addWithUser','PROCEDURE','juan@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','adminBoss','balanceNestTree_addChild','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','adminBoss','balanceNestTree_delete','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','adminBoss','balanceNestTree_move','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','company_getSuppliersDebt','PROCEDURE','jgallego@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','multipleInventoryHistory','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','bi','salesAssistant','defaultersFromDate','PROCEDURE','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','buy_updatepacking','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','buy_updategrouping','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','item_comparative','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','entryEditor','item_getVolume','FUNCTION','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','clientgetmana','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_scan','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','client_getSalesPersonByTicket','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','client_create','PROCEDURE','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','entryEditor','entry_isintrastat','FUNCTION','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','manager','collection_make','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','android','debugadd','PROCEDURE','jenkins@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','copyComponentsFromSaleList','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaEntryValueUpdate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaInvoiceInBooking','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelvinglog_get','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expedition_getstate','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','srt','production','expedition_scan','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','productionBoss','saleSplit','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana','client_getDebt','FUNCTION','guillermo@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','client_getDebt','PROCEDURE','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','tx_commit','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','grafana','firstdayofyear','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','claimManager','dayend','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','employee','log_add','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','srt','employee','moving_between','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','bi','financial','defaultersfromdate','PROCEDURE','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','getuser','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','hasanynegativebase','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','marketingBoss','hasanynegativebase','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','hassomenegativebase','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','administrative','accountshorttostandard','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana','lastdayofweek','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','creditInsurance_GetRisk','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','marketingBoss','invoicefromclient','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','invoicefromclient','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','invoicefromticket','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','invoiceindueday_calculate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','invoiceindueday_calculate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','entry_splitbyshelving','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','invoiceintaxmakebydua','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','invoiceintax_getfromentries','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','invoiceintax_getfromentries','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','marketingBoss','invoiceoutbooking','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','invoiceoutbooking','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','clienttaxarea','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_add','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','invoicefromclient','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','hasanynegativebase','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','invoiceserial','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','invoiceserial','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','VN_CURTIME','FUNCTION','juan@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaTaxBooking','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','adminBoss','invoiceout_newfromclient','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','invoiceout_newfromticket','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','marketingBoss','invoiceserial','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','clientgetmana','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','packingsite_startcollection','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','invoiceoutbooking','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','ticket_gettax','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','productionAssi','midnight','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','dipole','employee','expedition_add','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_transfer','PROCEDURE','alexm@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','coolerBoss','itempacking','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesPerson','ticket_clone','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','cache','employee','available_refresh','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','ticket_clone','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','coolerBoss','ticket_clone','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','payment_add','PROCEDURE','jgallego@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','timebusiness_calculatebyuser','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','itemsale_byweek','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','itemsale_byweek','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','timecontrol_calculatebyuser','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','ticket_clone','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','timecontrol_calculateall','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','manager','midnight','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','timebusiness_calculateall','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','cache','buyer','last_buy_refresh','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','supplierpackaging_reportsource','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','cache','buyer','stock_refresh','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','itemshelvingproblem','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','itemshelvingradar','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','cache','employee','visible_refresh','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','grafana','quarterfirstday','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','workertimecontrol_sendmailbydepartment','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','agency','item_getStock','PROCEDURE','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','employee','debugadd','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','buyer','dayend','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','invoiceindueday_calculate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','invoiceintax_getfromentries','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_get','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','zone_getstate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','worker_gethierarchy','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','workertimecontrol_weekcheckbreak','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','ticket_split','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','agency','agencyVolume','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','saletracking_new','PROCEDURE','alexm@pc325.algemesi.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','ticketnotinvoicedbyclient','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','coolerBoss','workerjourney_replace','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','artificialBoss','workerjourney_replace','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','workerjourney_replace','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','item_getinfo','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','item_getlack','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','workerjourney_replace','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','item_getpackage','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','workerdisable','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','client_getDebt','FUNCTION','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','developer','ticket_add','PROCEDURE','jenkins@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','workercalendar_calculateyear','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','workercalendar_calculatebusiness','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','ticketparking_findskipped','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','ticketcollection_getnopacked','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','supplier_checkbalance','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','ledger_docompensation','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','ledger_next','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','invoicein_booking','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','supplierpackaging_reportsource','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','logshow','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyerBoss','supplierpackaging_reportsource','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financialBoss','supplierexpenses','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana','firstdayofweek','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','stockbuyed_add','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','mail_insert','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaParcialMake','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','palletizerBoss','packingsite_startcollection','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','sale_calculatecomponent','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesPerson','manaspellersrequery','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','packinglistswitch','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','previoussticker_get','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','productioncontrol','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','productionsectorlist','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','routemonitor_calculate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','account','developer','user_haspriv','FUNCTION','jgallego@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','salegroup_add','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','salepreparinglist','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','zone_getLanded','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','saletracking_del','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','manager','ekt_getEntry','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaTax_doRecalc','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','ticketGetTotal','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','adminBoss','tickettoinvoicebyaddress','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','ticket_canmerge','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','tickettotalvolume','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','tickettotalvolumeboxes','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','subordinategetlist','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','entry_clone','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myuser_haspriv','FUNCTION','jgallego@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','coolerAssist','ticket_canmerge','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','ticket_cloneweekly','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','ticket_closebyticket','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','ticket_getfromfloramondo','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','ticket_get','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','artificialBoss','ticket_getfromfloramondo','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','ticket_getfromfloramondo','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','ticket_getsplitlist','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','adminBoss','ticket_gettax','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','entryEditor','entry_lock','PROCEDURE','guillermo@10.5.1.4','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','account','developerBoss','role_syncPrivileges','PROCEDURE','juan@10.5.1.1','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','ticket_recalccomponents','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','entryDelivered','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','coolerBoss','ticket_splitpackingcomplete','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','account','guest','myuser_hasroutinepriv','FUNCTION','jgallego@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','productionAssi','timebusiness_calculateall','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','timecontrol_geterror','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','logistic','travel_weeklyclone','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_recalcPricesByBuy','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','handmadeBoss','confection_controlSource','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','bi','productionAssi','rutasanalyze','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','productionPlus','workerCreateExternal','PROCEDURE','juan@10.5.1.2','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','productionAssi','confection_controlSource','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','VN_NOW','FUNCTION','juan@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','VN_UNIX_TIMESTAMP','FUNCTION','juan@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','VN_UTC_DATE','FUNCTION','juan@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','VN_UTC_TIME','FUNCTION','juan@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','VN_UTC_TIMESTAMP','FUNCTION','juan@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_getsaledate','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','ticket_setState','PROCEDURE','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','invoicing','invoiceout_new','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','sale_replaceItem','PROCEDURE','jgallego@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','ledger_next','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','deliveryAssistant','workerjourney_replace','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','account','developerBoss','role_sync','PROCEDURE','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','deliveryAssistant','ticket_weightdeclaration','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','clientPackagingOverstock','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','clientPackagingOverstockReturn','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_filterbuyer','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','deliveryAssistant','dayend','FUNCTION','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','deliveryAssistant','routeproposal','FUNCTION','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','account','developer','user_hasroutinepriv','FUNCTION','jgallego@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','account','grafana','user_hasRole','FUNCTION','jgallego@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','time_generate','PROCEDURE','jenkins@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_addbyclaim','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_addByCollection','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_addlist','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_selfconsumption','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','cooler','item_getSimilar','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelvingsale_add','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','collection_printsticker','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','deviceproductionuser_getworker','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','ticket_printlabelprevious','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','ticket_isoutclosurezone','FUNCTION','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','workermachinery_isregistered','FUNCTION','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','ticketstatetoday_setstate','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','device_checklogin','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','worker_getfromhasmistake','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','sectorcollection_new','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','sectorcollection_get','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','setparking','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','shelvingparking_get','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','machine_getworkerplate','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','saletracking_addprevok','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','sectorcollectionsalegroup_add','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','saletracking_updateischecked','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','saletracking_addpreparedsalegroup','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','travel_updatepacking','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','freelance_getinfo','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','company_getfiscaldata','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expedition_getfromroute','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','machineworker_gethistorical','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemplacementsupplyaiming','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionstate_addbypallet','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','srt','production','expeditionloading_add','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionpallet_list','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionpallet_printlabel','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionpallet_view','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionscan_add','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionscan_list','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionscan_put','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','cmrpallet_add','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','item_getbalance','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expedition_checkroute','FUNCTION','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','addnotefromdelivery','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','client_getSalesPerson','FUNCTION','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','buy_updatepacking','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','buy_updategrouping','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','srt','delivery','buffer_settypebyname','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expedition_getstate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','srt','delivery','expedition_scan','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_get','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelvinglog_get','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_getsaledate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_filterbuyer','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_addbyclaim','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_addlist','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_selfconsumption','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','reviewer','item_getSimilar','PROCEDURE','guillermo@10.5.1.6','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelvingsale_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','collection_printsticker','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','deviceproductionuser_getworker','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','ticket_printlabelprevious','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','ticket_isoutclosurezone','FUNCTION','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','workermachinery_isregistered','FUNCTION','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','ticketstatetoday_setstate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','device_checklogin','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','worker_getfromhasmistake','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','sectorcollection_new','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','sectorcollection_get','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','setparking','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','shelvingparking_get','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','machine_getworkerplate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','saletracking_addprevok','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','sectorcollectionsalegroup_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','saletracking_updateischecked','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','saletracking_addpreparedsalegroup','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','travel_updatepacking','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','freelance_getinfo','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','company_getfiscaldata','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expedition_getfromroute','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','machineworker_gethistorical','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemplacementsupplyaiming','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionstate_addbypallet','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','srt','delivery','expeditionloading_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionpallet_list','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionpallet_printlabel','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionpallet_view','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionscan_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionscan_list','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionscan_put','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','cmrpallet_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','item_getbalance','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expedition_checkroute','FUNCTION','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','addnotefromdelivery','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelving_getinfo','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemShelving_getinfo','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','collection_get','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','item_comparative','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','sale_getBoxPickingList','PROCEDURE','guillermo@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','worker_isInDepartment','FUNCTION','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','tx_rollback','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','tx_start','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_recalcPrices','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_recalcPricesByAwb','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_recalcPricesByEntry','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','hr','accountNumberToIban','FUNCTION','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','financial','accountNumberToIban','FUNCTION','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','supplier_statementWithEntries','PROCEDURE','guillermo@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','adminBoss','XDiario_check','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','travel_getDetailFromContinent','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','entry_getTransfer','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','entry_getTransfer','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','intrastat_estimateNet','FUNCTION','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','artificialBoss','confection_controlSource','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','remittance_calc','PROCEDURE','alexm@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','util','developer','connection_kill','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','client_getRisk','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','account','developer','user_hasRole','FUNCTION','root@localhost','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financialBoss','balance_create','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hrBoss','balance_create','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','buy_recalcPricesByEntry','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_recalcPricesByEntry','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','entryEditor','buy_recalcPricesByBuy','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','buy_recalcPricesByBuy','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_recalcPricesByBuy','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_addBySaleGroup','PROCEDURE','alexm@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','ledger_nextTx','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','ledger_docompensation','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_setQuantity','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_unpicked','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','collection_getAssigned','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','collection_addWithReservation','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_addBySectorCollection','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','sectorCollection_hasSalesReserved','FUNCTION','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_reallocate','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_setPicked','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','sectorCollection_getMyPartial','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana-write','item_ValuateInventory','PROCEDURE','guillermo@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','guest','ticketCalculatePurge','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_getUltimate','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','cooler','buy_getUltimate','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','bs','buyerBoss','waste_addSales','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','bs','grafana','waste_addSales','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); /*!40000 ALTER TABLE `procs_priv` ENABLE KEYS */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -2073,74 +2219,78 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_recalcPricesByB /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; USE `mysql`; +/*M!999999\- enable the sandbox mode */ /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; /*!40000 ALTER TABLE `global_priv` DISABLE KEYS */; -INSERT IGNORE INTO `global_priv` VALUES ('','account','{\"access\": 0, \"is_role\": true,\"version_id\":100707}'); -INSERT IGNORE INTO `global_priv` VALUES ('','adminBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','adminOfficer','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','administrative','{\"access\": 0, \"is_role\": true, \"version_id\": 101106}'); -INSERT IGNORE INTO `global_priv` VALUES ('','agency','{\"access\": 0, \"max_questions\": 40000, \"max_updates\": 1000, \"max_connections\": 20000, \"max_user_connections\": 50, \"max_statement_time\": 0.000000, \"is_role\": true,\"version_id\":101106}'); -INSERT IGNORE INTO `global_priv` VALUES ('','android','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','artificialBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','assetManager','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','buyer','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','buyerAssistant','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','buyerBoss','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','claimManager','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','cooler','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','coolerAssist','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','coolerBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','customer','{\"access\": 0, \"max_questions\": 0, \"max_updates\": 30000, \"max_connections\": 300000, \"max_user_connections\": 400, \"max_statement_time\": 0.000000, \"is_role\": true,\"version_id\":100707}'); -INSERT IGNORE INTO `global_priv` VALUES ('','delivery','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','deliveryAssistant','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','deliveryBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','developer','{\"access\": 5909905728, \"is_role\": true, \"version_id\": 101106}'); -INSERT IGNORE INTO `global_priv` VALUES ('','developerBoss','{\"access\":33554432,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','employee','{\"access\": 0, \"is_role\": true, \"version_id\": 101106}'); -INSERT IGNORE INTO `global_priv` VALUES ('','entryEditor','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','ext','{\"access\": 0, \"is_role\": true, \"version_id\": 100707}'); -INSERT IGNORE INTO `global_priv` VALUES ('','financial','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','financialBoss','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','floranet','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','grafana','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','greenhouseBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','guest','{\"access\": 0, \"max_questions\": 40000, \"max_updates\": 1000, \"max_connections\": 150000, \"max_user_connections\": 200, \"max_statement_time\": 0.000000, \"is_role\": true, \"version_id\": 101106}'); -INSERT IGNORE INTO `global_priv` VALUES ('','handmadeBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','hedera-web','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','hr','{\"access\": 0, \"is_role\": true, \"version_id\": 101106}'); -INSERT IGNORE INTO `global_priv` VALUES ('','hrBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','invoicing','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','itBoss','{\"access\": 541165846527, \"is_role\": true, \"version_id\": 100707}'); -INSERT IGNORE INTO `global_priv` VALUES ('','itManagement','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','itemPicker','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','logistic','{\"access\": 0, \"is_role\": true, \"version_id\": 101106}'); -INSERT IGNORE INTO `global_priv` VALUES ('','logisticAssist','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','logisticBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','maintenance','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','maintenanceBos','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','maintenanceBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','manager','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','marketing','{\"access\": 0, \"is_role\": true,\"version_id\":101106}'); -INSERT IGNORE INTO `global_priv` VALUES ('','marketingBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','officeBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','packager','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','palletizer','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','palletizerBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','preservedBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','production','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','productionAssi','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','productionBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','productionPlus','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','root','{\"access\": 549755781119, \"version_id\": 100705, \"is_role\": true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','salesAssistant','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','salesBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','salesPerson','{\"access\": 0, \"is_role\": true,\"version_id\":101106}'); -INSERT IGNORE INTO `global_priv` VALUES ('','salesTeamBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','salix','{\"access\":33555456,\"version_id\":100707,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','sysadmin','{\"access\": 201326592, \"is_role\": true, \"version_id\": 100707}'); +INSERT IGNORE INTO `global_priv` VALUES ('','account','{\"access\": 0, \"is_role\": true,\"version_id\":100707}'); +INSERT IGNORE INTO `global_priv` VALUES ('','adminBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','adminOfficer','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','administrative','{\"access\": 0, \"is_role\": true, \"version_id\": 101106}'); +INSERT IGNORE INTO `global_priv` VALUES ('','agency','{\"access\": 0, \"max_questions\": 40000, \"max_updates\": 1000, \"max_connections\": 20000, \"max_user_connections\": 50, \"max_statement_time\": 0.000000, \"is_role\": true,\"version_id\":101106}'); +INSERT IGNORE INTO `global_priv` VALUES ('','android','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','artificialBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','assetManager','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','buyer','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','buyerAssistant','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','buyerBoss','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','claimManager','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','cooler','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','coolerAssist','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','coolerBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','customer','{\"access\": 0, \"max_questions\": 0, \"max_updates\": 30000, \"max_connections\": 300000, \"max_user_connections\": 400, \"max_statement_time\": 0.000000, \"is_role\": true,\"version_id\":100707}'); +INSERT IGNORE INTO `global_priv` VALUES ('','delivery','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','deliveryAssistant','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','deliveryBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','developer','{\"access\": 5909905728, \"is_role\": true, \"version_id\": 101106}'); +INSERT IGNORE INTO `global_priv` VALUES ('','developerBoss','{\"access\":33554432,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','employee','{\"access\": 0, \"is_role\": true, \"version_id\": 101106}'); +INSERT IGNORE INTO `global_priv` VALUES ('','entryEditor','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','ext','{\"access\": 0, \"is_role\": true, \"version_id\": 100707}'); +INSERT IGNORE INTO `global_priv` VALUES ('','financial','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','financialBoss','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','floranet','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','grafana','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','grafana-write','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','greenhouseBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','guest','{\"access\": 0, \"max_questions\": 40000, \"max_updates\": 1000, \"max_connections\": 150000, \"max_user_connections\": 200, \"max_statement_time\": 0.000000, \"is_role\": true, \"version_id\": 101106}'); +INSERT IGNORE INTO `global_priv` VALUES ('','handmadeBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','hedera-web','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','hr','{\"access\": 0, \"is_role\": true, \"version_id\": 101106}'); +INSERT IGNORE INTO `global_priv` VALUES ('','hrBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','invoicing','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','itBoss','{\"access\": 541165846527, \"is_role\": true, \"version_id\": 100707}'); +INSERT IGNORE INTO `global_priv` VALUES ('','itManagement','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','itemPicker','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','logistic','{\"access\": 0, \"is_role\": true, \"version_id\": 101106}'); +INSERT IGNORE INTO `global_priv` VALUES ('','logisticAssist','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','logisticBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','maintenance','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','maintenanceBos','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','maintenanceBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','manager','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','marketing','{\"access\": 0, \"is_role\": true,\"version_id\":101106}'); +INSERT IGNORE INTO `global_priv` VALUES ('','marketingBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','officeBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','packager','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','palletizer','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','palletizerBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','preservedBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','production','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','productionAssi','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','productionBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','productionPlus','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','reviewer','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','root','{\"access\": 549755781119, \"version_id\": 100705, \"is_role\": true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','salesAssistant','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','salesBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','salesPerson','{\"access\": 0, \"is_role\": true,\"version_id\":101106}'); +INSERT IGNORE INTO `global_priv` VALUES ('','salesTeamBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','salix','{\"access\":33555456,\"version_id\":100707,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','sysadmin','{\"access\": 201326592, \"is_role\": true, \"version_id\": 100707}'); +INSERT IGNORE INTO `global_priv` VALUES ('','teamBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); /*!40000 ALTER TABLE `global_priv` ENABLE KEYS */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; diff --git a/db/dump/.dump/structure.sql b/db/dump/.dump/structure.sql index 1cb5c2964..0bd03ac32 100644 --- a/db/dump/.dump/structure.sql +++ b/db/dump/.dump/structure.sql @@ -1,4 +1,5 @@ --- MariaDB dump 10.19 Distrib 10.5.23-MariaDB, for debian-linux-gnu (x86_64) +/*M!999999\- enable the sandbox mode */ +-- MariaDB dump 10.19 Distrib 10.5.26-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: account -- ------------------------------------------------------ @@ -75,13 +76,13 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `accountLog` +-- Table structure for table `accountLog__` -- -DROP TABLE IF EXISTS `accountLog`; +DROP TABLE IF EXISTS `accountLog__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `accountLog` ( +CREATE TABLE `accountLog__` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `msg` varchar(255) NOT NULL, `pid` varchar(255) NOT NULL, @@ -89,8 +90,9 @@ CREATE TABLE `accountLog` ( `host` varchar(255) NOT NULL, `rhost` varchar(255) NOT NULL, `time` varchar(255) NOT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='@deprecated 2024-09-02 refs #7819'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -156,11 +158,14 @@ CREATE TABLE `mailAliasAccount` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `mailAlias` int(10) unsigned NOT NULL, `account` int(10) unsigned NOT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `mailAlias` (`mailAlias`,`account`), KEY `account` (`account`), + KEY `mailAliasAccount_editorFk` (`editorFk`), CONSTRAINT `account` FOREIGN KEY (`account`) REFERENCES `account` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `mailAlias` FOREIGN KEY (`mailAlias`) REFERENCES `mailAlias` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `mailAlias` FOREIGN KEY (`mailAlias`) REFERENCES `mailAlias` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `mailAliasAccount_editorFk` FOREIGN KEY (`editorFk`) REFERENCES `user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Mail alias that is assigned to each account'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -181,23 +186,6 @@ CREATE TABLE `mailAliasAcl` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `mailClientAccess__` --- - -DROP TABLE IF EXISTS `mailClientAccess__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `mailClientAccess__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `client` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL, - `action` set('OK','REJECT') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT 'REJECT', - `description` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `mailFrom` (`client`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='@deprecated 2023-09-03'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `mailConfig` -- @@ -231,23 +219,6 @@ CREATE TABLE `mailForward` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Mail forwarding'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `mailSenderAccess__` --- - -DROP TABLE IF EXISTS `mailSenderAccess__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `mailSenderAccess__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `sender` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL, - `action` set('OK','REJECT') NOT NULL DEFAULT 'REJECT', - `description` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `mailFrom` (`sender`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='@deprecated 2023-09-03'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `myRole` -- @@ -361,10 +332,12 @@ CREATE TABLE `roleLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `roleLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), KEY `roleLog_originFk` (`originFk`,`creationDate`), + KEY `roleLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `roleLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -420,6 +393,7 @@ CREATE TABLE `signInLog` ( `userName` varchar(30) NOT NULL, `ip` varchar(100) NOT NULL, `owner` tinyint(1) DEFAULT 1, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), CONSTRAINT `signInLog_ibfk_1` FOREIGN KEY (`userFk`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -449,7 +423,6 @@ CREATE TABLE `user` ( `created` timestamp NOT NULL DEFAULT current_timestamp(), `updated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `image` varchar(255) DEFAULT NULL, - `password__` char(64) NOT NULL COMMENT 'Deprecated', `recoverPass` tinyint(3) unsigned NOT NULL DEFAULT 1 COMMENT 'Deprecated', `sync` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Deprecated', `hasGrant` tinyint(1) NOT NULL, @@ -504,10 +477,12 @@ CREATE TABLE `userLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `userLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), KEY `userLog_originFk` (`originFk`,`creationDate`), + KEY `userLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `userLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -2284,23 +2259,6 @@ CREATE TABLE `Greuge_comercial_recobro` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `Greuges_comercial_detail` --- - -DROP TABLE IF EXISTS `Greuges_comercial_detail`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Greuges_comercial_detail` ( - `Id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Id_Trabajador` int(10) unsigned NOT NULL, - `Comentario` varchar(45) NOT NULL, - `Importe` decimal(10,2) NOT NULL, - `Fecha` datetime DEFAULT NULL, - PRIMARY KEY (`Id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci ROW_FORMAT=COMPACT; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `Ticket_Portes` -- @@ -2411,27 +2369,6 @@ CREATE TABLE `analisis_ventas_almacen_evolution` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `analisis_ventas_familia_evolution__` --- - -DROP TABLE IF EXISTS `analisis_ventas_familia_evolution__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `analisis_ventas_familia_evolution__` ( - `semana` int(11) NOT NULL, - `familia` varchar(50) NOT NULL, - `ventas` int(11) NOT NULL, - `año` int(11) NOT NULL, - `periodo` int(11) NOT NULL, - `typeFk` smallint(5) unsigned DEFAULT NULL, - UNIQUE KEY `familia` (`familia`,`periodo`), - KEY `periodo` (`periodo`), - KEY `analisis_ventas_familia_evolution_FK` (`typeFk`), - CONSTRAINT `analisis_ventas_familia_evolution_FK` FOREIGN KEY (`typeFk`) REFERENCES `vn`.`itemType` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #5196 Deprecated 2023-06-05'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `analisis_ventas_provincia_evolution` -- @@ -2653,54 +2590,6 @@ SET character_set_client = utf8; 1 AS `Consumo` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `live_counter__` --- - -DROP TABLE IF EXISTS `live_counter__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `live_counter__` ( - `odbc_date` timestamp NOT NULL DEFAULT current_timestamp(), - `amount` double NOT NULL, - PRIMARY KEY (`odbc_date`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #5744 Deprecated 2023-06-06'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `partitioning_information__` --- - -DROP TABLE IF EXISTS `partitioning_information__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `partitioning_information__` ( - `schema_name` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `table_name` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `date_field` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `table_depending` varchar(15) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `execution_order` tinyint(3) unsigned NOT NULL, - PRIMARY KEY (`schema_name`,`table_name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #5744 Deprecated 2023-06-06'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `primer_pedido__` --- - -DROP TABLE IF EXISTS `primer_pedido__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `primer_pedido__` ( - `Id_Cliente` int(11) NOT NULL, - `Id_Ticket` int(11) NOT NULL, - `month` tinyint(1) NOT NULL, - `year` smallint(2) NOT NULL, - `total` decimal(10,2) NOT NULL DEFAULT 0.00, - PRIMARY KEY (`Id_Cliente`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #5744 Deprecated 2023-06-06'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `rotacion` -- @@ -2734,26 +2623,13 @@ CREATE TABLE `rutasBoard` ( `id` int(11) NOT NULL AUTO_INCREMENT, `Id_Ruta` int(10) unsigned NOT NULL DEFAULT 0, `Id_Agencia` int(11) NOT NULL DEFAULT 0, - `km__` varchar(9) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT '@deprecated 2023-11-01, refs #6087', - `Dia__` varchar(9) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT '@deprecated 2023-11-01, refs #6087', `Fecha` date NOT NULL, - `Terceros__` int(11) DEFAULT NULL COMMENT '@deprecated 2023-11-01, refs #6087', `Bultos` int(11) NOT NULL DEFAULT 0, - `Matricula__` varchar(10) DEFAULT NULL COMMENT '@deprecated 2023-11-01, refs #6087', - `Tipo__` varchar(1) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT '@deprecated 2023-11-01, refs #6087', - `year__` int(4) DEFAULT NULL COMMENT '@deprecated 2023-11-01, refs #6087', - `month__` int(2) DEFAULT NULL COMMENT '@deprecated 2023-11-01, refs #6087', - `warehouse_id__` smallint(5) unsigned DEFAULT NULL COMMENT '@deprecated 2023-11-01, refs #6087', - `coste_bulto__` decimal(10,2) unsigned DEFAULT NULL COMMENT '@deprecated 2023-11-01, refs #6087', `teorico` decimal(10,2) NOT NULL DEFAULT 0.00, `practico` decimal(10,2) NOT NULL DEFAULT 0.00, `greuge` decimal(10,2) NOT NULL DEFAULT 0.00, - `m3__` decimal(10,1) unsigned DEFAULT NULL COMMENT '@deprecated 2023-11-01, refs #6087', PRIMARY KEY (`id`), - UNIQUE KEY `rutasBoard_Ruta` (`Id_Ruta`), - KEY `rutasBoard_ix1` (`year__`), - KEY `rutasBoard_ix2` (`month__`), - KEY `rutasBoard_ix3` (`warehouse_id__`) + UNIQUE KEY `rutasBoard_Ruta` (`Id_Ruta`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Se usa en https://grafana.verdnatura.es/d/c089276b-5ab5-430f-aa76-e5d8e0e7fe2e/analisis-de-volumen-y-rendimiento-por-agencia?orgId=1'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -2790,36 +2666,6 @@ SET character_set_client = utf8; 1 AS `margen` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `tarifa_premisas__` --- - -DROP TABLE IF EXISTS `tarifa_premisas__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tarifa_premisas__` ( - `Id_Premisa` int(11) NOT NULL AUTO_INCREMENT, - `premisa` varchar(45) NOT NULL, - PRIMARY KEY (`Id_Premisa`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #5744 Deprecated 2023-06-06'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `tarifa_warehouse__` --- - -DROP TABLE IF EXISTS `tarifa_warehouse__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tarifa_warehouse__` ( - `Id_Tarifa_Warehouse` int(11) NOT NULL AUTO_INCREMENT, - `warehouse_id` int(11) NOT NULL, - `Id_Premisa` int(11) NOT NULL, - `Valor` double NOT NULL, - PRIMARY KEY (`Id_Tarifa_Warehouse`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #5744 Deprecated 2023-06-06\nAlmacena los valores de gasto por almacen'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Dumping events for database 'bi' -- @@ -3166,185 +3012,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `claim_ratio_routine` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `claim_ratio_routine`() -BEGIN - DECLARE vMonthToRefund INT DEFAULT 4; - - /* - * PAK 2015-11-20 - * Se trata de añadir a la tabla Greuges todos los - * cargos que luego vamos a utilizar para calcular el recobro - */ - - -- Reclamaciones demasiado sensibles - - INSERT INTO vn.greuge(shipped, clientFk, description, - amount, greugeTypeFk, ticketFk) - SELECT c.ticketCreated - , c.clientFk - , concat('Claim ', c.id,' : ', s.concept) - ,round( -1 * ((c.responsibility -1)/4) * s.quantity * - s.price * (100 - s.discount) / 100, 2) - , 4 - , s.ticketFk - FROM vn.sale s - JOIN vn.claimEnd ce ON ce.saleFk = s.id - JOIN vn.claim c ON c.id = ce.claimFk - WHERE ce.claimDestinationFk NOT IN (1,5) - AND NOT ce.isGreuge - AND c.claimStateFk = 3; - - -- Reclamaciones que pasan a Maná - - INSERT INTO vn.greuge(shipped, clientFk, description, - amount, greugeTypeFk, ticketFk) - SELECT c.ticketCreated - , c.clientFk - , concat('Claim_mana ',c.id,' : ', s.concept) - ,round( ((c.responsibility -1)/4) * s.quantity * s.price * (100 - s.discount) / 100, 2) - ,3 - ,s.ticketFk - FROM vn.sale s - JOIN vn.claimEnd ce ON ce.saleFk = s.id - JOIN vn.claim c ON c.id = ce.claimFk - WHERE ce.claimDestinationFk NOT IN (1,5) - AND NOT ce.isGreuge - AND c.claimStateFk = 3 - AND c.isChargedToMana; - - -- Marcamos para no repetir - UPDATE vn.claimEnd ce - JOIN vn.claim c ON c.id = ce.claimFk - SET c.isChargedToMana = TRUE - WHERE ce.claimDestinationFk NOT IN (1,5) - AND NOT ce.isGreuge - AND c.claimStateFk = 3; - - -- Recobros - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; - CREATE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (Id_Ticket)) - SELECT DISTINCT t.id Id_Ticket - FROM vn.saleComponent sc - JOIN vn.sale s ON sc.saleFk = s.id - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.ticketLastState ts ON ts.ticketFk = t.id - JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk - JOIN vn.state st ON st.id = tt.stateFk - WHERE sc.componentFk = 17 - AND sc.isGreuge = 0 - AND t.shipped >= '2016-10-01' - AND t.shipped < util.VN_CURDATE() - AND st.alertLevel >= 3; - - DELETE g.* - FROM vn.greuge g - JOIN tmp.ticket_list t ON g.ticketFk = t.Id_Ticket - WHERE g.greugeTypeFk = 2; - - INSERT INTO vn.greuge(clientFk, description, amount,shipped, - greugeTypeFk, ticketFk) - SELECT t.clientFk - ,concat('recobro ', s.ticketFk), - round(SUM(sc.value*s.quantity),2) - AS dif, - date(t.shipped) - , 2 - ,tt.Id_Ticket - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.id - JOIN vn.saleComponent sc - ON sc.saleFk = s.id AND sc.componentFk = 17 - GROUP BY t.id - HAVING ABS(dif) > 1; - - UPDATE vn.saleComponent sc - JOIN vn.sale s ON s.id = sc.saleFk - JOIN tmp.ticket_list tt ON tt.Id_Ticket = s.ticketFk - SET sc.isGreuge = 1 - WHERE sc.componentFk = 17; - - /* - * Recalculamos la ratio de las reclamaciones, que luego - * se va a utilizar en el recobro - */ - - REPLACE bi.claims_ratio(Id_Cliente, Consumo, Reclamaciones, Ratio, recobro) - SELECT id, 0,0,0,0 - FROM vn.client; - - REPLACE bi.claims_ratio(Id_Cliente, Consumo, Reclamaciones, Ratio, recobro) - SELECT fm.Id_Cliente, 12 * fm.Consumo, Reclamaciones, - round(Reclamaciones / (12*fm.Consumo),4), 0 - FROM bi.facturacion_media_anual fm - LEFT JOIN( - SELECT c.clientFk, round(sum(-1 * ((c.responsibility -1)/4) * - s.quantity * s.price * (100 - s.discount) / 100)) - AS Reclamaciones - FROM vn.sale s - JOIN vn.claimEnd ce ON ce.saleFk = s.id - JOIN vn.claim c ON c.id = ce.claimFk - WHERE ce.claimDestinationFk NOT IN (1,5) - AND c.claimStateFk = 3 - AND c.ticketCreated >= TIMESTAMPADD(YEAR, -1, util.VN_CURDATE()) - GROUP BY c.clientFk - ) claims ON claims.clientFk = fm.Id_Cliente; - - - -- Calculamos el porcentaje del recobro para añadirlo al precio de venta - UPDATE bi.claims_ratio cr - JOIN ( - SELECT clientFk Id_Cliente, IFNULL(SUM(amount), 0) AS Greuge - FROM vn.greuge - WHERE shipped <= util.VN_CURDATE() - GROUP BY clientFk - ) g ON g.Id_Cliente = cr.Id_Cliente - SET recobro = GREATEST(0,round(IFNULL(Greuge, 0) / - (IFNULL(Consumo, 0) * vMonthToRefund / 12 ) ,3)); - - -- Protección neonatos - UPDATE bi.claims_ratio cr - JOIN vn.firstTicketShipped fts ON fts.clientFk = cr.Id_Cliente - SET recobro = 0, Ratio = 0 - WHERE fts.shipped > TIMESTAMPADD(MONTH,-1,util.VN_CURDATE()); - - -- CLIENTE 7983, JULIAN SUAU - UPDATE bi.claims_ratio SET recobro = LEAST(0.05, recobro) WHERE Id_Cliente = 7983; - - -- CLIENTE 4358 - UPDATE bi.claims_ratio SET recobro = GREATEST(0.05, recobro) WHERE Id_Cliente = 4358; - - -- CLIENTE 5523, VERDECORA - UPDATE bi.claims_ratio SET recobro = GREATEST(0.12, recobro) WHERE Id_Cliente = 5523; - - -- CLIENTE 15979, SERVEIS VETERINARIS - UPDATE bi.claims_ratio SET recobro = GREATEST(0.05, recobro) WHERE Id_Cliente = 15979; - - -- CLIENTE 5189 i 8942, son de CSR i son el mateix client - UPDATE bi.claims_ratio cr - JOIN (SELECT sum(Consumo * recobro)/sum(Consumo) as recobro - FROM bi.claims_ratio - WHERE Id_Cliente IN ( 5189,8942) - ) sub - SET cr.recobro = sub.recobro - WHERE Id_Cliente IN ( 5189,8942); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clean` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -3912,7 +3579,7 @@ BEGIN JOIN vn.saleComponent sc ON sc.saleFk = s.id JOIN vn.component c ON c.id = sc.componentFk JOIN vn.componentType ct ON ct.id = c.typeFk - WHERE ct.code = 'FREIGHT' + WHERE ct.code = 'freight' AND r.created BETWEEN vDatedFrom AND vDatedTo GROUP BY r.id ) sub ON sub.routeFk = r.Id_Ruta @@ -4065,10 +3732,7 @@ DROP TABLE IF EXISTS `clientDied`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `clientDied` ( `clientFk` int(11) NOT NULL DEFAULT 0, - `clientName__` varchar(50) NOT NULL COMMENT '@deprecated 2023-10-15', `lastInvoiced` date DEFAULT NULL, - `workerCode__` varchar(3) NOT NULL COMMENT '@deprecated 2023-10-15', - `Boss__` varchar(3) NOT NULL COMMENT '@deprecated 2023-10-15', `warning` enum('first','second','third') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, PRIMARY KEY (`clientFk`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Clientes que no han comprado en los ultimos 3 meses, se actualiza con proceso nocturno el 3 de cada mes'; @@ -4109,24 +3773,6 @@ CREATE TABLE `clientNewBorn` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Listado de clientes que se consideran nuevos a efectos de cobrar la comision adicional del comercial'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `compradores__` --- - -DROP TABLE IF EXISTS `compradores__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `compradores__` ( - `Id_Trabajador` int(10) unsigned NOT NULL, - `año` int(4) NOT NULL, - `semana` int(2) NOT NULL, - `importe` decimal(10,2) DEFAULT NULL, - `comision` decimal(10,2) DEFAULT NULL, - PRIMARY KEY (`Id_Trabajador`,`año`,`semana`), - CONSTRAINT `comprador_trabajador` FOREIGN KEY (`Id_Trabajador`) REFERENCES `vn`.`worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `compradores_evolution` -- @@ -4481,7 +4127,6 @@ DROP TABLE IF EXISTS `salesByItemTypeDay`; CREATE TABLE `salesByItemTypeDay` ( `itemTypeFk` smallint(5) unsigned NOT NULL, `dated` date NOT NULL, - `netSale__` int(11) NOT NULL DEFAULT 0 COMMENT '@deprecated 2023-08-31, Mismo valor que campo sale', `stems` int(11) NOT NULL DEFAULT 0 COMMENT 'Número de tallos vendidos', `references` int(11) NOT NULL DEFAULT 0 COMMENT 'Número de artículos distintos por tipo vendidos', `trash` int(11) NOT NULL DEFAULT 0 COMMENT 'Tallos basura', @@ -4536,31 +4181,6 @@ CREATE TABLE `salesByclientSalesPerson` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Ventas diarias por cliente y comercial'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `salesMonthlySnapshot___` --- - -DROP TABLE IF EXISTS `salesMonthlySnapshot___`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `salesMonthlySnapshot___` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `salesPersonName` varchar(100) DEFAULT '', - `teamName` varchar(100) DEFAULT NULL, - `year` int(11) DEFAULT NULL, - `month` int(11) DEFAULT NULL, - `currentSale` decimal(10,3) DEFAULT NULL, - `commissionSale` decimal(10,3) DEFAULT NULL, - `individualPlus` decimal(10,3) DEFAULT NULL, - `teamPlus` decimal(10,3) DEFAULT NULL, - `teamScore` decimal(10,3) DEFAULT NULL, - `newClientPlus` decimal(10,3) DEFAULT NULL, - `newClientScore` decimal(10,3) DEFAULT NULL, - `teamBossPlus` decimal(10,3) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='@deprecated 2022-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `salesPersonEvolution` -- @@ -4581,48 +4201,6 @@ CREATE TABLE `salesPersonEvolution` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Evolución Comerciales'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `salesPerson__` --- - -DROP TABLE IF EXISTS `salesPerson__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `salesPerson__` ( - `workerFk` int(10) unsigned NOT NULL, - `year` int(4) NOT NULL, - `month` int(2) NOT NULL, - `amount` decimal(10,2) DEFAULT NULL, - `commission` decimal(10,2) DEFAULT NULL, - `leasedCommission` decimal(10,2) DEFAULT NULL COMMENT 'comision proveniente de clientes que han sido donados. Ver tabla Clientes_cedidos', - `cededCommission` decimal(10,2) DEFAULT NULL COMMENT 'comision generada por los clientes que han sido donados. Ver tabla Clientes_cedidos', - `newCommission` decimal(10,2) DEFAULT NULL, - `leasedReplacement` decimal(10,2) DEFAULT NULL, - `itemTypeBorrowed` decimal(10,2) DEFAULT NULL, - `portfolioWeight` decimal(10,2) DEFAULT NULL COMMENT 'Pero de la cartera del comercial a fecha vendedores.updated', - `updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - PRIMARY KEY (`workerFk`,`year`,`month`), - CONSTRAINT `salesPerson_FK` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='@deprecated 2022-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `vendedores_evolution__` --- - -DROP TABLE IF EXISTS `vendedores_evolution__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `vendedores_evolution__` ( - `workerFk` int(10) unsigned NOT NULL, - `year` int(11) NOT NULL, - `sales` decimal(10,2) DEFAULT NULL, - `month` int(11) NOT NULL, - PRIMARY KEY (`workerFk`,`year`,`month`), - CONSTRAINT `evo_vendedor_trabajador` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='@deprecated 2022-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `ventas` -- @@ -4672,20 +4250,25 @@ DROP TABLE IF EXISTS `waste`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `waste` ( - `buyer` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, `year` int(4) NOT NULL, `week` int(2) NOT NULL, - `family` varchar(30) NOT NULL, + `buyerFk` int(10) unsigned NOT NULL, + `itemTypeFk` smallint(5) unsigned NOT NULL, `itemFk` int(11) NOT NULL DEFAULT 0, - `itemTypeFk` smallint(5) unsigned DEFAULT NULL, - `saleTotal` decimal(16,0) DEFAULT NULL, - `saleWaste` decimal(16,0) DEFAULT NULL, - `rate` decimal(5,1) DEFAULT NULL, - PRIMARY KEY (`buyer`,`year`,`week`,`family`,`itemFk`), + `saleTotal` decimal(10,2) DEFAULT NULL COMMENT 'Coste', + `saleWasteQuantity` decimal(10,2) DEFAULT NULL, + `saleExternalWaste` decimal(10,2) DEFAULT NULL, + `saleFaultWaste` decimal(10,2) DEFAULT NULL, + `saleContainerWaste` decimal(10,2) DEFAULT NULL, + `saleBreakWaste` decimal(10,2) DEFAULT NULL, + `saleOtherWaste` decimal(10,2) DEFAULT NULL, + PRIMARY KEY (`year`,`week`,`buyerFk`,`itemTypeFk`,`itemFk`), KEY `waste_itemType_id` (`itemTypeFk`), KEY `waste_item_id` (`itemFk`), + KEY `waste_user_FK` (`buyerFk`), CONSTRAINT `waste_itemType_id` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn`.`itemType` (`id`), - CONSTRAINT `waste_item_id` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE + CONSTRAINT `waste_item_id` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE, + CONSTRAINT `waste_user_FK` FOREIGN KEY (`buyerFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -6335,8 +5918,8 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `salesByItemTypeDay_addLauncher`() -BEGIN - CALL bs.salesByItemTypeDay_add(util.VN_CURDATE() - INTERVAL 30 DAY, util.VN_CURDATE()); +BEGIN + CALL bs.salesByItemTypeDay_add(util.VN_CURDATE() - INTERVAL 30 DAY, util.VN_CURDATE()); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6458,7 +6041,8 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_add`( IN vStarted DATE, - IN vEnded DATE) + IN vEnded DATE +) BEGIN /** * Añade las ventas que se realizaron entre 2 fechas a la tabla bs.sale @@ -6467,64 +6051,55 @@ BEGIN * @param vEnded Fecha de fin * */ - DECLARE vLoopDate DATE; - DECLARE vLoopDateTime DATETIME; - IF vStarted < (util.VN_CURDATE() - INTERVAL 5 YEAR) OR vStarted > vEnded THEN CALL util.throw('Wrong date'); END IF; - SET vLoopDate = vStarted; - DELETE FROM sale WHERE dated BETWEEN vStarted AND vEnded; - WHILE vLoopDate <= vEnded DO - SET vLoopDateTime = util.dayEnd(vLoopDate); - - REPLACE sale( - saleFk, - amount, - surcharge, - dated, - typeFk, - clientFk, - companyFk, - margin - )WITH calculatedSales AS( - SELECT s.id saleFk, - SUM(IF(ct.isBase, s.quantity * sc.value, 0)) amount, - SUM(IF(ct.isBase, 0, s.quantity * sc.value)) surcharge, - s.total pvp, - DATE(t.shipped) dated, - i.typeFk, - t.clientFk, - t.companyFk, - SUM(IF(ct.isMargin, s.quantity * sc.value, 0 )) marginComponents - FROM vn.ticket t - STRAIGHT_JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk - JOIN vn.saleComponent sc ON sc.saleFk = s.id - JOIN vn.component c ON c.id = sc.componentFk - JOIN vn.componentType ct ON ct.id = c.typeFk - WHERE t.shipped BETWEEN vLoopDate AND vLoopDateTime - AND s.quantity <> 0 - AND ic.merchandise - GROUP BY s.id - )SELECT saleFk, - amount, - surcharge, - dated, - typeFk, - clientFk, - companyFk, - marginComponents + amount + surcharge - pvp - FROM calculatedSales; - - SET vLoopDate = vLoopDate + INTERVAL 1 DAY; - END WHILE; + REPLACE sale( + saleFk, + amount, + surcharge, + dated, + typeFk, + clientFk, + companyFk, + margin + )WITH calculatedSales AS( + SELECT s.id saleFk, + CAST(SUM(IF(ct.isBase, s.quantity * sc.value, 0)) AS DECIMAL(10, 3)) amount, + CAST(SUM(IF(ct.isBase, 0, s.quantity * sc.value)) AS DECIMAL(10, 3)) surcharge, + s.total, + DATE(t.shipped) dated, + i.typeFk, + t.clientFk, + t.companyFk, + CAST(SUM(IF(ct.isMargin, s.quantity * sc.value, 0 )) AS DECIMAL(10, 3)) marginComponents + FROM vn.ticket t + STRAIGHT_JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.saleComponent sc ON sc.saleFk = s.id + JOIN vn.component c ON c.id = sc.componentFk + JOIN vn.componentType ct ON ct.id = c.typeFk + WHERE t.shipped BETWEEN vStarted AND vEnded + AND s.quantity <> 0 + AND ic.merchandise + GROUP BY s.id + )SELECT saleFk, + amount, + surcharge, + dated, + typeFk, + clientFk, + companyFk, + IF (marginComponents IS NULL, + 0, + CAST(marginComponents + amount + surcharge - total AS DECIMAL(10, 3))) + FROM calculatedSales; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6704,34 +6279,97 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `waste_addSales`() +CREATE DEFINER=`root`@`localhost` PROCEDURE `waste_addSales`( + vDateFrom DATE, + vDateTo DATE +) BEGIN - DECLARE vWeek INT; - DECLARE vYear INT; +/** + * Recalcula las mermas de un periodo. + * + * @param vDateFrom Fecha desde + * @param vDateTo Fecha hasta + */ + IF vDateFrom IS NULL THEN + SET vDateFrom = util.VN_CURDATE() - INTERVAL WEEKDAY(util.VN_CURDATE()) DAY; + END IF; + + IF vDateTo IS NULL THEN + SET vDateTo = vDateFrom + INTERVAL 6 DAY; + END IF; + + CALL cache.last_buy_refresh(FALSE); - SELECT week, year - INTO vWeek, vYear - FROM vn.time - WHERE dated = util.VN_CURDATE(); - REPLACE bs.waste - SELECT *, 100 * mermas / total as porcentaje - FROM ( - SELECT buyer, - year, - week, - family, - itemFk, - itemTypeFk, - floor(sum(value)) as total, - floor(sum(IF(typeFk = 'loses', value, 0))) as mermas - FROM vn.saleValue - where year = vYear and week = vWeek - - GROUP BY family, itemFk - - ) sub - ORDER BY mermas DESC; + SELECT YEAR(t.shipped), + WEEK(t.shipped, 4), + it.workerFk, + it.id, + s.itemFk, + SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity), + SUM(IF(aw.`type`, s.quantity, 0)), + SUM(IF( + aw.`type` = 'external', + (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, + 0 + ) + ), + SUM(IF( + aw.`type` = 'fault', + (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, + 0 + ) + ), + SUM(IF( + aw.`type` = 'container', + (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, + 0 + ) + ), + SUM(IF( + aw.`type` = 'break', + (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, + 0 + ) + ), + SUM(IF( + aw.`type` = 'other', + (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, + 0 + ) + ) + FROM vn.sale s + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.address a FORCE INDEX (PRIMARY) ON a.id = t.addressFk + LEFT JOIN vn.addressWaste aw ON aw.addressFk = a.id + JOIN vn.warehouse w ON w.id = t.warehouseFk + JOIN cache.last_buy lb ON lb.item_id = i.id + AND lb.warehouse_id = w.id + JOIN vn.buy b ON b.id = lb.buy_id + WHERE t.shipped BETWEEN vDateFrom AND vDateTo + AND w.isManaged + GROUP BY YEAR(t.shipped), WEEK(t.shipped, 4), i.id; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `waste_addSalesLauncher` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `waste_addSalesLauncher`() +BEGIN + CALL waste_addSales(NULL, NULL); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -7382,7 +7020,7 @@ proc: BEGIN )sub GROUP BY sub.itemFk; - DROP TEMPORARY TABLE tmp.itemCalc, tItemRange; + DROP TEMPORARY TABLE tmp.itemCalc, tItemRange, tmp.itemList; CALL cache_calc_end (vCalc); END ;; DELIMITER ; @@ -7435,7 +7073,12 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `available_refresh`(OUT `vCalc` INT, IN `vRefresh` INT, IN `vWarehouse` INT, IN `vDated` DATE) +CREATE DEFINER=`root`@`localhost` PROCEDURE `available_refresh`( + OUT `vCalc` INT, + `vRefresh` INT, + `vWarehouse` INT, + `vDated` DATE +) proc: BEGIN DECLARE vStartDate DATE; DECLARE vReserveDate DATETIME; @@ -7557,7 +7200,7 @@ proc: BEGIN )sub GROUP BY sub.itemFk; - DROP TEMPORARY TABLE tmp.itemCalc, itemRange; + DROP TEMPORARY TABLE tmp.itemCalc, itemRange, tmp.itemList; CALL cache_calc_end (vCalc); END ;; DELIMITER ; @@ -7567,6 +7210,50 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `available_updateItem` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `available_updateItem`( + `vItem` INT, + `vWarehouse` INT, + `vDated` DATE, + `vQuantity` INT +) +BEGIN +/** + * Immediately deduct/add an amount from the available cache (if exists). + * + * @param vItem The item id + * @param vWarehouse The warehouse id + * @param vDated Available cache date + * @param vQuantity The amount to be deducted from the cache + */ + DECLARE vCalc INT; + + SELECT id INTO vCalc + FROM cache_calc + WHERE cacheName = 'available' + AND params = CONCAT_WS('/', vWarehouse, vDated); + + IF vCalc IS NOT NULL THEN + UPDATE available + SET available = available - vQuantity + WHERE calc_id = vCalc + AND item_id = vItem; + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `cacheCalc_clean` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7900,7 +7587,7 @@ proc: BEGIN /** * Crea o actualiza la cache con la última compra y fecha de cada * artículo hasta ayer. Para obtener la última compra hasta una fecha - * determinada utilizar el procedimiento vn.buyUltimate(). + * determinada utilizar el procedimiento vn.buy_getUltimate(). * * @param vRefresh %TRUE para forzar el recálculo de la cache */ @@ -7926,7 +7613,7 @@ proc: BEGIN SELECT inventoried INTO started FROM vn.config LIMIT 1; SET ended = util.VN_CURDATE(); -- TIMESTAMPADD(DAY, -1, util.VN_CURDATE()); - CALL vn.buyUltimateFromInterval(NULL, started, ended); + CALL vn.buy_getUltimateFromInterval(NULL, NULL, started, ended); DELETE FROM last_buy; @@ -8050,14 +7737,14 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `visible_refresh`(OUT v_calc INT, v_refresh BOOL, v_warehouse INT) -proc: BEGIN +proc:BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN CALL cache_calc_unlock (v_calc); RESIGNAL; END; - CALL cache_calc_start (v_calc, v_refresh, 'visible', v_warehouse); + CALL cache_calc_start (v_calc, v_refresh, 'visible', v_warehouse); IF !v_refresh THEN LEAVE proc; @@ -8065,22 +7752,26 @@ proc: BEGIN -- Calculamos el stock hasta ayer - CALL `cache`.stock_refresh(false); + CALL cache.stock_refresh(false); CREATE OR REPLACE TEMPORARY TABLE tmp.itemVisible (PRIMARY KEY (item_id)) ENGINE = MEMORY - SELECT item_id, amount stock, amount visible FROM `cache`.stock - WHERE warehouse_id = v_warehouse; + SELECT s.item_id, SUM(s.amount) stock, SUM(s.amount) visible + FROM stock s + JOIN vn.warehouse w ON w.id = s.warehouse_id + WHERE (v_warehouse IS NULL OR s.warehouse_id = v_warehouse) + AND w.isComparative + GROUP BY s.item_id; -- Calculamos los movimientos confirmados de hoy - CALL vn.item_GetVisible(v_warehouse, NULL); + CALL vn.item_calcVisible(NULL, v_warehouse); DELETE FROM visible WHERE calc_id = v_calc; INSERT INTO visible (calc_id, item_id,visible) SELECT v_calc, item_id, visible FROM tmp.itemVisible; - CALL cache_calc_end (v_calc); + CALL cache_calc_end (v_calc); DROP TEMPORARY TABLE tmp.itemVisible; END ;; @@ -8127,7 +7818,7 @@ CREATE TABLE `expedition_PrintOut` ( `postalCode` varchar(10) NOT NULL DEFAULT ' ', `city` varchar(100) NOT NULL DEFAULT ' ', `shopName` varchar(100) NOT NULL DEFAULT ' ', - `isPrinted` int(11) NOT NULL DEFAULT 0, + `isPrinted` int(11) NOT NULL DEFAULT 0 COMMENT '0.- Not Printed ; 1.- Printed; 2.- Selected ; 3.- Error ; 4.- Waiting to be printed', `created` timestamp NOT NULL DEFAULT current_timestamp(), `printerFk` int(10) unsigned NOT NULL DEFAULT 0, `routeFk` int(11) NOT NULL DEFAULT 0, @@ -8144,6 +7835,7 @@ CREATE TABLE `expedition_PrintOut` ( `longName` varchar(30) DEFAULT NULL, `shelvingFk` varchar(5) DEFAULT NULL, `comments` varchar(100) DEFAULT NULL, + `isChecked` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si la expedición ha sido revisada por un revisor', PRIMARY KEY (`expeditionFk`), KEY `expedition_PrintOut_FK` (`printerFk`), CONSTRAINT `expedition_PrintOut_FK` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -8276,7 +7968,7 @@ BEGIN vPrinterFk, IFNULL(right(`t`.`routeFk`, 3),0), if (@vVolume := vn.ticketTotalVolume(t.id) > 1.5, @vVolume, IFNULL( rm.beachFk, 0)), - LEFT(IFNULL(et.description ,replace(`z`.`name`, 'ZONA ', 'Z')),14) truckName, + LEFT(IFNULL(rs.description ,replace(`z`.`name`, 'ZONA ', 'Z')),14) truckName, t.clientFk , ifnull(c.mobile, ifnull(a.mobile, ifnull(c.phone, a.phone))), LEFT(p.name, 20), @@ -8288,7 +7980,7 @@ BEGIN JOIN vn.address a ON a.id = t.addressFk JOIN vn.province p ON p.id = a.provinceFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk LEFT JOIN vn.beach b ON b.code = rm.beachFk LEFT JOIN vn.`zone`z ON z.id = t.zoneFk JOIN vn.agencyMode am ON t.agencyModeFk = am.id @@ -8644,7 +8336,6 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `ektRecent` AS SELECT 1 AS `id`, - 1 AS `barcode`, 1 AS `entryYear`, 1 AS `batchNumber`, 1 AS `deliveryNumber`, @@ -8789,13 +8480,13 @@ CREATE TABLE `feature` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `fileConfig` +-- Table structure for table `fileMultiConfig` -- -DROP TABLE IF EXISTS `fileConfig`; +DROP TABLE IF EXISTS `fileMultiConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `fileConfig` ( +CREATE TABLE `fileMultiConfig` ( `name` varchar(25) NOT NULL, `checksum` text DEFAULT NULL, `keyValue` tinyint(1) NOT NULL DEFAULT 1, @@ -8868,13 +8559,13 @@ CREATE TABLE `goodCharacteristic` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `imapConfig` +-- Table structure for table `imapMultiConfig` -- -DROP TABLE IF EXISTS `imapConfig`; +DROP TABLE IF EXISTS `imapMultiConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `imapConfig` ( +CREATE TABLE `imapMultiConfig` ( `id` tinyint(3) unsigned NOT NULL, `environment` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, `host` varchar(150) NOT NULL DEFAULT 'localhost', @@ -9400,13 +9091,13 @@ CREATE TABLE `supplyResponseLog` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `tableConfig` +-- Table structure for table `tableMultiConfig` -- -DROP TABLE IF EXISTS `tableConfig`; +DROP TABLE IF EXISTS `tableMultiConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tableConfig` ( +CREATE TABLE `tableMultiConfig` ( `fileName` varchar(2) NOT NULL, `toTable` varchar(15) NOT NULL, `file` varchar(30) NOT NULL, @@ -9475,27 +9166,6 @@ CREATE TABLE `warehouseFloramondo` ( -- -- Dumping events for database 'edi' -- -/*!50106 SET @save_time_zone= @@TIME_ZONE */ ; -/*!50106 DROP EVENT IF EXISTS `floramondo` */; -DELIMITER ;; -/*!50003 SET @saved_cs_client = @@character_set_client */ ;; -/*!50003 SET @saved_cs_results = @@character_set_results */ ;; -/*!50003 SET @saved_col_connection = @@collation_connection */ ;; -/*!50003 SET character_set_client = utf8mb4 */ ;; -/*!50003 SET character_set_results = utf8mb4 */ ;; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ;; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; -/*!50003 SET @saved_time_zone = @@time_zone */ ;; -/*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `floramondo` ON SCHEDULE EVERY 6 MINUTE STARTS '2022-01-28 09:52:45' ON COMPLETION NOT PRESERVE DISABLE DO CALL edi.floramondo_offerRefresh() */ ;; -/*!50003 SET time_zone = @saved_time_zone */ ;; -/*!50003 SET sql_mode = @saved_sql_mode */ ;; -/*!50003 SET character_set_client = @saved_cs_client */ ;; -/*!50003 SET character_set_results = @saved_cs_results */ ;; -/*!50003 SET collation_connection = @saved_col_connection */ ;; -DELIMITER ; -/*!50106 SET TIME_ZONE= @save_time_zone */ ; -- -- Dumping routines for database 'edi' @@ -10019,7 +9689,6 @@ BEGIN */ DECLARE vRewriteKop INT DEFAULT NULL; DECLARE vTruncatePutOrder INT DEFAULT NULL; - DECLARE vBarcode CHAR(15) DEFAULT NULL; DECLARE vKop INT; DECLARE vPutOrderFk BIGINT; @@ -10028,17 +9697,6 @@ BEGIN FROM ekt WHERE id = vSelf; - -- Generates the barcode - - SELECT CONCAT( - LPAD(IFNULL(auction,0), 3, 0), - LPAD(IFNULL(klo, 99), 2, 0), - LPAD(DAYOFYEAR(fec), 3, 0), - COALESCE(agj, RIGHT(batchNumber,7), id)) - INTO vBarcode - FROM ekt - WHERE id = vSelf; - -- Rewrites the kop parameter IF vKop IS NULL THEN @@ -10058,10 +9716,9 @@ BEGIN -- Refresh EKT - UPDATE ekt SET - barcode = vBarcode - ,kop = vKop - ,putOrderFk = vTruncatePutOrder + UPDATE ekt + SET kop = vKop, + putOrderFk = vTruncatePutOrder WHERE id = vSelf; END ;; DELIMITER ; @@ -10103,42 +9760,39 @@ BEGIN DECLARE vXtraLongAgj INT; DECLARE vDefaultKlo INT; - SELECT - ec.usefulAuctionLeftSegmentLength, - ec.standardBarcodeLength, - ec.floridayBarcodeLength, - ec.floramondoBarcodeLength, - ec.defaultKlo - INTO - vUsefulAuctionLeftSegmentLength, + SELECT usefulAuctionLeftSegmentLength, + standardBarcodeLength, + floridayBarcodeLength, + floramondoBarcodeLength, + defaultKlo + INTO vUsefulAuctionLeftSegmentLength, vStandardBarcodeLength, vFloridayBarcodeLength, vFloramondoBarcodeLength, vDefaultKlo - FROM edi.ektConfig ec; + FROM ektConfig; - DROP TEMPORARY TABLE IF EXISTS tmp.ekt; - CREATE TEMPORARY TABLE tmp.ekt + CREATE OR REPLACE TEMPORARY TABLE tmp.ekt ENGINE = MEMORY SELECT id ektFk FROM ekt LIMIT 0; - CASE + CASE WHEN LENGTH(vBarcode) <= vFloridayBarcodeLength THEN INSERT INTO tmp.ekt SELECT id - FROM edi.ektRecent e + FROM ektRecent e WHERE e.cps = vBarcode OR e.batchNumber = vBarcode; WHEN LENGTH(vBarcode) = vFloramondoBarcodeLength THEN INSERT INTO tmp.ekt SELECT e.id - FROM edi.ektRecent e + FROM ektRecent e WHERE e.pro = MID(vBarcode,2,6) - AND CAST(e.ptd AS SIGNED) = MID(vBarcode,8,5); + AND CAST(e.ptd AS SIGNED) = MID(vBarcode, 8, 5); ELSE - SET vBarcode = LPAD(vBarcode,vStandardBarcodeLength,'0'); + SET vBarcode = LPAD(vBarcode, vStandardBarcodeLength, '0'); SET vAuction = MID(vBarcode, 1, 3); SET vKlo = MID(vBarcode, 4, 2); SET vFec = MAKEDATE(YEAR(util.VN_CURDATE()), MID(vBarcode, 6, 3)); @@ -10149,21 +9803,23 @@ BEGIN -- Clásico de subasta -- Trade standard -- Trade que construye como la subasta - -- Trade como el anterior pero sin trade code + -- Trade como el anterior pero sin trade code INSERT INTO tmp.ekt SELECT id FROM ekt WHERE fec >= vFec - INTERVAL 1 DAY - AND (( - vKlo = vDefaultKlo + AND ( + (vKlo = vDefaultKlo AND (klo = vKlo OR klo IS NULL OR klo = 0) - AND agj IN (vShortAgj, vLongAgj, vXtraLongAgj)) - OR (klo = vKlo + AND agj IN (vShortAgj, vLongAgj, vXtraLongAgj) + ) OR ( + klo = vKlo AND auction = vAuction - AND agj = vShortAgj) + AND agj = vShortAgj + ) ) - ORDER BY agj DESC, fec DESC - LIMIT 1; + ORDER BY agj DESC, fec DESC + LIMIT 1; SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; @@ -10171,9 +9827,11 @@ BEGIN IF NOT vIsFound THEN INSERT INTO tmp.ekt SELECT id - FROM edi.ektRecent e - WHERE e.batchNumber - = LEFT(vBarcode,vUsefulAuctionLeftSegmentLength) + FROM ektRecent e + WHERE e.batchNumber = LEFT( + vBarcode, + vUsefulAuctionLeftSegmentLength + ) AND e.batchNumber > 0; SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; @@ -10183,7 +9841,7 @@ BEGIN IF NOT vIsFound THEN INSERT INTO tmp.ekt SELECT id - FROM edi.ektRecent e + FROM ektRecent e WHERE e.putOrderFk = vBarcode; SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; @@ -10193,18 +9851,28 @@ BEGIN IF NOT vIsFound THEN INSERT INTO tmp.ekt SELECT id - FROM edi.ektRecent e - WHERE e.deliveryNumber - = MID(vBarcode, 4, 13) + FROM ektRecent e + WHERE e.deliveryNumber = MID(vBarcode, 4, 13) AND e.deliveryNumber > 0; SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; END IF; + + -- Solo campo agj + IF NOT vIsFound THEN + INSERT INTO tmp.ekt + SELECT id + FROM ektRecent + WHERE agj = vShortAgj; + + SELECT COUNT(*) FROM tmp.ekt INTO vIsFound; + END IF; + END CASE; IF vIsFound THEN UPDATE ekt e - JOIN tmp.ekt t ON t.ektFk = e.id + JOIN tmp.ekt t ON t.ektFk = e.id SET e.scanned = TRUE; END IF; END ;; @@ -10215,541 +9883,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `floramondo_offerRefresh` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `floramondo_offerRefresh`() -proc: BEGIN - DECLARE vLanded DATETIME; - DECLARE vDone INT DEFAULT FALSE; - DECLARE vFreeId INT; - DECLARE vSupplyResponseFk INT; - DECLARE vLastInserted DATETIME; - DECLARE vIsAuctionDay BOOLEAN; - DECLARE vMaxNewItems INT DEFAULT 10000; - DECLARE vStartingTime DATETIME; - DECLARE vAalsmeerMarketPlaceID VARCHAR(13) DEFAULT '8713783439043'; - DECLARE vDayRange INT; - - DECLARE cur1 CURSOR FOR - SELECT id - FROM edi.item_free; - - DECLARE cur2 CURSOR FOR - SELECT srId - FROM itemToInsert; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DECLARE EXIT HANDLER FOR SQLSTATE '45000' - BEGIN - ROLLBACK; - RESIGNAL; - END; - - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION - BEGIN - DO RELEASE_LOCK('edi.floramondo_offerRefresh'); - SET @isTriggerDisabled = FALSE; - RESIGNAL; - END; - - IF 'test' = (SELECT environment FROM util.config) THEN - LEAVE proc; - END IF; - - IF !GET_LOCK('edi.floramondo_offerRefresh', 0) THEN - LEAVE proc; - END IF; - - SELECT dayRange INTO vDayRange - FROM offerRefreshConfig; - - IF vDayRange IS NULL THEN - CALL util.throw("Variable vDayRange not declared"); - END IF; - - SET vStartingTime = util.VN_NOW(); - - TRUNCATE edi.offerList; - - INSERT INTO edi.offerList(supplier, total) - SELECT v.name, COUNT(DISTINCT sr.ID) total - FROM edi.supplyResponse sr - JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID - WHERE sr.NumberOfUnits > 0 - AND sr.EmbalageCode != 999 - GROUP BY sr.vmpID; - - UPDATE edi.offerList o - JOIN (SELECT v.name, COUNT(*) total - FROM edi.supplyOffer sr - JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID - GROUP BY sr.vmpID) sub ON o.supplier = sub.name - SET o.`filter` = sub.total; - - -- Elimina de la lista de items libres aquellos que ya existen - DELETE itf.* - FROM edi.item_free itf - JOIN vn.item i ON i.id = itf.id; - - CREATE OR REPLACE TEMPORARY TABLE tmp - (INDEX (`Item_ArticleCode`)) - ENGINE = MEMORY - SELECT t.* - FROM ( - SELECT * - FROM edi.supplyOffer - ORDER BY (MarketPlaceID = vAalsmeerMarketPlaceID) DESC, - NumberOfUnits DESC LIMIT 10000000000000000000) t - GROUP BY t.srId; - - CREATE OR REPLACE TEMPORARY TABLE edi.offer (INDEX (`srID`), INDEX (`EmbalageCode`), - INDEX (`ef1`), INDEX (`ef2`), INDEX (`ef3`), INDEX (`ef4`),INDEX (`ef5`), INDEX (`ef6`), - INDEX (`s1Value`), INDEX (`s2Value`), INDEX (`s3Value`), INDEX (`s4Value`),INDEX (`s5Value`), INDEX (`s6Value`)) - ENGINE = MEMORY - SELECT so.*, - ev1.type_description s1Value, - ev2.type_description s2Value, - ev3.type_description s3Value, - ev4.type_description s4Value, - ev5.type_description s5Value, - ev6.type_description s6Value, - eif1.feature ef1, - eif2.feature ef2, - eif3.feature ef3, - eif4.feature ef4, - eif5.feature ef5, - eif6.feature ef6 - FROM tmp so - LEFT JOIN edi.item_feature eif1 ON eif1.item_id = so.Item_ArticleCode - AND eif1.presentation_order = 1 - AND eif1.expiry_date IS NULL - LEFT JOIN edi.item_feature eif2 ON eif2.item_id = so.Item_ArticleCode - AND eif2.presentation_order = 2 - AND eif2.expiry_date IS NULL - LEFT JOIN edi.item_feature eif3 ON eif3.item_id = so.Item_ArticleCode - AND eif3.presentation_order = 3 - AND eif3.expiry_date IS NULL - LEFT JOIN edi.item_feature eif4 ON eif4.item_id = so.Item_ArticleCode - AND eif4.presentation_order = 4 - AND eif4.expiry_date IS NULL - LEFT JOIN edi.item_feature eif5 ON eif5.item_id = so.Item_ArticleCode - AND eif5.presentation_order = 5 - AND eif5.expiry_date IS NULL - LEFT JOIN edi.item_feature eif6 ON eif6.item_id = so.Item_ArticleCode - AND eif6.presentation_order = 6 - AND eif6.expiry_date IS NULL - LEFT JOIN edi.`value` ev1 ON ev1.type_id = eif1.feature - AND so.s1 = ev1.type_value - LEFT JOIN edi.`value` ev2 ON ev2.type_id = eif2.feature - AND so.s2 = ev2.type_value - LEFT JOIN edi.`value` ev3 ON ev3.type_id = eif3.feature - AND so.s3 = ev3.type_value - LEFT JOIN edi.`value` ev4 ON ev4.type_id = eif4.feature - AND so.s4 = ev4.type_value - LEFT JOIN edi.`value` ev5 ON ev5.type_id = eif5.feature - AND so.s5 = ev5.type_value - LEFT JOIN edi.`value` ev6 ON ev6.type_id = eif6.feature - AND so.s6 = ev6.type_value - ORDER BY Price; - - DROP TEMPORARY TABLE tmp; - - DELETE o - FROM edi.offer o - LEFT JOIN vn.tag t1 ON t1.ediTypeFk = o.ef1 AND t1.overwrite = 'size' - LEFT JOIN vn.tag t2 ON t2.ediTypeFk = o.ef2 AND t2.overwrite = 'size' - LEFT JOIN vn.tag t3 ON t3.ediTypeFk = o.ef3 AND t3.overwrite = 'size' - LEFT JOIN vn.tag t4 ON t4.ediTypeFk = o.ef4 AND t4.overwrite = 'size' - LEFT JOIN vn.tag t5 ON t5.ediTypeFk = o.ef5 AND t5.overwrite = 'size' - LEFT JOIN vn.tag t6 ON t6.ediTypeFk = o.ef6 AND t6.overwrite = 'size' - JOIN vn.floramondoConfig fc ON TRUE - WHERE (t1.id IS NOT NULL AND CONVERT(s1Value, UNSIGNED) > fc.itemMaxSize) - OR (t2.id IS NOT NULL AND CONVERT(s2Value, UNSIGNED) > fc.itemMaxSize) - OR (t3.id IS NOT NULL AND CONVERT(s3Value, UNSIGNED) > fc.itemMaxSize) - OR (t4.id IS NOT NULL AND CONVERT(s4Value, UNSIGNED) > fc.itemMaxSize) - OR (t5.id IS NOT NULL AND CONVERT(s5Value, UNSIGNED) > fc.itemMaxSize) - OR (t6.id IS NOT NULL AND CONVERT(s6Value, UNSIGNED) > fc.itemMaxSize); - - START TRANSACTION; - - -- Actualizamos el campo supplyResponseFk para aquellos articulos que ya estan creados y reutilizamos - UPDATE IGNORE edi.offer o - JOIN vn.item i - ON i.name = o.product_name - AND i.subname <=> o.company_name - AND i.value5 <=> o.s1Value - AND i.value6 <=> o.s2Value - AND i.value7 <=> o.s3Value - AND i.value8 <=> o.s4Value - AND i.value9 <=> o.s5Value - AND i.value10 <=> o.s6Value - AND i.NumberOfItemsPerCask <=> o.NumberOfItemsPerCask - AND i.EmbalageCode <=> o.EmbalageCode - AND i.quality <=> o.Quality - JOIN vn.itemType it ON it.id = i.typeFk - LEFT JOIN vn.sale s ON s.itemFk = i.id - LEFT JOIN vn.ticket t ON t.id = s.ticketFk - AND t.shipped > (util.VN_CURDATE() - INTERVAL 1 WEEK) - LEFT JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - LEFT JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID - LEFT JOIN edi.putOrder po ON po.supplyResponseID = i.supplyResponseFk - AND po.OrderTradeLineDateTime > (util.VN_CURDATE() - INTERVAL 1 WEEK) - SET i.supplyResponseFk = o.srID - WHERE (sr.ID IS NULL - OR sr.NumberOfUnits = 0 - OR di.LatestOrderDateTime < util.VN_NOW() - OR di.ID IS NULL) - AND it.isInventory - AND t.id IS NULL - AND po.id IS NULL; - - CREATE OR REPLACE TEMPORARY TABLE itemToInsert - ENGINE = MEMORY - SELECT o.*, CAST(NULL AS DECIMAL(6,0)) itemFk - FROM edi.offer o - LEFT JOIN vn.item i ON i.supplyResponseFk = o.srId - WHERE i.id IS NULL - LIMIT vMaxNewItems; - - -- Reciclado de nº de item - OPEN cur1; - OPEN cur2; - - read_loop: LOOP - - FETCH cur2 INTO vSupplyResponseFk; - FETCH cur1 INTO vFreeId; - - IF vDone THEN - LEAVE read_loop; - END IF; - - UPDATE itemToInsert - SET itemFk = vFreeId - WHERE srId = vSupplyResponseFk; - - END LOOP; - - CLOSE cur1; - CLOSE cur2; - - -- Insertamos todos los items en Articles de la oferta - INSERT INTO vn.item(id, - `name`, - longName, - subName, - expenseFk, - typeFk, - intrastatFk, - originFk, - supplyResponseFk, - numberOfItemsPerCask, - embalageCode, - quality, - isFloramondo) - SELECT iti.itemFk, - iti.product_name, - iti.product_name, - iti.company_name, - iti.expenseFk, - iti.itemTypeFk, - iti.intrastatFk, - iti.originFk, - iti.`srId`, - iti.NumberOfItemsPerCask, - iti.EmbalageCode, - iti.Quality, - TRUE - FROM itemToInsert iti; - - -- Inserta la foto de los articulos nuevos (prioridad alta) - INSERT IGNORE INTO vn.itemImageQueue(itemFk, url) - SELECT i.id, PictureReference - FROM itemToInsert ii - JOIN vn.item i ON i.supplyResponseFk = ii.srId - WHERE PictureReference IS NOT NULL - AND i.image IS NULL; - - INSERT INTO edi.`log`(tableName, fieldName,fieldValue) - SELECT 'itemImageQueue','NumImagenesPtes', COUNT(*) - FROM vn.itemImageQueue - WHERE attempts = 0; - - -- Inserta si se añadiesen tags nuevos - INSERT IGNORE INTO vn.tag (name, ediTypeFk) - SELECT description, type_id FROM edi.type; - - -- Desabilita el trigger para recalcular los tags al final - SET @isTriggerDisabled = TRUE; - - -- Inserta los tags sólo en los articulos nuevos - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , ii.product_name, 1 - FROM itemToInsert ii - JOIN vn.tag t ON t.`name` = 'Producto' - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT ii.product_name IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , ii.Quality, 3 - FROM itemToInsert ii - JOIN vn.tag t ON t.`name` = 'Calidad' - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT ii.Quality IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , ii.company_name, 4 - FROM itemToInsert ii - JOIN vn.tag t ON t.`name` = 'Productor' - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT ii.company_name IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s1Value, 5 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef1 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT s1Value IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s2Value, 6 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef2 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT s2Value IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s3Value, 7 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef3 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT s3Value IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s4Value, 8 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef4 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT s4Value IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s5Value, 9 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef5 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT s5Value IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s6Value, 10 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef6 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT s6Value IS NULL; - - INSERT IGNORE INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id, IFNULL(ink.name, ik.color), 11 - FROM itemToInsert ii - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - JOIN vn.tag t ON t.`name` = 'Color' - LEFT JOIN edi.feature f ON f.item_id = ii.Item_ArticleCode - LEFT JOIN edi.`type` tp ON tp.type_id = f.feature_type_id - AND tp.`description` = 'Hoofdkleur 1' - LEFT JOIN vn.ink ON ink.dutchCode = f.feature_value - LEFT JOIN vn.itemInk ik ON ik.longName = i.longName - WHERE ink.name IS NOT NULL - OR ik.color IS NOT NULL; - - CREATE OR REPLACE TABLE tmp.item - (PRIMARY KEY (id)) - SELECT i.id FROM vn.item i - JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId`; - - CALL vn.item_refreshTags(); - - DROP TABLE tmp.item; - - SELECT MIN(LatestDeliveryDateTime) INTO vLanded - FROM edi.supplyResponse sr - JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID - JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID - JOIN vn.floramondoConfig fc - WHERE mp.isLatestOrderDateTimeRelevant - AND di.LatestOrderDateTime > IF( - fc.MaxLatestOrderHour > HOUR(util.VN_NOW()), - util.VN_CURDATE(), - util.VN_CURDATE() + INTERVAL 1 DAY); - - UPDATE vn.floramondoConfig - SET nextLanded = vLanded - WHERE vLanded IS NOT NULL; - - -- Elimina la oferta obsoleta - UPDATE vn.buy b - JOIN vn.entry e ON e.id = b.entryFk - JOIN vn.travel tr ON tr.id = e.travelFk - JOIN vn.agencyMode am ON am.id = tr.agencyModeFk - JOIN vn.item i ON i.id = b.itemFk - LEFT JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID - LEFT JOIN edi.deliveryInformation di ON di.ID = b.deliveryFk - SET b.quantity = 0 - WHERE (IFNULL(di.LatestOrderDateTime,util.VN_NOW()) <= util.VN_NOW() - OR i.supplyResponseFk IS NULL - OR sr.NumberOfUnits = 0) - AND am.name = 'LOGIFLORA' - AND e.isRaid; - - -- Localiza las entradas de cada almacen - UPDATE edi.warehouseFloramondo - SET entryFk = vn.entry_getForLogiflora(vLanded + INTERVAL travellingDays DAY, warehouseFk); - - IF vLanded IS NOT NULL THEN - -- Actualiza la oferta existente - UPDATE vn.buy b - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk - JOIN vn.item i ON i.id = b.itemFk - JOIN edi.offer o ON i.supplyResponseFk = o.`srId` - SET b.quantity = o.NumberOfUnits * o.NumberOfItemsPerCask, - b.buyingValue = o.price - WHERE (b.quantity <> o.NumberOfUnits * o.NumberOfItemsPerCask - OR b.buyingValue <> o.price); - - -- Inserta el resto - SET vLastInserted := util.VN_NOW(); - - -- Inserta la oferta - INSERT INTO vn.buy ( - entryFk, - itemFk, - quantity, - buyingValue, - stickers, - packing, - `grouping`, - groupingMode, - packagingFk, - deliveryFk) - SELECT wf.entryFk, - i.id, - o.NumberOfUnits * o.NumberOfItemsPerCask quantity, - o.Price, - o.NumberOfUnits etiquetas, - o.NumberOfItemsPerCask packing, - GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask `grouping`, - 'packing', - o.embalageCode, - o.diId - FROM edi.offer o - JOIN vn.item i ON i.supplyResponseFk = o.srId - JOIN edi.warehouseFloramondo wf - JOIN vn.packaging p ON p.id - LIKE o.embalageCode - LEFT JOIN vn.buy b ON b.itemFk = i.id - AND b.entryFk = wf.entryFk - WHERE b.id IS NULL; -- Quitar esta linea y mirar de crear los packages a tiempo REAL - - INSERT INTO vn.itemCost( - itemFk, - warehouseFk, - cm3, - cm3delivery) - SELECT b.itemFk, - wf.warehouseFk, - @cm3 := vn.buy_getUnitVolume(b.id), - IFNULL((vc.standardFlowerBox * 1000) / i.packingOut, @cm3) - FROM warehouseFloramondo wf - JOIN vn.volumeConfig vc - JOIN vn.buy b ON b.entryFk = wf.entryFk - JOIN vn.item i ON i.id = b.itemFk - LEFT JOIN vn.itemCost ic ON ic.itemFk = b.itemFk - AND ic.warehouseFk = wf.warehouseFk - WHERE (ic.cm3 IS NULL OR ic.cm3 = 0) - ON DUPLICATE KEY UPDATE cm3 = @cm3, cm3delivery = IFNULL((vc.standardFlowerBox * 1000) / i.packingOut, @cm3); - - CREATE OR REPLACE TEMPORARY TABLE tmp.buyRecalc - SELECT b.id - FROM vn.buy b - JOIN warehouseFloramondo wf ON wf.entryFk = b.entryFk - WHERE b.created >= vLastInserted; - - CALL vn.buy_recalcPrices(); - - UPDATE edi.offerList o - JOIN (SELECT v.name, COUNT(DISTINCT b.itemFk) total - FROM vn.buy b - JOIN vn.item i ON i.id = b.itemFk - JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk - JOIN vn.warehouse w ON w.id = wf.warehouseFk - WHERE w.name = 'VNH' - AND b.quantity > 0 - GROUP BY sr.vmpID) sub ON o.supplier = sub.name - SET o.vnh = sub.total; - - UPDATE edi.offerList o - JOIN (SELECT v.name, COUNT(DISTINCT b.itemFk) total - FROM vn.buy b - JOIN vn.item i ON i.id = b.itemFk - JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk - JOIN vn.warehouse w ON w.id = wf.warehouseFk - WHERE w.name = 'ALGEMESI' - AND b.quantity > 0 - GROUP BY sr.vmpID) sub ON o.supplier = sub.name - SET o.algemesi = sub.total; - END IF; - - DROP TEMPORARY TABLE - edi.offer, - itemToInsert; - - SET @isTriggerDisabled = FALSE; - - COMMIT; - - -- Esto habria que pasarlo a procesos programados o trabajar con tags y dejar las familias - UPDATE vn.item i - SET typeFk = 121 - WHERE i.longName LIKE 'Rosa Garden %' - AND typeFk = 17; - - UPDATE vn.item i - SET typeFk = 156 - WHERE i.longName LIKE 'Rosa ec %' - AND typeFk = 17; - - -- Refresca las fotos de los items existentes que mostramos (prioridad baja) - INSERT IGNORE INTO vn.itemImageQueue(itemFk, url, priority) - SELECT i.id, sr.PictureReference, 100 - FROM edi.supplyResponse sr - JOIN vn.item i ON i.supplyResponseFk = sr.ID - JOIN edi.supplyOffer so ON so.srId = sr.ID - JOIN hedera.image i2 ON i2.name = i.image - AND i2.collectionFk = 'catalog' - WHERE i2.updated <= (UNIX_TIMESTAMP(util.VN_NOW()) - vDayRange) - AND sr.NumberOfUnits; - - INSERT INTO edi.`log` - SET tableName = 'floramondo_offerRefresh', - fieldName = 'Tiempo de proceso', - fieldValue = TIMEDIFF(util.VN_NOW(), vStartingTime); - - DO RELEASE_LOCK('edi.floramondo_offerRefresh'); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_freeAdd` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -11075,26 +10208,6 @@ CREATE TABLE `addressPostCode` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Client''s address registered for floranet network'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `builder` --- - -DROP TABLE IF EXISTS `builder`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `builder` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `itemFk` int(11) NOT NULL, - `elementFk` int(11) NOT NULL, - `quantity` int(10) unsigned NOT NULL DEFAULT 1, - PRIMARY KEY (`id`), - KEY `builder_FK` (`itemFk`), - KEY `builder_FK_1` (`elementFk`), - CONSTRAINT `builder_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `builder_FK_1` FOREIGN KEY (`elementFk`) REFERENCES `element` (`itemFk`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Links handmade products with their elements'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `catalogue` -- @@ -11114,37 +10227,25 @@ CREATE TABLE `catalogue` ( `description` text DEFAULT NULL, `created` timestamp NULL DEFAULT current_timestamp(), `payed` datetime DEFAULT NULL, + `addressFk` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `itemFk` (`itemFk`), + KEY `catalogue_address_FK` (`addressFk`), + CONSTRAINT `catalogue_address_FK` FOREIGN KEY (`addressFk`) REFERENCES `vn`.`address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `catalogue_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `element` +-- Table structure for table `config` -- -DROP TABLE IF EXISTS `element`; +DROP TABLE IF EXISTS `config`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `element` ( - `itemFk` int(11) NOT NULL, - `typeFk` smallint(5) unsigned DEFAULT NULL, - `size` int(11) DEFAULT NULL, - `inkFk` char(3) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, - `originFk` tinyint(2) unsigned DEFAULT NULL, - `name` varchar(30) DEFAULT NULL, - `quantity` int(11) NOT NULL DEFAULT 1, - PRIMARY KEY (`itemFk`), - KEY `element_FK` (`itemFk`), - KEY `element_FK_1` (`typeFk`), - KEY `element_FK_2` (`inkFk`), - KEY `element_FK_3` (`originFk`), - CONSTRAINT `element_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `element_FK_1` FOREIGN KEY (`typeFk`) REFERENCES `vn`.`itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `element_FK_2` FOREIGN KEY (`inkFk`) REFERENCES `vn`.`ink` (`id`) ON UPDATE CASCADE, - CONSTRAINT `element_FK_3` FOREIGN KEY (`originFk`) REFERENCES `vn`.`origin` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Filtro para localizar posibles items que coincidan con la descripción'; +CREATE TABLE `config` ( + `email` varchar(255) NOT NULL DEFAULT 'floranet@verdnatura.es' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11167,47 +10268,37 @@ CREATE TABLE `order` ( `isPaid` tinyint(1) NOT NULL DEFAULT 0, `payed` datetime DEFAULT NULL, `created` timestamp NULL DEFAULT current_timestamp(), + `observations` text DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `catalogueFk` (`catalogueFk`), CONSTRAINT `order_ibfk_1` FOREIGN KEY (`catalogueFk`) REFERENCES `catalogue` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `recipe` +-- + +DROP TABLE IF EXISTS `recipe`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `recipe` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemFk` int(11) NOT NULL COMMENT 'Bouquet or plant name', + `elementFk` int(11) NOT NULL COMMENT 'Item detail for bouquet''s composition', + `quantity` int(10) unsigned NOT NULL DEFAULT 1, + `cost` decimal(10,2) NOT NULL DEFAULT 1.00, + PRIMARY KEY (`id`), + KEY `recipe_FK` (`itemFk`), + KEY `recipe_FK_1` (`elementFk`), + CONSTRAINT `recipe_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE, + CONSTRAINT `recipe_item_FK` FOREIGN KEY (`elementFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Links handmade products with their elements'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Dumping events for database 'floranet' -- -/*!50106 SET @save_time_zone= @@TIME_ZONE */ ; -/*!50106 DROP EVENT IF EXISTS `clean` */; -DELIMITER ;; -/*!50003 SET @saved_cs_client = @@character_set_client */ ;; -/*!50003 SET @saved_cs_results = @@character_set_results */ ;; -/*!50003 SET @saved_col_connection = @@collation_connection */ ;; -/*!50003 SET character_set_client = utf8mb4 */ ;; -/*!50003 SET character_set_results = utf8mb4 */ ;; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ;; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; -/*!50003 SET @saved_time_zone = @@time_zone */ ;; -/*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `clean` ON SCHEDULE EVERY 1 DAY STARTS '2024-01-01 23:00:00' ON COMPLETION PRESERVE ENABLE DO BEGIN - DELETE - FROM `order` - WHERE created < CURDATE() - AND isPaid = FALSE; - - DELETE c.* - FROM catalogue c - LEFT JOIN `order` o ON o.catalogueFk = c.id - WHERE c.created < CURDATE() - AND o.id IS NULL; -END */ ;; -/*!50003 SET time_zone = @saved_time_zone */ ;; -/*!50003 SET sql_mode = @saved_sql_mode */ ;; -/*!50003 SET character_set_client = @saved_cs_client */ ;; -/*!50003 SET character_set_results = @saved_cs_results */ ;; -/*!50003 SET collation_connection = @saved_col_connection */ ;; -DELIMITER ; -/*!50106 SET TIME_ZONE= @save_time_zone */ ; -- -- Dumping routines for database 'floranet' @@ -11251,11 +10342,12 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `catalogue_get`(vLanded DATE, vPosta 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, for the designed shop * * @param vLanded Delivery date * @param vPostalCode Delivery address postal code */ + DECLARE vAddressFk INT; DECLARE vLastCatalogueFk INT; DECLARE vLockName VARCHAR(20); DECLARE vLockTime INT; @@ -11266,7 +10358,7 @@ proc:BEGIN RESIGNAL; END; - + SET vLockName = 'catalogue_get'; SET vLockTime = 15; @@ -11277,6 +10369,15 @@ proc:BEGIN SELECT MAX(id) INTO vLastCatalogueFk FROM catalogue; + SELECT addressFk + INTO vAddressFk + FROM addressPostCode apc + WHERE apc.dayOfWeek = dayOfWeek(vLanded) + AND NOW() < vLanded - INTERVAL apc.hoursInAdvance HOUR + AND apc.postCode = vPostalCode + -- Aquí hay que incluir los criterios de selección de tienda + LIMIT 1; + INSERT INTO catalogue( name, price, @@ -11285,19 +10386,25 @@ proc:BEGIN postalCode, `type`, image, - description + description, + addressFk ) - SELECT i.name, - i.`size`, - i.id, + SELECT CONCAT(i.name, ' by ',a.nickname), + r.price + apc.deliveryCost, + r.itemFk, vLanded, vPostalCode, it.name, CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image), - i.description + i.description, + vAddressFk FROM vn.item i + JOIN (SELECT itemFk, SUM(quantity * cost) price + FROM recipe + GROUP BY itemFk) r ON r.itemFk = i.id JOIN vn.itemType it ON it.id = i.typeFk - WHERE it.code IN ('FNR','FNP'); + JOIN addressPostCode apc ON addressFk = vAddressFk + JOIN vn.address a ON a.id = vAddressFk; SELECT * FROM catalogue @@ -11331,9 +10438,18 @@ BEGIN /** * Set actions for contact request * - * @param vPostalCode Delivery address postal code + * @param vName Name + * @param vPhone Phone number + * @param vEmail e-mail + * @param vMessage text of the message */ - + + CALL vn.mail_insert( + 'floranet@verdnatura.es', + vEmail, + 'Contact request', + CONCAT('Phone: ',vPhone, ' Message: ', vMessage) + ); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -11369,7 +10485,7 @@ BEGIN apc.dayOfWeek - vCurrentDayOfWeek, 7 - apc.dayOfWeek ) DAY nextDay, - NOW() + INTERVAL apc.hoursInAdvance - 12 HOUR minDeliveryTime + NOW() + INTERVAL apc.hoursInAdvance HOUR minDeliveryTime FROM addressPostCode apc WHERE apc.postCode = vPostalCode HAVING nextDay > minDeliveryTime) sub; @@ -11391,21 +10507,165 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `order_confirm`(vCatalogueFk INT) READS SQL DATA -BEGIN -/** Update order.isPaid field. +proc:BEGIN +/** Update order.isPaid field, and makes the ticket * * @param vCatalogueFk floranet.catalogue.id * * @returns floranet.order.isPaid */ + DECLARE vNewTicketFk INT; + DECLARE vCustomerEmail VARCHAR(255); + DECLARE vFloranetEmail VARCHAR(255); + DECLARE vSubjectEmail VARCHAR(100); + DECLARE vBodyEmail TEXT; + DECLARE vZoneFk INT; + + DECLARE exit handler FOR SQLEXCEPTION + BEGIN + ROLLBACK; + + GET DIAGNOSTICS CONDITION 2 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT; + + SELECT CONCAT('ERROR ', IFNULL(@errno,0), ': ', ifnull(@text,'texto')) AS `SQLEXCEPTION`; + + CALL vn.mail_insert( + 'floranet@verdnatura.es,pako@verdnatura.es', + 'noreply@verdnatura.es', + 'Floranet.order_confirm failure', + CONCAT('CatalogueFk: ', vCatalogueFk, '\n','ERROR ', IFNULL(@errno, 0), ': ', ifnull(@text, 'texto')) + ); + END; + + IF (SELECT isPaid FROM `order` WHERE catalogueFk = vCatalogueFk) THEN + SELECT CONCAT('CatalogueFk: ', vCatalogueFk, ' Esta orden ya está confirmada') AS `ERROR`; + LEAVE proc; + END IF; + + START TRANSACTION; + UPDATE `order` SET isPaid = TRUE, payed = NOW() WHERE catalogueFk = vCatalogueFk; - SELECT isPaid + SELECT zoneFk + INTO vZoneFk + FROM ( + SELECT zoneFk, COUNT(*) totalCount + FROM vn.ticket t + JOIN catalogue c ON c.id = vCatalogueFk + WHERE t.shipped > util.VN_CURDATE() - INTERVAL 1 YEAR + AND t.addressFk = c.addressFk + GROUP BY zoneFk + ORDER BY totalCount DESC + LIMIT 10000000000000000000 + ) sub + LIMIT 1; + + INSERT INTO vn.ticket ( + clientFk, + shipped, + addressFk, + agencyModeFk, + nickname, + warehouseFk, + routeFk, + companyFk, + landed, + zoneFk + ) + SELECT a.clientFk, + c.dated - INTERVAL 1 DAY, + c.addressFk, + a.agencyModeFk, + a.nickname, + ag.warehouseFk, + NULL, + co.id, + c.dated, + vZoneFk + FROM vn.address a + JOIN vn.agencyMode am ON am.id = a.agencyModeFk + JOIN vn.agency ag ON ag.id = am.agencyFk + JOIN catalogue c ON c.addressFk = a.id + JOIN vn.company co ON co.code = 'VNL' + WHERE c.id = vCatalogueFk; + + SET vNewTicketFk = LAST_INSERT_ID(); + + INSERT INTO vn.sale( + ticketFk, + itemFk, + concept, + price, + quantity) + SELECT + vNewTicketFk, + c.itemFk, + CONCAT('Entrega: ',c.name), + - apc.deliveryCost, + 1 + FROM catalogue c + JOIN addressPostCode apc + ON apc.addressFk = c.addressFk + AND apc.dayOfWeek = dayOfWeek(c.dated) + WHERE c.id = vCatalogueFk; + + INSERT INTO vn.sale( + ticketFk, + itemFk, + concept, + price, + quantity) + SELECT + vNewTicketFk, + r.elementFk, + i.longName, + 0, + r.quantity + FROM catalogue c + JOIN recipe r ON r.itemFk = c.itemFk + JOIN vn.item i ON i.id = r.elementFk + WHERE c.id = vCatalogueFk; + + SELECT cl.email, + cf.email, + CONCAT('Nuevo pedido FLORANET para entrega el ',c.dated), + CONCAT_WS('\n', + CONCAT('Producto: ', c.name), + CONCAT('Fecha de entrega: ',c.dated), + CONCAT('Destinatario: ', o.deliveryName), + CONCAT('Dirección: ', o.address), + CONCAT('CP: ', c.postalCode), + CONCAT('Foto: ', c.image), + CONCAT('Mensaje: ', IFNULL(o.message,"Ninguno.")), + CONCAT('Teléfono: ',IFNULL(o.deliveryPhone,"--")), + CONCAT('Observaciones: ', IFNULL(o.observations,"No hay.")) + ) + INTO vCustomerEmail, + vFloranetEmail, + vSubjectEmail, + vBodyEmail + FROM vn.client cl + JOIN vn.address a ON a.clientFk = cl.id + JOIN catalogue c ON c.addressFk = a.id + JOIN `order` o ON o.catalogueFk = c.id + JOIN config cf + WHERE c.id = vCatalogueFk; + + CALL vn.mail_insert( + vCustomerEmail, + vFloranetEmail, + vSubjectEmail, + vBodyEmail); + + SELECT isPaid, vNewTicketFk FROM `order` WHERE catalogueFk = vCatalogueFk; + + COMMIT; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -11430,7 +10690,7 @@ BEGIN * * @param vJsonData The order data in json format */ - INSERT INTO `order` + REPLACE `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')), @@ -11438,7 +10698,8 @@ BEGIN 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')); + deliveryPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryPhone')), + observations = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.observations')); SELECT LAST_INSERT_ID() orderFk; END ;; @@ -11464,13 +10725,12 @@ BEGIN * Returns list of url for sliders. */ SELECT - CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url, - i.longName - FROM vn.item i - JOIN vn.itemType it ON it.id = i.typeFk - WHERE it.code IN ('FNR','FNP') - LIMIT 3; - + CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url, + i.longName + FROM vn.item i + JOIN vn.itemType it ON it.id = i.typeFk + WHERE it.code IN ('FNR','FNP') + LIMIT 3; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -12312,13 +11572,13 @@ CREATE TABLE `shelf` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `shelfConfig` +-- Table structure for table `shelfMultiConfig` -- -DROP TABLE IF EXISTS `shelfConfig`; +DROP TABLE IF EXISTS `shelfMultiConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `shelfConfig` ( +CREATE TABLE `shelfMultiConfig` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(25) NOT NULL, `namePrefix` varchar(50) DEFAULT NULL, @@ -12332,9 +11592,9 @@ CREATE TABLE `shelfConfig` ( KEY `shelf_id` (`shelf`), KEY `family_id` (`family`), KEY `warehouse_id` (`warehouse`), - CONSTRAINT `shelfConfig_ibfk_1` FOREIGN KEY (`family`) REFERENCES `vn`.`itemType` (`id`), - CONSTRAINT `shelfConfig_ibfk_2` FOREIGN KEY (`shelf`) REFERENCES `shelf` (`id`) ON UPDATE CASCADE, - CONSTRAINT `shelfConfig_ibfk_3` FOREIGN KEY (`warehouse`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `shelfMultiConfig_ibfk_1` FOREIGN KEY (`family`) REFERENCES `vn`.`itemType` (`id`), + CONSTRAINT `shelfMultiConfig_ibfk_2` FOREIGN KEY (`shelf`) REFERENCES `shelf` (`id`) ON UPDATE CASCADE, + CONSTRAINT `shelfMultiConfig_ibfk_3` FOREIGN KEY (`warehouse`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -12493,10 +11753,11 @@ DROP TABLE IF EXISTS `tpvMerchantEnable`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `tpvMerchantEnable` ( `merchantFk` int(10) unsigned NOT NULL DEFAULT 0, - `companyFk` smallint(6) unsigned NOT NULL, - PRIMARY KEY (`merchantFk`,`companyFk`), + `companyFk` int(10) unsigned NOT NULL, + PRIMARY KEY (`merchantFk`), UNIQUE KEY `company_id` (`companyFk`), - CONSTRAINT `tpvMerchantEnable_ibfk_1` FOREIGN KEY (`merchantFk`, `companyFk`) REFERENCES `tpvMerchant` (`id`, `companyFk`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `tpvMerchantEnable_company_FK` FOREIGN KEY (`companyFk`) REFERENCES `vn`.`company` (`id`) ON UPDATE CASCADE, + CONSTRAINT `tpvMerchantEnable_tpvMerchant_FK` FOREIGN KEY (`merchantFk`) REFERENCES `tpvMerchant` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Virtual TPV enabled providers'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -12922,12 +12183,8 @@ BEGIN JOIN vn.warehouse w ON w.id = p.warehouseFk ORDER BY warehouseFk, `grouping`; - DROP TEMPORARY TABLE - tmp.ticketCalculateItem, - tmp.ticketComponentPrice, - tmp.ticketComponent, - tmp.ticketLot, - tmp.zoneGetShipped; + CALL vn.ticketCalculatePurge(); + DROP TEMPORARY TABLE tmp.item; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -12950,7 +12207,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getVisible`( vType INT, vPrefix VARCHAR(255)) BEGIN - + /** * Gets visible items of the specified type at specified date. * @@ -12959,7 +12216,7 @@ BEGIN * @param vType The type id * @param vPrefix The article prefix to filter or %NULL for all * @return tmp.itemVisible Visible items - */ + */ DECLARE vPrefixLen SMALLINT; DECLARE vFilter VARCHAR(255) DEFAULT NULL; DECLARE vDateInv DATE DEFAULT vn.getInventoryDate(); @@ -12968,13 +12225,13 @@ BEGIN GET DIAGNOSTICS CONDITION 1 @message = MESSAGE_TEXT; CALL vn.mail_insert( - 'cau@verdnatura.es', - NULL, + 'cau@verdnatura.es', + NULL, CONCAT('hedera.item_getVisible error: ', @message), CONCAT( - 'warehouse: ', IFNULL(vWarehouse, ''), - ', Fecha:', IFNULL(vDate, ''), - ', tipo: ', IFNULL(vType,''), + 'warehouse: ', IFNULL(vWarehouse, ''), + ', Fecha:', IFNULL(vDate, ''), + ', tipo: ', IFNULL(vType,''), ', prefijo: ', IFNULL(vPrefix,''))); RESIGNAL; END; @@ -13019,9 +12276,10 @@ BEGIN FROM vn.sale m JOIN vn.ticket t ON t.id = m.ticketFk JOIN vn.ticketState s ON s.ticketFk = t.id + JOIN vn.alertLevel al ON al.code = 'DELIVERED' WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE() AND t.warehouseFk = vWarehouse - AND s.alertLevel = 3 + AND s.alertLevel = al.id ) t GROUP BY itemFk HAVING quantity > 0; @@ -13053,7 +12311,7 @@ BEGIN IF(p.depth > 0, p.depth, 0) depth, p.width, p.height, CEIL(s.quantity / t.packing) etiquetas FROM vn.item i - JOIN `filter` f ON f.itemFk = i.id + JOIN `filter` f ON f.itemFk = i.id JOIN currentStock s ON s.itemFk = i.id LEFT JOIN tmp t ON t.itemFk = i.id LEFT JOIN vn.packaging p ON p.id = t.packagingFk @@ -13936,8 +13194,8 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `order_addItem`( vSelf INT, - vWarehouse INT, - vItem INT, + vWarehouse INT, + vItem INT, vAmount INT) BEGIN /** @@ -13972,7 +13230,7 @@ BEGIN ROLLBACK; RESIGNAL; END; - + CALL order_calcCatalogFromItem(vSelf, vItem); START TRANSACTION; @@ -13982,20 +13240,36 @@ BEGIN FROM tmp.zoneGetShipped WHERE warehouseFk = vWarehouse; - SELECT IFNULL(available, 0) INTO vAvailable + SELECT available INTO vAvailable FROM tmp.ticketLot WHERE warehouseFk = vWarehouse AND itemFk = vItem; + IF vAvailable IS NULL THEN + SET vAvailable = 0; + END IF; + IF vAmount > vAvailable THEN CALL util.throw ('ORDER_ROW_UNAVAILABLE'); END IF; - SELECT IFNULL(minQuantity, 0) INTO vMinQuantity - FROM vn.item - WHERE id = vItem; + WITH itemMinQuantityPriority AS ( + SELECT quantity, + ROW_NUMBER() OVER ( + PARTITION BY itemFk + ORDER BY warehouseFk IS NULL + ) priority + FROM vn.itemMinimumQuantity + WHERE itemFk = vItem + AND `started` <= vShipment + AND (`ended` >= vShipment OR `ended` IS NULL) + AND (warehouseFk = vWarehouse OR warehouseFk IS NULL) + ) + SELECT quantity INTO vMinQuantity + FROM itemMinQuantityPriority + WHERE priority = 1; - IF vAmount < LEAST(vMinQuantity, vAvailable) THEN + IF vAmount < LEAST(IFNULL(vMinQuantity, 0), vAvailable) THEN CALL util.throw ('quantityLessThanMin'); END IF; @@ -14025,6 +13299,8 @@ BEGIN amount = vAdd, price = vPrice; + CALL cache.available_updateItem(vItem, vWarehouse, vShipment, vAdd); + SET vRow = LAST_INSERT_ID(); INSERT INTO orderRowComponent (rowFk, componentFk, price) @@ -14044,7 +13320,7 @@ BEGIN END IF; COMMIT; - CALL vn.ticketCalculatePurge; + CALL vn.ticketCalculatePurge; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -14400,61 +13676,64 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `order_confirmWithUser`(vSelf INT, vUserId INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `order_confirmWithUser`( + vSelf INT, + vUserFk INT +) BEGIN /** - * Confirms an order, creating each of its tickets on the corresponding - * date, store and user. + * Confirms an order, creating each of its tickets + * on the corresponding date, store and user. * * @param vSelf The order identifier * @param vUser The user identifier */ - DECLARE vOk BOOL; - DECLARE vDone BOOL DEFAULT FALSE; - DECLARE vWarehouse INT; + DECLARE vHasRows BOOL; + DECLARE vDone BOOL; + DECLARE vWarehouseFk INT; DECLARE vShipment DATE; - DECLARE vTicket INT; + DECLARE vShipmentDayEnd DATETIME; + DECLARE vTicketFk INT; DECLARE vNotes VARCHAR(255); - DECLARE vItem INT; + DECLARE vItemFk INT; DECLARE vConcept VARCHAR(30); DECLARE vAmount INT; + DECLARE vAvailable INT; DECLARE vPrice DECIMAL(10,2); - DECLARE vSale INT; - DECLARE vRate INT; - DECLARE vRowId INT; + DECLARE vSaleFk INT; + DECLARE vRowFk INT; DECLARE vPriceFixed DECIMAL(10,2); - DECLARE vDelivery DATE; - DECLARE vAddress INT; - DECLARE vIsConfirmed BOOL; - DECLARE vClientId INT; - DECLARE vCompanyId INT; - DECLARE vAgencyModeId INT; - DECLARE TICKET_FREE INT DEFAULT 2; - DECLARE vCalc INT; - DECLARE vIsLogifloraItem BOOL; - DECLARE vOldQuantity INT; - DECLARE vNewQuantity INT; + DECLARE vLanded DATE; + DECLARE vAddressFk INT; + DECLARE vClientFk INT; + DECLARE vCompanyFk INT; + DECLARE vAgencyModeFk INT; + DECLARE vCalcFk INT; DECLARE vIsTaxDataChecked BOOL; - DECLARE cDates CURSOR FOR - SELECT zgs.shipped, r.warehouse_id + DECLARE vDates CURSOR FOR + SELECT zgs.shipped, r.warehouseFk FROM `order` o - JOIN order_row r ON r.order_id = o.id - LEFT JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = r.warehouse_id - WHERE o.id = vSelf AND r.amount != 0 - GROUP BY r.warehouse_id; + JOIN orderRow r ON r.orderFk = o.id + LEFT JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = r.warehouseFk + WHERE o.id = vSelf + AND r.amount + GROUP BY r.warehouseFk; - DECLARE cRows CURSOR FOR - SELECT r.id, r.item_id, i.name, r.amount, r.price, r.rate, i.isFloramondo - FROM order_row r - JOIN vn.item i ON i.id = r.item_id - WHERE r.amount != 0 - AND r.warehouse_id = vWarehouse - AND r.order_id = vSelf + DECLARE vRows CURSOR FOR + SELECT r.id, + r.itemFk, + i.name, + r.amount, + r.price + FROM orderRow r + JOIN vn.item i ON i.id = r.itemFk + WHERE r.amount + AND r.warehouseFk = vWarehouseFk + AND r.orderFk = vSelf ORDER BY r.rate DESC; - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN @@ -14463,26 +13742,36 @@ BEGIN END; -- Carga los datos del pedido - SELECT o.date_send, o.address_id, o.note, a.clientFk, - o.company_id, o.agency_id, c.isTaxDataChecked - INTO vDelivery, vAddress, vNotes, vClientId, - vCompanyId, vAgencyModeId, vIsTaxDataChecked - FROM hedera.`order` o + SELECT o.date_send, + o.address_id, + o.note, + a.clientFk, + o.company_id, + o.agency_id, + c.isTaxDataChecked + INTO vLanded, + vAddressFk, + vNotes, + vClientFk, + vCompanyFk, + vAgencyModeFk, + vIsTaxDataChecked + FROM `order` o JOIN vn.address a ON a.id = o.address_id JOIN vn.client c ON c.id = a.clientFk WHERE o.id = vSelf; -- Verifica si el cliente tiene los datos comprobados IF NOT vIsTaxDataChecked THEN - CALL util.throw ('clientNotVerified'); + CALL util.throw('clientNotVerified'); END IF; -- Carga las fechas de salida de cada almacen - CALL vn.zone_getShipped (vDelivery, vAddress, vAgencyModeId, FALSE); + CALL vn.zone_getShipped(vLanded, vAddressFk, vAgencyModeFk, FALSE); -- Trabajador que realiza la accion - IF vUserId IS NULL THEN - SELECT employeeFk INTO vUserId FROM orderConfig; + IF vUserFk IS NULL THEN + SELECT employeeFk INTO vUserFk FROM orderConfig; END IF; START TRANSACTION; @@ -14490,206 +13779,188 @@ BEGIN CALL order_checkEditable(vSelf); -- Check order is not empty + SELECT COUNT(*) > 0 INTO vHasRows + FROM orderRow + WHERE orderFk = vSelf + AND amount > 0; - SELECT COUNT(*) > 0 INTO vOk - FROM order_row WHERE order_id = vSelf AND amount > 0; - - IF NOT vOk THEN - CALL util.throw ('ORDER_EMPTY'); + IF NOT vHasRows THEN + CALL util.throw('ORDER_EMPTY'); END IF; -- Crea los tickets del pedido - - OPEN cDates; - - lDates: - LOOP - SET vTicket = NULL; + OPEN vDates; + lDates: LOOP + SET vTicketFk = NULL; SET vDone = FALSE; - FETCH cDates INTO vShipment, vWarehouse; + FETCH vDates INTO vShipment, vWarehouseFk; IF vDone THEN LEAVE lDates; END IF; - -- Busca un ticket existente que coincida con los parametros - WITH tPrevia AS - (SELECT DISTINCT s.ticketFk + SET vShipmentDayEnd = util.dayEnd(vShipment); + + -- Busca un ticket libre disponible + WITH tPrevia AS ( + SELECT DISTINCT s.ticketFk FROM vn.sale s JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id JOIN vn.ticket t ON t.id = s.ticketFk - WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) - ) - SELECT t.id INTO vTicket + WHERE t.shipped BETWEEN vShipment AND vShipmentDayEnd + ) + SELECT t.id INTO vTicketFk FROM vn.ticket t + JOIN vn.alertLevel al ON al.code = 'FREE' LEFT JOIN tPrevia tp ON tp.ticketFk = t.id - LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id - JOIN hedera.`order` o - ON o.address_id = t.addressFk - AND vWarehouse = t.warehouseFk - AND o.date_send = t.landed - AND DATE(t.shipped) = vShipment + LEFT JOIN vn.ticketState tls ON tls.ticketFk = t.id + JOIN hedera.`order` o ON o.address_id = t.addressFk + AND t.shipped BETWEEN vShipment AND vShipmentDayEnd + AND t.warehouseFk = vWarehouseFk + AND o.date_send = t.landed WHERE o.id = vSelf AND t.refFk IS NULL AND tp.ticketFk IS NULL - AND IFNULL(tls.alertLevel,0) = 0 + AND (tls.alertLevel IS NULL OR tls.alertLevel = al.id) LIMIT 1; + -- Comprobamos si hay un ticket de previa disponible + IF vTicketFk IS NULL THEN + WITH tItemPackingTypeOrder AS ( + SELECT GROUP_CONCAT( + DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk + ) distinctItemPackingTypes, + o.address_id + FROM vn.item i + JOIN hedera.orderRow oro ON oro.itemFk = i.id + JOIN hedera.`order` o ON o.id = oro.orderFk + WHERE oro.orderFk = vSelf + ), + tItemPackingTypeTicket AS ( + SELECT t.id, + GROUP_CONCAT( + DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk + ) distinctItemPackingTypes + FROM vn.ticket t + JOIN vn.ticketState tls ON tls.ticketFk = t.id + JOIN vn.alertLevel al ON al.id = tls.alertLevel + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN tItemPackingTypeOrder ipto + WHERE t.shipped BETWEEN vShipment AND vShipmentDayEnd + AND t.refFk IS NULL + AND t.warehouseFk = vWarehouseFk + AND t.addressFk = ipto.address_id + AND al.code = 'ON_PREVIOUS' + GROUP BY t.id + ) + SELECT iptt.id INTO vTicketFk + FROM tItemPackingTypeTicket iptt + JOIN tItemPackingTypeOrder ipto + WHERE INSTR(iptt.distinctItemPackingTypes, ipto.distinctItemPackingTypes) + LIMIT 1; + END IF; + -- Crea el ticket en el caso de no existir uno adecuado - IF vTicket IS NULL - THEN - + IF vTicketFk IS NULL THEN SET vShipment = IFNULL(vShipment, util.VN_CURDATE()); - CALL vn.ticket_add( - vClientId, + vClientFk, vShipment, - vWarehouse, - vCompanyId, - vAddress, - vAgencyModeId, + vWarehouseFk, + vCompanyFk, + vAddressFk, + vAgencyModeFk, NULL, - vDelivery, - vUserId, + vLanded, + vUserFk, TRUE, - vTicket + vTicketFk ); ELSE INSERT INTO vn.ticketTracking - SET ticketFk = vTicket, - userFk = vUserId, - stateFk = TICKET_FREE; + SET ticketFk = vTicketFk, + userFk = vUserFk, + stateFk = (SELECT id FROM vn.state WHERE code = 'FREE'); END IF; INSERT IGNORE INTO vn.orderTicket SET orderFk = vSelf, - ticketFk = vTicket; + ticketFk = vTicketFk; -- Añade las notas - - IF vNotes IS NOT NULL AND vNotes != '' - THEN - INSERT INTO vn.ticketObservation SET - ticketFk = vTicket, - observationTypeFk = 4 /* salesperson */ , + IF vNotes IS NOT NULL AND vNotes <> '' THEN + INSERT INTO vn.ticketObservation + SET ticketFk = vTicketFk, + observationTypeFk = (SELECT id FROM vn.observationType WHERE code = 'salesPerson'), `description` = vNotes ON DUPLICATE KEY UPDATE `description` = CONCAT(VALUES(`description`),'. ', `description`); END IF; -- Añade los movimientos y sus componentes - - OPEN cRows; - + OPEN vRows; lRows: LOOP + SET vSaleFk = NULL; SET vDone = FALSE; - FETCH cRows INTO vRowId, vItem, vConcept, vAmount, vPrice, vRate, vIsLogifloraItem; + FETCH vRows INTO vRowFk, vItemFk, vConcept, vAmount, vPrice; IF vDone THEN LEAVE lRows; END IF; - SET vSale = NULL; - - SELECT s.id, s.quantity INTO vSale, vOldQuantity + SELECT s.id INTO vSaleFk FROM vn.sale s - WHERE ticketFk = vTicket + WHERE ticketFk = vTicketFk AND price = vPrice - AND itemFk = vItem + AND itemFk = vItemFk AND discount = 0 LIMIT 1; - IF vSale THEN + IF vSaleFk THEN UPDATE vn.sale SET quantity = quantity + vAmount, originalQuantity = quantity - WHERE id = vSale; - - SELECT s.quantity INTO vNewQuantity - FROM vn.sale s - WHERE id = vSale; + WHERE id = vSaleFk; ELSE -- Obtiene el coste SELECT SUM(rc.`price`) valueSum INTO vPriceFixed FROM orderRowComponent rc JOIN vn.component c ON c.id = rc.componentFk - JOIN vn.componentType ct ON ct.id = c.typeFk AND ct.isBase - WHERE rc.rowFk = vRowId; + JOIN vn.componentType ct ON ct.id = c.typeFk + AND ct.isBase + WHERE rc.rowFk = vRowFk; INSERT INTO vn.sale - SET itemFk = vItem, - ticketFk = vTicket, + SET itemFk = vItemFk, + ticketFk = vTicketFk, concept = vConcept, quantity = vAmount, price = vPrice, priceFixed = vPriceFixed, isPriceFixed = TRUE; - SET vSale = LAST_INSERT_ID(); + SET vSaleFk = LAST_INSERT_ID(); - INSERT INTO vn.saleComponent - (saleFk, componentFk, `value`) - SELECT vSale, rc.componentFk, rc.price + INSERT INTO vn.saleComponent (saleFk, componentFk, `value`) + SELECT vSaleFk, rc.componentFk, rc.price FROM orderRowComponent rc JOIN vn.component c ON c.id = rc.componentFk - WHERE rc.rowFk = vRowId - GROUP BY vSale, rc.componentFk; + WHERE rc.rowFk = vRowFk + GROUP BY vSaleFk, rc.componentFk; END IF; - UPDATE order_row SET Id_Movimiento = vSale - WHERE id = vRowId; - - -- Inserta en putOrder si la compra es de Floramondo - IF vIsLogifloraItem THEN - CALL cache.availableNoRaids_refresh(vCalc,FALSE,vWarehouse,vShipment); - - SET @available := 0; - - SELECT GREATEST(0,available) INTO @available - FROM cache.availableNoRaids - WHERE calc_id = vCalc - AND item_id = vItem; - - UPDATE cache.availableNoRaids - SET available = GREATEST(0,available - vAmount) - WHERE item_id = vItem - AND calc_id = vCalc; - - INSERT INTO edi.putOrder ( - deliveryInformationID, - supplyResponseId, - quantity , - EndUserPartyId, - EndUserPartyGLN, - FHAdminNumber, - saleFk - ) - SELECT di.ID, - i.supplyResponseFk, - CEIL((vAmount - @available)/ sr.NumberOfItemsPerCask), - o.address_id , - vClientId, - IFNULL(ca.fhAdminNumber, fhc.defaultAdminNumber), - vSale - FROM edi.deliveryInformation di - JOIN vn.item i ON i.supplyResponseFk = di.supplyResponseID - JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - LEFT JOIN edi.clientFHAdminNumber ca ON ca.clientFk = vClientId - JOIN edi.floraHollandConfig fhc - JOIN hedera.`order` o ON o.id = vSelf - WHERE i.id = vItem - AND di.LatestOrderDateTime > util.VN_NOW() - AND vAmount > @available - LIMIT 1; - END IF; + UPDATE orderRow + SET saleFk = vSaleFk + WHERE id = vRowFk; END LOOP; - - CLOSE cRows; + CLOSE vRows; END LOOP; + CLOSE vDates; - CLOSE cDates; - - UPDATE `order` SET confirmed = TRUE, confirm_date = util.VN_NOW() + UPDATE `order` + SET confirmed = TRUE, + confirm_date = util.VN_NOW() WHERE id = vSelf; COMMIT; @@ -15107,7 +14378,7 @@ BEGIN -- Código redundante - DO vn.till_new( + CALL vn.till_new( vCustomer ,vBank ,vAmount / 100 @@ -15880,7 +15151,7 @@ CREATE TABLE `queue` ( UNIQUE KEY `name` (`name`), UNIQUE KEY `description` (`description`), KEY `config` (`config`), - CONSTRAINT `queue_ibfk_1` FOREIGN KEY (`config`) REFERENCES `queueConfig` (`id`) ON UPDATE CASCADE + CONSTRAINT `queue_ibfk_1` FOREIGN KEY (`config`) REFERENCES `queueMultiConfig` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Queues'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -15902,25 +15173,6 @@ SET character_set_client = utf8; 1 AS `ringinuse` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `queueConfig` --- - -DROP TABLE IF EXISTS `queueConfig`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `queueConfig` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `strategy` varchar(128) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `timeout` int(10) unsigned NOT NULL, - `retry` int(10) unsigned NOT NULL, - `weight` int(10) unsigned NOT NULL, - `maxLen` int(10) unsigned NOT NULL, - `ringInUse` tinyint(4) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Default values for queues configuration'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `queueMember` -- @@ -15955,6 +15207,25 @@ SET character_set_client = utf8; 1 AS `paused` */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `queueMultiConfig` +-- + +DROP TABLE IF EXISTS `queueMultiConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `queueMultiConfig` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `strategy` varchar(128) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `timeout` int(10) unsigned NOT NULL, + `retry` int(10) unsigned NOT NULL, + `weight` int(10) unsigned NOT NULL, + `maxLen` int(10) unsigned NOT NULL, + `ringInUse` tinyint(4) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Default values for queues configuration'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `queuePhone` -- @@ -16028,7 +15299,7 @@ SET character_set_client = utf8; 1 AS `permit`, 1 AS `type`, 1 AS `context`, - 1 AS `incominglimit`, + 1 AS `call-limit`, 1 AS `pickupgroup`, 1 AS `directmedia`, 1 AS `insecure`, @@ -16060,7 +15331,7 @@ CREATE TABLE `sipConfig` ( `permit` varchar(95) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, `type` enum('user','peer','friend') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, `context` varchar(80) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `incomingLimit` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `call-limit` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, `pickupGroup` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, `directMedia` enum('yes','no') DEFAULT NULL, `insecure` varchar(45) NOT NULL, @@ -16858,6 +16129,22 @@ SET character_set_client = utf8; 1 AS `companyFk` */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `clientSupplier` +-- + +DROP TABLE IF EXISTS `clientSupplier`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientSupplier` ( + `companyFk` smallint(6) NOT NULL, + `type` enum('C','P') NOT NULL, + `idClientSupplier` int(11) NOT NULL, + `isSync` tinyint(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`companyFk`,`idClientSupplier`,`type`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='Clients and suppliers present in Sage and their synchronization status'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `clientesProveedores` -- @@ -17441,7 +16728,8 @@ BEGIN DECLARE vTransactionExportTaxFreeFk INT; DECLARE vSerialDua VARCHAR(1) DEFAULT 'D'; DECLARE vInvoiceTypeInformativeCode VARCHAR(1); - DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2) ; + DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2); + DECLARE vCompanyCode INT; SELECT SiglaNacion INTO vCountryCanariasCode FROM Naciones @@ -17451,9 +16739,6 @@ BEGIN FROM Naciones WHERE Nacion ='CEUTA Y MELILLA'; - SELECT pendingServiceTransactionTypeFk INTO vDuaTransactionFk - FROM config; - SELECT id INTO vTaxImportFk FROM taxType WHERE code = 'import21'; @@ -17466,10 +16751,14 @@ BEGIN FROM taxType WHERE code = 'import4'; - SELECT definitiveExportTransactionTypeFk INTO vTransactionExportFk - FROM config; - - SELECT shipmentTransactionTypeFk INTO vTransactionExportTaxFreeFk + SELECT shipmentTransactionTypeFk, + definitiveExportTransactionTypeFk, + pendingServiceTransactionTypeFk, + company_getCode(vCompanyFk) + INTO vTransactionExportTaxFreeFk, + vTransactionExportFk, + vDuaTransactionFk, + vCompanyCode FROM config; SELECT codeSage INTO vInvoiceTypeInformativeCode @@ -17484,8 +16773,6 @@ BEGIN WHERE enlazadoSage = FALSE AND Asiento <> 1 ; - CALL clientSupplier_add(vCompanyFk); - CALL pgc_add(vCompanyFk); CALL invoiceOut_manager(vYear, vCompanyFk); CALL invoiceIn_manager(vYear, vCompanyFk); @@ -17578,7 +16865,7 @@ BEGIN ) SELECT 'EN' TipoEntrada, YEAR(x.FECHA) Ejercicio, - company_getCode(vCompanyFk) AS CodigoEmpresa, + vCompanyCode CodigoEmpresa, x.ASIEN Asiento, IF(EURODEBE <> 0 OR (EURODEBE = 0 AND EUROHABER IS NULL), 'D', 'H') CargoAbono, @@ -17711,20 +16998,6 @@ BEGIN WHERE m.CargoAbono = 'D' AND m.enlazadoSage = FALSE; --- Elimina cuentas de cliente/proveedor que no se utilizarán en la importación - DELETE cp - FROM clientesProveedores cp - LEFT JOIN movConta mc ON mc.codigoCuenta = cp.codigoCuenta - AND mc.enlazadoSage = FALSE - WHERE mc.codigoCuenta IS NULL; - --- Elimina cuentas contables que no se utilizarán en la importación - DELETE pc - FROM planCuentasPGC pc - LEFT JOIN movConta mc ON mc.codigoCuenta = pc.codigoCuenta - AND mc.enlazadoSage = FALSE - WHERE mc.codigoCuenta IS NULL; - -- DUAS UPDATE movConta mci JOIN vn.XDiario x ON x.ASIEN = mci.Asiento @@ -17831,6 +17104,56 @@ BEGIN AND importeDivisa > 0 AND ImporteAsiento < 0; + CREATE OR REPLACE TEMPORARY TABLE tmp.clientSupplier + (INDEX(idClientSupplier, `type`)) + ENGINE = MEMORY + WITH client AS( + SELECT DISTINCT c.id + FROM sage.movConta mc + JOIN vn.client c ON c.accountingAccount = mc.CodigoCuenta + WHERE NOT enlazadoSage + ),supplier AS( + SELECT DISTINCT s.id + FROM sage.movConta mc + JOIN vn.supplier s ON s.account = mc.CodigoCuenta + WHERE NOT enlazadoSage + ),clientSupplierSync AS( + SELECT idClientSupplier, `type` + FROM sage.clientSupplier cs + WHERE isSync + ) + SELECT idClientSupplier, `type` + FROM sage.clientSupplier cs + WHERE NOT isSync + UNION + SELECT id, 'C' + FROM client c + LEFT JOIN clientSupplierSync cs ON cs.idClientSupplier = c.id + AND cs.Type ='C' + WHERE cs.idClientSupplier IS NULL + UNION + SELECT id, 'P' + FROM supplier s + LEFT JOIN clientSupplierSync cs ON cs.idClientSupplier = s.id + AND cs.Type ='P' + WHERE cs.idClientSupplier IS NULL; + + CALL clientSupplier_add(vCompanyFk); + + INSERT IGNORE INTO sage.clientSupplier (companyFk, `type`, idClientSupplier, isSync) + SELECT vCompanyCode, `type`, idClientSupplier, FALSE + FROM tmp.clientSupplier; + + DROP TEMPORARY TABLE tmp.clientSupplier; + + CALL pgc_add(vCompanyFk); +-- Elimina cuentas contables que no se utilizarán en la importación + DELETE pc + FROM planCuentasPGC pc + LEFT JOIN movConta mc ON mc.codigoCuenta = pc.codigoCuenta + AND mc.enlazadoSage = FALSE + WHERE mc.codigoCuenta IS NULL; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -17872,13 +17195,18 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `clientSupplier_add`(vCompanyFk INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `clientSupplier_add`( + vCompanyFk INT +) BEGIN /** - * Prepara los datos de clientes y proveedores para exportarlos a Sage - * @vCompanyFk Empresa dela que se quiere trasladar datos + * Inserta en la tabla sage.clientesProveedores los datos de clientes y proveedores + * que se actualizaran o se daran de alta en Sage + * @vCompanyFk Id de empresa + * @table tmp.clientSupplier(idClientSupplier, `type`) */ DECLARE vCountryCeutaMelillaFk INT; + DECLARE vCompanyCode INT DEFAULT company_getCode(vCompanyFk); DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2); SELECT SiglaNacion INTO vCountryCanariasCode @@ -17918,7 +17246,7 @@ BEGIN Email1, iban) SELECT - company_getCode(vCompanyFk), + vCompanyCode, 'C', c.id, c.socialName, @@ -17926,7 +17254,7 @@ BEGIN IFNULL(c.street, ''), c.accountingAccount, @fi := IF(cu.code = LEFT(TRIM(c.fi), 2) AND c.isVies, MID(TRIM(c.fi), 3, LENGTH(TRIM(c.fi))-1), TRIM(c.fi)), - IF(c.isVies, CONCAT(cu.code, @fi ), TRIM(c.fi)), + IF(c.isVies, CONCAT(IFNULL(cu.viesCode,cu.code), @fi ), TRIM(c.fi)), IFNULL(c.postcode, ''), IFNULL(c.city, ''), IFNULL(pr.CodigoProvincia, ''), @@ -17948,15 +17276,14 @@ BEGIN IFNULL(SUBSTR(c.email, 1, LOCATE(',', CONCAT(c.email, ','))-1), ''), IFNULL(c.iban, '') FROM vn.`client` c - JOIN clientLastTwoMonths clm ON clm.clientFk = c.id + JOIN tmp.clientSupplier cs ON cs.idClientSupplier = c.id LEFT JOIN vn.country cu ON cu.id = c.countryFk LEFT JOIN Naciones n ON n.countryFk = cu.id LEFT JOIN vn.province p ON p.id = c.provinceFk LEFT JOIN Provincias pr ON pr.provinceFk = p.id - WHERE c.isRelevant - AND clm.companyFk = vCompanyFk + WHERE cs.type = 'C' UNION ALL - SELECT company_getCode(vCompanyFk), + SELECT vCompanyCode, 'P', s.id, s.name, @@ -17964,7 +17291,7 @@ BEGIN IFNULL(s.street, ''), s.account, @nif := IF(co.code = LEFT(TRIM(s.nif), 2), MID(TRIM(s.nif), 3, LENGTH(TRIM(s.nif))-1), TRIM(s.nif)), - IF(s.isVies, CONCAT(co.code, @nif), TRIM(s.nif)), + IF(s.isVies, CONCAT(IFNULL(co.viesCode,co.code), @nif), TRIM(s.nif)), IFNULL(s.postCode,''), IFNULL(s.city, ''), IFNULL(pr.CodigoProvincia, ''), @@ -17980,19 +17307,17 @@ BEGIN IFNULL(s.transactionTypeSageFk, 0), IFNULL(s.withholdingSageFk, '0'), IFNULL(SUBSTR(sc.email, 1, (COALESCE(NULLIF(LOCATE(',', sc.email), 0), 99) - 1)), ''), - IFNULL(iban, '') + IFNULL(sa.iban, '') FROM vn.supplier s - JOIN supplierLastThreeMonths pl ON pl.supplierFk = s.id + JOIN tmp.clientSupplier cs ON cs.idClientSupplier = s.id LEFT JOIN vn.country co ON co.id = s.countryFk LEFT JOIN Naciones n ON n.countryFk = co.id LEFT JOIN vn.province p ON p.id = s.provinceFk LEFT JOIN Provincias pr ON pr.provinceFk = p.id LEFT JOIN vn.supplierContact sc ON sc.supplierFk = s.id LEFT JOIN vn.supplierAccount sa ON sa.supplierFk = s.id - WHERE pl.companyFk = vCompanyFk AND - s.isActive AND - s.nif <> '' - GROUP BY pl.supplierFk, pl.companyFk; + WHERE cs.type = 'P' + GROUP BY s.id; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -18953,6 +18278,7 @@ CREATE TABLE `ACL` ( `permission` set('DENY','ALLOW') DEFAULT 'ALLOW', `principalType` set('ROLE','USER') DEFAULT 'ROLE', `principalId` varchar(512) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `model_ix` (`model`(255)) COMMENT 'ernesto 3.8.2020. Mysql pide indices', KEY `property_ix` (`property`(255)), @@ -18960,6 +18286,35 @@ CREATE TABLE `ACL` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `ACLLog` +-- + +DROP TABLE IF EXISTS `ACLLog`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ACLLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete','select') NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `changedModel` enum('Acl') NOT NULL DEFAULT 'Acl', + `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)), + `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), + `changedModelId` int(11) NOT NULL, + `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `logRateuserFk` (`userFk`), + KEY `ACLLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), + KEY `ACLLog_originFk` (`originFk`,`creationDate`), + KEY `ACLLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, + CONSTRAINT `aclUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `AccessToken` -- @@ -19082,13 +18437,13 @@ CREATE TABLE `authCode` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `defaultViewConfig` +-- Table structure for table `defaultViewMultiConfig` -- -DROP TABLE IF EXISTS `defaultViewConfig`; +DROP TABLE IF EXISTS `defaultViewMultiConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `defaultViewConfig` ( +CREATE TABLE `defaultViewMultiConfig` ( `tableCode` varchar(25) NOT NULL, `columns` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='The default configuration of columns for views'; @@ -19272,6 +18627,7 @@ CREATE TABLE `buffer` ( `hasStrapper` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'tiene una flejadora acoplada', `typeDefaultFk` int(11) NOT NULL DEFAULT 1 COMMENT 'estado por defecto', `motors` int(11) NOT NULL DEFAULT 1 COMMENT 'número de fotocélulas que corresponden con sectores de motor independientes', + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`), KEY `buffer_FK` (`stateFk`), @@ -19339,6 +18695,35 @@ CREATE TABLE `bufferGroup` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Agrupación de buffers que sirven de salida para las mismas rutas'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `bufferLog` +-- + +DROP TABLE IF EXISTS `bufferLog`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `bufferLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete','select') NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `changedModel` enum('Buffer','Config') NOT NULL DEFAULT 'Buffer', + `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)), + `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), + `changedModelId` int(11) NOT NULL, + `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `logBufferUserFk` (`userFk`), + KEY `bufferLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), + KEY `bufferLog_originFk` (`originFk`,`creationDate`), + KEY `bufferLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, + CONSTRAINT `bufferUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `bufferPool` -- @@ -19446,6 +18831,7 @@ CREATE TABLE `config` ( `isBalanced` tinyint(1) NOT NULL DEFAULT 1, `testMode` tinyint(1) NOT NULL DEFAULT 0, `isAllowedUnloading` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Permite que se pueda cambiar el mode de los buffers a UNLOADING', + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), CONSTRAINT `config_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -19626,7 +19012,6 @@ CREATE TABLE `moving` ( `created` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), UNIQUE KEY `moving_UN` (`expeditionFk`), - KEY `moving_fk1_idx` (`expeditionFk`), KEY `moving_fk2_idx` (`bufferFromFk`), KEY `moving_fk3_idx` (`bufferToFk`), KEY `moving_FK` (`stateFk`), @@ -19803,18 +19188,14 @@ DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; /*!50003 SET @saved_col_connection = @@collation_connection */ ;; -/*!50003 SET character_set_client = utf8mb3 */ ;; -/*!50003 SET character_set_results = utf8mb3 */ ;; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `moving_clean` ON SCHEDULE EVERY 5 MINUTE STARTS '2022-01-21 00:00:00' ON COMPLETION PRESERVE ENABLE COMMENT 'Llama a srt.moving_clean para que elimine y notifique de registr' DO BEGIN - - CALL srt.moving_clean(); - -END */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `moving_clean` ON SCHEDULE EVERY 15 MINUTE STARTS '2022-01-21 00:00:00' ON COMPLETION PRESERVE ENABLE COMMENT 'Llama a srt.moving_clean para que elimine y notifique de registr' DO CALL srt.moving_clean() */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -20277,14 +19658,14 @@ BEGIN DECLARE vDayMinute INT; - SELECT HOUR(IFNULL(et.ETD, z.`hour`)) * 60 + MINUTE(IFNULL(et.ETD, z.`hour`)) INTO vDayMinute + SELECT HOUR(IFNULL(rs.ETD, z.`hour`)) * 60 + MINUTE(IFNULL(rs.ETD, z.`hour`)) INTO vDayMinute FROM vn.expedition e JOIN vn.ticket t ON e.ticketFk = t.id JOIN vn.`zone` z ON z.id = t.zoneFk LEFT JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.routesMonitor rm ON t.routeFk = rm.routeFk - LEFT JOIN vn.expeditionTruck et ON rm.expeditionTruckFk = et.id + LEFT JOIN vn.roadmapStop rs ON rm.roadmapStopFk = rs.id WHERE e.id = vExpeditionFk; RETURN vDayMinute; @@ -21803,8 +21184,8 @@ BEGIN SET @dm := (24 * 60) - 10; - UPDATE vn.expeditionTruck et - SET et.eta = timestampadd(MINUTE ,@dm := 1 + @dm,util.VN_CURDATE()) + UPDATE vn.roadmapStop rs + SET rs.eta = timestampadd(MINUTE ,@dm := 1 + @dm,util.VN_CURDATE()) WHERE description LIKE 'PRU%' ; DELETE FROM srt.movingLog ; @@ -22177,62 +21558,70 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `moving_clean`() BEGIN /** * Elimina movimientos por inactividad - * */ DECLARE vExpeditionFk INT; - DECLARE vBufferToFk INT; DECLARE vBufferFromFk INT; - DECLARE done BOOL DEFAULT FALSE; - - DECLARE cur CURSOR FOR - SELECT m.expeditionFk, m.bufferToFk, m.bufferFromFk - FROM srt.moving m - JOIN srt.config c - JOIN (SELECT bufferFk, SUM(isActive) hasBox - FROM srt.photocell - GROUP BY bufferFk) sub ON sub.bufferFk = m.bufferFromFk - WHERE m.created < TIMESTAMPADD(MINUTE, - c.movingMaxLife , util.VN_NOW()) + DECLARE vStateOutFk INT + DEFAULT (SELECT id FROM expeditionState WHERE `description` = 'OUT'); + DECLARE vDone BOOL; + DECLARE vSorter CURSOR FOR + SELECT m.expeditionFk, m.bufferFromFk + FROM moving m + JOIN ( + SELECT bufferFk, SUM(isActive) hasBox + FROM photocell + GROUP BY bufferFk + ) sub ON sub.bufferFk = m.bufferFromFk + WHERE m.created < (util.VN_NOW() - INTERVAL (SELECT movingMaxLife FROM config) MINUTE) AND NOT sub.hasBox; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - OPEN cur; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; - bucle: LOOP + OPEN vSorter; + l: LOOP + SET vDone = FALSE; + FETCH vSorter INTO vExpeditionFk, vBufferFromFk; - FETCH cur INTO vExpeditionFk, vBufferToFk, vBufferFromFk; - - IF done THEN - LEAVE bucle; + IF vDone THEN + LEAVE l; END IF; - DELETE FROM srt.moving + START TRANSACTION; + + SELECT id + FROM moving + WHERE expeditionFk = vExpeditionFk + FOR UPDATE; + + DELETE FROM moving WHERE expeditionFk = vExpeditionFk; - UPDATE srt.expedition e - JOIN srt.expeditionState es ON es.description = 'OUT' - SET - bufferFk = NULL, + SELECT id + FROM expedition + WHERE id = vExpeditionFk + OR (bufferFk = vBufferFromFk AND `position` > 0) + FOR UPDATE; + + UPDATE expedition + SET bufferFk = NULL, `position` = NULL, - stateFk = es.id - WHERE e.id = vExpeditionFk; + stateFk = vStateOutFk + WHERE id = vExpeditionFk; - UPDATE srt.expedition e - SET e.`position` = e.`position` - 1 - WHERE e.bufferFk = vBufferFromFk - AND e.`position` > 0; - - CALL vn.mail_insert( - 'pako@verdnatura.es, carles@verdnatura.es', - NULL, - CONCAT('Moving_clean. Expedition: ', vExpeditionFk, ' estaba parada'), - CONCAT('Expedition: ', vExpeditionFk,' vBufferToFk: ', vBufferToFk) - ); - - END LOOP bucle; - - CLOSE cur; + UPDATE expedition + SET `position` = `position` - 1 + WHERE bufferFk = vBufferFromFk + AND `position` > 0; + COMMIT; + END LOOP l; + CLOSE vSorter; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -23437,12 +22826,13 @@ BEGIN m.created, TIMESTAMPADD(DAY, tp.life, t.shipped) expired, m.quantity < 0 isIn, - m.isPicked OR s.alertLevel > 1 isPicked + m.isPicked OR s.alertLevel > al.id isPicked FROM vn.sale m JOIN vn.ticket t ON t.id = m.ticketFk JOIN vn.ticketState s ON s.ticketFk = t.id JOIN vn.item i ON i.id = m.itemFk JOIN vn.itemType tp ON tp.id = i.typeFk + JOIN vn.alertLevel al ON al.code = 'ON_PREPARATION' WHERE ( vTableId IS NULL OR (vTableName = 'ticket' AND t.id = vTableId) @@ -23962,8 +23352,8 @@ DROP TABLE IF EXISTS `config`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `config` ( `id` int(10) unsigned NOT NULL, - `dbVersion` char(11) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT 'The current database version', - `hasTriggersDisabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Defines if triggers are disabled', + `dbVersion__` char(11) DEFAULT NULL COMMENT '@deprecated 2024-09-02 refs #7819', + `hasTriggersDisabled__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-09-02 refs #7819', `environment` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT 'The current Database environment', `lastDump` datetime DEFAULT NULL COMMENT 'Timestamp of the last data dump', `mockUtcTime` datetime DEFAULT NULL, @@ -24026,6 +23416,24 @@ SET character_set_client = utf8; 1 AS `error` */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `logCleanMultiConfig` +-- + +DROP TABLE IF EXISTS `logCleanMultiConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `logCleanMultiConfig` ( + `schemaName` varchar(64) NOT NULL, + `tableName` varchar(64) NOT NULL, + `retentionDays` int(11) DEFAULT NULL, + `order` int(11) DEFAULT NULL, + `started` datetime DEFAULT NULL, + `finished` datetime DEFAULT NULL, + PRIMARY KEY (`schemaName`,`tableName`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `notification` -- @@ -24172,7 +23580,25 @@ CREATE TABLE `versionLog` ( -- Dumping events for database 'util' -- /*!50106 SET @save_time_zone= @@TIME_ZONE */ ; -/*!50106 DROP EVENT IF EXISTS `slowLog_prune` */; +/*!50106 DROP EVENT IF EXISTS `log_clean` */; +DELIMITER ;; +/*!50003 SET @saved_cs_client = @@character_set_client */ ;; +/*!50003 SET @saved_cs_results = @@character_set_results */ ;; +/*!50003 SET @saved_col_connection = @@collation_connection */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ;; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; +/*!50003 SET @saved_time_zone = @@time_zone */ ;; +/*!50003 SET time_zone = 'SYSTEM' */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `log_clean` ON SCHEDULE EVERY 1 DAY STARTS '2024-07-09 00:30:00' ON COMPLETION PRESERVE ENABLE DO CALL util.log_clean */ ;; +/*!50003 SET time_zone = @saved_time_zone */ ;; +/*!50003 SET sql_mode = @saved_sql_mode */ ;; +/*!50003 SET character_set_client = @saved_cs_client */ ;; +/*!50003 SET character_set_results = @saved_cs_results */ ;; +/*!50003 SET collation_connection = @saved_col_connection */ ;; +/*!50106 DROP EVENT IF EXISTS `slowLog_prune` */;; DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; @@ -24863,6 +24289,7 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `midnight`() RETURNS datetime READS SQL DATA + DETERMINISTIC BEGIN RETURN TIMESTAMP(util.VN_CURDATE(), '23:59:59'); @@ -25481,7 +24908,10 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `debugAdd`(vVariable VARCHAR(255), vValue VARCHAR(255)) +CREATE DEFINER=`root`@`localhost` PROCEDURE `debugAdd`( + vVariable VARCHAR(255), + vValue TEXT +) MODIFIES SQL DATA BEGIN /** @@ -25625,6 +25055,73 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `log_clean` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `log_clean`() +BEGIN +/** + * Hace limpieza de los datos de las tablas log, + * dejando únicamente los días de retención configurados. + */ + DECLARE vSchemaName VARCHAR(65); + DECLARE vSchemaNameQuoted VARCHAR(65); + DECLARE vTableName VARCHAR(65); + DECLARE vTableNameQuoted VARCHAR(65); + DECLARE vRetentionDays INT; + DECLARE vStarted DATETIME; + DECLARE vDated DATE; + DECLARE vDone BOOL; + + DECLARE vQueue CURSOR FOR + SELECT schemaName, tableName, retentionDays + FROM logCleanMultiConfig + ORDER BY `order`; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vQueue; + l: LOOP + SET vDone = FALSE; + FETCH vQueue INTO vSchemaName, vTableName, vRetentionDays; + + IF vDone THEN + LEAVE l; + END IF; + + IF vRetentionDays THEN + SET vStarted = VN_NOW(); + SET vSchemaNameQuoted = quoteIdentifier(vSchemaName); + SET vTableNameQuoted = quoteIdentifier(vTableName); + SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY; + + EXECUTE IMMEDIATE CONCAT( + 'DELETE FROM ', vSchemaNameQuoted, + '.', vTableNameQuoted, + " WHERE creationDate < '", vDated, "'" + ); + + UPDATE logCleanMultiConfig + SET `started` = vStarted, + `finished` = VN_NOW() + WHERE schemaName = vSchemaName + AND tableName = vTableName; + END IF; + END LOOP; + CLOSE vQueue; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `log_cleanInstances` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -25942,14 +25439,14 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `tx_commit`(isTx BOOL) +CREATE DEFINER=`root`@`localhost` PROCEDURE `tx_commit`(vIsTx BOOL) BEGIN /** * Confirma los cambios asociados a una transacción. * - * @param isTx es true si existe transacción asociada + * @param vIsTx es true si existe transacción asociada */ - IF isTx THEN + IF vIsTx THEN COMMIT; END IF; END ;; @@ -25968,14 +25465,14 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `tx_rollback`(isTx BOOL) +CREATE DEFINER=`root`@`localhost` PROCEDURE `tx_rollback`(vIsTx BOOL) BEGIN /** * Deshace los cambios asociados a una transacción. * - * @param isTx es true si existe transacción asociada + * @param vIsTx es true si existe transacción asociada */ - IF isTx THEN + IF vIsTx THEN ROLLBACK; END IF; END ;; @@ -25994,14 +25491,14 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `tx_start`(isTx BOOL) +CREATE DEFINER=`root`@`localhost` PROCEDURE `tx_start`(vIsTx BOOL) BEGIN /** * Inicia una transacción. * - * @param isTx es true si existe transacción asociada + * @param vIsTx es true si existe transacción asociada */ - IF isTx THEN + IF vIsTx THEN START TRANSACTION; END IF; END ;; @@ -26143,6 +25640,7 @@ CREATE TABLE `absenceType` ( `holidayEntitlementRate` decimal(3,2) DEFAULT 1.00, `isNaturalDay` tinyint(1) DEFAULT 0 COMMENT 'Para el cálculo de los salarios de los repartidores', `isCalculate` tinyint(1) DEFAULT 0 COMMENT 'Para el cálculo de los salarios de los repartidores', + `isFestiveEligible` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Para marcar un tipo de absence', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -26177,7 +25675,9 @@ DROP TABLE IF EXISTS `accountDetailType`; CREATE TABLE `accountDetailType` ( `id` int(11) NOT NULL AUTO_INCREMENT, `description` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id`) + `code` varchar(45) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `code` (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -26415,14 +25915,15 @@ CREATE TABLE `addressObservation` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `addressShortage` +-- Table structure for table `addressWaste` -- -DROP TABLE IF EXISTS `addressShortage`; +DROP TABLE IF EXISTS `addressWaste`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `addressShortage` ( +CREATE TABLE `addressWaste` ( `addressFk` int(11) NOT NULL, + `type` enum('external','fault','container','break','other') NOT NULL, PRIMARY KEY (`addressFk`), CONSTRAINT `addressShortage_FK` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -26439,17 +25940,14 @@ CREATE TABLE `agency` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(25) NOT NULL, `warehouseFk` smallint(5) unsigned DEFAULT NULL COMMENT 'A nulo si se puede enrutar desde todos los almacenes', - `warehouseAliasFk__` smallint(5) unsigned DEFAULT NULL COMMENT '@deprecated 2024-01-23 refs #5167', `isOwn` tinyint(1) NOT NULL DEFAULT 0, `workCenterFk` int(11) DEFAULT NULL, `isAnyVolumeAllowed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Permite vender productos que tengan vn.itemType.IsUnconventionalSize = TRUE', `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `warehouse_id` (`warehouseFk`), - KEY `agencias_alias_idx` (`warehouseAliasFk__`), KEY `agency_ibfk_3_idx` (`workCenterFk`), KEY `agency_user_FK` (`editorFk`), - CONSTRAINT `agency_FK` FOREIGN KEY (`warehouseAliasFk__`) REFERENCES `warehouseAlias__` (`id`) ON UPDATE CASCADE, CONSTRAINT `agency_ibfk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `agency_ibfk_3` FOREIGN KEY (`workCenterFk`) REFERENCES `workCenter` (`id`) ON UPDATE CASCADE, CONSTRAINT `agency_user_FK` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) @@ -26476,6 +25974,19 @@ CREATE TABLE `agencyExtraCharge` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `agencyIncoming` +-- + +DROP TABLE IF EXISTS `agencyIncoming`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `agencyIncoming` ( + `agencyModeFk` int(11) NOT NULL, + PRIMARY KEY (`agencyModeFk`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Agencias de entrada de mercancias'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `agencyLog` -- @@ -26495,10 +26006,12 @@ CREATE TABLE `agencyLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `logAgencyUserFk` (`userFk`), KEY `agencyLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), KEY `agencyLog_originFk` (`originFk`,`creationDate`), + KEY `agencyLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `agencyOriginFk` FOREIGN KEY (`originFk`) REFERENCES `agency` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `agencyUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -26882,7 +26395,6 @@ CREATE TABLE `awbComponent` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `awbFk` smallint(11) unsigned DEFAULT NULL, `supplierFk` int(11) NOT NULL, - `dated__` date NOT NULL, `typeFk` mediumint(3) unsigned DEFAULT NULL, `awbRoleFk` tinyint(1) unsigned NOT NULL DEFAULT 1, `awbUnitFk` varchar(10) DEFAULT NULL, @@ -27241,30 +26753,6 @@ CREATE TABLE `bookingPlanner` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `botanicExport__` --- - -DROP TABLE IF EXISTS `botanicExport__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `botanicExport__` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `ediGenusFk` mediumint(8) unsigned NOT NULL, - `ediSpecieFk` mediumint(8) unsigned DEFAULT NULL, - `countryFk__` mediumint(8) unsigned DEFAULT NULL, - `restriction` enum('Sin restriccion','Importacion Prohibida','pasaporte fitosanitario','pasaporte individual','declaracion origen') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `description` varchar(45) DEFAULT NULL, - `isProtectedZone` tinyint(1) NOT NULL DEFAULT 0, - `code` enum('importProhibited','phytosanitaryPassport','individualPassport') DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `Id_Paises` (`countryFk__`), - KEY `botanicExport_ibfk_2_idx` (`ediGenusFk`), - KEY `botanicExport_ibfk_3_idx` (`ediSpecieFk`), - CONSTRAINT `botanicExport___ibfk_1` FOREIGN KEY (`countryFk__`) REFERENCES `country` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #4419 Deprecated 2023-07-20'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `budget` -- @@ -27514,7 +27002,6 @@ CREATE TABLE `buy` ( `packing` int(11) NOT NULL DEFAULT 1 CHECK (`packing` > 0), `grouping` smallint(5) unsigned NOT NULL DEFAULT 1, `groupingMode` enum('grouping','packing') DEFAULT NULL, - `containerFk` smallint(5) unsigned DEFAULT NULL, `comissionValue` decimal(10,3) NOT NULL DEFAULT 0.000, `packageValue` decimal(10,3) NOT NULL DEFAULT 0.000, `location` varchar(5) DEFAULT NULL, @@ -27539,7 +27026,6 @@ CREATE TABLE `buy` ( KEY `CompresId_Trabajador` (`workerFk`), KEY `Id_Cubo` (`packagingFk`), KEY `Id_Entrada` (`entryFk`), - KEY `container_id` (`containerFk`), KEY `buy_edi_id` (`ektFk`), KEY `itemFk_entryFk` (`itemFk`,`entryFk`), KEY `buy_fk_4_idx` (`deliveryFk`), @@ -27547,7 +27033,6 @@ CREATE TABLE `buy` ( KEY `buy_itemFk_IDX` (`itemFk`) USING BTREE, KEY `buy_fk_editor` (`editorFk`), CONSTRAINT `buy_FK` FOREIGN KEY (`itemOriginalFk`) REFERENCES `item` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `buy_FK_1` FOREIGN KEY (`containerFk`) REFERENCES `vn2008`.`container__` (`container_id`) ON UPDATE CASCADE, CONSTRAINT `buy_ektFk` FOREIGN KEY (`ektFk`) REFERENCES `edi`.`ekt` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `buy_fk_4` FOREIGN KEY (`deliveryFk`) REFERENCES `edi`.`deliveryInformation` (`ID`) ON DELETE SET NULL ON UPDATE SET NULL, CONSTRAINT `buy_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), @@ -27630,14 +27115,17 @@ CREATE TABLE `calendar` ( `businessFk` int(11) NOT NULL, `dayOffTypeFk` int(11) NOT NULL, `dated` date NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `calendar_UN` (`businessFk`,`dated`), KEY `calendar_employee_business_labour_id_idx` (`businessFk`), KEY `calendar_employee_calendar_state_calendar_state_id_idx` (`dayOffTypeFk`), KEY `id_index` (`id`), + KEY `calendar_user_FK` (`editorFk`), CONSTRAINT `calendar_FK` FOREIGN KEY (`dayOffTypeFk`) REFERENCES `absenceType` (`id`) ON UPDATE CASCADE, - CONSTRAINT `calendar_businessFk` FOREIGN KEY (`businessFk`) REFERENCES `business` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `calendar_businessFk` FOREIGN KEY (`businessFk`) REFERENCES `business` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `calendar_user_FK` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -27776,7 +27264,6 @@ CREATE TABLE `chat` ( `dated` datetime DEFAULT NULL, `checkUserStatus` tinyint(1) DEFAULT NULL, `message` text DEFAULT NULL, - `status__` tinyint(1) DEFAULT NULL, `attempts` int(1) DEFAULT NULL, `error` text DEFAULT NULL, `status` enum('pending','sent','error','sending') NOT NULL DEFAULT 'pending', @@ -27824,7 +27311,6 @@ CREATE TABLE `claim` ( `ticketFk` int(11) DEFAULT NULL, `pickup` enum('agency','delivery') DEFAULT NULL, `packages` smallint(10) unsigned DEFAULT 0 COMMENT 'packages received by the client', - `rma__` varchar(100) DEFAULT NULL, `responsabilityRate` decimal(3,2) GENERATED ALWAYS AS ((5 - `responsibility`) / 4) VIRTUAL, `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), @@ -27873,6 +27359,8 @@ DROP TABLE IF EXISTS `claimConfig`; CREATE TABLE `claimConfig` ( `id` int(10) unsigned NOT NULL, `maxResponsibility` int(11) DEFAULT NULL, + `monthsToRefund` int(11) DEFAULT NULL, + `minShipped` date DEFAULT NULL, PRIMARY KEY (`id`), CONSTRAINT `claimConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -27889,6 +27377,7 @@ CREATE TABLE `claimDestination` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, `description` varchar(15) NOT NULL, `addressFk` int(10) DEFAULT NULL COMMENT 'Indica el consignatario para el ticket que regulariza el inventario', + `code` varchar(45) DEFAULT NULL, PRIMARY KEY (`id`), KEY `clSolAddressFk_idx` (`addressFk`), CONSTRAINT `clSolAddressFk` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON DELETE SET NULL ON UPDATE CASCADE @@ -27999,10 +27488,12 @@ CREATE TABLE `claimLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `claimLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), KEY `claimLog_claimLog` (`originFk`,`creationDate`), + KEY `claimLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `claimUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -28111,22 +27602,6 @@ CREATE TABLE `claimResult` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Consecuencias de los motivos'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `claimRma__` --- - -DROP TABLE IF EXISTS `claimRma__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `claimRma__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `code` varchar(100) NOT NULL, - `created` timestamp NOT NULL DEFAULT current_timestamp(), - `workerFk` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='kkeada el 2024-02-26 por Pablo'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `claimState` -- @@ -28193,7 +27668,6 @@ CREATE TABLE `client` ( `riskCalculated` date NOT NULL, `hasCoreVnh` tinyint(1) DEFAULT 0, `isRelevant` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Define los clientes cuyas ventas hay que tener en cuenta en los calculos estadisticos.', - `clientTypeFk__` int(11) NOT NULL DEFAULT 1 COMMENT '@deprecated 2024-02-20 refs #6784', `creditInsurance` int(11) DEFAULT NULL, `eypbc` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Email\\nYesterday\\nPurchases\\nBy\\nConsigna', `hasToInvoiceByAddress` tinyint(1) DEFAULT 0, @@ -28209,10 +27683,10 @@ CREATE TABLE `client` ( `transferorFk` int(11) DEFAULT NULL COMMENT 'Cliente que le ha transmitido la titularidad de la empresa', `lastSalesPersonFk` int(10) unsigned DEFAULT NULL COMMENT 'ultimo comercial que tuvo, para el calculo del peso en los rankings de equipo', `businessTypeFk` varchar(20) NOT NULL DEFAULT 'florist', - `hasIncoterms` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Received incoterms authorization from client', `rating` int(10) unsigned DEFAULT NULL COMMENT 'información proporcionada por Informa', `recommendedCredit` int(10) unsigned DEFAULT NULL COMMENT 'información proporcionada por Informa', `editorFk` int(10) unsigned DEFAULT NULL, + `hasDailyInvoice` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si el cliente requiere facturación diaria por defecto se copiará lo que tenga country.hasDailyInvoice', PRIMARY KEY (`id`), UNIQUE KEY `IF` (`fi`), KEY `Id_Trabajador` (`salesPersonFk`), @@ -28224,7 +27698,6 @@ CREATE TABLE `client` ( KEY `default_address` (`defaultAddressFk`), KEY `Telefono` (`phone`), KEY `movil` (`mobile`), - KEY `tipos_de_cliente_idx` (`clientTypeFk__`), KEY `fk_Clientes_entity_idx` (`bankEntityFk`), KEY `typeFk` (`typeFk`), KEY `client_taxTypeSageFk_idx` (`taxTypeSageFk`), @@ -28290,6 +27763,7 @@ CREATE TABLE `clientConfig` ( `defaultIsTaxDataChecked` tinyint(1) DEFAULT NULL, `defaultHasCoreVnl` tinyint(1) DEFAULT NULL, `defaultMandateTypeFk` smallint(5) DEFAULT NULL, + `monthsToDisableUser` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `clientNewConfigPayMethod_FK` (`defaultPayMethodFk`), KEY `clientNewConfigMandateType_FK` (`defaultMandateTypeFk`), @@ -28390,7 +27864,7 @@ CREATE TABLE `clientInforma` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `clientFk` int(11) NOT NULL, `rating` int(10) unsigned DEFAULT NULL, - `recommendedCredit` int(10) unsigned DEFAULT NULL, + `recommendedCredit` int(10) unsigned NOT NULL, `workerFk` int(10) unsigned NOT NULL, `created` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), @@ -28435,15 +27909,17 @@ CREATE TABLE `clientLog` ( `action` set('insert','update','delete') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `changedModel` enum('Client','Address','ClientContact','ClientDms','ClientObservation','ClientSample','Greuge','Recovery','TpvTransaction','WorkerDms','Sms') NOT NULL DEFAULT 'Client', + `changedModel` enum('Client','Address','ClientContact','ClientDms','ClientObservation','ClientSample','ClientUnpaid','Greuge','Recovery','TpvTransaction','WorkerDms','Sms') NOT NULL DEFAULT 'Client', `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)), `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `clientLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), KEY `clientLog_clientLog` (`originFk`,`creationDate`), + KEY `clientLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `clientLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -28549,6 +28025,24 @@ CREATE TABLE `clientProtected` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Lista de clientes y comerciales que no se van a ver afectados por las desagsignaciones mensuales automaticas'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `clientRate` +-- + +DROP TABLE IF EXISTS `clientRate`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientRate` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `clientFk` int(11) NOT NULL, + `dated` date NOT NULL DEFAULT current_timestamp(), + `value` decimal(10,2) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `clientRate_unique` (`clientFk`,`dated`), + CONSTRAINT `clientRate_client_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `clientRisk` -- @@ -28624,7 +28118,6 @@ DROP TABLE IF EXISTS `clientType`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `clientType` ( - `id__` int(11) NOT NULL COMMENT '@deprecated 2024-02-20 refs #6784', `code` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, `type` varchar(45) NOT NULL, `isCreatedAsServed` tinyint(1) DEFAULT 0, @@ -28644,7 +28137,10 @@ CREATE TABLE `clientUnpaid` ( `clientFk` int(11) NOT NULL, `dated` date NOT NULL, `amount` double DEFAULT 0, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`clientFk`), + KEY `ClientUnpaid_editorFk` (`editorFk`), + CONSTRAINT `ClientUnpaid_editorFk` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `clientUnpaid_clientFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -28675,7 +28171,6 @@ DROP TABLE IF EXISTS `cmr`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `cmr` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `ticketFk__` int(11) DEFAULT NULL COMMENT '@deprecated 2023-10-20 refs #6092', `truckPlate` varchar(30) DEFAULT NULL, `observations` varchar(255) DEFAULT NULL, `senderInstruccions` varchar(255) DEFAULT NULL, @@ -28692,14 +28187,12 @@ CREATE TABLE `cmr` ( `landed` datetime DEFAULT NULL COMMENT 'Hora de llegada a destino', `ead` datetime DEFAULT NULL COMMENT 'Estimated Arriving Date', PRIMARY KEY (`id`), - KEY `cmr_fk1_idx` (`ticketFk__`), KEY `cmr_fk2_idx` (`companyFk`), KEY `cmr_fk3_idx` (`addressToFk`), KEY `cm_fk4_idx` (`supplierFk`), KEY `cmr_FK` (`addressFromFk`), CONSTRAINT `cmrCompany_Fk` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `cmr_FK` FOREIGN KEY (`addressFromFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE, - CONSTRAINT `cmr_fk1` FOREIGN KEY (`ticketFk__`) REFERENCES `ticket` (`id`), CONSTRAINT `cmr_fk3` FOREIGN KEY (`addressToFk`) REFERENCES `address` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `cmr_supplierFk` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -28840,7 +28333,7 @@ DROP TABLE IF EXISTS `collectionWagon`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `collectionWagon` ( `collectionFk` int(11) NOT NULL, - `wagonFk` varchar(6) NOT NULL, + `wagonFk` int(11) unsigned NOT NULL, `position` int(11) unsigned NOT NULL, PRIMARY KEY (`collectionFk`,`position`), UNIQUE KEY `collectionWagon_unique` (`collectionFk`,`wagonFk`), @@ -28859,7 +28352,7 @@ DROP TABLE IF EXISTS `collectionWagonTicket`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `collectionWagonTicket` ( `ticketFk` int(11) NOT NULL, - `wagonFk` varchar(6) NOT NULL, + `wagonFk` int(11) unsigned NOT NULL, `trayFk` int(11) unsigned NOT NULL, `side` set('L','R') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, `rgb` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT 'Color de la balda', @@ -28869,7 +28362,7 @@ CREATE TABLE `collectionWagonTicket` ( KEY `collectionWagonTicket_FK_1` (`wagonFk`), CONSTRAINT `collectionWagonTicket_FK` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE, CONSTRAINT `collectionWagonTicket_FK_1` FOREIGN KEY (`wagonFk`) REFERENCES `wagon` (`id`) ON UPDATE CASCADE, - CONSTRAINT `collectionWagonTicket_tray` FOREIGN KEY (`trayFk`) REFERENCES `wagonTypeTray` (`id`) ON UPDATE CASCADE + CONSTRAINT `collectionWagonTicket_tray` FOREIGN KEY (`trayFk`) REFERENCES `wagonTypeTray` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -28925,7 +28418,6 @@ CREATE TABLE `company` ( `stamp` longblob DEFAULT NULL, `created` timestamp NOT NULL ON UPDATE current_timestamp(), `clientFk` int(11) DEFAULT NULL, - `sage200Company__` int(2) DEFAULT NULL COMMENT '@deprecated 06/03/2024', `supplierAccountFk` mediumint(8) unsigned DEFAULT NULL COMMENT 'Cuenta por defecto para ingresos desde este pais', `isDefaulter` tinyint(4) NOT NULL DEFAULT 0, `companyGroupFk` int(11) NOT NULL DEFAULT 1 COMMENT 'usado para calcular los greuges ', @@ -29129,12 +28621,12 @@ DROP TABLE IF EXISTS `componentType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `componentType` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `type` varchar(45) NOT NULL, + `code` varchar(20) DEFAULT NULL, + `name` varchar(45) NOT NULL, `isBase` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Marca aquellas series que se utilizan para calcular el precio base de las ventas, a efectos estadisticos', `isMargin` tinyint(4) NOT NULL DEFAULT 0, - `code` varchar(20) DEFAULT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `Serie_UNIQUE` (`type`) + UNIQUE KEY `Serie_UNIQUE` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Permite organizar de forma ordenada los distintos componentes'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -29276,24 +28768,6 @@ CREATE TABLE `conveyorBuildingClass` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tipo de caja para el montaje de pallets'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `conveyorConfig` --- - -DROP TABLE IF EXISTS `conveyorConfig`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `conveyorConfig` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `itemName` varchar(45) NOT NULL, - `length` int(11) DEFAULT NULL, - `width` int(11) DEFAULT NULL, - `height` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `itemName_UNIQUE` (`itemName`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `conveyorExpedition` -- @@ -29342,6 +28816,24 @@ CREATE TABLE `conveyorMode` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `conveyorMultiConfig` +-- + +DROP TABLE IF EXISTS `conveyorMultiConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `conveyorMultiConfig` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemName` varchar(45) NOT NULL, + `length` int(11) DEFAULT NULL, + `width` int(11) DEFAULT NULL, + `height` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `itemName_UNIQUE` (`itemName`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `conveyorType` -- @@ -29357,23 +28849,6 @@ CREATE TABLE `conveyorType` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `coolerPathDetail` --- - -DROP TABLE IF EXISTS `coolerPathDetail`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `coolerPathDetail` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `coolerPathFk` int(11) NOT NULL DEFAULT 1, - `hallway` varchar(3) NOT NULL, - PRIMARY KEY (`coolerPathFk`,`hallway`), - UNIQUE KEY `cooler_path_detail_id_UNIQUE` (`id`), - CONSTRAINT `coolerPathDetail_FK` FOREIGN KEY (`coolerPathFk`) REFERENCES `vn2008`.`cooler_path__` (`cooler_path_id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `corridor` -- @@ -29398,11 +28873,11 @@ DROP TABLE IF EXISTS `country`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `country` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `country` varchar(25) NOT NULL, + `name` varchar(25) NOT NULL, `CEE` tinyint(1) NOT NULL DEFAULT 1, `code` varchar(2) NOT NULL, + `viesCode` varchar(2) DEFAULT NULL, `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT 1, - `politicalCountryFk__` mediumint(8) unsigned DEFAULT NULL COMMENT 'Pais Real(apaño por culpa del España Exento)', `geoFk` int(11) DEFAULT NULL, `hasDailyInvoice` tinyint(4) NOT NULL DEFAULT 0, `isUeeMember` tinyint(4) NOT NULL DEFAULT 0, @@ -29412,13 +28887,11 @@ CREATE TABLE `country` ( `isSocialNameUnique` tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `country_unique` (`code`), - KEY `Id_Paisreal` (`politicalCountryFk__`), KEY `currency_id_fk_idx` (`currencyFk`), - KEY `country_Ix4` (`country`), + KEY `country_Ix4` (`name`), KEY `continent_id_fk_idx` (`continentFk`), KEY `country_FK_1` (`geoFk`), CONSTRAINT `continent_id_fk` FOREIGN KEY (`continentFk`) REFERENCES `continent` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, - CONSTRAINT `country_FK` FOREIGN KEY (`politicalCountryFk__`) REFERENCES `country` (`id`) ON UPDATE CASCADE, CONSTRAINT `country_FK_1` FOREIGN KEY (`geoFk`) REFERENCES `zoneGeo` (`id`) ON UPDATE CASCADE, CONSTRAINT `currency_id_fk` FOREIGN KEY (`currencyFk`) REFERENCES `currency` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -29522,15 +28995,14 @@ DROP TABLE IF EXISTS `creditInsurance`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `creditInsurance` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `creditClassification` int(11) DEFAULT NULL, + `creditClassification__` int(11) DEFAULT NULL COMMENT '@deprecated 2024-09-11', `credit` int(11) DEFAULT NULL, `creationDate` timestamp NOT NULL DEFAULT current_timestamp(), `grade` tinyint(1) DEFAULT NULL, `creditClassificationFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), - KEY `CreditInsurance_Fk1_idx` (`creditClassification`), + KEY `CreditInsurance_Fk1_idx` (`creditClassification__`), KEY `creditInsurance_creditClassificationFk` (`creditClassificationFk`), - CONSTRAINT `CreditInsurance_Fk1` FOREIGN KEY (`creditClassification`) REFERENCES `creditClassification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `creditInsurance_creditClassificationFk` FOREIGN KEY (`creditClassificationFk`) REFERENCES `creditClassification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -29664,7 +29136,6 @@ CREATE TABLE `deliveryNote` ( `supervisorFk` int(10) unsigned NOT NULL, `departmentFk` int(11) NOT NULL, `invoiceInFk` mediumint(8) unsigned DEFAULT NULL, - `farmingFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `fk_albaran_Proveedores_idx` (`supplierFk`), KEY `fk_albaran_empresa1_idx` (`companyFk`), @@ -29674,9 +29145,7 @@ CREATE TABLE `deliveryNote` ( KEY `fk_albaran_Trabajadores2_idx` (`supervisorFk`), KEY `fk_albaran_department1_idx` (`departmentFk`), KEY `fk_albaran_recibida_idx` (`invoiceInFk`), - KEY `albaran_FK` (`farmingFk`), CONSTRAINT `albaranCompany_Fk` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, - CONSTRAINT `albaran_FK` FOREIGN KEY (`farmingFk`) REFERENCES `farming` (`id`), CONSTRAINT `albaran_supplierFk` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `fk_albaran_Trabajadores1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `fk_albaran_Trabajadores2` FOREIGN KEY (`supervisorFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, @@ -29923,6 +29392,7 @@ CREATE TABLE `deviceProductionConfig` ( `id` int(10) unsigned NOT NULL, `isAllUsersallowed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Permite que cualquier usuario pueda loguearse', `isTractorHuntingMode` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Habilita el modo cazador para usuarios que no se han logeado un tractor para sacar', + `maxDevicesPerUser` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), CONSTRAINT `deviceProductionConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -29947,10 +29417,12 @@ CREATE TABLE `deviceProductionLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `deviceProductionLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), KEY `deviceProductionLog_deviceProductionLog` (`originFk`,`creationDate`), + KEY `deviceProductionLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `deviceProductionUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -29996,16 +29468,18 @@ DROP TABLE IF EXISTS `deviceProductionUser`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `deviceProductionUser` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `deviceProductionFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL, `created` timestamp NULL DEFAULT current_timestamp(), `editorFk` int(10) unsigned DEFAULT NULL, - PRIMARY KEY (`deviceProductionFk`), - UNIQUE KEY `deviceProductionUser_UN` (`userFk`), + `simSerialNumber` text DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `deviceProductionUser_unique` (`deviceProductionFk`), KEY `userFgn_idx` (`userFk`), KEY `deviceProductionUser_fk_editor` (`editorFk`), - CONSTRAINT `deviceProductionUser_FK` FOREIGN KEY (`deviceProductionFk`) REFERENCES `deviceProduction` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `deviceProductionUser_PK` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `deviceProductionUser_deviceProduction_FK` FOREIGN KEY (`deviceProductionFk`) REFERENCES `deviceProduction` (`id`), CONSTRAINT `deviceProductionUser_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -30087,7 +29561,6 @@ CREATE TABLE `dmsType` ( `id` int(11) NOT NULL AUTO_INCREMENT, `code` varchar(45) NOT NULL, `name` varchar(45) NOT NULL, - `path__` varchar(255) NOT NULL COMMENT '@deprecated 2024-01-08 refs #6410', `writeRoleFk` int(10) unsigned DEFAULT NULL, `readRoleFk` int(10) unsigned DEFAULT NULL, `monthToDelete` int(10) unsigned DEFAULT NULL COMMENT 'Meses en el pasado para ir borrando registros, dejar a null para no borrarlos nunca', @@ -30175,7 +29648,6 @@ DROP TABLE IF EXISTS `dua`; CREATE TABLE `dua` ( `id` int(11) NOT NULL AUTO_INCREMENT, `code` varchar(45) DEFAULT NULL, - `awbFk__` smallint(11) unsigned DEFAULT NULL COMMENT '@Deprecated refs #5871 01/10/2023', `issued` date DEFAULT NULL, `operated` date DEFAULT NULL, `booked` date DEFAULT NULL, @@ -30186,7 +29658,6 @@ CREATE TABLE `dua` ( `ASIEN` double DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`), - KEY `fk_awb_dua_awb_idx` (`awbFk__`), KEY `fk_dua_gestdoc1_idx` (`gestdocFk`), KEY `dua_fk4_idx` (`companyFk`), CONSTRAINT `duaCompany_Fk` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, @@ -30438,7 +29909,6 @@ CREATE TABLE `entry` ( `companyFk` int(10) unsigned NOT NULL DEFAULT 442, `gestDocFk` int(11) DEFAULT NULL, `invoiceInFk` mediumint(8) unsigned DEFAULT NULL, - `isBlocked__` tinyint(4) NOT NULL DEFAULT 0 COMMENT '@deprecated 27/03/2024', `loadPriority` int(11) DEFAULT NULL, `kop` int(11) DEFAULT NULL, `sub` mediumint(8) unsigned DEFAULT NULL, @@ -30533,10 +30003,12 @@ CREATE TABLE `entryLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `entryLog_ibfk_2` (`userFk`), KEY `entryLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), KEY `entryLog_originFk` (`originFk`,`creationDate`), + KEY `entryLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `entryLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -30804,43 +30276,6 @@ SET character_set_client = utf8; 1 AS `rate` */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `exchangeReportSource` --- - -DROP TABLE IF EXISTS `exchangeReportSource`; -/*!50001 DROP VIEW IF EXISTS `exchangeReportSource`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `exchangeReportSource` AS SELECT - 1 AS `dated`, - 1 AS `amountIn`, - 1 AS `rateIn`, - 1 AS `amountOut`, - 1 AS `rateOut`, - 1 AS `amountEntry`, - 1 AS `rateEntry`, - 1 AS `rateECB` */; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `exchangeReportSourcePrevious` --- - -DROP TABLE IF EXISTS `exchangeReportSourcePrevious`; -/*!50001 DROP VIEW IF EXISTS `exchangeReportSourcePrevious`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `exchangeReportSourcePrevious` AS SELECT - 1 AS `dated`, - 1 AS `amountIn`, - 1 AS `rateIn`, - 1 AS `amountOut`, - 1 AS `rateOut`, - 1 AS `amountEntry`, - 1 AS `rateEntry` */; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `excuse` -- @@ -30869,7 +30304,6 @@ CREATE TABLE `expedition` ( `ticketFk` int(10) NOT NULL, `freightItemFk` int(11) DEFAULT 1 COMMENT 'itemFk del artículo que nos va a facturar el proveedor de transporte.', `created` timestamp NULL DEFAULT current_timestamp(), - `itemFk__` int(11) DEFAULT NULL COMMENT 'Si es necesario el itemFk del cubo, se obtiene mediante packagingFk, join packing.itemFk', `counter` smallint(5) unsigned NOT NULL, `workerFk` int(10) unsigned DEFAULT NULL, `externalId` varchar(20) DEFAULT NULL, @@ -30939,7 +30373,7 @@ SET character_set_client = utf8; 1 AS `routeFk`, 1 AS `scanFk`, 1 AS `expeditionFk`, - 1 AS `expeditionTruckFk`, + 1 AS `roadmapStopFk`, 1 AS `warehouseFk`, 1 AS `lastPacked`, 1 AS `ticketFk` */; @@ -30995,7 +30429,7 @@ CREATE TABLE `expeditionPallet` ( `isPrint` tinyint(4) NOT NULL DEFAULT 2, PRIMARY KEY (`id`), KEY `expeditionPallet_fk1_idx` (`truckFk`), - CONSTRAINT `expeditionPallet_fk1` FOREIGN KEY (`truckFk`) REFERENCES `expeditionTruck` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `expeditionPallet_fk1` FOREIGN KEY (`truckFk`) REFERENCES `roadmapStop` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -31108,12 +30542,15 @@ CREATE TABLE `expeditionState` ( `created` timestamp NOT NULL DEFAULT current_timestamp(), `expeditionFk` int(11) NOT NULL, `typeFk` int(11) NOT NULL, - `userFk` int(11) DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `isScanned` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `expeditionState_FK` (`expeditionFk`), KEY `expeditionState_FK_1` (`typeFk`), + KEY `expeditionState_userFk` (`userFk`), CONSTRAINT `expeditionState_FK` FOREIGN KEY (`expeditionFk`) REFERENCES `expedition` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `expeditionState_FK_1` FOREIGN KEY (`typeFk`) REFERENCES `expeditionStateType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `expeditionState_FK_1` FOREIGN KEY (`typeFk`) REFERENCES `expeditionStateType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `expeditionState_userFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Historico de estados de las expediciones'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -31190,94 +30627,21 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `expeditionTruck` +-- Temporary table structure for view `expeditionTruck` -- DROP TABLE IF EXISTS `expeditionTruck`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `expeditionTruck` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `roadmapFk` int(10) unsigned DEFAULT NULL, - `warehouseFk` smallint(6) unsigned DEFAULT NULL, - `eta` datetime DEFAULT NULL COMMENT 'Estimated time of arrival', - `description` varchar(45) NOT NULL, - `bufferFk` int(11) DEFAULT NULL COMMENT 'buffer destino de las cajas', - `created` timestamp NULL DEFAULT current_timestamp(), - `userFk` int(10) unsigned DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `expeditionTruck_idx1` (`eta`), - KEY `expeditionTruck_FK` (`bufferFk`), - KEY `expeditionTruck_FK_1` (`warehouseFk`), - KEY `expeditionTruck_FK_2` (`roadmapFk`), - KEY `expeditionTruck_FK_3` (`userFk`), - CONSTRAINT `expeditionTruck_FK` FOREIGN KEY (`bufferFk`) REFERENCES `srt`.`buffer` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `expeditionTruck_FK_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, - CONSTRAINT `expeditionTruck_FK_2` FOREIGN KEY (`roadmapFk`) REFERENCES `roadmap` (`id`) ON UPDATE CASCADE, - CONSTRAINT `expeditionTruck_FK_3` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Distintas paradas que hacen los trocales'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Temporary table structure for view `expeditionTruck_Control` --- - -DROP TABLE IF EXISTS `expeditionTruck_Control`; -/*!50001 DROP VIEW IF EXISTS `expeditionTruck_Control`*/; +/*!50001 DROP VIEW IF EXISTS `expeditionTruck`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `expeditionTruck_Control` AS SELECT +/*!50001 CREATE VIEW `expeditionTruck` AS SELECT 1 AS `id`, - 1 AS `ETD`, + 1 AS `roadmapFk`, + 1 AS `eta`, 1 AS `description`, - 1 AS `ticketsSinBultos`, - 1 AS `pallets`, - 1 AS `routes`, - 1 AS `scans`, - 1 AS `expeditions`, - 1 AS `fallos`, - 1 AS `lastPacked` */; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `expeditionTruck_Control_Detail` --- - -DROP TABLE IF EXISTS `expeditionTruck_Control_Detail`; -/*!50001 DROP VIEW IF EXISTS `expeditionTruck_Control_Detail`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `expeditionTruck_Control_Detail` AS SELECT - 1 AS `id`, - 1 AS `eta`, - 1 AS `destino`, - 1 AS `pallet`, - 1 AS `routes`, - 1 AS `scans`, - 1 AS `destinos`, - 1 AS `fallos`, - 1 AS `lastPacked` */; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `expeditionTruck_Control_Detail_Pallet` --- - -DROP TABLE IF EXISTS `expeditionTruck_Control_Detail_Pallet`; -/*!50001 DROP VIEW IF EXISTS `expeditionTruck_Control_Detail_Pallet`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `expeditionTruck_Control_Detail_Pallet` AS SELECT - 1 AS `id`, - 1 AS `eta`, - 1 AS `destino`, - 1 AS `pallet`, - 1 AS `route`, - 1 AS `scans`, - 1 AS `destinos`, - 1 AS `fallos`, - 1 AS `expeditionTruckFk`, - 1 AS `lastPacked` */; + 1 AS `bufferFk`, + 1 AS `created`, + 1 AS `userFk` */; SET character_set_client = @saved_cs_client; -- @@ -31513,29 +30877,6 @@ CREATE TABLE `floramondoConfig` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `forecastedBalance` --- - -DROP TABLE IF EXISTS `forecastedBalance`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `forecastedBalance` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(45) DEFAULT NULL, - `amount` double NOT NULL DEFAULT 0, - `dated` date NOT NULL, - `accountingFk` int(11) DEFAULT NULL, - `companyFk` int(10) unsigned NOT NULL DEFAULT 442, - PRIMARY KEY (`id`), - KEY `Fecha_indice` (`dated`), - KEY `banco_prevision_idx` (`accountingFk`), - KEY `empresa_prevision_idx` (`companyFk`), - CONSTRAINT `Saldos_PrevisionCompany_Fk` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, - CONSTRAINT `banco_prevision` FOREIGN KEY (`accountingFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Aqui ponemos los gastos e ingresos pendientes de introducir '; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `franceExpressConfig` -- @@ -31682,7 +31023,7 @@ DROP TABLE IF EXISTS `greuge`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `greuge` ( - `Id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `clientFk` int(11) NOT NULL, `description` varchar(45) NOT NULL, `amount` decimal(10,2) NOT NULL, @@ -31692,7 +31033,7 @@ CREATE TABLE `greuge` ( `ticketFk` int(11) DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL, `editorFk` int(10) unsigned DEFAULT NULL, - PRIMARY KEY (`Id`), + PRIMARY KEY (`id`), KEY `greuges_type_fk_idx` (`greugeTypeFk`), KEY `Id_Ticket_Greuge_Ticket_idx` (`ticketFk`), KEY `Greuges_cliente_idx` (`clientFk`), @@ -31761,6 +31102,7 @@ CREATE TABLE `host` ( `routeDaysBefore` smallint(6) DEFAULT 2, `routeDaysAfter` smallint(6) DEFAULT 1, `updated` timestamp NULL DEFAULT current_timestamp(), + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `host_UN` (`code`), KEY `configHost_FK_3` (`companyFk`), @@ -32014,10 +31356,10 @@ CREATE TABLE `invoiceCorrection` ( KEY `invoiceCorrection_ibfk_1_idx` (`cplusRectificationTypeFk`), KEY `cplusInvoiceTyoeFk_idx` (`siiTypeInvoiceOutFk`), KEY `invoiceCorrectionTypeFk_idx` (`invoiceCorrectionTypeFk`), - CONSTRAINT `corrected_fk` FOREIGN KEY (`correctedFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `correcting_fk` FOREIGN KEY (`correctingFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `cplusRectificationType_FK` FOREIGN KEY (`cplusRectificationTypeFk`) REFERENCES `cplusRectificationType` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoiceCorrectionType_FK` FOREIGN KEY (`invoiceCorrectionTypeFk`) REFERENCES `invoiceCorrectionType` (`id`) ON UPDATE CASCADE, + CONSTRAINT `invoiceCorrection_invoiceOut_FK` FOREIGN KEY (`correctingFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `invoiceCorrection_invoiceOut_FK_1` FOREIGN KEY (`correctedFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `siiTypeInvoiceOut_FK` FOREIGN KEY (`siiTypeInvoiceOutFk`) REFERENCES `siiTypeInvoiceOut` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Relacion entre las facturas rectificativas y las rectificadas.'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -32128,12 +31470,14 @@ CREATE TABLE `invoiceInConfig` ( `id` int(10) unsigned NOT NULL, `retentionRate` int(3) NOT NULL, `retentionName` varchar(25) NOT NULL, - `sageWithholdingFk` smallint(6) NOT NULL, + `sageFarmerWithholdingFk` smallint(6) NOT NULL, `daysAgo` int(10) unsigned DEFAULT 45 COMMENT 'Días en el pasado para mostrar facturas en invoiceIn series en salix', `taxRowLimit` int(11) DEFAULT 4 COMMENT 'Número máximo de líneas de IVA que puede tener una factura', + `dueDateMarginDays` int(10) unsigned DEFAULT 2, + `balanceStartingDate` date NOT NULL DEFAULT '2015-01-01', PRIMARY KEY (`id`), - KEY `invoiceInConfig_sageWithholdingFk` (`sageWithholdingFk`), - CONSTRAINT `invoiceInConfig_sageWithholdingFk` FOREIGN KEY (`sageWithholdingFk`) REFERENCES `sage`.`TiposRetencion` (`CodigoRetencion`) ON DELETE CASCADE ON UPDATE CASCADE, + KEY `invoiceInConfig_sageWithholdingFk` (`sageFarmerWithholdingFk`), + CONSTRAINT `invoiceInConfig_sageWithholdingFk` FOREIGN KEY (`sageFarmerWithholdingFk`) REFERENCES `sage`.`TiposRetencion` (`CodigoRetencion`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceInConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -32234,10 +31578,12 @@ CREATE TABLE `invoiceInLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `invoiceInLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), KEY `invoiceInLog_originFk` (`originFk`,`creationDate`), + KEY `invoiceInLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `invoiceInLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -32378,8 +31724,8 @@ CREATE TABLE `invoiceOut` ( `cplusTaxBreakFk` int(10) unsigned NOT NULL DEFAULT 1, `cplusSubjectOpFk` int(10) unsigned NOT NULL DEFAULT 1, `siiTrascendencyInvoiceOutFk` int(10) unsigned NOT NULL DEFAULT 1, - PRIMARY KEY (`id`,`ref`), - UNIQUE KEY `Id_Factura` (`ref`), + PRIMARY KEY (`id`), + UNIQUE KEY `invoiceOut_unique` (`ref`), KEY `Id_Banco` (`bankFk`), KEY `Id_Cliente` (`clientFk`), KEY `empresa_id` (`companyFk`), @@ -32431,8 +31777,8 @@ CREATE TABLE `invoiceOutExpense` ( PRIMARY KEY (`id`), KEY `invoiceOutExpence_FK_1_idx` (`invoiceOutFk`), KEY `invoiceOutExpence_expenceFk_idx` (`expenseFk`), - CONSTRAINT `invoiceOutExpence_FK_1` FOREIGN KEY (`invoiceOutFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `invoiceOutExpence_expenceFk` FOREIGN KEY (`expenseFk`) REFERENCES `expense` (`id`) ON UPDATE CASCADE + CONSTRAINT `invoiceOutExpence_expenceFk` FOREIGN KEY (`expenseFk`) REFERENCES `expense` (`id`) ON UPDATE CASCADE, + CONSTRAINT `invoiceOutExpense_invoiceOut_FK` FOREIGN KEY (`invoiceOutFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Desglosa la base imponible de una factura en funcion del tipo de gasto/venta'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -32452,8 +31798,9 @@ CREATE TABLE `invoiceOutSerial` ( `cplusInvoiceType477Fk` int(10) unsigned DEFAULT 1, `footNotes` longtext DEFAULT NULL, `isRefEditable` tinyint(4) NOT NULL DEFAULT 0, - `type` enum('global','quick') DEFAULT NULL, + `type` enum('global','quick','multiple') DEFAULT NULL, PRIMARY KEY (`code`), + UNIQUE KEY `invoiceOutSerial_taxAreaFk_IDX` (`taxAreaFk`,`type`) USING BTREE, KEY `taxAreaFk_idx` (`taxAreaFk`), CONSTRAINT `invoiceOutSeriaTaxArea` FOREIGN KEY (`taxAreaFk`) REFERENCES `taxArea` (`code`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -32477,19 +31824,19 @@ CREATE TABLE `invoiceOutTax` ( UNIQUE KEY `invoiceOutTax_Resctriccion` (`invoiceOutFk`,`pgcFk`), KEY `invoiceOutFk_idx` (`invoiceOutFk`), KEY `pgcFk` (`pgcFk`), - CONSTRAINT `invoiceOutFk` FOREIGN KEY (`invoiceOutFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `invoiceOutTax_ibfk_1` FOREIGN KEY (`pgcFk`) REFERENCES `pgc` (`code`) ON UPDATE CASCADE + CONSTRAINT `invoiceOutTax_ibfk_1` FOREIGN KEY (`pgcFk`) REFERENCES `pgc` (`code`) ON UPDATE CASCADE, + CONSTRAINT `invoiceOutTax_invoiceOut_FK` FOREIGN KEY (`invoiceOutFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `invoiceOutTaxConfig` +-- Table structure for table `invoiceOutTaxMultiConfig` -- -DROP TABLE IF EXISTS `invoiceOutTaxConfig`; +DROP TABLE IF EXISTS `invoiceOutTaxMultiConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `invoiceOutTaxConfig` ( +CREATE TABLE `invoiceOutTaxMultiConfig` ( `id` int(11) NOT NULL AUTO_INCREMENT, `taxClassCodeFk` varchar(1) DEFAULT NULL, `taxTypeSageFk` smallint(6) DEFAULT NULL, @@ -32569,15 +31916,20 @@ CREATE TABLE `item` ( `itemPackingTypeFk` varchar(1) DEFAULT NULL, `packingOut` decimal(10,2) DEFAULT NULL COMMENT 'cantidad que cabe en una caja de verdnatura', `genericFk` int(11) DEFAULT NULL COMMENT 'Item genérico', - `packingShelve__` int(11) DEFAULT NULL COMMENT '@deprecated 2024-31-01', `isLaid` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si el producto se puede tumbar a efectos del transporte desde Holanda', `lastUsed` datetime DEFAULT current_timestamp(), `weightByPiece` int(10) unsigned DEFAULT NULL COMMENT 'peso por defecto para un articulo por tallo/unidad', `editorFk` int(10) unsigned DEFAULT NULL, - `recycledPlastic` int(11) DEFAULT NULL, - `nonRecycledPlastic` int(11) DEFAULT NULL, - `minQuantity` int(10) unsigned DEFAULT NULL COMMENT 'Cantidad mínima para una línea de venta', + `recycledPlastic` decimal(10,2) DEFAULT NULL, + `nonRecycledPlastic` decimal(10,2) DEFAULT NULL, `isBoxPickingMode` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'FALSE: using item.packingOut TRUE: boxPicking using itemShelving.packing', + `photoMotivation` varchar(255) DEFAULT NULL, + `tag11` varchar(20) DEFAULT NULL, + `value11` varchar(50) DEFAULT NULL, + `tag12` varchar(20) DEFAULT NULL, + `value12` varchar(50) DEFAULT NULL, + `tag13` varchar(20) DEFAULT NULL, + `value13` varchar(50) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `item_supplyResponseFk_idx` (`supplyResponseFk`), KEY `Color` (`inkFk`), @@ -32597,6 +31949,7 @@ CREATE TABLE `item` ( KEY `item_lastUsed_IDX` (`lastUsed`) USING BTREE, KEY `item_expenceFk_idx` (`expenseFk`), KEY `item_fk_editor` (`editorFk`), + KEY `item_itemPackingType_FK` (`itemPackingTypeFk`), CONSTRAINT `item_FK` FOREIGN KEY (`genericFk`) REFERENCES `item` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `item_FK_1` FOREIGN KEY (`typeFk`) REFERENCES `itemType` (`id`), CONSTRAINT `item_expenceFk` FOREIGN KEY (`expenseFk`) REFERENCES `expense` (`id`) ON UPDATE CASCADE, @@ -32604,6 +31957,7 @@ CREATE TABLE `item` ( CONSTRAINT `item_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `item_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `origin` (`id`) ON UPDATE CASCADE, CONSTRAINT `item_ibfk_2` FOREIGN KEY (`intrastatFk`) REFERENCES `intrastat` (`id`) ON UPDATE CASCADE, + CONSTRAINT `item_itemPackingType_FK` FOREIGN KEY (`itemPackingTypeFk`) REFERENCES `itemPackingType` (`code`) ON UPDATE CASCADE, CONSTRAINT `itemsupplyResponseFk` FOREIGN KEY (`supplyResponseFk`) REFERENCES `edi`.`supplyResponse` (`ID`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `producer_id` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -32916,15 +32270,17 @@ CREATE TABLE `itemLog` ( `action` set('insert','update','delete') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `changedModel` enum('Item','ItemBarcode','ItemBotanical','ItemNiche','ItemTag','ItemTaxCountry') NOT NULL DEFAULT 'Item', + `changedModel` enum('Item','ItemBarcode','ItemBotanical','ItemNiche','ItemTag','ItemTaxCountry','ItemMinimumQuantity') NOT NULL DEFAULT 'Item', `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)), `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `itemLogUserFk_idx` (`userFk`), KEY `itemLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), KEY `itemLog_originFk` (`originFk`,`creationDate`), + KEY `itemLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `itemLogUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -32946,6 +32302,37 @@ CREATE TABLE `itemMatchProperties` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Propiedades para encontrar articulos equivalentes en verdnatura'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `itemMinimumQuantity` +-- + +DROP TABLE IF EXISTS `itemMinimumQuantity`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemMinimumQuantity` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemFk` int(10) NOT NULL, + `quantity` int(10) NOT NULL, + `started` date NOT NULL, + `ended` date DEFAULT NULL, + `warehouseFk` smallint(5) unsigned DEFAULT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `editorFk` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `itemMinimumQuantity_UNIQUE` (`itemFk`,`started`,`ended`,`warehouseFk`), + KEY `itemFk` (`itemFk`), + KEY `started` (`started`), + KEY `ended` (`ended`), + KEY `warehouseFk` (`warehouseFk`), + KEY `editorFk` (`editorFk`), + CONSTRAINT `itemMinimumQuantity_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `itemMinimumQuantity_ibfk_2` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, + CONSTRAINT `itemMinimumQuantity_ibfk_3` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), + CONSTRAINT `itemMinimumQuantity_check_1` CHECK (`started` <= `ended`), + CONSTRAINT `itemMinimumQuantity_check` CHECK (`quantity` > 0) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `itemPackingType` -- @@ -33081,12 +32468,14 @@ CREATE TABLE `itemShelving` ( `isChecked` tinyint(1) DEFAULT NULL COMMENT 'Este valor cambia al escanear un carro. True: Existe. False: Nuevo. Null: No escaneado', `buyFk` int(11) DEFAULT NULL, `editorFk` int(10) unsigned DEFAULT NULL, + `available` int(11) DEFAULT NULL, + `isSplit` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Este valor cambia al splitar un carro que se ha quedado en holanda', PRIMARY KEY (`id`), - UNIQUE KEY `itemShelving_UN` (`buyFk`,`shelvingFk`), KEY `itemShelving_fk1_idx` (`itemFk`), KEY `itemShelving_fk2_idx` (`shelvingFk`), KEY `itemShelving_fk3_idx` (`packagingFk`), KEY `itemShelving_fk3_idx1` (`userFk`), + KEY `itemShelvingBuy_FK` (`buyFk`), CONSTRAINT `itemShelvingBuy_FK` FOREIGN KEY (`buyFk`) REFERENCES `buy` (`id`), CONSTRAINT `itemShelving_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelving_fk2` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -33112,7 +32501,6 @@ SET character_set_client = utf8; 1 AS `concept`, 1 AS `size`, 1 AS `Estado`, - 1 AS `sectorProdPriority`, 1 AS `available`, 1 AS `sectorFk`, 1 AS `matricula`, @@ -33239,7 +32627,7 @@ CREATE TABLE `itemShelvingSale` ( `quantity` decimal(10,0) NOT NULL DEFAULT 0, `created` timestamp NOT NULL DEFAULT current_timestamp(), `userFk` int(11) unsigned NOT NULL, - `isPicked` tinyint(1) NOT NULL DEFAULT 0, + `isPicked` tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY (`id`), KEY `itemShelvingSale_fk1_idx` (`itemShelvingFk`), KEY `itemShelvingSale_fk2_idx` (`saleFk`), @@ -33250,6 +32638,24 @@ CREATE TABLE `itemShelvingSale` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Detalle del producto que se retira de los carros, relacionando la linea de movimiento correspondiente'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `itemShelvingSaleReserve` +-- + +DROP TABLE IF EXISTS `itemShelvingSaleReserve`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemShelvingSaleReserve` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `saleFk` int(11) NOT NULL, + `sectorFk` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `itemShelvingSaleReserve_ibfk_1` (`saleFk`), + KEY `itemShelvingSaleReserve_sector_FK` (`sectorFk`), + CONSTRAINT `itemShelvingSaleReserve_sector_FK` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Queue of changed itemShelvingSale to reserve'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `itemShelvingSaleSum` -- @@ -33458,20 +32864,10 @@ CREATE TABLE `itemType` ( `workerFk` int(10) unsigned NOT NULL, `isInventory` tinyint(4) NOT NULL DEFAULT 1 COMMENT 'Se utiliza tanto en el cálculo del inventario, como en el del informe del inventario valorado', `created` timestamp NULL DEFAULT current_timestamp(), - `transaction__` tinyint(4) NOT NULL DEFAULT 0, `making` int(10) unsigned DEFAULT NULL COMMENT 'Son productos de confección propia', - `location__` varchar(10) DEFAULT NULL, `life` smallint(5) unsigned DEFAULT NULL, - `maneuver` double NOT NULL DEFAULT 0.21, - `target` double NOT NULL DEFAULT 0.15, - `topMargin` double NOT NULL DEFAULT 0.3, - `profit` double NOT NULL DEFAULT 0.02, - `density` double NOT NULL DEFAULT 167 COMMENT 'Almacena el valor por defecto de la densidad en kg/m3 para el calculo de los portes aereos, en articulos se guarda la correcta', `promo` double NOT NULL DEFAULT 0, `isPackaging` tinyint(1) NOT NULL DEFAULT 0, - `hasComponents__` tinyint(1) NOT NULL DEFAULT 1, - `warehouseFk__` smallint(6) unsigned NOT NULL DEFAULT 60, - `compression__` decimal(5,2) DEFAULT 1.00, `itemPackingTypeFk` varchar(1) DEFAULT NULL, `temperatureFk` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, `isUnconventionalSize` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'familia con productos cuyas medidas no son aptas para la cinta transportadora o paletizar', @@ -33485,13 +32881,11 @@ CREATE TABLE `itemType` ( KEY `Trabajador` (`workerFk`), KEY `reino_id` (`categoryFk`), KEY `Tipos_fk3_idx` (`making`), - KEY `warehouseFk5_idx` (`warehouseFk__`), KEY `temperatureFk` (`temperatureFk`), CONSTRAINT `Tipos_fk3` FOREIGN KEY (`making`) REFERENCES `confectionType` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `Trabajador` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `itemType_ibfk_1` FOREIGN KEY (`categoryFk`) REFERENCES `itemCategory` (`id`) ON UPDATE CASCADE, - CONSTRAINT `temperatureFk` FOREIGN KEY (`temperatureFk`) REFERENCES `temperature` (`code`), - CONSTRAINT `warehouseFk5` FOREIGN KEY (`warehouseFk__`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE + CONSTRAINT `temperatureFk` FOREIGN KEY (`temperatureFk`) REFERENCES `temperature` (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Protege la tabla tipos de updates para los 4 parámetros de los compradores, en funcion del valor del campo CodigoRojo de tblContadores.'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -33674,6 +33068,22 @@ SET character_set_client = utf8; 1 AS `totalAmount` */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `ledgerCompany` +-- + +DROP TABLE IF EXISTS `ledgerCompany`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ledgerCompany` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `fiscalYear` int(10) unsigned NOT NULL COMMENT 'Año del ejercicio contable', + `bookEntry` int(10) unsigned NOT NULL DEFAULT 1 COMMENT 'Contador asiento contable', + PRIMARY KEY (`id`), + UNIQUE KEY `ledgerCompany_unique` (`fiscalYear`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Contador para asientos contables'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `ledgerConfig` -- @@ -33682,9 +33092,26 @@ DROP TABLE IF EXISTS `ledgerConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ledgerConfig` ( - `lastBookEntry` int(11) NOT NULL, - `maxTolerance` decimal(10,2) NOT NULL, - PRIMARY KEY (`lastBookEntry`) + `maxTolerance` decimal(10,2) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `locker` +-- + +DROP TABLE IF EXISTS `locker`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `locker` ( + `id` int(100) NOT NULL AUTO_INCREMENT, + `code` varchar(10) DEFAULT NULL, + `gender` enum('M','F') DEFAULT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `code` (`code`), + UNIQUE KEY `workerFk` (`workerFk`), + CONSTRAINT `locker_ibfk_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -33899,8 +33326,9 @@ DROP TABLE IF EXISTS `mandateType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mandateType` ( `id` smallint(5) NOT NULL AUTO_INCREMENT, - `name` varchar(45) NOT NULL, - PRIMARY KEY (`id`) + `code` varchar(45) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `code` (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -33921,6 +33349,21 @@ CREATE TABLE `manuscript` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `material` +-- + +DROP TABLE IF EXISTS `material`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `material` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `mdbApp` -- @@ -34197,6 +33640,16 @@ CREATE TABLE `mrwConfig` ( `password` varchar(100) DEFAULT NULL, `franchiseCode` varchar(100) DEFAULT NULL, `subscriberCode` varchar(100) DEFAULT NULL, + `defaultHeight` int(10) unsigned DEFAULT NULL COMMENT 'default height in centimeters', + `defaultLength` int(10) unsigned DEFAULT NULL COMMENT 'default length in centimeters', + `defaultWidth` int(10) unsigned DEFAULT NULL COMMENT 'default width in centimeters', + `defaultWeight` int(10) unsigned DEFAULT NULL COMMENT 'default weight in centimeters', + `expeditionDeadLine` time DEFAULT NULL COMMENT 'This field stores the latest time by which expeditions can be generated to be sent today', + `counterWidth` int(10) unsigned DEFAULT NULL COMMENT 'If it does not reach the required value, it will be padded with zeros on the left to meet the specified length.', + `serviceTypeWidth` int(10) unsigned DEFAULT NULL COMMENT 'If it does not reach the required value, it will be padded with zeros on the left to meet the specified length.', + `portugalPostCodeTrim` int(10) unsigned DEFAULT NULL COMMENT 'It will trim the last characters of the postal code', + `notified` timestamp NULL DEFAULT NULL COMMENT 'Date when it was notified that the web service deadline was exceeded', + `clientTypeWidth` int(10) unsigned DEFAULT NULL COMMENT 'If it does not reach the required value, it will be padded with zeros on the left to meet the specified length.', PRIMARY KEY (`id`), CONSTRAINT `mrwConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -34352,8 +33805,10 @@ CREATE TABLE `operator` ( `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT 60, `sectorFk` int(11) DEFAULT NULL, `labelerFk` int(10) unsigned DEFAULT NULL, - `linesLimit` int(11) DEFAULT 20 COMMENT 'Límite de lineas en una colección para la asignación de pedidos', + `linesLimit` int(10) unsigned DEFAULT 20 COMMENT 'Límite de lineas en una colección para la asignación de pedidos', `volumeLimit` decimal(10,6) DEFAULT 0.500000 COMMENT 'Límite de volumen en una colección para la asignación de pedidos', + `sizeLimit` int(10) unsigned DEFAULT NULL COMMENT 'Límite de altura en una colección para la asignación de pedidos', + `isOnReservationMode` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`workerFk`), KEY `operator_FK` (`workerFk`), KEY `operator_FK_1` (`trainFk`), @@ -34450,6 +33905,21 @@ SET character_set_client = utf8; 1 AS `name` */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `ormConfig` +-- + +DROP TABLE IF EXISTS `ormConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ormConfig` ( + `id` int(11) NOT NULL, + `selectLimit` int(5) NOT NULL, + PRIMARY KEY (`id`), + CONSTRAINT `ormConfig_check` CHECK (`id` = 1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `osTicketConfig` -- @@ -34550,9 +34020,9 @@ DROP TABLE IF EXISTS `packaging`; CREATE TABLE `packaging` ( `id` varchar(10) NOT NULL, `volume` decimal(10,2) DEFAULT NULL CHECK (`volume` >= coalesce(`width`,1) * coalesce(`depth`,1) * coalesce(`height`,1)), - `width` decimal(10,2) DEFAULT 0.00, - `depth` decimal(10,2) DEFAULT 0.00, - `height` decimal(10,2) DEFAULT 0.00, + `width` decimal(10,2) DEFAULT NULL, + `depth` decimal(10,2) DEFAULT NULL, + `height` decimal(10,2) DEFAULT NULL, `value` decimal(10,2) DEFAULT 0.00, `isPackageReturnable` tinyint(1) NOT NULL DEFAULT 0, `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), @@ -34571,6 +34041,8 @@ CREATE TABLE `packaging` ( `conveyorBuildingClassFk` int(11) DEFAULT NULL, `isTrolley` tinyint(1) NOT NULL DEFAULT 0, `isPallet` tinyint(1) NOT NULL DEFAULT 0, + `isPlantTray` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'The container is a plant tray. Used to restrict the picking of full plant trays, to make previous picking.', + `isActive` tinyint(1) DEFAULT 1, PRIMARY KEY (`id`), KEY `packaging_fk1` (`itemFk`), KEY `packaging_fk2_idx` (`freightItemFk`), @@ -34686,7 +34158,6 @@ CREATE TABLE `packingSite` ( `scannerFk` int(11) DEFAULT NULL, `screenFk` int(11) DEFAULT NULL, `editorFk` int(10) unsigned DEFAULT NULL, - `hasNewLabelMrwMethod` tinyint(1) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `packingSite_UN` (`code`), UNIQUE KEY `printerRfidFk` (`printerRfidFk`), @@ -34760,10 +34231,12 @@ CREATE TABLE `packingSiteDeviceLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `packingSiteDeviceLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), KEY `packingSiteDeviceLog_packingSiteDeviceLog` (`originFk`,`creationDate`), + KEY `packingSiteDeviceLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `packingSiteDeviceLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -34837,6 +34310,7 @@ CREATE TABLE `parking` ( `id` int(11) NOT NULL AUTO_INCREMENT, `column` varchar(5) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT '--', `row` varchar(5) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT '--', + `floor` varchar(5) DEFAULT NULL, `sectorFk` int(11) NOT NULL, `code` varchar(8) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, `pickingOrder` int(11) DEFAULT NULL, @@ -34844,8 +34318,8 @@ CREATE TABLE `parking` ( PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`), KEY `parking_fk1_idx` (`sectorFk`), - CONSTRAINT `parking_fk1` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `chkParkingCodeFormat` CHECK (char_length(`code`) > 4 and `code` like '%-%') + CONSTRAINT `parking_fk1` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON UPDATE CASCADE, + CONSTRAINT `chkParkingCodeFormat` CHECK (char_length(`code`) > 4 and `code` regexp '^[^ ]+-[^ ]+$') ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tabla con los parkings del altillo'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -34863,15 +34337,17 @@ CREATE TABLE `parkingLog` ( `action` set('insert','update','delete','select') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `changedModel` enum('Parking','SaleGroup','SaleGroupDetail') NOT NULL DEFAULT 'Parking', + `changedModel` enum('Parking') NOT NULL DEFAULT 'Parking', `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)), `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `logParkinguserFk` (`userFk`), KEY `parkingLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), KEY `parkingLog_originFk` (`originFk`,`creationDate`), + KEY `parkingLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `parkingOriginFk` FOREIGN KEY (`originFk`) REFERENCES `parking` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `parkingUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -35045,15 +34521,7 @@ DROP TABLE IF EXISTS `payrollWorkCenter`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `payrollWorkCenter` ( `workCenterFkA3` int(11) NOT NULL COMMENT 'Columna que hace referencia a A3.', - `Centro__` varchar(255) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', - `nss_cotizacion__` varchar(15) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', - `domicilio__` varchar(255) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', - `poblacion__` varchar(45) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', - `cp__` varchar(5) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', - `empresa_id__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', - `companyFkA3` int(11) DEFAULT NULL COMMENT 'Columna que hace referencia a A3.', - PRIMARY KEY (`workCenterFkA3`,`empresa_id__`), - KEY `payroll_centros_ix1` (`empresa_id__`) + `companyFkA3` int(11) DEFAULT NULL COMMENT 'Columna que hace referencia a A3.' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -35066,17 +34534,10 @@ DROP TABLE IF EXISTS `payrollWorker`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `payrollWorker` ( `workerFkA3` int(11) NOT NULL COMMENT 'Columna que hace referencia a A3.', - `nss__` varchar(23) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', - `codpuesto__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', `companyFkA3` int(10) NOT NULL COMMENT 'Columna que hace referencia a A3.', - `codcontrato__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', - `FAntiguedad__` date NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', - `grupotarifa__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', - `codcategoria__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', - `ContratoTemporal__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@Deprecated refs #6738 15/03/2024', + `grupotarifa` int(10) NOT NULL, `workerFk` int(11) unsigned DEFAULT NULL, PRIMARY KEY (`workerFkA3`,`companyFkA3`), - KEY `sajvgfh_idx` (`codpuesto__`), KEY `payroll_employee_workerFk_idx` (`workerFk`), CONSTRAINT `payroll_employee_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -35433,6 +34894,45 @@ CREATE TABLE `ppePlan` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Plan de amortizacion para la tabla ppe'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `priceDelta` +-- + +DROP TABLE IF EXISTS `priceDelta`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `priceDelta` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `itemTypeFk` smallint(5) unsigned NOT NULL, + `minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size', + `maxSize` int(10) unsigned DEFAULT NULL COMMENT 'Maximum item.size', + `inkFk` varchar(3) DEFAULT NULL, + `originFk` tinyint(2) unsigned DEFAULT NULL, + `producerFk` mediumint(3) unsigned DEFAULT NULL, + `fromDated` date DEFAULT NULL, + `toDated` date DEFAULT NULL, + `absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price', + `ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price', + `warehouseFk` smallint(6) unsigned NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `editorFk` int(10) unsigned DEFAULT NULL, + `zoneGeoFk` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `priceDelta_itemType_FK` (`itemTypeFk`), + KEY `priceDelta_ink_FK` (`inkFk`), + KEY `priceDelta_producer_FK` (`producerFk`), + KEY `priceDelta_warehouse_FK` (`warehouseFk`), + KEY `priceDelta_worker_FK` (`editorFk`), + KEY `priceDelta_zoneGeo_FK` (`zoneGeoFk`), + CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_worker_FK` FOREIGN KEY (`editorFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `priceDelta_zoneGeo_FK` FOREIGN KEY (`zoneGeoFk`) REFERENCES `zoneGeo` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `priceFixed` -- @@ -35633,7 +35133,6 @@ CREATE TABLE `productionConfig` ( `pendingCollectionsAge` tinyint(3) unsigned DEFAULT 6, `maxNotAssignedCollectionLifeTime` time NOT NULL DEFAULT '00:10:00' COMMENT 'Tiempo de vida de las colecciones sin asignar. Cuando se supera son eliminadas', `maxProductionScopeDays` int(11) NOT NULL DEFAULT 1 COMMENT 'maximo numero de dias en F11', - `orderMode` enum('Location','Age') NOT NULL DEFAULT 'Location', `stockScopeDays` int(11) DEFAULT 1 COMMENT 'Días a futuro al revisar el stock', `shortageAddressFk` int(11) DEFAULT NULL COMMENT 'Consignatario por defecto para añadir un item de alta', `clientSelfConsumptionFk` int(11) DEFAULT NULL COMMENT 'Cliente para crear el ticket de autoconsumo', @@ -35644,18 +35143,59 @@ CREATE TABLE `productionConfig` ( `collection_new_lockname` varchar(100) NOT NULL DEFAULT 'collection_new' COMMENT 'Lockname value for proc vn.collection_new', `collection_assign_lockname` varchar(100) DEFAULT 'collection_assign' COMMENT 'Lockname value for proc vn.collection_new', `defaultSectorFk` int(10) unsigned NOT NULL DEFAULT 37 COMMENT 'Default sector', - `scannableCodeType` enum('qr','barcode') NOT NULL DEFAULT 'barcode', + `itemOlderReviewHours` int(11) NOT NULL DEFAULT 0 COMMENT 'Horas que se tienen en cuenta para comprobar si un ítem es más viejo.', + `sectorFromCode` varchar(15) DEFAULT NULL COMMENT 'Sector origen que se revisa ítems más nuevos al parkinear', + `sectorToCode` varchar(15) DEFAULT NULL COMMENT 'Sector destino que se revisa ítems más nuevos al parkinear', + `orderMode` enum('Location','Age') NOT NULL DEFAULT 'Location', + `editorFk` int(10) unsigned DEFAULT NULL, + `hasNewLabelMrwMethod` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'column to activate the new mrw integration', + `minPlantTrayLength` int(11) NOT NULL DEFAULT 53 COMMENT 'minimum length for plant tray restriction. Avoid to make collection of the ticket with this kind of item', PRIMARY KEY (`id`), KEY `productionConfig_FK` (`shortageAddressFk`), KEY `productionConfig_FK_1` (`clientSelfConsumptionFk`), KEY `productionConfig_FK_2` (`addressSelfConsumptionFk`), + KEY `productionConfig_sector_FK` (`sectorFromCode`), + KEY `productionConfig_sector_FK_1` (`sectorToCode`), + KEY `productionConfig_user_FK` (`editorFk`), CONSTRAINT `productionConfig_FK` FOREIGN KEY (`shortageAddressFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE, CONSTRAINT `productionConfig_FK_1` FOREIGN KEY (`clientSelfConsumptionFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `productionConfig_FK_2` FOREIGN KEY (`addressSelfConsumptionFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE, + CONSTRAINT `productionConfig_sector_FK` FOREIGN KEY (`sectorFromCode`) REFERENCES `sector` (`code`) ON UPDATE CASCADE, + CONSTRAINT `productionConfig_sector_FK_1` FOREIGN KEY (`sectorToCode`) REFERENCES `sector` (`code`) ON UPDATE CASCADE, + CONSTRAINT `productionConfig_user_FK` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `productionConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Recoge los parámetros que condicionan la producción'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `productionConfigLog` +-- + +DROP TABLE IF EXISTS `productionConfigLog`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `productionConfigLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete','select') NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `changedModel` enum('ProductionConfig') NOT NULL DEFAULT 'ProductionConfig', + `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)), + `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), + `changedModelId` int(11) NOT NULL, + `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `productionConfigLog_userFk` (`userFk`), + KEY `productionConfigLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), + KEY `productionConfigLog_originFk` (`originFk`,`creationDate`), + KEY `productionConfigLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, + CONSTRAINT `productionConfigUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `productionError` -- @@ -35936,7 +35476,7 @@ CREATE TABLE `province` ( `name` varchar(30) NOT NULL, `countryFk` mediumint(8) unsigned NOT NULL, `warehouseFk` smallint(6) unsigned DEFAULT NULL COMMENT 'warehouse responsable de las rutas', - `zoneFk` tinyint(4) DEFAULT NULL, + `zoneFk` int(11) DEFAULT NULL, `geoFk` int(11) DEFAULT NULL, `autonomyFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), @@ -35947,7 +35487,7 @@ CREATE TABLE `province` ( KEY `province_FK` (`autonomyFk`), CONSTRAINT `province_FK` FOREIGN KEY (`autonomyFk`) REFERENCES `autonomy` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `province_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE, - CONSTRAINT `province_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `vn2008`.`zones__` (`zone_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `province_zone_FK` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `warehouse_Id` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -35967,6 +35507,26 @@ CREATE TABLE `punchState` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Table for storing punches that have cars with errors'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `quadmindsApiConfig` +-- + +DROP TABLE IF EXISTS `quadmindsApiConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `quadmindsApiConfig` ( + `id` int(10) unsigned NOT NULL, + `url` varchar(255) DEFAULT NULL, + `key` varchar(255) DEFAULT NULL, + `maxObjects` int(11) DEFAULT NULL COMMENT 'Número máximo de objetos en el array por petición', + `limit` int(11) DEFAULT NULL COMMENT 'Limite de objetos solicitados por petición', + `orderTimeFrom` varchar(5) DEFAULT NULL COMMENT 'Inicio de ventana horaria de pedido', + `orderTimeTo` varchar(5) DEFAULT NULL COMMENT 'Fin de ventana horaria de pedido', + PRIMARY KEY (`id`), + CONSTRAINT `quadMindsConfig_check` CHECK (`id` = 1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `quality` -- @@ -36073,10 +35633,12 @@ CREATE TABLE `rateLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `logRateuserFk` (`userFk`), KEY `rateLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), KEY `rateLog_originFk` (`originFk`,`creationDate`), + KEY `rateLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `rateUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36306,14 +35868,69 @@ CREATE TABLE `roadmap` ( `userFk` int(10) unsigned DEFAULT NULL, `price` decimal(10,2) DEFAULT NULL, `driverName` varchar(45) DEFAULT NULL, + `kmStart` mediumint(9) DEFAULT NULL, + `kmEnd` mediumint(9) DEFAULT NULL, + `started` datetime DEFAULT NULL, + `finished` datetime DEFAULT NULL, + `m3` int(10) unsigned DEFAULT NULL, + `driver2Fk` int(10) unsigned DEFAULT NULL, + `driver1Fk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `roadmap_supplierFk` (`supplierFk`), + KEY `roadmap_worker_FK` (`driver1Fk`), + KEY `roadmap_worker_FK_2` (`driver2Fk`), CONSTRAINT `roadmap_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE, - CONSTRAINT `roadmap_supplierFk` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE + CONSTRAINT `roadmap_supplierFk` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, + CONSTRAINT `roadmap_worker_FK` FOREIGN KEY (`driver1Fk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, + CONSTRAINT `roadmap_worker_FK_2` FOREIGN KEY (`driver2Fk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Troncales diarios que se contratan'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `roadmapAddress` +-- + +DROP TABLE IF EXISTS `roadmapAddress`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `roadmapAddress` ( + `addressFk` int(11) NOT NULL, + `isActive` tinyint(4) DEFAULT 1, + PRIMARY KEY (`addressFk`), + CONSTRAINT `roadmapAddress_address_FK` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Direcciones de los troncales'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `roadmapStop` +-- + +DROP TABLE IF EXISTS `roadmapStop`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `roadmapStop` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `roadmapFk` int(10) unsigned DEFAULT NULL, + `addressFk` int(11) DEFAULT NULL, + `eta` datetime DEFAULT NULL COMMENT 'Estimated time of arrival', + `description` varchar(45) NOT NULL, + `bufferFk` int(11) DEFAULT NULL COMMENT 'buffer destino de las cajas', + `created` timestamp NULL DEFAULT current_timestamp(), + `userFk` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `expeditionTruck_idx1` (`eta`), + KEY `expeditionTruck_FK` (`bufferFk`), + KEY `expeditionTruck_FK_2` (`roadmapFk`), + KEY `expeditionTruck_FK_3` (`userFk`), + KEY `roadmapStop_roadmapAddress_FK` (`addressFk`), + CONSTRAINT `expeditionTruck_FK` FOREIGN KEY (`bufferFk`) REFERENCES `srt`.`buffer` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `expeditionTruck_FK_2` FOREIGN KEY (`roadmapFk`) REFERENCES `roadmap` (`id`) ON UPDATE CASCADE, + CONSTRAINT `expeditionTruck_FK_3` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE, + CONSTRAINT `roadmapStop_roadmapAddress_FK` FOREIGN KEY (`addressFk`) REFERENCES `roadmapAddress` (`addressFk`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Distintas paradas que hacen los trocales'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `role` -- @@ -36356,7 +35973,7 @@ DROP TABLE IF EXISTS `route`; CREATE TABLE `route` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `workerFk` int(10) unsigned DEFAULT NULL, - `firstEditorFk` int(10) unsigned NOT NULL COMMENT 'Usuario creador de la ruta', + `firstEditorFk` int(10) unsigned DEFAULT NULL, `created` date NOT NULL, `vehicleFk` int(10) unsigned DEFAULT NULL, `agencyModeFk` int(11) DEFAULT NULL, @@ -36386,13 +36003,17 @@ CREATE TABLE `route` ( KEY `route_idxIsOk` (`isOk`), KEY `route_WorkCenterFk_idx` (`commissionWorkCenterFk`), KEY `route_fk_editor` (`editorFk`), + KEY `route_vehicleFk` (`vehicleFk`), + KEY `route_firstEditorFk` (`firstEditorFk`), CONSTRAINT `fk_route_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `route_WorkCenterFk` FOREIGN KEY (`commissionWorkCenterFk`) REFERENCES `workCenter` (`id`) ON UPDATE CASCADE, + CONSTRAINT `route_firstEditorFk` FOREIGN KEY (`firstEditorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `route_fk5` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `route_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `route_ibfk_1` FOREIGN KEY (`gestdocFk`) REFERENCES `dms` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `route_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, - CONSTRAINT `route_invoiceInFk` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE SET NULL ON UPDATE CASCADE + CONSTRAINT `route_invoiceInFk` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `route_vehicleFk` FOREIGN KEY (`vehicleFk`) REFERENCES `vehicle` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36536,21 +36157,6 @@ CREATE TABLE `routeDefaultAgencyMode` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `routeLoadWorker__` --- - -DROP TABLE IF EXISTS `routeLoadWorker__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `routeLoadWorker__` ( - `routeFk` int(10) unsigned NOT NULL, - `workerFk` int(10) unsigned NOT NULL, - PRIMARY KEY (`routeFk`,`workerFk`), - KEY `frmWorker_idx` (`workerFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Table deprecated on 26/04/23'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `routeLog` -- @@ -36570,10 +36176,12 @@ CREATE TABLE `routeLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `routeLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), KEY `routeLog_originFk` (`originFk`,`creationDate`), + KEY `routeLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `routeLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36623,24 +36231,6 @@ CREATE TABLE `routeRecalc` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin COMMENT='Queue of changed volume to recalc route volumen'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `routeUserPercentage__` --- - -DROP TABLE IF EXISTS `routeUserPercentage__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `routeUserPercentage__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `workerFk` int(10) unsigned NOT NULL, - `percentage` decimal(10,2) NOT NULL, - `dated` date NOT NULL, - PRIMARY KEY (`id`), - KEY `routeUserPercentageFk_idx` (`workerFk`), - CONSTRAINT `routeUserPercentageFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `routesControl` -- @@ -36680,7 +36270,7 @@ CREATE TABLE `routesMonitor` ( `m3` decimal(10,1) DEFAULT NULL, `priority` int(11) NOT NULL DEFAULT 0, `etd` time DEFAULT NULL, - `expeditionTruckFk` int(11) DEFAULT NULL, + `roadmapStopFk` int(11) DEFAULT NULL, `m3boxes` decimal(10,1) DEFAULT NULL, `bufferFk` int(11) DEFAULT NULL COMMENT 'Buffer del sorter por el que se quiere sacar esa ruta', `isPickingAllowed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Los tickets de esta ruta se pueden preparar', @@ -36689,12 +36279,12 @@ CREATE TABLE `routesMonitor` ( KEY `routesMonitor_FK` (`bufferFk`), KEY `routesMonitor_FK_2` (`beachFk`), KEY `routesMonitor_FK_1` (`dockFk`), - KEY `routesMonitor_FK_3` (`expeditionTruckFk`), + KEY `routesMonitor_FK_3` (`roadmapStopFk`), KEY `routesMonitor_fk_editor` (`editorFk`), CONSTRAINT `routesMonitor_FK` FOREIGN KEY (`bufferFk`) REFERENCES `srt`.`buffer` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `routesMonitor_FK_1` FOREIGN KEY (`dockFk`) REFERENCES `dock` (`code`) ON UPDATE CASCADE, CONSTRAINT `routesMonitor_FK_2` FOREIGN KEY (`beachFk`) REFERENCES `beach` (`code`) ON UPDATE CASCADE, - CONSTRAINT `routesMonitor_FK_3` FOREIGN KEY (`expeditionTruckFk`) REFERENCES `expeditionTruck` (`id`) ON UPDATE CASCADE, + CONSTRAINT `routesMonitor_FK_3` FOREIGN KEY (`roadmapStopFk`) REFERENCES `roadmapStop` (`id`) ON UPDATE CASCADE, CONSTRAINT `routesMonitor_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36723,6 +36313,7 @@ CREATE TABLE `sale` ( `isAdded` tinyint(1) NOT NULL DEFAULT 0, `total` decimal(10,2) GENERATED ALWAYS AS (`price` * `quantity` * (100 - `discount`) / 100) VIRTUAL, `editorFk` int(10) unsigned DEFAULT NULL, + `problem` set('hasItemShortage','hasComponentLack','hasItemDelay','hasRounding','hasItemLost') NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `Id_Ticket` (`ticketFk`), KEY `itemFk_ticketFk` (`itemFk`,`ticketFk`), @@ -36844,14 +36435,17 @@ CREATE TABLE `saleGroup` ( `sectorFk` int(11) DEFAULT NULL, `ticketFk` int(11) DEFAULT NULL, `editorFk` int(10) unsigned DEFAULT NULL, + `stateFk` tinyint(3) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `saleGroup_FK` (`ticketFk`), KEY `saleGroup_userFK` (`userFk`), KEY `saleGroup_parkingFK` (`parkingFk`), KEY `saleGroup_sectorFK` (`sectorFk`), + KEY `saleGroup_state_FK` (`stateFk`), CONSTRAINT `saleGroup_FK` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `saleGroup_parkingFK` FOREIGN KEY (`parkingFk`) REFERENCES `parking` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `saleGroup_sectorFK` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `saleGroup_state_FK` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE, CONSTRAINT `saleGroup_userFK` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='agrupa lineas de venta'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36876,6 +36470,36 @@ CREATE TABLE `saleGroupDetail` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='relaciona sale y saleGroup'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `saleGroupLog` +-- + +DROP TABLE IF EXISTS `saleGroupLog`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `saleGroupLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete','select') NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `changedModel` enum('SaleGroup','SaleGroupDetail') NOT NULL DEFAULT 'SaleGroup', + `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)), + `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), + `changedModelId` int(11) NOT NULL, + `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, + `reason` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `saleGroupUserFk` (`userFk`), + KEY `saleGroupLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), + KEY `saleGroupLog_originFk` (`originFk`,`creationDate`), + KEY `saleGroupLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, + CONSTRAINT `saleGroupLogUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `saleLabel` -- @@ -36994,7 +36618,6 @@ CREATE TABLE `saleTracking` ( `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `originalQuantity` double DEFAULT NULL, `workerFk` int(10) unsigned NOT NULL, - `actionFk__` int(11) DEFAULT NULL, `id` int(11) NOT NULL AUTO_INCREMENT, `stateFk` tinyint(3) unsigned NOT NULL, `isScanned` tinyint(1) DEFAULT NULL COMMENT 'TRUE: se ha escaneado. FALSE: escrito a mano. NULL:demás casos', @@ -37003,15 +36626,30 @@ CREATE TABLE `saleTracking` ( KEY `Id_Movimiento` (`saleFk`), KEY `fgnStateFk_idx` (`stateFk`), KEY `saleTracking_idx5` (`created`), - KEY `saleTracking_fk2_idx` (`actionFk__`), KEY `saleTracking_FK_2` (`workerFk`), CONSTRAINT `fgnStateFk` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE, CONSTRAINT `saleTracking_FK` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `saleTracking_FK_1` FOREIGN KEY (`actionFk__`) REFERENCES `ticketTrackingState__` (`id`) ON UPDATE CASCADE, CONSTRAINT `saleTracking_FK_2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `saleUnit` +-- + +DROP TABLE IF EXISTS `saleUnit`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `saleUnit` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + `isVisible` tinyint(1) NOT NULL DEFAULT 1, + `created` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `saleValue` -- @@ -37337,11 +36975,10 @@ CREATE TABLE `sectorCollectionSaleGroup` ( `sectorCollectionFk` int(11) NOT NULL, `saleGroupFk` int(11) NOT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `saleGroupFk` (`saleGroupFk`), - KEY `sectorCollectionFk` (`sectorCollectionFk`), + UNIQUE KEY `sectorCollectionSaleGroup_unique` (`sectorCollectionFk`,`saleGroupFk`), + KEY `sectorCollectionSaleGroup_saleGroup_FK` (`saleGroupFk`), CONSTRAINT `sectorCollectionSaleGroup_ibfk_1` FOREIGN KEY (`sectorCollectionFk`) REFERENCES `sectorCollection` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `sectorCollectionSaleGroup_ibfk_2` FOREIGN KEY (`saleGroupFk`) REFERENCES `saleGroup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `sectorCollectionSaleGroup_ibfk_3` FOREIGN KEY (`saleGroupFk`) REFERENCES `saleGroup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `sectorCollectionSaleGroup_saleGroup_FK` FOREIGN KEY (`saleGroupFk`) REFERENCES `saleGroup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Relaciona las lineas de venta con la coleccion del sector'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -37543,10 +37180,12 @@ CREATE TABLE `shelvingLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `shelvingLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), KEY `shelvingLog_originFk` (`originFk`,`creationDate`), + KEY `shelvingLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `shelvingLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -37612,20 +37251,20 @@ CREATE TABLE `siiTypeInvoiceOut` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `silexACL` +-- Table structure for table `silexACL__` -- -DROP TABLE IF EXISTS `silexACL`; +DROP TABLE IF EXISTS `silexACL__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `silexACL` ( +CREATE TABLE `silexACL__` ( `id` int(11) NOT NULL AUTO_INCREMENT, `module` varchar(50) NOT NULL, `method` varchar(50) NOT NULL, `role` varchar(20) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `module_UNIQUE` (`module`,`method`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='@deprecated 2024-08-05 refs #7820'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -37956,7 +37595,6 @@ CREATE TABLE `state` ( `order` tinyint(3) unsigned DEFAULT NULL, `alertLevel` int(11) NOT NULL DEFAULT 0, `code` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `sectorProdPriority` tinyint(3) DEFAULT NULL, `nextStateFk` tinyint(3) unsigned NOT NULL COMMENT 'Estado al que tiene que cambiar el ticket despues de preparacion previa', `isPreviousPreparable` tinyint(1) NOT NULL DEFAULT 0, `isPicked` tinyint(1) NOT NULL DEFAULT 0, @@ -37970,10 +37608,10 @@ CREATE TABLE `state` ( PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`), KEY `state_id3` (`semaphore`), - KEY `alertLevel` (`alertLevel`), KEY `state_FK` (`nextStateFk`), + KEY `state_ibfk_1` (`alertLevel`), CONSTRAINT `state_FK` FOREIGN KEY (`nextStateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE, - CONSTRAINT `state_ibfk_1` FOREIGN KEY (`alertLevel`) REFERENCES `alertLevel` (`id`) + CONSTRAINT `state_ibfk_1` FOREIGN KEY (`alertLevel`) REFERENCES `alertLevel` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -37993,6 +37631,25 @@ CREATE TABLE `stateI18n` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `stockBought` +-- + +DROP TABLE IF EXISTS `stockBought`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `stockBought` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `workerFk` int(10) unsigned NOT NULL, + `bought` decimal(10,2) NOT NULL COMMENT 'purchase volume in m3 for the day', + `reserve` decimal(10,2) DEFAULT NULL COMMENT 'reserved volume in m3 for the day', + `dated` date NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + UNIQUE KEY `stockBought_unique` (`workerFk`,`dated`), + CONSTRAINT `stockBought_worker_FK` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `stockBuyed` -- @@ -38047,7 +37704,6 @@ CREATE TABLE `supplier` ( `countryFk` mediumint(8) unsigned DEFAULT NULL, `nif` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, `isOfficial` tinyint(1) NOT NULL DEFAULT 1, - `isFarmer` tinyint(1) NOT NULL DEFAULT 0, `retAccount` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, `phone` varchar(16) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, `commission` float NOT NULL DEFAULT 0, @@ -38114,7 +37770,6 @@ CREATE TABLE `supplierAccount` ( `office` varchar(4) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, `DC` varchar(2) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, `number` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `description__` varchar(45) DEFAULT NULL COMMENT '@deprecated 2023-03-23', `bankEntityFk` int(10) unsigned DEFAULT NULL, `accountingFk` int(11) DEFAULT NULL, `beneficiary` varchar(50) DEFAULT NULL, @@ -38323,10 +37978,12 @@ CREATE TABLE `supplierLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `supplierLog_ibfk_2` (`userFk`), KEY `supplierLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), KEY `supplierLog_originFk` (`originFk`,`creationDate`), + KEY `supplierLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `supplierLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -38626,7 +38283,10 @@ CREATE TABLE `ticket` ( `weight` decimal(10,2) DEFAULT NULL COMMENT 'En caso de informar, se utilizará su valor para calcular el peso de la factura', `clonedFrom` int(11) DEFAULT NULL, `cmrFk` int(11) DEFAULT NULL, + `problem` set('hasTicketRequest','isFreezed','hasRisk','hasHighRisk','isTaxDataChecked','isTooLittle') NOT NULL DEFAULT '', + `risk` decimal(10,2) DEFAULT NULL COMMENT 'cache calculada con el riesgo del cliente', `editorFk` int(10) unsigned DEFAULT NULL, + `volume` decimal(10,6) DEFAULT NULL COMMENT 'Unidad en m3', PRIMARY KEY (`id`), KEY `Id_Cliente` (`clientFk`), KEY `Id_Consigna` (`addressFk`), @@ -38642,7 +38302,6 @@ CREATE TABLE `ticket` ( KEY `ticket_fk_editor` (`editorFk`), KEY `ticket_cmrFk` (`cmrFk`), CONSTRAINT `ticketCompany_Fk` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, - CONSTRAINT `ticket_FK` FOREIGN KEY (`refFk`) REFERENCES `invoiceOut` (`ref`) ON UPDATE CASCADE, CONSTRAINT `ticket_cmrFk` FOREIGN KEY (`cmrFk`) REFERENCES `cmr` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticket_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticket_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), @@ -38650,10 +38309,26 @@ CREATE TABLE `ticket` ( CONSTRAINT `ticket_ibfk_6` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticket_ibfk_8` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`), CONSTRAINT `ticket_ibfk_9` FOREIGN KEY (`routeFk`) REFERENCES `route` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `ticket_invoiceOut_FK` FOREIGN KEY (`refFk`) REFERENCES `invoiceOut` (`ref`) ON UPDATE CASCADE, CONSTRAINT `tickets_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `ticketCanAdvanceConfig` +-- + +DROP TABLE IF EXISTS `ticketCanAdvanceConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ticketCanAdvanceConfig` ( + `id` int(10) unsigned NOT NULL, + `destinationOrder` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + CONSTRAINT `ticketCanAdvanceConfig_check` CHECK (`id` = 1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `ticketCollection` -- @@ -38802,7 +38477,7 @@ DROP TABLE IF EXISTS `ticketLastState`; CREATE TABLE `ticketLastState` ( `ticketFk` int(11) NOT NULL DEFAULT 0, `ticketTrackingFk` int(11) NOT NULL, - `name` varchar(15) NOT NULL, + `name` varchar(20) NOT NULL, PRIMARY KEY (`ticketFk`), KEY `double_foreign` (`ticketFk`,`ticketTrackingFk`), CONSTRAINT `Id_Ticket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -38855,10 +38530,12 @@ CREATE TABLE `ticketLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `logTicketuserFk` (`userFk`), KEY `ticketLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), KEY `ticketLog_originFk` (`originFk`,`creationDate`), + KEY `ticketLog_creationDate_IDX` (`creationDate`,`changedModel`,`action`) USING BTREE, CONSTRAINT `ticketLog_user` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -38932,16 +38609,13 @@ CREATE TABLE `ticketPackaging` ( `quantity` int(10) DEFAULT 0, `created` timestamp NOT NULL DEFAULT current_timestamp(), `pvp` double DEFAULT NULL, - `workerFk` int(10) unsigned DEFAULT NULL, `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `ticketPackaging_fk1_idx` (`ticketFk`), KEY `ticketPackaging_fk2_idx` (`packagingFk`), - KEY `ticketPackaging_fk3_idx` (`workerFk`), KEY `ticketPackaging_fk_editor` (`editorFk`), CONSTRAINT `ticketPackaging_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketPackaging_fk2` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE, - CONSTRAINT `ticketPackaging_fk3` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketPackaging_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -38964,7 +38638,7 @@ CREATE TABLE `ticketPackagingStartingStock` ( KEY `ticketPackagingStartingStock_fk2_idx` (`packagingFk`), KEY `ticketPackagingStartingStock_fk3_idx` (`itemFk`), CONSTRAINT `ticketPackagingStartingStock_fk1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `ticketPackagingStartingStock_fk2` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `ticketPackagingStartingStock_fk2` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticketPackagingStartingStock_fk3` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -39067,7 +38741,6 @@ CREATE TABLE `ticketRequest` ( `ordered` datetime DEFAULT NULL, `shipped` datetime DEFAULT NULL, `salesPersonCode` varchar(3) DEFAULT NULL, - `buyerCode__` varchar(3) NOT NULL COMMENT '@deprecated 2024-04-23 refs #6731 field not used', `quantity` int(11) DEFAULT NULL, `price` double DEFAULT NULL, `itemFk` double DEFAULT NULL, @@ -39086,7 +38759,6 @@ CREATE TABLE `ticketRequest` ( UNIQUE KEY `Id_Movimiento_UNIQUE` (`saleFk`), KEY `Id_ARTICLE` (`itemFk`), KEY `Id_CLIENTE` (`clientFk`), - KEY `Id_Comprador` (`buyerCode__`), KEY `Id_Movimiento` (`saleFk`), KEY `Id_Vendedor` (`salesPersonCode`), KEY `fgnRequester_idx` (`requesterFk`), @@ -39146,23 +38818,6 @@ CREATE TABLE `ticketServiceType` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='Lista de los posibles servicios a elegir'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `ticketSms__` --- - -DROP TABLE IF EXISTS `ticketSms__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `ticketSms__` ( - `smsFk` mediumint(8) unsigned NOT NULL, - `ticketFk` int(11) DEFAULT NULL, - PRIMARY KEY (`smsFk`), - KEY `ticketSms_FK_1` (`ticketFk`), - CONSTRAINT `ticketSms_FK` FOREIGN KEY (`smsFk`) REFERENCES `sms` (`id`) ON UPDATE CASCADE, - CONSTRAINT `ticketSms_FK_1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `ticketState` -- @@ -39236,20 +38891,6 @@ CREATE TABLE `ticketTracking` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `ticketTrackingState__` --- - -DROP TABLE IF EXISTS `ticketTrackingState__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `ticketTrackingState__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `action` varchar(15) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `ticketTrolley` -- @@ -39358,6 +38999,21 @@ CREATE TABLE `tillConfig` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `tillSerial` +-- + +DROP TABLE IF EXISTS `tillSerial`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `tillSerial` ( + `code` varchar(2) NOT NULL, + `description` varchar(30) DEFAULT NULL, + `account` varchar(10) DEFAULT NULL, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `time` -- @@ -39584,7 +39240,6 @@ CREATE TABLE `travel` ( `landingHour` time DEFAULT NULL, `warehouseInFk` smallint(6) unsigned DEFAULT NULL, `warehouseOutFk` smallint(6) unsigned DEFAULT NULL, - `agencyFk__` smallint(5) unsigned NOT NULL COMMENT '@deprecated 2024-10-01 refs #6604', `ref` varchar(20) DEFAULT NULL, `isDelivered` tinyint(1) NOT NULL DEFAULT 0, `isReceived` tinyint(1) NOT NULL DEFAULT 0, @@ -39599,7 +39254,6 @@ CREATE TABLE `travel` ( `awbFk` smallint(11) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `shipment_1` (`shipped`,`landed`,`warehouseInFk`,`warehouseOutFk`,`agencyModeFk`,`ref`), - KEY `agency_id` (`agencyFk__`), KEY `shipment` (`shipped`), KEY `landing` (`landed`), KEY `warehouse_landing` (`warehouseInFk`,`landed`), @@ -39608,6 +39262,7 @@ CREATE TABLE `travel` ( KEY `travel_FK` (`agencyModeFk`), KEY `travel_fk_editor` (`editorFk`), KEY `travel_FK_1` (`awbFk`), + KEY `travel_landed_IDX` (`landed` DESC,`warehouseInFk`,`warehouseOutFk`) USING BTREE, CONSTRAINT `travel_FK` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_FK_1` FOREIGN KEY (`awbFk`) REFERENCES `awb` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `travel_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), @@ -39663,19 +39318,40 @@ CREATE TABLE `travelConfig` ( `warehouseOutFk` smallint(6) unsigned NOT NULL DEFAULT 60 COMMENT 'Warehouse destino', `agencyFk` int(11) NOT NULL DEFAULT 1378 COMMENT 'Agencia por defecto', `companyFk` int(10) unsigned NOT NULL DEFAULT 442 COMMENT 'Compañía por defecto', + `devalueWarehouseOutFk` smallint(6) unsigned DEFAULT NULL COMMENT 'Datos del travel para las entradas generadas al devaluar artículos de A1 a A2', + `devalueAgencyModeFk` int(11) DEFAULT NULL, + `devalueRef` varchar(20) DEFAULT NULL, PRIMARY KEY (`id`), KEY `travelConfig_FK` (`warehouseInFk`), KEY `travelConfig_FK_1` (`warehouseOutFk`), KEY `travelConfig_FK_2` (`agencyFk`), KEY `travelConfig_FK_3` (`companyFk`), + KEY `travelConfig_agencyMode_FK` (`devalueAgencyModeFk`), + KEY `travelConfig_warehouse_FK` (`devalueWarehouseOutFk`), CONSTRAINT `travelConfig_FK` FOREIGN KEY (`warehouseInFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `travelConfig_FK_1` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `travelConfig_FK_2` FOREIGN KEY (`agencyFk`) REFERENCES `agencyMode` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `travelConfig_FK_3` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `travelConfig_agencyMode_FK` FOREIGN KEY (`devalueAgencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `travelConfig_warehouse_FK` FOREIGN KEY (`devalueWarehouseOutFk`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `travelConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `travelKgPercentage` +-- + +DROP TABLE IF EXISTS `travelKgPercentage`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `travelKgPercentage` ( + `value` int(3) NOT NULL, + `className` varchar(50) DEFAULT NULL, + PRIMARY KEY (`value`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `travelLog` -- @@ -39695,10 +39371,12 @@ CREATE TABLE `travelLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `travelLog_changedModel` (`changedModel`,`changedModelId`,`originFk`), KEY `travelLog_originFk` (`originFk`,`creationDate`), + KEY `travelLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `travelLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -39770,27 +39448,6 @@ CREATE TABLE `trolley` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `userConfig` --- - -DROP TABLE IF EXISTS `userConfig`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `userConfig` ( - `userFk` int(10) unsigned NOT NULL, - `warehouseFk` smallint(6) DEFAULT NULL, - `companyFk` smallint(5) unsigned DEFAULT NULL, - `created` timestamp NULL DEFAULT current_timestamp(), - `updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `darkMode` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Salix interface dark mode', - `tabletFk` varchar(100) DEFAULT NULL, - PRIMARY KEY (`userFk`), - KEY `tabletFk` (`tabletFk`), - CONSTRAINT `userConfig_ibfk_1` FOREIGN KEY (`tabletFk`) REFERENCES `docuwareTablet` (`tablet`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Configuración de usuario en Salix'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `userLog` -- @@ -39810,13 +39467,36 @@ CREATE TABLE `userLog` ( `newInstance` text DEFAULT NULL, `changedModelId` int(11) DEFAULT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `originFk` (`originFk`), KEY `userFk` (`userFk`), + KEY `userLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `userLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `userMultiConfig` +-- + +DROP TABLE IF EXISTS `userMultiConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `userMultiConfig` ( + `userFk` int(10) unsigned NOT NULL, + `warehouseFk` smallint(6) DEFAULT NULL, + `companyFk` smallint(5) unsigned DEFAULT NULL, + `created` timestamp NULL DEFAULT current_timestamp(), + `updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `darkMode` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Salix interface dark mode', + `tabletFk` varchar(100) DEFAULT NULL, + PRIMARY KEY (`userFk`), + KEY `tabletFk` (`tabletFk`), + CONSTRAINT `userMultiConfig_ibfk_1` FOREIGN KEY (`tabletFk`) REFERENCES `docuwareTablet` (`tablet`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Configuración de usuario en Salix'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `userPhone` -- @@ -39891,14 +39571,14 @@ CREATE TABLE `vehicle` ( KEY `vehicle_supplierFk` (`supplierFk`), KEY `vehicle_supplierCoolerFk` (`supplierCoolerFk`), KEY `vehicle_bankPolicyFk` (`bankPolicyFk`), - CONSTRAINT `provinceFk` FOREIGN KEY (`warehouseFk`) REFERENCES `province` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `vehicleCompany_Fk` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, CONSTRAINT `vehicle_FK` FOREIGN KEY (`fuelTypeFk`) REFERENCES `fuelType` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `vehicle_FK_1` FOREIGN KEY (`ppeFk`) REFERENCES `ppe` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `vehicle_bankPolicyFk` FOREIGN KEY (`bankPolicyFk`) REFERENCES `bankPolicy` (`id`) ON UPDATE CASCADE, CONSTRAINT `vehicle_deliveryPointFk` FOREIGN KEY (`deliveryPointFk`) REFERENCES `deliveryPoint` (`id`) ON UPDATE CASCADE, CONSTRAINT `vehicle_supplierCoolerFk` FOREIGN KEY (`supplierCoolerFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, - CONSTRAINT `vehicle_supplierFk` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) + CONSTRAINT `vehicle_supplierFk` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`), + CONSTRAINT `vehicle_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -40115,7 +39795,7 @@ DROP TABLE IF EXISTS `wagon`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `wagon` ( - `id` varchar(6) NOT NULL COMMENT '26 letras de alfabeto inglés', + `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '26 letras de alfabeto inglés', `volume` int(11) NOT NULL DEFAULT 150 COMMENT 'Volumen en litros', `plate` varchar(10) NOT NULL COMMENT 'Matrícula', `typeFk` int(11) unsigned NOT NULL, @@ -40140,7 +39820,11 @@ CREATE TABLE `wagonConfig` ( `maxWagonHeight` int(11) unsigned DEFAULT 200, `minHeightBetweenTrays` int(11) unsigned DEFAULT 50, `maxTrays` int(11) unsigned DEFAULT 6, + `defaultHeight` int(10) unsigned DEFAULT 0 COMMENT 'Default height in cm for a base tray', + `defaultTrayColorFk` int(11) unsigned DEFAULT NULL COMMENT 'Default color for a base tray', PRIMARY KEY (`id`), + KEY `wagonConfig_wagonTypeColor_FK` (`defaultTrayColorFk`), + CONSTRAINT `wagonConfig_wagonTypeColor_FK` FOREIGN KEY (`defaultTrayColorFk`) REFERENCES `wagonTypeColor` (`id`), CONSTRAINT `wagonConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -40187,15 +39871,15 @@ DROP TABLE IF EXISTS `wagonTypeTray`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `wagonTypeTray` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `typeFk` int(11) unsigned DEFAULT NULL, - `height` int(11) unsigned NOT NULL, - `colorFk` int(11) unsigned DEFAULT NULL, + `wagonTypeFk` int(11) unsigned DEFAULT NULL, + `height` int(11) unsigned DEFAULT NULL, + `wagonTypeColorFk` int(11) unsigned DEFAULT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `typeFk` (`typeFk`,`height`), - KEY `wagonTypeTray_color` (`colorFk`), - CONSTRAINT `wagonTypeTray_color` FOREIGN KEY (`colorFk`) REFERENCES `wagonTypeColor` (`id`) ON UPDATE CASCADE, - CONSTRAINT `wagonTypeTray_type` FOREIGN KEY (`typeFk`) REFERENCES `wagonType` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; + KEY `wagonTypeTray_wagonType_FK` (`wagonTypeFk`), + KEY `wagonTypeTray_wagonTypeColor_FK` (`wagonTypeColorFk`), + CONSTRAINT `wagonTypeTray_wagonTypeColor_FK` FOREIGN KEY (`wagonTypeColorFk`) REFERENCES `wagonTypeColor` (`id`), + CONSTRAINT `wagonTypeTray_wagonType_FK` FOREIGN KEY (`wagonTypeFk`) REFERENCES `wagonType` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40211,7 +39895,7 @@ CREATE TABLE `wagonVolumetry` ( `lines` int(10) unsigned NOT NULL DEFAULT 1, `liters` int(10) unsigned NOT NULL DEFAULT 0, `height` int(10) unsigned NOT NULL DEFAULT 20, - `wagonFk` varchar(6) NOT NULL, + `wagonFk` int(11) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `wagonVolumetry_FK_1` (`wagonFk`), CONSTRAINT `wagonVolumetry_FK_1` FOREIGN KEY (`wagonFk`) REFERENCES `wagon` (`id`) ON UPDATE CASCADE @@ -40246,7 +39930,6 @@ CREATE TABLE `warehouse` ( `hasDms` tinyint(1) NOT NULL DEFAULT 0, `pickUpAgencyModeFk` int(11) DEFAULT NULL, `isBuyerToBeEmailed` tinyint(2) NOT NULL DEFAULT 0, - `aliasFk__` smallint(5) unsigned DEFAULT NULL COMMENT '@deprecated 2024-01-23 refs #5167', `labelReport` int(11) DEFAULT NULL, `hasUbications` tinyint(1) NOT NULL DEFAULT 1, `hasProduction` tinyint(1) NOT NULL DEFAULT 0, @@ -40261,31 +39944,14 @@ CREATE TABLE `warehouse` ( UNIQUE KEY `name_UNIQUE` (`name`), KEY `Id_Paises` (`countryFk`), KEY `isComparativeIdx` (`isComparative`), - KEY `warehouse_ibfk_1_idx` (`aliasFk__`), KEY `warehouse_FK` (`addressFk`), KEY `warehouse_FK_1` (`pickUpAgencyModeFk`), CONSTRAINT `warehouse_FK` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `warehouse_FK_1` FOREIGN KEY (`pickUpAgencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, - CONSTRAINT `warehouse_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`), - CONSTRAINT `warehouse_ibfk_2` FOREIGN KEY (`aliasFk__`) REFERENCES `warehouseAlias__` (`id`) ON DELETE SET NULL ON UPDATE CASCADE + CONSTRAINT `warehouse_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `warehouseAlias__` --- - -DROP TABLE IF EXISTS `warehouseAlias__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `warehouseAlias__` ( - `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(15) NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='@deprecated 2024-01-23 refs #5167'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `warehousePickup` -- @@ -40361,9 +40027,8 @@ CREATE TABLE `worker` ( `hasMachineryAuthorized` tinyint(2) DEFAULT 0, `seniority` date DEFAULT NULL, `isTodayRelative` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Para el F11. Calcula los problemas de visiblidad en funcion del dia actual', - `isF11Allowed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Usuario autorizado para abrir el F11', + `isF11Allowed__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-09-22', `maritalStatus` enum('S','M') NOT NULL, - `labelerFk__` tinyint(3) unsigned DEFAULT NULL COMMENT '@deprecated 2023-06-26', `originCountryFk` mediumint(8) unsigned DEFAULT NULL COMMENT 'País de origen', `educationLevelFk` smallint(6) DEFAULT NULL, `SSN` varchar(15) DEFAULT NULL, @@ -40375,15 +40040,12 @@ CREATE TABLE `worker` ( `sex` enum('M','F') NOT NULL DEFAULT 'F' COMMENT 'M Masculino F Femenino', `businessFk` int(11) DEFAULT NULL, `balance` decimal(10,2) DEFAULT NULL, - `locker` int(10) unsigned DEFAULT NULL, `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `CodigoTrabajador_UNIQUE` (`code`), UNIQUE KEY `worker_business` (`businessFk`), - UNIQUE KEY `locker` (`locker`), KEY `sub` (`sub`), KEY `boss_idx` (`bossFk`), - KEY `worker_FK` (`labelerFk__`), KEY `worker_FK_2` (`educationLevelFk`), KEY `worker_FK_1` (`originCountryFk`), KEY `worker_fk_editor` (`editorFk`), @@ -40605,25 +40267,25 @@ CREATE TABLE `workerDistributionCategory` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `workerDocument` +-- Table structure for table `workerDms` -- -DROP TABLE IF EXISTS `workerDocument`; +DROP TABLE IF EXISTS `workerDms`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `workerDocument` ( +CREATE TABLE `workerDms` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `worker` int(10) unsigned DEFAULT NULL, - `document` int(11) DEFAULT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, + `dmsFk` int(11) DEFAULT NULL, `isReadableByWorker` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si el empleado tiene permiso para acceder al documento', `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), - KEY `workerDocument_ibfk_1` (`worker`), - KEY `workerDocument_ibfk_2` (`document`), + KEY `workerDocument_ibfk_1` (`workerFk`), + KEY `workerDocument_ibfk_2` (`dmsFk`), KEY `workerDocument_fk_editor` (`editorFk`), - CONSTRAINT `workerDocument_FK` FOREIGN KEY (`worker`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, - CONSTRAINT `workerDocument_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), - CONSTRAINT `workerDocument_ibfk_2` FOREIGN KEY (`document`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `workerDms_ibfk_2` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `workerDocument_FK` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, + CONSTRAINT `workerDocument_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -40777,15 +40439,17 @@ CREATE TABLE `workerLog` ( `action` set('insert','update','delete') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), `description` text DEFAULT NULL, - `changedModel` enum('Worker','Calendar','WorkerTimeControlMail','Business','WorkerDms','WorkerTimeControl') NOT NULL DEFAULT 'Worker', + `changedModel` enum('Worker','Calendar','WorkerTimeControlMail','Business','WorkerDms','WorkerTimeControl','Locker') NOT NULL DEFAULT 'Worker', `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)), `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk_idx` (`userFk`), KEY `workerLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), KEY `workerLog_originFk` (`originFk`,`creationDate`), + KEY `workerLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `userFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -41288,9 +40952,10 @@ CREATE TABLE `zone` ( `isVolumetric` tinyint(1) NOT NULL DEFAULT 0, `inflation` decimal(5,2) NOT NULL DEFAULT 1.00, `m3Max` decimal(10,2) unsigned DEFAULT NULL, - `itemMaxSize` int(11) DEFAULT NULL COMMENT 'tamaño maximo de los articulos que esa ruta puede transportar', + `itemMaxSize` int(11) DEFAULT NULL COMMENT 'Altura maxima de los articulos que esa agencia puede transportar', `code` varchar(45) DEFAULT NULL, `editorFk` int(10) unsigned DEFAULT NULL, + `itemMaxLength` int(11) DEFAULT NULL COMMENT 'Longitud maxima para articulos acostados que esa agencia puede transportar', PRIMARY KEY (`id`), KEY `fk_zone_2_idx` (`agencyModeFk`), KEY `zone_name_idx` (`name`), @@ -41559,10 +41224,12 @@ CREATE TABLE `zoneLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `zoneLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), KEY `zoneLog_originFk` (`originFk`,`creationDate`), + KEY `zoneLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `zoneLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -41593,7 +41260,7 @@ CREATE TABLE `zoneWarehouse` ( -- Dumping events for database 'vn' -- /*!50106 SET @save_time_zone= @@TIME_ZONE */ ; -/*!50106 DROP EVENT IF EXISTS `clientsDisable` */; +/*!50106 DROP EVENT IF EXISTS `claim_changeState` */; DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; @@ -41605,23 +41272,20 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `clientsDisable` ON SCHEDULE EVERY 1 MONTH STARTS '2023-06-01 00:00:00' ON COMPLETION PRESERVE ENABLE DO BEGIN - UPDATE account.user u - JOIN client c ON c.id = u.id - LEFT JOIN account.account a ON a.id = u.id - SET u.active = FALSE - WHERE c.typeFk = 'normal' - AND a.id IS NULL - AND u.active - AND c.created < util.VN_CURDATE() - INTERVAL 12 MONTH - AND u.id NOT IN ( - SELECT DISTINCT c.id - FROM client c - LEFT JOIN ticket t ON t.clientFk = c.id - WHERE c.salesPersonFk IS NOT NULL - OR t.created > util.VN_CURDATE() - INTERVAL 12 MONTH - OR shipped > util.VN_CURDATE() - INTERVAL 12 MONTH - ); +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `claim_changeState` ON SCHEDULE EVERY 1 DAY STARTS '2024-06-06 07:52:46' ON COMPLETION PRESERVE ENABLE DO BEGIN + + DECLARE vClaimState INT; + + SELECT id INTO vClaimState + FROM claimState cs + WHERE cs.code = 'canceled'; + + UPDATE claim c + JOIN claimState cs ON cs.id = c.claimStateFk + SET c.claimStateFk = vClaimState + WHERE c.created < util.VN_CURDATE() - INTERVAL 2 MONTH + AND cs.code IN('incomplete','coming','waiting','out'); + END */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; @@ -41633,14 +41297,32 @@ DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; /*!50003 SET @saved_col_connection = @@collation_connection */ ;; -/*!50003 SET character_set_client = utf8mb3 */ ;; -/*!50003 SET character_set_results = utf8mb3 */ ;; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `client_unassignSalesPerson` ON SCHEDULE EVERY 1 DAY STARTS '2023-06-01 03:30:00' ON COMPLETION PRESERVE ENABLE DO CALL client_unassignSalesPerson */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `client_unassignSalesPerson` ON SCHEDULE EVERY 1 DAY STARTS '2023-06-01 03:30:00' ON COMPLETION PRESERVE ENABLE DO CALL client_unassignSalesPerson */ ;; +/*!50003 SET time_zone = @saved_time_zone */ ;; +/*!50003 SET sql_mode = @saved_sql_mode */ ;; +/*!50003 SET character_set_client = @saved_cs_client */ ;; +/*!50003 SET character_set_results = @saved_cs_results */ ;; +/*!50003 SET collation_connection = @saved_col_connection */ ;; +/*!50106 DROP EVENT IF EXISTS `client_userDisable` */;; +DELIMITER ;; +/*!50003 SET @saved_cs_client = @@character_set_client */ ;; +/*!50003 SET @saved_cs_results = @@character_set_results */ ;; +/*!50003 SET @saved_col_connection = @@collation_connection */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ;; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; +/*!50003 SET @saved_time_zone = @@time_zone */ ;; +/*!50003 SET time_zone = 'SYSTEM' */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `client_userDisable` ON SCHEDULE EVERY 1 MONTH STARTS '2023-06-01 00:00:00' ON COMPLETION PRESERVE ENABLE DO CALL client_userDisable() */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -41651,14 +41333,14 @@ DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; /*!50003 SET @saved_col_connection = @@collation_connection */ ;; -/*!50003 SET character_set_client = utf8mb3 */ ;; -/*!50003 SET character_set_results = utf8mb3 */ ;; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `collection_make` ON SCHEDULE EVERY 5 MINUTE STARTS '2022-09-15 00:00:00' ON COMPLETION PRESERVE ENABLE DO CALL vn.collection_make */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `collection_make` ON SCHEDULE EVERY 5 MINUTE STARTS '2022-09-15 00:00:00' ON COMPLETION PRESERVE ENABLE DO CALL vn.collection_make */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -41669,14 +41351,14 @@ DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; /*!50003 SET @saved_col_connection = @@collation_connection */ ;; -/*!50003 SET character_set_client = utf8mb3 */ ;; -/*!50003 SET character_set_results = utf8mb3 */ ;; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `department_doCalc` ON SCHEDULE EVERY 15 SECOND STARTS '2019-11-15 00:00:00' ON COMPLETION PRESERVE ENABLE DO CALL vn.department_doCalc */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `department_doCalc` ON SCHEDULE EVERY 15 SECOND STARTS '2019-11-15 00:00:00' ON COMPLETION PRESERVE ENABLE DO CALL vn.department_doCalc */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -41687,14 +41369,14 @@ DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; /*!50003 SET @saved_col_connection = @@collation_connection */ ;; -/*!50003 SET character_set_client = utf8mb3 */ ;; -/*!50003 SET character_set_results = utf8mb3 */ ;; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `envialiaThreHoldChecker` ON SCHEDULE EVERY 1 DAY STARTS '2022-01-28 09:52:46' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `envialiaThreHoldChecker` ON SCHEDULE EVERY 1 DAY STARTS '2022-01-28 09:52:46' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN DECLARE vActualNumber BIGINT; DECLARE vEndRange BIGINT; DECLARE vIsAlreadyNotified BOOLEAN; @@ -41733,14 +41415,14 @@ DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; /*!50003 SET @saved_col_connection = @@collation_connection */ ;; -/*!50003 SET character_set_client = utf8mb3 */ ;; -/*!50003 SET character_set_results = utf8mb3 */ ;; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `greuge_notify` ON SCHEDULE EVERY 1 DAY STARTS '2023-01-01 00:07:00' ON COMPLETION NOT PRESERVE ENABLE COMMENT 'Notifies subscribed users of events in wrong greuges' DO CALL vn.greuge_notifyEvents() */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `greuge_notify` ON SCHEDULE EVERY 1 DAY STARTS '2023-01-01 00:07:00' ON COMPLETION NOT PRESERVE ENABLE COMMENT 'Notifies subscribed users of events in wrong greuges' DO CALL vn.greuge_notifyEvents() */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -41751,35 +41433,53 @@ DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; /*!50003 SET @saved_col_connection = @@collation_connection */ ;; -/*!50003 SET character_set_client = utf8mb3 */ ;; -/*!50003 SET character_set_results = utf8mb3 */ ;; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `itemImageQueue_check` ON SCHEDULE EVERY 1 HOUR STARTS '2023-07-28 00:00:00' ON COMPLETION PRESERVE ENABLE DO BEGIN - DELETE FROM itemImageQueue - WHERE attempts >= (SELECT downloadMaxAttempts FROM itemConfig); +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `itemImageQueue_check` ON SCHEDULE EVERY 1 HOUR STARTS '2023-07-28 00:00:00' ON COMPLETION PRESERVE ENABLE DO BEGIN + DELETE FROM itemImageQueue + WHERE attempts >= (SELECT downloadMaxAttempts FROM itemConfig); END */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; /*!50003 SET character_set_results = @saved_cs_results */ ;; /*!50003 SET collation_connection = @saved_col_connection */ ;; +/*!50106 DROP EVENT IF EXISTS `itemShelvingSale_doReserve` */;; +DELIMITER ;; +/*!50003 SET @saved_cs_client = @@character_set_client */ ;; +/*!50003 SET @saved_cs_results = @@character_set_results */ ;; +/*!50003 SET @saved_col_connection = @@collation_connection */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ;; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; +/*!50003 SET @saved_time_zone = @@time_zone */ ;; +/*!50003 SET time_zone = 'SYSTEM' */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `itemShelvingSale_doReserve` ON SCHEDULE EVERY 15 SECOND STARTS '2023-10-16 00:00:00' ON COMPLETION PRESERVE ENABLE DO CALL vn.itemShelvingSale_doReserve */ ;; +/*!50003 SET time_zone = @saved_time_zone */ ;; +/*!50003 SET sql_mode = @saved_sql_mode */ ;; +/*!50003 SET character_set_client = @saved_cs_client */ ;; +/*!50003 SET character_set_results = @saved_cs_results */ ;; +/*!50003 SET collation_connection = @saved_col_connection */ ;; /*!50106 DROP EVENT IF EXISTS `mysqlConnectionsSorter_kill` */;; DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; /*!50003 SET @saved_col_connection = @@collation_connection */ ;; -/*!50003 SET character_set_client = utf8mb3 */ ;; -/*!50003 SET character_set_results = utf8mb3 */ ;; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `mysqlConnectionsSorter_kill` ON SCHEDULE EVERY 1 MINUTE STARTS '2021-10-28 09:56:27' ON COMPLETION NOT PRESERVE ENABLE DO CALL mysqlConnectionsSorter_kill() */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `mysqlConnectionsSorter_kill` ON SCHEDULE EVERY 1 MINUTE STARTS '2021-10-28 09:56:27' ON COMPLETION NOT PRESERVE ENABLE DO CALL mysqlConnectionsSorter_kill() */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -41790,14 +41490,14 @@ DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; /*!50003 SET @saved_col_connection = @@collation_connection */ ;; -/*!50003 SET character_set_client = utf8mb3 */ ;; -/*!50003 SET character_set_results = utf8mb3 */ ;; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `printQueue_check` ON SCHEDULE EVERY 10 MINUTE STARTS '2022-01-28 09:52:46' ON COMPLETION PRESERVE ENABLE DO BEGIN +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `printQueue_check` ON SCHEDULE EVERY 10 MINUTE STARTS '2022-01-28 09:52:46' ON COMPLETION PRESERVE ENABLE DO BEGIN DECLARE vCurrentCount INT; DECLARE vCheckSum INT; @@ -41808,14 +41508,7 @@ DELIMITER ;; DECLARE vPrintQueueLimit INT; DECLARE vCur CURSOR FOR - SELECT CONCAT(' - ', IFNULL(pq.id, ''), ' - ', IFNULL(p.path, ''),' - ', IFNULL(r.name, ''),' - ', IFNULL(pq.statusCode, ''),' - ', IFNULL(w.firstname, ''), " ", IFNULL(w.lastName, ''),' - ', IFNULL(pq.`error`, ''),' - ') + SELECT CONCAT('\n\t\t\t\t\t\t\t', IFNULL(pq.id, ''), '\n\t\t\t\t\t\t\t', IFNULL(p.path, ''),'\n\t\t\t\t\t\t\t', IFNULL(r.name, ''),'\n\t\t\t\t\t\t\t', IFNULL(pq.statusCode, ''),'\n\t\t\t\t\t\t\t', IFNULL(w.firstname, ''), " ", IFNULL(w.lastName, ''),'\n\t\t\t\t\t\t\t', IFNULL(pq.`error`, ''),'\n\t\t\t\t\t\t') FROM printQueue pq LEFT JOIN worker w ON w.id = pq.workerFk LEFT JOIN printer p ON p.id = pq.printerFk @@ -41840,15 +41533,7 @@ DELIMITER ;; vIsAlreadyNotified = FALSE AND vCurrentCount > 0 THEN - SELECT ' - - - - - - - - ' INTO vTableQueue; + SELECT '
Id ColaRuta ImpresoraInformeEstadoTrabajadorError
\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t' INTO vTableQueue; OPEN vCur; @@ -41906,7 +41591,7 @@ DELIMITER ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `raidUpdate` ON SCHEDULE EVERY 1 DAY STARTS '2017-12-29 00:05:00' ON COMPLETION PRESERVE ENABLE DO CALL raidUpdate */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `raidUpdate` ON SCHEDULE EVERY 1 DAY STARTS '2017-12-29 00:05:00' ON COMPLETION PRESERVE ENABLE DO CALL raidUpdate */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -41917,14 +41602,36 @@ DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; /*!50003 SET @saved_col_connection = @@collation_connection */ ;; -/*!50003 SET character_set_client = utf8mb3 */ ;; -/*!50003 SET character_set_results = utf8mb3 */ ;; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `route_doRecalc` ON SCHEDULE EVERY 10 SECOND STARTS '2021-07-08 07:32:23' ON COMPLETION PRESERVE ENABLE DO CALL route_doRecalc */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `route_doRecalc` ON SCHEDULE EVERY 10 SECOND STARTS '2021-07-08 07:32:23' ON COMPLETION PRESERVE ENABLE DO CALL route_doRecalc */ ;; +/*!50003 SET time_zone = @saved_time_zone */ ;; +/*!50003 SET sql_mode = @saved_sql_mode */ ;; +/*!50003 SET character_set_client = @saved_cs_client */ ;; +/*!50003 SET character_set_results = @saved_cs_results */ ;; +/*!50003 SET collation_connection = @saved_col_connection */ ;; +/*!50106 DROP EVENT IF EXISTS `travel_setDelivered` */;; +DELIMITER ;; +/*!50003 SET @saved_cs_client = @@character_set_client */ ;; +/*!50003 SET @saved_cs_results = @@character_set_results */ ;; +/*!50003 SET @saved_col_connection = @@collation_connection */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ;; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; +/*!50003 SET @saved_time_zone = @@time_zone */ ;; +/*!50003 SET time_zone = 'SYSTEM' */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `travel_setDelivered` ON SCHEDULE EVERY 1 DAY STARTS '2024-07-12 00:10:00' ON COMPLETION PRESERVE ENABLE DO BEGIN + UPDATE travel t + SET t.isDelivered = TRUE + WHERE t.shipped < util.VN_CURDATE(); +END */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -41935,14 +41642,14 @@ DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; /*!50003 SET @saved_col_connection = @@collation_connection */ ;; -/*!50003 SET character_set_client = utf8mb3 */ ;; -/*!50003 SET character_set_results = utf8mb3 */ ;; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `vehicle_notify` ON SCHEDULE EVERY 1 DAY STARTS '2022-01-01 00:07:00' ON COMPLETION NOT PRESERVE ENABLE COMMENT 'Notifies subscribed users of events in vehicles that are about t' DO CALL vn.vehicle_notifyEvents */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `vehicle_notify` ON SCHEDULE EVERY 1 DAY STARTS '2022-01-01 00:07:00' ON COMPLETION NOT PRESERVE ENABLE COMMENT 'Notifies subscribed users of events in vehicles that are about t' DO CALL vn.vehicle_notifyEvents */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -41953,14 +41660,14 @@ DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; /*!50003 SET @saved_col_connection = @@collation_connection */ ;; -/*!50003 SET character_set_client = utf8mb3 */ ;; -/*!50003 SET character_set_results = utf8mb3 */ ;; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `workerJourney_doRecalc` ON SCHEDULE EVERY 1 DAY STARTS '2023-07-22 04:00:00' ON COMPLETION PRESERVE ENABLE DO CALL workerJourney_replace(util.VN_CURDATE() - INTERVAL 1 WEEK, util.VN_CURDATE(), NULL) */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `workerJourney_doRecalc` ON SCHEDULE EVERY 1 DAY STARTS '2023-07-22 04:00:00' ON COMPLETION PRESERVE ENABLE DO CALL workerJourney_replace(util.VN_CURDATE() - INTERVAL 1 WEEK, util.VN_CURDATE(), NULL) */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -41971,14 +41678,14 @@ DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; /*!50003 SET @saved_col_connection = @@collation_connection */ ;; -/*!50003 SET character_set_client = utf8mb3 */ ;; -/*!50003 SET character_set_results = utf8mb3 */ ;; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `worker_updateChangedBusiness` ON SCHEDULE EVERY 1 DAY STARTS '2000-01-01 00:00:05' ON COMPLETION NOT PRESERVE ENABLE DO CALL worker_updateChangedBusiness */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `worker_updateChangedBusiness` ON SCHEDULE EVERY 1 DAY STARTS '2000-01-01 00:00:05' ON COMPLETION NOT PRESERVE ENABLE DO CALL worker_updateChangedBusiness */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -42007,14 +41714,14 @@ DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; /*!50003 SET @saved_col_connection = @@collation_connection */ ;; -/*!50003 SET character_set_client = utf8mb3 */ ;; -/*!50003 SET character_set_results = utf8mb3 */ ;; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `zoneGeo_doCalc` ON SCHEDULE EVERY 15 SECOND STARTS '2019-09-13 15:30:47' ON COMPLETION PRESERVE ENABLE DO CALL vn.zoneGeo_doCalc */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`vn`@`localhost`*/ /*!50106 EVENT `zoneGeo_doCalc` ON SCHEDULE EVERY 15 SECOND STARTS '2019-09-13 15:30:47' ON COMPLETION PRESERVE ENABLE DO CALL vn.zoneGeo_doCalc */ ;; /*!50003 SET time_zone = @saved_time_zone */ ;; /*!50003 SET sql_mode = @saved_sql_mode */ ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; @@ -42036,7 +41743,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `addressTaxArea`(vAddresId INT, vCompanyId INT) RETURNS varchar(25) CHARSET utf8mb3 COLLATE utf8mb3_general_ci +CREATE DEFINER=`vn`@`localhost` FUNCTION `addressTaxArea`(vAddresId INT, vCompanyId INT) RETURNS varchar(25) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN /** @@ -42078,7 +41785,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `address_getGeo`(vSelf INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `address_getGeo`(vSelf INT) RETURNS int(11) DETERMINISTIC BEGIN /** @@ -42105,16 +41812,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `barcodeToItem` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `barcodeToItem`(vBarcode VARCHAR(22)) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `barcodeToItem`(vBarcode VARCHAR(22)) RETURNS int(11) DETERMINISTIC BEGIN @@ -42168,16 +41875,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `buy_getUnitVolume` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `buy_getUnitVolume`(vSelf INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `buy_getUnitVolume`(vSelf INT) RETURNS int(11) DETERMINISTIC BEGIN /** @@ -42212,7 +41919,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `buy_getVolume`(vSelf INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `buy_getVolume`(vSelf INT) RETURNS int(11) DETERMINISTIC BEGIN /** @@ -42245,7 +41952,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `catalog_componentReverse`(vWarehouse INT, +CREATE DEFINER=`vn`@`localhost` FUNCTION `catalog_componentReverse`(vWarehouse INT, vCost DECIMAL(10,3), vM3 DECIMAL(10,3), vAddressFk INT, @@ -42352,7 +42059,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `clientGetMana`(vClient INT) RETURNS decimal(10,2) +CREATE DEFINER=`vn`@`localhost` FUNCTION `clientGetMana`(vClient INT) RETURNS decimal(10,2) DETERMINISTIC BEGIN /** @@ -42392,7 +42099,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `clientGetSalesPerson`(vClientFk INT, vDated DATE) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `clientGetSalesPerson`(vClientFk INT, vDated DATE) RETURNS int(11) DETERMINISTIC BEGIN /** @@ -42415,7 +42122,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `clientTaxArea`(vClientId INT, vCompanyId INT) RETURNS varchar(25) CHARSET utf8mb3 COLLATE utf8mb3_general_ci +CREATE DEFINER=`vn`@`localhost` FUNCTION `clientTaxArea`(vClientId INT, vCompanyId INT) RETURNS varchar(25) CHARSET utf8mb3 COLLATE utf8mb3_general_ci READS SQL DATA BEGIN /** @@ -42450,7 +42157,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `client_getDebt`(`vClient` INT, `vDate` DATE) RETURNS decimal(10,2) +CREATE DEFINER=`vn`@`localhost` FUNCTION `client_getDebt`(`vClient` INT, `vDate` DATE) RETURNS decimal(10,2) READS SQL DATA BEGIN /** @@ -42499,7 +42206,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `client_getFromPhone`(vPhone VARCHAR(255)) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `client_getFromPhone`(vPhone VARCHAR(255)) RETURNS int(11) DETERMINISTIC BEGIN /** @@ -42510,10 +42217,7 @@ BEGIN */ DECLARE vClient INT DEFAULT NULL; - -- SET vPhone = vPhone COLLATE 'utf8_unicode_ci'; - - DROP TEMPORARY TABLE IF EXISTS tClient; - CREATE TEMPORARY TABLE tClient + CREATE OR REPLACE TEMPORARY TABLE tClient ENGINE = MEMORY SELECT id clientFk FROM `client` @@ -42526,13 +42230,14 @@ BEGIN OR mobile = vPhone UNION SELECT clientFk - FROM vn.clientContact + FROM clientContact WHERE phone = vPhone; SELECT t.clientFk INTO vClient FROM tClient t JOIN `client` c ON c.id = t.clientFk WHERE c.isActive + AND c.salesPersonFk LIMIT 1; DROP TEMPORARY TABLE tClient; @@ -42554,7 +42259,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `client_getSalesPerson`(vClientFk INT, vDated DATE) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `client_getSalesPerson`(vClientFk INT, vDated DATE) RETURNS int(11) DETERMINISTIC BEGIN /** @@ -42640,7 +42345,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `client_getSalesPersonByTicket`(vTicketFk INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `client_getSalesPersonByTicket`(vTicketFk INT) RETURNS int(11) DETERMINISTIC BEGIN /** @@ -42675,7 +42380,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `client_getSalesPersonCode`(vClientFk INT, vDated DATE) RETURNS varchar(3) CHARSET utf8mb3 COLLATE utf8mb3_general_ci +CREATE DEFINER=`vn`@`localhost` FUNCTION `client_getSalesPersonCode`(vClientFk INT, vDated DATE) RETURNS varchar(3) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN /** @@ -42713,7 +42418,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `client_getSalesPersonCodeByTicket`(vTicketFk INT) RETURNS varchar(3) CHARSET utf8mb3 COLLATE utf8mb3_general_ci +CREATE DEFINER=`vn`@`localhost` FUNCTION `client_getSalesPersonCodeByTicket`(vTicketFk INT) RETURNS varchar(3) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN /** @@ -42748,7 +42453,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `client_hasDifferentCountries`(vClientFk INT) RETURNS tinyint(1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `client_hasDifferentCountries`(vClientFk INT) RETURNS tinyint(1) READS SQL DATA BEGIN /** @@ -42780,7 +42485,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `collection_isPacked`(vSelf INT) RETURNS tinyint(1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `collection_isPacked`(vSelf INT) RETURNS tinyint(1) DETERMINISTIC BEGIN /** @@ -42814,7 +42519,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `currency_getCommission`(vSelf INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `currency_getCommission`(vSelf INT) RETURNS int(11) DETERMINISTIC BEGIN /** @@ -42849,7 +42554,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `currentRate`(vCurrencyFk INT, vDated DATE) RETURNS decimal(10,4) +CREATE DEFINER=`vn`@`localhost` FUNCTION `currentRate`(vCurrencyFk INT, vDated DATE) RETURNS decimal(10,4) READS SQL DATA BEGIN @@ -42880,7 +42585,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `deviceProductionUser_accessGranted`(vUserFK INT(10) , android_id VARCHAR(50)) RETURNS tinyint(1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `deviceProductionUser_accessGranted`(vUserFK INT(10) , android_id VARCHAR(50)) RETURNS tinyint(1) DETERMINISTIC BEGIN /* @@ -42921,7 +42626,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `duaTax_getRate`(vDuaFk INT, vTaxClassFk INT) RETURNS decimal(5,2) +CREATE DEFINER=`vn`@`localhost` FUNCTION `duaTax_getRate`(vDuaFk INT, vTaxClassFk INT) RETURNS decimal(5,2) DETERMINISTIC BEGIN /** @@ -42956,7 +42661,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ekt_getEntry`(vEktFk INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `ekt_getEntry`(vEktFk INT) RETURNS int(11) READS SQL DATA BEGIN /** @@ -43038,7 +42743,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ekt_getTravel`(vEntryAssignFk INT, vEktFk INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `ekt_getTravel`(vEntryAssignFk INT, vEktFk INT) RETURNS int(11) READS SQL DATA BEGIN /** @@ -43094,7 +42799,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `entry_getCommission`(vTravelFk INT, +CREATE DEFINER=`vn`@`localhost` FUNCTION `entry_getCommission`(vTravelFk INT, vCurrencyFk INT, vSupplierFk INT ) RETURNS int(11) @@ -43163,7 +42868,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `entry_getCurrency`(vCurrency INT, +CREATE DEFINER=`vn`@`localhost` FUNCTION `entry_getCurrency`(vCurrency INT, vSupplierFk INT ) RETURNS int(11) READS SQL DATA @@ -43186,81 +42891,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP FUNCTION IF EXISTS `entry_getForLogiflora` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `entry_getForLogiflora`(vLanded DATE, vWarehouseFk INT) RETURNS int(11) - READS SQL DATA -BEGIN - - /** - * Devuelve una entrada para Logiflora. Si no existe la crea. - * - * @param vLanded Fecha de llegada al almacén - * @param vWarehouseFk Identificador de vn.warehouse - */ - - DECLARE vTravelFk INT; - DECLARE vEntryFk INT; - DECLARE previousEntryFk INT; - - SET vTravelFk = vn.travel_getForLogiflora(vLanded, vWarehouseFk); - - IF vLanded THEN - - SELECT IFNULL(MAX(id),0) INTO vEntryFk - FROM vn.entry - WHERE travelFk = vTravelFk - AND isRaid; - - IF NOT vEntryFk THEN - - INSERT INTO vn.entry(travelFk, supplierFk, commission, companyFk, currencyFk, isRaid) - SELECT vTravelFk, s.id, 4, c.id, cu.id, TRUE - FROM vn.supplier s - JOIN vn.company c ON c.code = 'VNL' - JOIN vn.currency cu ON cu.code = 'EUR' - WHERE s.name = 'KONINKLIJE COOPERATIEVE BLOEMENVEILING FLORAHOLLAN'; - - SELECT MAX(id) INTO vEntryFk - FROM vn.entry - WHERE travelFk = vTravelFk; - - END IF; - - END IF; - - SELECT entryFk INTO previousEntryFk - FROM edi.warehouseFloramondo wf - WHERE wf.warehouseFk = vWarehouseFk; - - IF IFNULL(previousEntryFk,0) != vEntryFk THEN - - UPDATE buy b - SET b.printedStickers = 0 - WHERE entryFk = previousEntryFk; - - DELETE FROM buy WHERE entryFk = previousEntryFk; - - DELETE FROM entry WHERE id = previousEntryFk; - - END IF; - - RETURN vEntryFk; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `entry_isIntrastat` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43269,7 +42899,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `entry_isIntrastat`(vSelf INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `entry_isIntrastat`(vSelf INT) RETURNS int(11) READS SQL DATA BEGIN /** @@ -43319,7 +42949,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `entry_isInventoryOrPrevious`(vSelf INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `entry_isInventoryOrPrevious`(vSelf INT) RETURNS int(11) DETERMINISTIC BEGIN DECLARE vIsInventoryOrPrevious BOOL; @@ -43349,7 +42979,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `expedition_checkRoute`(vPalletFk INT,vExpeditionFk INT) RETURNS tinyint(1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `expedition_checkRoute`(vPalletFk INT,vExpeditionFk INT) RETURNS tinyint(1) DETERMINISTIC BEGIN /** @@ -43393,7 +43023,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `firstDayOfWeek`(vYear INT, vWeek INT) RETURNS date +CREATE DEFINER=`vn`@`localhost` FUNCTION `firstDayOfWeek`(vYear INT, vWeek INT) RETURNS date DETERMINISTIC BEGIN /** @@ -43429,7 +43059,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `getAlert3State`(vTicket INT) RETURNS varchar(45) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci +CREATE DEFINER=`vn`@`localhost` FUNCTION `getAlert3State`(vTicket INT) RETURNS varchar(45) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci READS SQL DATA BEGIN DECLARE vDeliveryType INTEGER DEFAULT 0; @@ -43479,7 +43109,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `getDueDate`(vDated DATE, vDayToPay INT) RETURNS date +CREATE DEFINER=`vn`@`localhost` FUNCTION `getDueDate`(vDated DATE, vDayToPay INT) RETURNS date NO SQL BEGIN DECLARE vDued DATE; @@ -43507,10 +43137,10 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `getInventoryDate`() RETURNS date +CREATE DEFINER=`vn`@`localhost` FUNCTION `getInventoryDate`() RETURNS date DETERMINISTIC -BEGIN - RETURN (SELECT inventoried FROM config LIMIT 1); +BEGIN + RETURN (SELECT inventoried FROM config LIMIT 1); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -43527,7 +43157,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `getNewItemId`() RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `getNewItemId`() RETURNS int(11) READS SQL DATA BEGIN DECLARE newItemId INT; @@ -43556,7 +43186,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `getNextDueDate`(vDated DATE, vGapDays INT, vPayDay INT) RETURNS date +CREATE DEFINER=`vn`@`localhost` FUNCTION `getNextDueDate`(vDated DATE, vGapDays INT, vPayDay INT) RETURNS date NO SQL BEGIN @@ -43598,7 +43228,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `getShipmentHour`(vTicket INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `getShipmentHour`(vTicket INT) RETURNS int(11) READS SQL DATA BEGIN DECLARE vShipmentHour INT; @@ -43643,7 +43273,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `getSpecialPrice`(vItemFk int(11),vClientFk int(11)) RETURNS decimal(10,2) +CREATE DEFINER=`vn`@`localhost` FUNCTION `getSpecialPrice`(vItemFk int(11),vClientFk int(11)) RETURNS decimal(10,2) READS SQL DATA BEGIN DECLARE price DECIMAL(10,2); @@ -43677,7 +43307,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `getTicketTrolleyLabelCount`(vTicket INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `getTicketTrolleyLabelCount`(vTicket INT) RETURNS int(11) READS SQL DATA BEGIN DECLARE vLabelCount INT DEFAULT 0; @@ -43708,7 +43338,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `getUser`() RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `getUser`() RETURNS int(11) DETERMINISTIC BEGIN /** @@ -43731,7 +43361,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `getUserId`(userName varchar(30)) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `getUserId`(userName varchar(30)) RETURNS int(11) READS SQL DATA BEGIN DECLARE vUser INT; @@ -43749,16 +43379,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `hasAnyNegativeBase` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `hasAnyNegativeBase`() RETURNS tinyint(1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `hasAnyNegativeBase`() RETURNS tinyint(1) DETERMINISTIC BEGIN @@ -43791,16 +43421,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `hasAnyPositiveBase` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `hasAnyPositiveBase`() RETURNS tinyint(1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `hasAnyPositiveBase`() RETURNS tinyint(1) DETERMINISTIC BEGIN @@ -43842,7 +43472,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `hasItemsInSector`(vTicketFk INT, vSectorFk INT) RETURNS tinyint(1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `hasItemsInSector`(vTicketFk INT, vSectorFk INT) RETURNS tinyint(1) DETERMINISTIC BEGIN @@ -43874,7 +43504,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `hasSomeNegativeBase`(vTicket INT) RETURNS tinyint(1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `hasSomeNegativeBase`(vTicket INT) RETURNS tinyint(1) READS SQL DATA BEGIN DECLARE vCountry INT; @@ -43915,7 +43545,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `intrastat_estimateNet`(vSelf INT, +CREATE DEFINER=`vn`@`localhost` FUNCTION `intrastat_estimateNet`(vSelf INT, vStems INT ) RETURNS double DETERMINISTIC @@ -43958,7 +43588,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceOutAmount`(vInvoiceRef VARCHAR(15)) RETURNS decimal(10,2) +CREATE DEFINER=`vn`@`localhost` FUNCTION `invoiceOutAmount`(vInvoiceRef VARCHAR(15)) RETURNS decimal(10,2) READS SQL DATA BEGIN DECLARE totalAmount DECIMAL(10,2); @@ -43984,16 +43614,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `invoiceOut_getMaxIssued` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceOut_getMaxIssued`(vSerial VARCHAR(2), +CREATE DEFINER=`vn`@`localhost` FUNCTION `invoiceOut_getMaxIssued`(vSerial VARCHAR(2), vCompanyFk INT, vYear INT ) RETURNS date @@ -44036,7 +43666,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceOut_getPath`(vSelf INT) RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_general_ci +CREATE DEFINER=`vn`@`localhost` FUNCTION `invoiceOut_getPath`(vSelf INT) RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN DECLARE vIssued DATE; @@ -44060,16 +43690,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `invoiceOut_getWeight` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceOut_getWeight`(vInvoiceRef VARCHAR(15) +CREATE DEFINER=`vn`@`localhost` FUNCTION `invoiceOut_getWeight`(vInvoiceRef VARCHAR(15) ) RETURNS decimal(10,2) READS SQL DATA BEGIN @@ -44110,73 +43740,43 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceSerial`(vClientFk INT, vCompanyFk INT, vType CHAR(1)) RETURNS char(1) CHARSET utf8mb3 COLLATE utf8mb3_general_ci +CREATE DEFINER=`vn`@`localhost` FUNCTION `invoiceSerial`(vClientFk INT, + vCompanyFk INT, + vType CHAR(15) +) RETURNS char(2) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN - /** - * Obtiene la serie de de una factura - * dependiendo del area del cliente. - * - * @param vClientFk Id del cliente - * @param vCompanyFk Id de la empresa - * @param vType Tipo de factura ["R", "M", "G"] - * @return Serie de la factura - */ - DECLARE vTaxArea VARCHAR(25); - DECLARE vSerie CHAR(1); +/** +* Obtiene la serie de una factura +* dependiendo del area del cliente. +* +* @param vClientFk Id del cliente +* @param vCompanyFk Id de la empresa +* @param vType Tipo de factura (vn.invoiceOutSerial.type[ENUM]) +* @return vSerie de la factura +*/ + DECLARE vTaxArea VARCHAR(25) COLLATE utf8mb3_general_ci; + DECLARE vTransactionCode INT(2); + DECLARE vSerie CHAR(2); IF (SELECT hasInvoiceSimplified FROM client WHERE id = vClientFk) THEN RETURN 'S'; END IF; - SELECT clientTaxArea(vClientFk, vCompanyFk) INTO vTaxArea; - SELECT invoiceSerialArea(vType,vTaxArea) INTO vSerie; - RETURN vSerie; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP FUNCTION IF EXISTS `invoiceSerialArea` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `invoiceSerialArea`(vType CHAR(1), vTaxArea VARCHAR(25)) RETURNS char(1) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci - DETERMINISTIC -BEGIN - DECLARE vSerie CHAR(1); + SELECT addressTaxArea(defaultAddressFk, vCompanyFk) INTO vTaxArea + FROM client + WHERE id = vClientFk; + + SELECT CodigoTransaccion INTO vTransactionCode + FROM taxArea + WHERE code = vTaxArea; + + SELECT ios.code INTO vSerie + FROM invoiceOutSerial ios + JOIN taxArea ta ON ta.code = ios.taxAreaFk + WHERE ios.`type` = vType + AND ta.CodigoTransaccion = vTransactionCode; - IF vType = 'R' THEN - SELECT - CASE vTaxArea - WHEN 'CEE' THEN 'H' - WHEN 'WORLD' THEN 'E' - ELSE 'T' - END INTO vSerie; - -- Factura multiple - ELSEIF vType = 'M' THEN - SELECT - CASE vTaxArea - WHEN 'CEE' THEN 'H' - WHEN 'WORLD' THEN 'E' - ELSE 'M' - END INTO vSerie; - -- Factura global - ELSEIF vType = 'G' THEN - SELECT - CASE vTaxArea - WHEN 'CEE' THEN 'V' - WHEN 'WORLD' THEN 'X' - ELSE 'A' - END INTO vSerie; - END IF; RETURN vSerie; END ;; DELIMITER ; @@ -44194,7 +43794,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `isLogifloraDay`(vShipped DATE, vWarehouse INT) RETURNS tinyint(1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `isLogifloraDay`(vShipped DATE, vWarehouse INT) RETURNS tinyint(1) DETERMINISTIC BEGIN @@ -44225,7 +43825,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `itemPacking`(vBarcode VARCHAR(22), vWarehouseFk INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `itemPacking`(vBarcode VARCHAR(22), vWarehouseFk INT) RETURNS int(11) DETERMINISTIC BEGIN @@ -44278,7 +43878,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `itemShelvingPlacementSupply_ClosestGet`(vParkingFk INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `itemShelvingPlacementSupply_ClosestGet`(vParkingFk INT) RETURNS int(11) READS SQL DATA BEGIN @@ -44322,7 +43922,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `itemsInSector_get`(vTicketFk INT, vSectorFk INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `itemsInSector_get`(vTicketFk INT, vSectorFk INT) RETURNS int(11) READS SQL DATA BEGIN @@ -44354,7 +43954,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `itemTag_getIntValue`(vValue VARCHAR(255)) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `itemTag_getIntValue`(vValue VARCHAR(255)) RETURNS int(11) DETERMINISTIC BEGIN IF vValue NOT REGEXP '^-?[0-9]+' THEN @@ -44378,7 +43978,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `item_getFhImage`(itemFk INT) RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci +CREATE DEFINER=`vn`@`localhost` FUNCTION `item_getFhImage`(itemFk INT) RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN DECLARE vImageUrl VARCHAR(255); @@ -44407,7 +44007,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `item_getPackage`(vItemFk INT) RETURNS varchar(50) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci +CREATE DEFINER=`vn`@`localhost` FUNCTION `item_getPackage`(vItemFk INT) RETURNS varchar(50) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN @@ -44449,7 +44049,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `item_getVolume`(vSelf INT, vPackaging VARCHAR(10)) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `item_getVolume`(vSelf INT, vPackaging VARCHAR(10)) RETURNS int(11) DETERMINISTIC BEGIN /** @@ -44488,7 +44088,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `lastDayOfWeek`(vYear INT, vWeek INT) RETURNS date +CREATE DEFINER=`vn`@`localhost` FUNCTION `lastDayOfWeek`(vYear INT, vWeek INT) RETURNS date DETERMINISTIC BEGIN /** @@ -44524,7 +44124,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `machine_checkPlate`(vPlate VARCHAR(10)) RETURNS tinyint(1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `machine_checkPlate`(vPlate VARCHAR(10)) RETURNS tinyint(1) READS SQL DATA BEGIN /** @@ -44559,7 +44159,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `messageSend`(vRecipient VARCHAR(255) CHARSET utf8, vMessage TEXT CHARSET utf8) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `messageSend`(vRecipient VARCHAR(255) CHARSET utf8, vMessage TEXT CHARSET utf8) RETURNS int(11) READS SQL DATA BEGIN DECLARE result INT; @@ -44585,7 +44185,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `messageSendWithUser`(vSenderFK INT, vRecipient VARCHAR(255) CHARSET utf8, vMessage TEXT CHARSET utf8) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `messageSendWithUser`(vSenderFK INT, vRecipient VARCHAR(255) CHARSET utf8, vMessage TEXT CHARSET utf8) RETURNS int(11) DETERMINISTIC BEGIN @@ -44642,26 +44242,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP FUNCTION IF EXISTS `MIDNIGHT` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `MIDNIGHT`(vDate DATE) RETURNS datetime - DETERMINISTIC -BEGIN - RETURN TIMESTAMP(vDate,'23:59:59'); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `orderTotalVolume` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44670,7 +44250,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `orderTotalVolume`(vOrderId INT) RETURNS decimal(10,3) +CREATE DEFINER=`vn`@`localhost` FUNCTION `orderTotalVolume`(vOrderId INT) RETURNS decimal(10,3) READS SQL DATA BEGIN -- Devuelte el volumen total de la orden sumada @@ -44701,7 +44281,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `orderTotalVolumeBoxes`(vOrderId INT) RETURNS decimal(10,3) +CREATE DEFINER=`vn`@`localhost` FUNCTION `orderTotalVolumeBoxes`(vOrderId INT) RETURNS decimal(10,3) READS SQL DATA BEGIN /** @@ -44737,7 +44317,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `packaging_calculate`(isPackageReturnable TINYINT(1), +CREATE DEFINER=`vn`@`localhost` FUNCTION `packaging_calculate`(isPackageReturnable TINYINT(1), packagingReturnFk INT(11), base DECIMAL(10,2), price DECIMAL(10,2), @@ -44776,7 +44356,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `priceFixed_getRate2`(vFixedPriceFk INT, vRate3 DOUBLE) RETURNS double +CREATE DEFINER=`vn`@`localhost` FUNCTION `priceFixed_getRate2`(vFixedPriceFk INT, vRate3 DOUBLE) RETURNS double BEGIN DECLARE vWarehouse INT; @@ -44808,7 +44388,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `routeProposal`(vTicketFk INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `routeProposal`(vTicketFk INT) RETURNS int(11) READS SQL DATA BEGIN @@ -44866,47 +44446,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP FUNCTION IF EXISTS `routeProposal_` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `routeProposal_`(vTicketFk INT) RETURNS int(11) - READS SQL DATA -BEGIN - - DECLARE vRouteFk INT; - DECLARE vAddressFk INT; - DECLARE vShipped DATETIME; - - SELECT addressFk, date(shipped) INTO vAddressFk, vShipped - FROM vn.ticket - WHERE id = vTicketFk; - - SELECT routeFk INTO vRouteFk - FROM - (SELECT t.routeFk, sum(af.friendship) friendshipSum - FROM vn.ticket t - JOIN cache.addressFriendship af ON af.addressFk2 = t.addressFk AND af.addressFk1 = vAddressFk - WHERE t.shipped BETWEEN vShipped and MIDNIGHT(vShipped) - AND t.routeFk - GROUP BY routeFk - ORDER BY friendshipSum DESC - ) sub - LIMIT 1; - - RETURN vRouteFk; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `routeProposal_beta` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44915,7 +44454,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `routeProposal_beta`(vTicketFk INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `routeProposal_beta`(vTicketFk INT) RETURNS int(11) READS SQL DATA BEGIN @@ -44973,6 +44512,84 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP FUNCTION IF EXISTS `sale_hasComponentLack` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` FUNCTION `sale_hasComponentLack`(vSelf INT +) RETURNS tinyint(1) + READS SQL DATA +BEGIN +/** + * Check if a sales line has all the required components. + * + * @param vSelf Id de sale + * @return BOOL + */ + DECLARE vHasComponentLack TINYINT(1); + + WITH componentRequired AS( + SELECT COUNT(*) total + FROM vn.component + WHERE isRequired + )SELECT SUM(IF(c.isRequired, TRUE, FALSE)) <> cr.total INTO vHasComponentLack + FROM vn.sale s + JOIN componentRequired cr + LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id + LEFT JOIN vn.component c ON c.id = sc.componentFk + WHERE s.id = vSelf; + + RETURN vHasComponentLack; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP FUNCTION IF EXISTS `sectorCollection_hasSalesReserved` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` FUNCTION `sectorCollection_hasSalesReserved`(vSelf INT) RETURNS tinyint(1) + DETERMINISTIC +BEGIN +/** + * Devuelve si sectorCollection tiene reservas + * @param vSelf Id de sectorCollection + * + * returns BOOLEAN + */ + DECLARE vHasSalesReserved BOOLEAN; + + SELECT DISTINCT COUNT(*) INTO vHasSalesReserved + FROM sectorCollection sc + JOIN sectorCollectionSaleGroup scsg ON sc.id = scsg.sectorCollectionFk + JOIN saleGroup sg ON sg.id = scsg.saleGroupFk + JOIN saleGroupDetail sgd ON sgd.saleGroupFk = sg.id + JOIN sale s ON s.id = sgd.saleFk + JOIN itemShelvingSale iss ON iss.saleFk = s.id + JOIN saleTracking st ON st.saleFk = s.id + WHERE sc.id = vSelf; + + RETURN vHasSalesReserved; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `specie_IsForbidden` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44981,7 +44598,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `specie_IsForbidden`(vItemFk INT, vAddressFk INT) RETURNS tinyint(1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `specie_IsForbidden`(vItemFk INT, vAddressFk INT) RETURNS tinyint(1) READS SQL DATA BEGIN @@ -45020,7 +44637,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `testCIF`(vCIF VARCHAR(9)) RETURNS varchar(10) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci +CREATE DEFINER=`vn`@`localhost` FUNCTION `testCIF`(vCIF VARCHAR(9)) RETURNS varchar(10) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN @@ -45105,7 +44722,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `testNIE`(vNIE VARCHAR(9)) RETURNS tinyint(1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `testNIE`(vNIE VARCHAR(9)) RETURNS tinyint(1) DETERMINISTIC BEGIN @@ -45172,7 +44789,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `testNIF`(vNIF VARCHAR(9)) RETURNS tinyint(1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `testNIF`(vNIF VARCHAR(9)) RETURNS tinyint(1) DETERMINISTIC BEGIN @@ -45213,7 +44830,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticketCollection_getNoPacked`(vCollectionFk INT) RETURNS varchar(100) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci +CREATE DEFINER=`vn`@`localhost` FUNCTION `ticketCollection_getNoPacked`(vCollectionFk INT) RETURNS varchar(100) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN @@ -45252,7 +44869,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticketGetTotal`(vTicketId INT) RETURNS decimal(10,2) +CREATE DEFINER=`vn`@`localhost` FUNCTION `ticketGetTotal`(vTicketId INT) RETURNS decimal(10,2) READS SQL DATA DETERMINISTIC BEGIN @@ -45295,7 +44912,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticketPositionInPath`(vTicketId INT) RETURNS varchar(10) CHARSET utf8mb3 COLLATE utf8mb3_general_ci +CREATE DEFINER=`vn`@`localhost` FUNCTION `ticketPositionInPath`(vTicketId INT) RETURNS varchar(10) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN @@ -45386,7 +45003,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticketSplitCounter`(vTicketFk INT) RETURNS varchar(15) CHARSET utf8mb3 COLLATE utf8mb3_general_ci +CREATE DEFINER=`vn`@`localhost` FUNCTION `ticketSplitCounter`(vTicketFk INT) RETURNS varchar(15) CHARSET utf8mb3 COLLATE utf8mb3_general_ci READS SQL DATA BEGIN DECLARE vSplitCounter VARCHAR(15); @@ -45418,7 +45035,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticketTotalVolume`(vTicketId INT) RETURNS decimal(10,3) +CREATE DEFINER=`vn`@`localhost` FUNCTION `ticketTotalVolume`(vTicketId INT) RETURNS decimal(10,3) READS SQL DATA BEGIN -- Devuelte el volumen total del ticket sumado @@ -45446,7 +45063,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticketTotalVolumeBoxes`(vTicketId INT) RETURNS decimal(10,1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `ticketTotalVolumeBoxes`(vTicketId INT) RETURNS decimal(10,1) DETERMINISTIC BEGIN @@ -45483,7 +45100,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticketWarehouseGet`(vTicketFk INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `ticketWarehouseGet`(vTicketFk INT) RETURNS int(11) READS SQL DATA BEGIN DECLARE vWarehouseFk INT; @@ -45509,7 +45126,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_CC_volume`(vTicketFk INT) RETURNS decimal(10,1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `ticket_CC_volume`(vTicketFk INT) RETURNS decimal(10,1) READS SQL DATA BEGIN @@ -45542,64 +45159,44 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_get`(vParamFk INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `ticket_get`(vParamFk INT) RETURNS int(11) READS SQL DATA -proc:BEGIN - - /* Devuelve el número de ticket o collection consultando en varias tablas posibles - * - * @param vParamFk Número a validar - * @return vValidFk Identificador validado - */ - - DECLARE vValidFk INT; +BEGIN +/** + * Devuelve el número de ticket / collection / sectorCollection consultando + * en que tabla se encuantra en la última semana + * + * @param vParamFk Número a validar + * @return vReturn Identificador validado + */ + DECLARE vReturn INT DEFAULT NULL; + DECLARE vDated DATE; - -- Tabla vn.saleGroup - SELECT s.ticketFk INTO vValidFk - FROM vn.sale s - JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id - JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk - WHERE sg.id = vParamFk - AND sg.created > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE()) - LIMIT 1; - - IF vValidFk THEN - - RETURN vValidFk; - - LEAVE proc; - - END IF; + SET vDated = util.VN_CURDATE() - INTERVAL 1 WEEK; - -- Tabla vn.collection - SELECT c.id INTO vValidFk - FROM vn.collection c - WHERE c.id = vParamFk - AND c.created > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE()); - - IF vValidFk THEN - - RETURN vValidFk; - - LEAVE proc; - - END IF; + SELECT COALESCE( + (SELECT s.ticketFk + FROM sale s + JOIN saleGroupDetail sgd ON sgd.saleFk = s.id + JOIN saleGroup sg ON sg.id = sgd.saleGroupFk + WHERE sg.id = vParamFk + AND sg.created > vDated + LIMIT 1), + (SELECT c.id + FROM collection c + WHERE c.id = vParamFk + AND c.created > vDated), + (SELECT id + FROM ticket + WHERE id = vParamFk + AND shipped > vDated), + (SELECT id + FROM sectorCollection + WHERE id = vParamFk + AND created > vDated) + ) INTO vReturn; - -- Tabla vn.ticket - SELECT t.id INTO vValidFk - FROM vn.ticket t - WHERE t.id = vParamFk - AND t.shipped > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE()); - - IF vValidFk THEN - - RETURN vValidFk; - - LEAVE proc; - - END IF; - - RETURN NULL; + RETURN vReturn; END ;; DELIMITER ; @@ -45617,7 +45214,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_getFreightCost`(vTicketFk INT) RETURNS decimal(10,2) +CREATE DEFINER=`vn`@`localhost` FUNCTION `ticket_getFreightCost`(vTicketFk INT) RETURNS decimal(10,2) DETERMINISTIC BEGIN /** @@ -45657,7 +45254,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_getWeight`(vTicketFk INT) RETURNS decimal(10,3) +CREATE DEFINER=`vn`@`localhost` FUNCTION `ticket_getWeight`(vTicketFk INT) RETURNS decimal(10,3) READS SQL DATA BEGIN /** @@ -45690,7 +45287,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_HasUbication`(vTicketFk INT) RETURNS tinyint(1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `ticket_HasUbication`(vTicketFk INT) RETURNS tinyint(1) READS SQL DATA BEGIN @@ -45720,7 +45317,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_isOutClosureZone`(vSelf INT) RETURNS tinyint(1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `ticket_isOutClosureZone`(vSelf INT) RETURNS tinyint(1) DETERMINISTIC BEGIN /** @@ -45747,6 +45344,87 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP FUNCTION IF EXISTS `ticket_isProblemCalcNeeded` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` FUNCTION `ticket_isProblemCalcNeeded`(vSelf INT +) RETURNS tinyint(1) + DETERMINISTIC +BEGIN +/** + * Check if the ticket requires to update column vn.ticket.problem + * + * @param vSelf Id ticket + * @return BOOL + */ + DECLARE vIsProblemCalcNeeded BOOL; + + SELECT COUNT(*) INTO vIsProblemCalcNeeded + FROM ticket t + JOIN client c ON c.id = t.clientFk + JOIN agencyMode am ON am.id = t.agencyModeFk + JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + WHERE t.id = vSelf + AND dm.code IN ('AGENCY','DELIVERY','PICKUP') + AND c.typeFk = 'normal'; + + RETURN vIsProblemCalcNeeded; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP FUNCTION IF EXISTS `ticket_isTooLittle` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` FUNCTION `ticket_isTooLittle`(vSelf INT +) RETURNS tinyint(1) + READS SQL DATA +BEGIN +/** + * Check if the ticket is small based on the volume and amount parameters. + * + * @param vSelf Id ticket + * @return BOOL + */ + DECLARE vIsTooLittle BOOL; + + WITH ticketData AS ( + SELECT addressFk, DATE(shipped) dated + FROM vn.ticket + WHERE id = vSelf + ) + SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume + AND SUM(IFNULL(t.totalWithoutVat, 0)) < vc.minTicketValue) INTO vIsTooLittle + FROM ticketData td + JOIN vn.ticket t ON t.addressFk = td.addressFk + LEFT JOIN vn.saleVolume sv ON sv.ticketFk = t.id + JOIN vn.volumeConfig vc + WHERE t.shipped BETWEEN td.dated AND util.dayEnd(td.dated) + AND ticket_isProblemCalcNeeded(t.id); + + RETURN vIsTooLittle; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `till_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45846,7 +45524,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `timeWorkerControl_getDirection`(vUserFk INT, vTimed DATETIME) RETURNS varchar(6) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci +CREATE DEFINER=`vn`@`localhost` FUNCTION `timeWorkerControl_getDirection`(vUserFk INT, vTimed DATETIME) RETURNS varchar(6) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci READS SQL DATA BEGIN /** @@ -45922,7 +45600,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `time_getSalesYear`(vMonth INT, vYear INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `time_getSalesYear`(vMonth INT, vYear INT) RETURNS int(11) DETERMINISTIC BEGIN DECLARE vSalesYear INT; @@ -45931,69 +45609,6 @@ FROM `time` WHERE `month` = vMonth AND `year` = vYear LIMIT 1; RETURN vSalesYear; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP FUNCTION IF EXISTS `travel_getForLogiflora` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `travel_getForLogiflora`(vLanded DATE, vWarehouseFk INT) RETURNS int(11) - READS SQL DATA -BEGIN - - /** - * Devuelve un número de travel para compras de Logiflora a partir de la fecha de llegada y del almacén. - * Si no existe lo genera. - * - * @param vLanded Fecha de llegada al almacén - * @param vWarehouseFk Identificador de vn.warehouse - */ - - DECLARE vTravelFk INT; - - IF vLanded THEN - - SELECT IFNULL(MAX(tr.id),0) INTO vTravelFk - FROM vn.travel tr - JOIN vn.warehouse wIn ON wIn.id = tr.warehouseInFk - JOIN vn.warehouse wOut ON wOut.id = tr.warehouseOutFk - JOIN vn.agencyMode am ON am.id = tr.agencyModeFk - WHERE wIn.id = vWarehouseFk - AND wOut.name = 'Holanda' - AND am.name = 'LOGIFLORA' - AND landed = vLanded; - - IF NOT vTravelFk THEN - - INSERT INTO vn.travel(landed, shipped, warehouseInFk, warehouseOutFk, agencyModeFk) - SELECT vLanded, util.VN_CURDATE(), vWarehouseFk, wOut.id, am.id - FROM vn.warehouse wOut - JOIN vn.agencyMode am ON am.name = 'LOGIFLORA' - WHERE wOut.name = 'Holanda'; - - SELECT MAX(tr.id) INTO vTravelFk - FROM vn.travel tr - JOIN vn.warehouse wIn ON wIn.id = tr.warehouseInFk - JOIN vn.warehouse wOut ON wOut.id = tr.warehouseOutFk - WHERE wIn.id = vWarehouseFk - AND wOut.name = 'Holanda' - AND landed = vLanded; - END IF; - - END IF; - - RETURN vTravelFk; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -46010,7 +45625,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `travel_hasUniqueAwb`(vSelf INT +CREATE DEFINER=`vn`@`localhost` FUNCTION `travel_hasUniqueAwb`(vSelf INT ) RETURNS tinyint(1) READS SQL DATA BEGIN @@ -46049,7 +45664,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `validationCode`(vString VARCHAR(255)) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `validationCode`(vString VARCHAR(255)) RETURNS int(11) DETERMINISTIC BEGIN @@ -46090,7 +45705,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `validationCode_beta`(vString VARCHAR(255)) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `validationCode_beta`(vString VARCHAR(255)) RETURNS int(11) DETERMINISTIC BEGIN @@ -46131,7 +45746,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `workerMachinery_isRegistered`(vWorkerFk VARCHAR(10)) RETURNS tinyint(1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `workerMachinery_isRegistered`(vWorkerFk VARCHAR(10)) RETURNS tinyint(1) READS SQL DATA BEGIN /** @@ -46165,7 +45780,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `workerNigthlyHours_calculate`(vTimeIn DATETIME, vTimeOut DATETIME) RETURNS decimal(5,2) +CREATE DEFINER=`vn`@`localhost` FUNCTION `workerNigthlyHours_calculate`(vTimeIn DATETIME, vTimeOut DATETIME) RETURNS decimal(5,2) READS SQL DATA BEGIN /** @@ -46204,7 +45819,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `worker_getCode`() RETURNS varchar(3) CHARSET utf8mb3 COLLATE utf8mb3_general_ci +CREATE DEFINER=`vn`@`localhost` FUNCTION `worker_getCode`() RETURNS varchar(3) CHARSET utf8mb3 COLLATE utf8mb3_general_ci READS SQL DATA BEGIN DECLARE vUserCode VARCHAR(3) CHARSET utf8 COLLATE utf8_unicode_ci; @@ -46230,7 +45845,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `worker_isBoss`(vUserId INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `worker_isBoss`(vUserId INT) RETURNS int(11) DETERMINISTIC BEGIN /** @@ -46289,7 +45904,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `worker_isInDepartment`(vDepartmentCode VARCHAR(255)) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `worker_isInDepartment`(vDepartmentCode VARCHAR(255)) RETURNS int(11) DETERMINISTIC BEGIN /** @@ -46328,7 +45943,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `worker_isWorking`(vWorkerFk INT) RETURNS tinyint(1) +CREATE DEFINER=`vn`@`localhost` FUNCTION `worker_isWorking`(vWorkerFk INT) RETURNS tinyint(1) READS SQL DATA BEGIN /** @@ -46359,61 +45974,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP FUNCTION IF EXISTS `xdiario_new` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `xdiario_new`(vAsiento INT, - vDated DATE, - vSubaccount VARCHAR(12), - vAccount VARCHAR(12), - vConcept VARCHAR(25), - vDebit DOUBLE, - vCredit DOUBLE, - vEuro DOUBLE, - vSerie CHAR(1), - vInvoice VARCHAR(8), - vVat DOUBLE, - vRe DOUBLE, - vAux TINYINT, - vCompany INT -) RETURNS int(11) - NO SQL -BEGIN - IF vAsiento IS NULL THEN - CALL vn.ledger_next(vAsiento); - END IF; - - INSERT INTO XDiario - SET ASIEN = vAsiento, - FECHA = vDated, - SUBCTA = vSubaccount, - CONTRA = vAccount, - CONCEPTO = vConcept, - EURODEBE = vDebit, - EUROHABER = vCredit, - BASEEURO = vEuro, - SERIE = vSerie, - FACTURA = vInvoice, - IVA = vVat, - RECEQUIV = vRe, - AUXILIAR = IF(vAux = FALSE, NULL, '*'), - MONEDAUSO = 2, - empresa_id = vCompany; - - RETURN vAsiento; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `zoneGeo_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46422,7 +45982,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `zoneGeo_new`(vType VARCHAR(255), vName VARCHAR(255), vParentFk INT) RETURNS int(11) +CREATE DEFINER=`vn`@`localhost` FUNCTION `zoneGeo_new`(vType VARCHAR(255), vName VARCHAR(255), vParentFk INT) RETURNS int(11) NO SQL BEGIN /** @@ -46462,7 +46022,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `absoluteInventoryHistory`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `absoluteInventoryHistory`( vItemFk INT, vWarehouseFk INT, vDate DATETIME @@ -46577,7 +46137,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `addAccountReconciliation`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `addAccountReconciliation`() BEGIN /** * Updates duplicate records in the accountReconciliation table, @@ -46656,7 +46216,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `addNoteFromDelivery`(idTicket INT,nota TEXT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `addNoteFromDelivery`(idTicket INT,nota TEXT) BEGIN DECLARE observationTypeFk INT DEFAULT 3; /*3 = REPARTIDOR*/ @@ -46682,7 +46242,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `addressTaxArea`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `addressTaxArea`() READS SQL DATA BEGIN /** @@ -46725,6 +46285,44 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `address_updateCoordinates` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `address_updateCoordinates`( + vTicketFk INT, + vLongitude DECIMAL(11,7), + vLatitude DECIMAL(11,7)) +BEGIN +/** + * Actualiza las coordenadas de una dirección. + * + * @param vTicketFk Id del ticket + * @param vLongitude Longitud de la dirección + * @param vLatitude Latitud de la dirección + */ + DECLARE vAddressFK INT; + + SELECT addressFK INTO vAddressFK + FROM ticket + WHERE id = vTicketFk; + + UPDATE address + SET longitude = vLongitude, + latitude = vLatitude + WHERE id = vAddressFK; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `agencyHourGetFirstShipped` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46733,7 +46331,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `agencyHourGetFirstShipped`(vAgencyMode INT, vAddress INT, vWarehouse INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `agencyHourGetFirstShipped`(vAgencyMode INT, vAddress INT, vWarehouse INT) BEGIN /** * DEPRECATED usar zoneGetFirstShipped @@ -46781,7 +46379,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `agencyHourGetLanded`(vDated DATE, vAddress INT, vAgency INT, vWarehouse INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `agencyHourGetLanded`(vDated DATE, vAddress INT, vAgency INT, vWarehouse INT) BEGIN /** * DEPRECATED usar zoneGetLanded @@ -46831,7 +46429,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `agencyHourGetWarehouse`(vAddress INT, vDate DATE, vWarehouse INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `agencyHourGetWarehouse`(vAddress INT, vDate DATE, vWarehouse INT) BEGIN /** * DEPRECATED usar zoneGetWarehouse @@ -46922,7 +46520,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `agencyHourListGetShipped`(vDate DATE, vAddress INT, vAgency INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `agencyHourListGetShipped`(vDate DATE, vAddress INT, vAgency INT) BEGIN /* * DEPRECATED usar zoneGetShipped */ @@ -46948,7 +46546,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `agencyVolume`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `agencyVolume`() BEGIN /** * Calculates and presents information on shipment and packaging volumes @@ -46958,7 +46556,7 @@ BEGIN DECLARE vEnded DATETIME DEFAULT util.dayEnd(util.VN_CURDATE()); SELECT ag.id agency_id, - CONCAT(RPAD(c.country, 16,' _') ,' ',ag.name) Agencia, + CONCAT(RPAD(c.name, 16,' _') ,' ',ag.name) Agencia, COUNT(*) expediciones, SUM(t.packages) Bultos, SUM(tpe.boxes) Faltan @@ -46999,7 +46597,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `available_calc`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `available_calc`( vDate DATE, vAddress INT, vAgencyMode INT) @@ -47069,7 +46667,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `available_traslate`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `available_traslate`( vWarehouseLanding INT, vDated DATE, vWarehouseShipment INT) @@ -47117,7 +46715,7 @@ proc: BEGIN -- Tabla con el ultimo dia de last_buy para cada producto -- que hace un replace de la anterior. - CALL buyUltimate(vWarehouseShipment, util.VN_CURDATE()); + CALL buy_getUltimate (NULL, vWarehouseShipment, util.VN_CURDATE()); INSERT INTO tItemRange SELECT t.itemFk, tr.landed @@ -47220,7 +46818,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `balanceNestTree_addChild`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `balanceNestTree_addChild`( vSelf INT, vName VARCHAR(45) ) @@ -47285,7 +46883,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `balanceNestTree_delete`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `balanceNestTree_delete`( vSelf INT ) BEGIN @@ -47351,7 +46949,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `balanceNestTree_move`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `balanceNestTree_move`( vSelf INT, vFather INT ) @@ -47481,7 +47079,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `balance_create`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `balance_create`( vStartingMonth INT, vEndingMonth INT, vCompany INT, @@ -47712,7 +47310,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `bankEntity_checkBic`(vBic VARCHAR(255)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `bankEntity_checkBic`(vBic VARCHAR(255)) BEGIN /** * If the bic length is Incorrect throw exception @@ -47744,7 +47342,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `bankPolicy_notifyExpired`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `bankPolicy_notifyExpired`() BEGIN /** * @@ -47769,208 +47367,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `buyUltimate` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buyUltimate`(vWarehouseFk SMALLINT, vDated DATE) -BEGIN -/** - * Calcula las últimas compras realizadas hasta una fecha - * - * @param vWarehouseFk Id del almacén - * @param vDated Compras hasta fecha - * @return tmp.buyUltimate - */ - CALL cache.last_buy_refresh (FALSE); - - DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimate; - CREATE TEMPORARY TABLE tmp.buyUltimate - (PRIMARY KEY (itemFk, warehouseFk), - INDEX(itemFk)) - ENGINE = MEMORY - SELECT item_id itemFk, buy_id buyFk, warehouse_id warehouseFk, landing - FROM cache.last_buy - WHERE warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL; - - CALL buyUltimateFromInterval(vWarehouseFk, util.VN_CURDATE(), vDated); - - REPLACE INTO tmp.buyUltimate - SELECT itemFk, buyFk, warehouseFk, landed landing - FROM tmp.buyUltimateFromInterval - WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) - AND landed <= vDated - AND NOT isIgnored; - - INSERT IGNORE INTO tmp.buyUltimate - SELECT itemFk, buyFk, warehouseFk, landed landing - FROM tmp.buyUltimateFromInterval - WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) - AND landed > vDated - ORDER BY isIgnored = FALSE DESC; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `buyUltimateFromInterval` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buyUltimateFromInterval`(vWarehouseFk SMALLINT, vStarted DATE, vEnded DATE) -BEGIN -/** - * Calcula las últimas compras realizadas - * desde un rango de fechas. - * - * @param vWarehouseFk Id del almacén si es NULL se actualizan todos - * @param vStarted Fecha inicial - * @param vEnded Fecha fin - * @return tmp.buyUltimateFromInterval - */ - IF vEnded IS NULL THEN - SET vEnded = vStarted; - END IF; - - IF vEnded < vStarted THEN - SET vStarted = TIMESTAMPADD(MONTH, -1, vEnded); - END IF; - - -- Item - DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; - CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval - (PRIMARY KEY (itemFk, warehouseFk), INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) - ENGINE = MEMORY - SELECT itemFk, - warehouseFk, - buyFk, - MAX(landed) landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT - b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed > vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - AND NOT b.isIgnored - GROUP BY itemFk, warehouseInFk; - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT - b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.quantity = 0 - GROUP BY itemFk, warehouseInFk; - - -- ItemOriginal - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - MAX(landed) landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - itemOriginalFk, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - AND NOT b.isIgnored - AND b.quantity > 0 - AND itemOriginalFk - ORDER BY t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemOriginalFk, warehouseFk; - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT - b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed > vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - AND NOT b.isIgnored - AND itemOriginalFk - GROUP BY itemOriginalFk, warehouseInFk; - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT - b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.quantity = 0 - AND itemOriginalFk - GROUP BY itemOriginalFk, warehouseInFk; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `buy_afterUpsert` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -47979,7 +47375,9 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_afterUpsert`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_afterUpsert`( + vSelf INT +) BEGIN /** * Triggered actions when a buy is updated or inserted. @@ -47996,7 +47394,7 @@ BEGIN DECLARE vIsFeedStock BOOL; DECLARE vWeight DECIMAL(10,2); DECLARE vPacking INT; - + SELECT b.entryFk, b.itemFk, i.packingOut, @@ -48027,8 +47425,11 @@ BEGIN WHERE e.id = vEntryFk; IF vIsMerchandise THEN + IF vWarehouse IS NULL THEN + CALL util.throw('The entry does not have travel'); + END IF; - REPLACE itemCost SET + REPLACE itemCost SET itemFk = vItemFk, warehouseFk = vWarehouse, cm3 = buy_getUnitVolume(vSelf), @@ -48054,7 +47455,7 @@ BEGIN WHERE b.id = vSelf; END IF; - CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck + CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck SELECT vSelf id; CALL buy_checkItem(); END ;; @@ -48073,7 +47474,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_checkGrouping`(vGrouping INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_checkGrouping`(vGrouping INT) BEGIN /** * Checks the buy grouping, throws an error if it's invalid. @@ -48100,16 +47501,17 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_checkItem`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_checkItem`() BEGIN /** * Checks if the item has weightByPiece or size null on any buy. * * @param tmp.buysToCheck(id as INT). */ - DECLARE hasVolumetricAgency INT; + DECLARE vHasVolumetricAgency INT; + DECLARE vItemFk INT; - SELECT a.hasWeightVolumetric INTO hasVolumetricAgency + SELECT a.hasWeightVolumetric, i.id INTO vHasVolumetricAgency, vItemFk FROM entry e JOIN travel t ON t.id = e.travelFk JOIN agencyMode a ON a.id = t.agencyModeFk @@ -48120,11 +47522,81 @@ BEGIN AND a.hasWeightVolumetric LIMIT 1; - DROP TEMPORARY TABLE tmp.buysToCheck; + DROP TEMPORARY TABLE tmp.buysToCheck; - IF hasVolumetricAgency THEN - CALL util.throw('Item lacks size/weight in purchase line at agency'); - END IF; + IF vHasVolumetricAgency THEN + CALL util.throw(CONCAT('Missing size/weight in buy line at agency, item: ', vItemFk)); + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `buy_clone` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_clone`(vEntryFk INT) +BEGIN +/** + * Clone buys to an entry + * + * @param vEntryFk The entry id + * @table tmp.buy(id) + */ + INSERT INTO buy( + entryFk, + itemFk, + quantity, + buyingValue, + freightValue, + isIgnored, + stickers, + packagingFk, + packing, + `grouping`, + groupingMode, + comissionValue, + packageValue, + price1, + price2, + price3, + minPrice, + isChecked, + location, + weight, + itemOriginalFk) + SELECT vEntryFk, + b.itemFk, + b.quantity, + b.buyingValue, + b.freightValue, + b.isIgnored, + b.stickers, + b.packagingFk, + b.packing, + b.`grouping`, + b.groupingMode, + b.comissionValue, + b.packageValue, + b.price1, + b.price2, + b.price3, + b.minPrice, + b.isChecked, + b.location, + b.weight, + b.itemOriginalFk + FROM tmp.buy tb + JOIN vn.buy b ON b.id = tb.id; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -48141,7 +47613,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_getSplit`(vSelf INT, vDated DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_getSplit`(vSelf INT, vDated DATE) BEGIN /** * Devuelve tantos registros como etiquetas se necesitan para cada uno de los cubos o cajas de @@ -48273,16 +47745,264 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `buy_getUltimate` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_getUltimate`( + vItemFk INT, + vWarehouseFk SMALLINT, + vDated DATE +) +BEGIN +/** + * Calcula las últimas compras realizadas hasta una fecha. + * + * @param vItemFk Id del artículo + * @param vWarehouseFk Id del almacén + * @param vDated Compras hasta fecha + * @return tmp.buyUltimate + */ + CALL cache.last_buy_refresh(FALSE); + + CREATE OR REPLACE TEMPORARY TABLE tmp.buyUltimate + (PRIMARY KEY (itemFk, warehouseFk), + INDEX(itemFk)) + ENGINE = MEMORY + SELECT item_id itemFk, buy_id buyFk, warehouse_id warehouseFk, landing + FROM cache.last_buy + WHERE (warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL) + AND (item_id = vItemFk OR vItemFk IS NULL); + + IF vDated >= util.VN_CURDATE() THEN + CALL buy_getUltimateFromInterval(vItemFk, vWarehouseFk, util.VN_CURDATE(), vDated); + + REPLACE INTO tmp.buyUltimate + SELECT itemFk, buyFk, warehouseFk, landed landing + FROM tmp.buyUltimateFromInterval + WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) + AND (itemFk = vItemFk OR vItemFk IS NULL) + AND landed <= vDated + AND NOT isIgnored; + + INSERT IGNORE INTO tmp.buyUltimate + SELECT itemFk, buyFk, warehouseFk, landed landing + FROM tmp.buyUltimateFromInterval + WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) + AND (itemFk = vItemFk OR vItemFk IS NULL) + AND landed > vDated + ORDER BY isIgnored = FALSE DESC; + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `buy_getUltimateFromInterval` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_getUltimateFromInterval`( + vItemFk INT, + vWarehouseFk SMALLINT, + vStarted DATE, + vEnded DATE +) +BEGIN +/** + * Calcula las últimas compras realizadas + * desde un rango de fechas. + * + * @param vItemFk Id del artículo + * @param vWarehouseFk Id del almacén si es NULL se actualizan todos + * @param vStarted Fecha inicial + * @param vEnded Fecha fin + * @return tmp.buyUltimateFromInterval + */ + IF vEnded IS NULL THEN + SET vEnded = vStarted; + END IF; + + IF vEnded < vStarted THEN + SET vStarted = vEnded - INTERVAL 1 MONTH; + END IF; + + -- Item + + CREATE OR REPLACE TEMPORARY TABLE tmp.buyUltimateFromInterval + (PRIMARY KEY (itemFk, warehouseFk), + INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) + ENGINE = MEMORY + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed > vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.quantity = 0 + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + -- ItemOriginal + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + itemOriginalFk, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + AND b.quantity > 0 + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed > vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM + (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.quantity = 0 + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `buy_getVolume` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_getVolume`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_getVolume`() BEGIN /** * Cálculo de volumen en líneas de compra @@ -48316,7 +48036,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_getVolumeByAgency`(vDated DATE, vAgencyFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_getVolumeByAgency`(vDated DATE, vAgencyFk INT) BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.buy; @@ -48349,7 +48069,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_getVolumeByEntry`(vEntryFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_getVolumeByEntry`(vEntryFk INT) BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.buy; @@ -48380,55 +48100,62 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_recalcPrices`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_recalcPrices`() BEGIN /** - * Recalcula los precios para las compras insertadas en tmp.buyRecalc + * Recalcula los precios para las compras insertadas en tmp.buyRecalc. * * @param tmp.buyRecalc (id) */ DECLARE vLanded DATE; DECLARE vWarehouseFk INT; - DECLARE vHasNotPrice BOOL; - DECLARE vBuyingValue DECIMAL(10,4); - DECLARE vPackagingFk VARCHAR(10); DECLARE vIsWarehouseFloramondo BOOL; + DECLARE vDone BOOL; + DECLARE vTravels CURSOR FOR + SELECT t.landed, t.warehouseInFk, (w.code = 'flm') + FROM tmp.buyRecalc br + JOIN buy b ON b.id = br.id + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + JOIN warehouse w ON w.id = t.warehouseInFk + GROUP BY t.landed, t.warehouseInFk; - SELECT t.landed, t.warehouseInFk, (w.`name` = 'Floramondo') - INTO vLanded, vWarehouseFk, vIsWarehouseFloramondo - FROM tmp.buyRecalc br - JOIN buy b ON b.id = br.id - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseInFk - LIMIT 1; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - CALL rate_getPrices(vLanded, vWarehouseFk); + OPEN vTravels; + l: LOOP + SET vDone = FALSE; + FETCH vTravels INTO vLanded, vWarehouseFk, vIsWarehouseFloramondo; - UPDATE buy b - JOIN tmp.buyRecalc br ON br.id = b.id AND (@buyId := b.id) - LEFT JOIN packaging p ON p.id = b.packagingFk - JOIN item i ON i.id = b.itemFk - JOIN entry e ON e.id = b.entryFk - JOIN itemType it ON it.id = i.typeFk - JOIN travel tr ON tr.id = e.travelFk - JOIN agencyMode am ON am.id = tr.agencyModeFk - JOIN tmp.rate r - JOIN volumeConfig vc - SET b.freightValue = @PF:= IFNULL(((am.m3 * @m3:= item_getVolume(b.itemFk, b.packagingFk) / 1000000) - / b.packing) * IF(am.hasWeightVolumetric, GREATEST(b.weight / @m3 / vc.aerealVolumetricDensity, 1), 1), 0), - b.comissionValue = @CF:= ROUND(IFNULL(e.commission * b.buyingValue / 100, 0), 3), - b.packageValue = @EF:= IF(vIsWarehouseFloramondo, 0, IFNULL(ROUND(IF(p.isPackageReturnable, p.returnCost / b.packing , p.`value` / b.packing), 3),0)), - b.price3 = @t3:= IF(r.rate3 = 0, b.buyingValue,ROUND((b.buyingValue + @CF + @EF + @PF) / ((100 - r.rate3 - it.promo ) /100) ,2)), -- He añadido que el coste sea igual a tarifa3 si t3 = 0 - b.price2 = @t2:= round(@t3 * (1 + ((r.rate2 - r.rate3)/100)),2), - b.price2 = @t2:= IF(@t2 <= @t3,@t3 , @t2); + IF vDone THEN + LEAVE l; + END IF; - SELECT (b.buyingValue = b.price2), b.buyingValue, b.packagingFk - INTO vHasNotPrice, vBuyingValue, vPackagingFk - FROM vn.buy b - WHERE b.id = @buyId AND b.buyingValue <> 0.01; + CALL rate_getPrices(vLanded, vWarehouseFk); - DROP TEMPORARY TABLE tmp.rate; + UPDATE buy b + JOIN tmp.buyRecalc br ON br.id = b.id AND (@buyId := b.id) + LEFT JOIN packaging p ON p.id = b.packagingFk + JOIN item i ON i.id = b.itemFk + JOIN entry e ON e.id = b.entryFk + JOIN itemType it ON it.id = i.typeFk + JOIN travel tr ON tr.id = e.travelFk + JOIN agencyMode am ON am.id = tr.agencyModeFk + JOIN tmp.rate r + JOIN volumeConfig vc + SET b.freightValue = @PF:= IFNULL(((am.m3 * @m3:= item_getVolume(b.itemFk, b.packagingFk) / 1000000) + / b.packing) * IF(am.hasWeightVolumetric, GREATEST(b.weight / @m3 / vc.aerealVolumetricDensity, 1), 1), 0), + b.comissionValue = @CF:= ROUND(IFNULL(e.commission * b.buyingValue / 100, 0), 3), + b.packageValue = @EF:= IF(vIsWarehouseFloramondo, 0, IFNULL(ROUND(IF(p.isPackageReturnable, p.returnCost / b.packing , p.`value` / b.packing), 3),0)), + b.price3 = @t3:= IF(r.rate3 = 0, b.buyingValue,ROUND((b.buyingValue + @CF + @EF + @PF) / ((100 - r.rate3 - it.promo ) /100) ,2)), -- He añadido que el coste sea igual a tarifa3 si t3 = 0 + b.price2 = @t2:= round(@t3 * (1 + ((r.rate2 - r.rate3)/100)),2), + b.price2 = @t2:= IF(@t2 <= @t3,@t3 , @t2) + WHERE tr.landed = vLanded + AND tr.warehouseInFk = vWarehouseFk; + + DROP TEMPORARY TABLE tmp.rate; + END LOOP; + CLOSE vTravels; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -48445,7 +48172,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_recalcPricesByAwb`(IN awbFk varchar(18)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_recalcPricesByAwb`(IN awbFk varchar(18)) BEGIN /** * inserta en tmp.buyRecalc las compras de un awb @@ -48481,7 +48208,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_recalcPricesByBuy`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_recalcPricesByBuy`( vBuyFk INT(11) ) BEGIN @@ -48492,7 +48219,7 @@ BEGIN */ DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc; - CREATE TEMPORARY TABLE tmp.buyRecalc + CREATE TEMPORARY TABLE tmp.buyRecalc SELECT vBuyFk id; CALL buy_recalcPrices(); @@ -48514,7 +48241,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_recalcPricesByEntry`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_recalcPricesByEntry`( vEntryFk INT(11) ) BEGIN @@ -48549,7 +48276,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_scan`(vBarcode VARCHAR(512)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_scan`(vBarcode VARCHAR(512)) BEGIN /** * Busca compras a partir de un código de barras de subasta, las marca como @@ -48601,7 +48328,11 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_updateGrouping`(vWarehouseFk INT, vItemFk INT, vGrouping INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_updateGrouping`( + vWarehouseFk INT, + vItemFk INT, + vGrouping INT +) BEGIN /** * Actualiza el grouping de las últimas compras de un artículo @@ -48610,9 +48341,9 @@ BEGIN * @param vItemFk Id del Artículo * @param vGrouping Cantidad de grouping */ - CALL vn.buyUltimate(vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(vItemFk, vWarehouseFk, util.VN_CURDATE()); - UPDATE vn.buy b + UPDATE buy b JOIN tmp.buyUltimate bu ON b.id = bu.buyFk SET b.`grouping` = vGrouping WHERE bu.warehouseFk = vWarehouseFk @@ -48635,7 +48366,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_updatePacking`(vWarehouseFk INT, vItemFk INT, vPacking INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_updatePacking`(vWarehouseFk INT, vItemFk INT, vPacking INT) BEGIN /** * Actualiza packing @@ -48644,7 +48375,7 @@ BEGIN * @param vItemFk id del item * @param vPacking packing a actualizar */ - CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(vItemFk, vWarehouseFk, util.VN_CURDATE()); UPDATE buy b JOIN tmp.buyUltimate bu ON b.id = bu.buyFk @@ -48670,7 +48401,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_calcFromItem`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `catalog_calcFromItem`( vLanded DATE, vAddressFk INT, vAgencyModeFk INT, @@ -48709,7 +48440,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_calculate`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `catalog_calculate`( vLanded DATE, vAddressFk INT, vAgencyModeFk INT, @@ -48739,7 +48470,7 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, vShowExpiredZones); + CALL zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, vShowExpiredZones); DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; CREATE TEMPORARY TABLE tmp.ticketLot( @@ -48755,8 +48486,7 @@ BEGIN CALL catalog_componentPrepare(); - DROP TEMPORARY TABLE IF EXISTS tmp.ticketCalculateItem; - CREATE TEMPORARY TABLE tmp.ticketCalculateItem( + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem( itemFk INT(11) NOT NULL, available INT(11), producer VARCHAR(50), @@ -48770,11 +48500,11 @@ BEGIN price DECIMAL(10,2), priceKg DECIMAL(10,2), `grouping` INT(10) UNSIGNED, + minQuantity INT(10) UNSIGNED, PRIMARY KEY `itemFk` (`itemFk`) ) ENGINE = MEMORY DEFAULT CHARSET=utf8; OPEN cTravelTree; - l: LOOP SET vDone = FALSE; FETCH cTravelTree INTO vZoneFk, vWarehouseFk, vShipped; @@ -48783,9 +48513,9 @@ BEGIN LEAVE l; END IF; - CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped); - CALL `cache`.availableNoRaids_refresh (vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped); - CALL vn.buyUltimate(vWarehouseFk, vShipped); + CALL `cache`.available_refresh(vAvailableCalc, FALSE, vWarehouseFk, vShipped); + CALL `cache`.availableNoRaids_refresh(vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped); + CALL buy_getUltimate(NULL, vWarehouseFk, vShipped); INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk) SELECT vWarehouseFk, @@ -48797,17 +48527,17 @@ BEGIN LEFT JOIN cache.availableNoRaids anr ON anr.item_id = a.item_id AND anr.calc_id = vAvailableNoRaidsCalc JOIN tmp.item i ON i.itemFk = a.item_id - JOIN vn.item it ON it.id = i.itemFk - JOIN vn.`zone` z ON z.id = vZoneFk + JOIN item it ON it.id = i.itemFk + JOIN `zone` z ON z.id = vZoneFk LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = a.item_id LEFT JOIN edi.supplyResponse sr ON sr.ID = it.supplyResponseFk LEFT JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID LEFT JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID LEFT JOIN (SELECT isVNHSupplier, isEarlyBird, TRUE AS itemAllowed - FROM vn.addressFilter af + FROM addressFilter af JOIN (SELECT ad.provinceFk, p.countryFk, ad.isLogifloraAllowed - FROM vn.address ad - JOIN vn.province p ON p.id = ad.provinceFk + FROM address ad + JOIN province p ON p.id = ad.provinceFk WHERE ad.id = vAddressFk ) sub2 ON sub2.provinceFk <=> IFNULL(af.provinceFk, sub2.provinceFk) AND sub2.countryFk <=> IFNULL(af.countryFk, sub2.countryFk) @@ -48819,34 +48549,37 @@ BEGIN OR ISNULL(af.afterDated)) ) sub ON sub.isVNHSupplier = v.isVNHSupplier AND (sub.isEarlyBird = mp.isEarlyBird OR ISNULL(sub.isEarlyBird)) - JOIN vn.agencyMode am ON am.id = vAgencyModeFk - JOIN vn.agency ag ON ag.id = am.agencyFk - JOIN vn.itemType itt ON itt.id = it.typeFk - JOIN vn.itemCategory itc on itc.id = itt.categoryFk - JOIN vn.address ad ON ad.id = vAddressFk - LEFT JOIN vn.clientItemType cit + JOIN agencyMode am ON am.id = vAgencyModeFk + JOIN agency ag ON ag.id = am.agencyFk + JOIN itemType itt ON itt.id = it.typeFk + JOIN itemCategory itc on itc.id = itt.categoryFk + JOIN address ad ON ad.id = vAddressFk + LEFT JOIN clientItemType cit ON cit.clientFk = ad.clientFk AND cit.itemTypeFk = itt.id - LEFT JOIN vn.zoneItemType zit + LEFT JOIN zoneItemType zit ON zit.zoneFk = vZoneFk AND zit.itemTypeFk = itt.id - LEFT JOIN vn.agencyModeItemType ait + LEFT JOIN agencyModeItemType ait ON ait.agencyModeFk = vAgencyModeFk AND ait.itemTypeFk = itt.id WHERE a.calc_id = vAvailableCalc AND a.available > 0 AND (sub.itemAllowed OR NOT it.isFloramondo OR anr.available > 0) AND (ag.isAnyVolumeAllowed OR NOT itt.isUnconventionalSize) - AND (itc.isReclining OR it.`size` IS NULL OR it.`size` < z.itemMaxSize OR z.itemMaxSize IS NULL) + AND (it.`size` IS NULL + OR IF(itc.isReclining, + it.size <= z.itemMaxLength OR z.itemMaxLength IS NULL, + it.size <= z.itemMaxSize OR z.itemMaxSize IS NULL)) AND cit.id IS NULL AND zit.id IS NULL AND ait.id IS NULL; DROP TEMPORARY TABLE tmp.buyUltimate; - CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); + CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); - INSERT INTO tmp.ticketCalculateItem ( + INSERT INTO tmp.ticketCalculateItem( itemFk, available, producer, @@ -48859,9 +48592,9 @@ BEGIN origin, price, priceKg, - `grouping`) - SELECT - tl.itemFk, + `grouping`, + minQuantity) + SELECT tl.itemFk, SUM(tl.available) available, p.name producer, i.name item, @@ -48873,7 +48606,8 @@ BEGIN o.code origin, bl.price, bl.priceKg, - bl.`grouping` + bl.`grouping`, + mq.quantity FROM tmp.ticketLot tl JOIN item i ON tl.itemFk = i.id LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible @@ -48889,12 +48623,28 @@ BEGIN ) sub GROUP BY itemFk ) bl ON bl.itemFk = tl.itemFk - WHERE tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk + LEFT JOIN ( + WITH itemMinQuantityPriority AS ( + SELECT itemFk, + quantity, + ROW_NUMBER() OVER ( + PARTITION BY itemFk + ORDER BY warehouseFk IS NULL + ) priority + FROM vn.itemMinimumQuantity + WHERE `started` <= vShipped + AND (`ended` >= vShipped OR `ended` IS NULL) + AND (warehouseFk = vWarehouseFk OR warehouseFk IS NULL) + ) + SELECT itemFk, quantity + FROM itemMinQuantityPriority + WHERE priority = 1 + ) mq ON mq.itemFk = tl.itemFk + WHERE tl.zoneFk = vZoneFk + AND tl.warehouseFk = vWarehouseFk GROUP BY tl.itemFk ON DUPLICATE KEY UPDATE available = available + VALUES(available); - END LOOP; - CLOSE cTravelTree; END ;; DELIMITER ; @@ -48912,7 +48662,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_componentCalculate`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `catalog_componentCalculate`( vZoneFk INT, vAddressFk INT, vShipped DATE, @@ -48920,7 +48670,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_componentCalculate`( ) BEGIN /** - * Calcula los componentes de los articulos de tmp.ticketLot + * Calcula los componentes de los articulos de la tabla tmp.ticketLot * * @param vZoneFk para calcular el transporte * @param vAddressFk Consignatario @@ -48938,18 +48688,41 @@ BEGIN FROM address WHERE id = vAddressFk; - CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice + CREATE OR REPLACE TEMPORARY TABLE tPriceDelta (INDEX (itemFk)) - ENGINE = MEMORY - SELECT * FROM ( + ENGINE = MEMORY + SELECT i.id itemFk, + SUM(IFNULL(pd.absIncreasing,0)) absIncreasing, + SUM(IFNULL(pd.ratIncreasing,0)) ratIncreasing, + pd.warehouseFk + FROM item i + JOIN priceDelta pd + ON pd.itemTypeFk = i.typeFk + AND (pd.minSize IS NULL OR pd.minSize <= i.`size`) + AND (pd.maxSize IS NULL OR pd.maxSize >= i.`size`) + AND (pd.inkFk IS NULL OR pd.inkFk = i.inkFk) + AND (pd.originFk IS NULL OR pd.originFk = i.originFk) + AND (pd.producerFk IS NULL OR pd.producerFk = i.producerFk) + AND (pd.warehouseFk IS NULL OR pd.warehouseFk = vWarehouseFk) + LEFT JOIN zoneGeo zg ON zg.id = pd.zoneGeoFk + LEFT JOIN zoneGeo zg2 ON zg2.id = address_getGeo(vAddressFk) + WHERE (pd.fromDated IS NULL OR pd.fromDated <= vShipped) + AND (pd.toDated IS NULL OR pd.toDated >= vShipped) + AND (pd.zoneGeoFk IS NULL OR zg2.lft BETWEEN zg.lft AND zg.rgt) + GROUP BY itemFk; + + CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice + (INDEX (itemFk)) + ENGINE = MEMORY + SELECT * FROM ( SELECT * - FROM specialPrice - WHERE (clientFk = vClientFk OR clientFk IS NULL) - AND started <= vShipped - AND (ended >= vShipped OR ended IS NULL) - ORDER BY (clientFk = vClientFk) DESC, id DESC - LIMIT 10000000000000000000) t - GROUP BY itemFk; + FROM specialPrice + WHERE (clientFk = vClientFk OR clientFk IS NULL) + AND started <= vShipped + AND (ended >= vShipped OR ended IS NULL) + ORDER BY (clientFk = vClientFk) DESC, id DESC + LIMIT 10000000000000000000) t + GROUP BY itemFk; CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentCalculate (PRIMARY KEY (itemFk, warehouseFk)) @@ -49021,6 +48794,19 @@ BEGIN JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tc.itemFk AND tcc.warehouseFk = tc.warehouseFk GROUP BY tc.itemFk, warehouseFk; + -- Bonus del comprador a un rango de productos + INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) + SELECT + tcb.warehouseFk, + tcb.itemFk, + c.id, + IFNULL(tcb.base * tpd.ratIncreasing / 100,0) + IFNULL(tpd.absIncreasing,0) + FROM tmp.ticketComponentBase tcb + JOIN component c ON c.code = 'bonus' + JOIN tPriceDelta tpd + ON tpd.itemFk = tcb.itemFk + AND tpd.warehouseFk = tcb.warehouseFk; + -- RECOBRO INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) SELECT tcb.warehouseFk, tcb.itemFk, c2.id, @@ -49216,7 +49002,8 @@ BEGIN tmp.ticketComponentBase, tmp.ticketComponentRate, tmp.ticketComponentCopy, - tSpecialPrice; + tPriceDelta, + tSpecialPrice; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -49233,7 +49020,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_componentPrepare`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `catalog_componentPrepare`() BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; @@ -49273,7 +49060,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `catalog_componentPurge`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `catalog_componentPurge`() BEGIN DROP TEMPORARY TABLE tmp.ticketComponentPrice, @@ -49287,6 +49074,209 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `claimRatio_add` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `claimRatio_add`() +BEGIN +/* +* Añade a la tabla greuges todos los cargos necesario y +* que luego lo utilizamos para calcular el recobro. +*/ + DECLARE vMonthToRefund INT + DEFAULT (SELECT monthsToRefund FROM claimConfig); + DECLARE vRecoveryGreugeType INT + DEFAULT (SELECT id FROM greugeType WHERE code = 'recovery'); + DECLARE vManaGreugeType INT + DEFAULT (SELECT id FROM greugeType WHERE code = 'mana'); + DECLARE vClaimGreugeType INT + DEFAULT (SELECT id FROM greugeType WHERE code = 'claim'); + DECLARE vDebtComponentType INT + DEFAULT (SELECT id FROM component WHERE code = 'debtCollection'); + + IF vMonthToRefund IS NULL + OR vRecoveryGreugeType IS NULL + OR vManaGreugeType IS NULL + OR vClaimGreugeType IS NULL + OR vDebtComponentType IS NULL THEN + + CALL util.throw('Required variables not found'); + END IF; + + -- Reclamaciones demasiado sensibles + INSERT INTO greuge( + shipped, + clientFk, + `description`, + amount, + greugeTypeFk, + ticketFk + ) + SELECT c.ticketCreated, + c.clientFk, + CONCAT('Claim ', c.id,' : ', s.concept), + ROUND(-1 * ((c.responsibility - 1) / 4) * s.quantity * + s.price * (100 - s.discount) / 100, 2), + vClaimGreugeType, + s.ticketFk + FROM sale s + JOIN claimEnd ce ON ce.saleFk = s.id + JOIN claimDestination cd ON cd.id = ce.claimDestinationFk + JOIN claim c ON c.id = ce.claimFk + JOIN claimState cs ON cs.id = c.claimStateFk + WHERE cd.description NOT IN ('Bueno', 'Corregido') + AND NOT ce.isGreuge + AND cs.code = 'resolved'; + + -- Reclamaciones que pasan a Maná + INSERT INTO greuge( + shipped, + clientFk, + `description`, + amount, + greugeTypeFk, + ticketFk + ) + SELECT c.ticketCreated, + c.clientFk, + CONCAT('Claim_mana ', c.id,' : ', s.concept), + ROUND(((c.responsibility - 1) / 4) * s.quantity * + s.price * (100 - s.discount) / 100, 2), + vManaGreugeType, + s.ticketFk + FROM sale s + JOIN claimEnd ce ON ce.saleFk = s.id + JOIN claimDestination cd ON cd.id = ce.claimDestinationFk + JOIN claim c ON c.id = ce.claimFk + JOIN claimState cs ON cs.id = c.claimStateFk + WHERE cd.description NOT IN ('Bueno', 'Corregido') + AND NOT ce.isGreuge + AND cs.code = 'resolved' + AND c.isChargedToMana; + + -- Marcamos para no repetir + UPDATE claimEnd ce + JOIN claimDestination cd ON cd.id = ce.claimDestinationFk + JOIN claim c ON c.id = ce.claimFk + JOIN claimState cs ON cs.id = c.claimStateFk + SET ce.isGreuge = TRUE + WHERE cd.description NOT IN ('Bueno', 'Corregido') + AND NOT ce.isGreuge + AND cs.code = 'resolved'; + + -- Recobros + CREATE OR REPLACE TEMPORARY TABLE tTicketList + (PRIMARY KEY (ticketFk)) + ENGINE = MEMORY + SELECT DISTINCT s.ticketFk + FROM saleComponent sc + JOIN sale s ON sc.saleFk = s.id + JOIN ticket t ON t.id = s.ticketFk + JOIN ticketLastState ts ON ts.ticketFk = t.id + JOIN ticketTracking tt ON tt.id = ts.ticketTrackingFk + JOIN state st ON st.id = tt.stateFk + JOIN alertLevel al ON al.id = st.alertLevel + WHERE sc.componentFk = vDebtComponentType + AND NOT sc.isGreuge + AND t.shipped >= (SELECT minShipped FROM claimConfig) + AND t.shipped < util.VN_CURDATE() + AND al.code = 'DELIVERED'; + + DELETE g.* + FROM greuge g + JOIN tTicketList t ON t.ticketFk = g.ticketFk + WHERE g.greugeTypeFk = vRecoveryGreugeType; + + INSERT INTO greuge( + clientFk, + `description`, + amount, + shipped, + greugeTypeFk, + ticketFk + ) + SELECT t.clientFk, + 'Recobro', + - ROUND(SUM(sc.value * s.quantity), 2) dif, + DATE(t.shipped), + vRecoveryGreugeType, + tl.ticketFk + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN tTicketList tl ON tl.ticketFk = t.id + JOIN saleComponent sc ON sc.saleFk = s.id + AND sc.componentFk = vDebtComponentType + GROUP BY t.id + HAVING ABS(dif) > 1; + + UPDATE saleComponent sc + JOIN sale s ON s.id = sc.saleFk + JOIN tTicketList tl ON tl.ticketFk = s.ticketFk + SET sc.isGreuge = TRUE + WHERE sc.componentFk = vDebtComponentType; + + REPLACE claimRatio( + clientFk, + yearSale, + claimAmount, + claimingRate, + priceIncreasing + ) + SELECT c.id, + 12 * cac.invoiced, + totalClaims, + ROUND(totalClaims / (12 * cac.invoiced), 4), + 0 + FROM client c + LEFT JOIN bs.clientAnnualConsumption cac ON cac.clientFk = c.id + LEFT JOIN ( + SELECT c.clientFk, + ROUND(SUM(-1 * ((c.responsibility - 1) / 4) * + s.quantity * s.price * (100 - s.discount) + / 100)) totalClaims + FROM sale s + JOIN claimEnd ce ON ce.saleFk = s.id + JOIN claimDestination cd ON cd.id = ce.claimDestinationFk + JOIN claim c ON c.id = ce.claimFk + JOIN claimState cs ON cs.id = c.claimStateFk + WHERE cd.description NOT IN ('Bueno', 'Corregido') + AND cs.code = 'resolved' + AND c.ticketCreated >= util.VN_CURDATE() - INTERVAL 1 YEAR + GROUP BY c.clientFk + ) sub ON sub.clientFk = c.id; + + -- Calculamos el porcentaje del recobro para añadirlo al precio de venta + UPDATE claimRatio cr + JOIN ( + SELECT clientFk, IFNULL(SUM(amount), 0) greuge + FROM greuge + WHERE shipped <= util.VN_CURDATE() + GROUP BY clientFk + ) sub ON sub.clientFk = cr.clientFk + SET cr.priceIncreasing = GREATEST(0, ROUND(IFNULL(sub.greuge, 0) / + (IFNULL(cr.yearSale, 0) * vMonthToRefund / 12 ), 3)); + + -- Protección neonatos + UPDATE claimRatio cr + JOIN firstTicketShipped fts ON fts.clientFk = cr.clientFk + SET cr.priceIncreasing = 0, + cr.claimingRate = 0 + WHERE fts.shipped > util.VN_CURDATE() - INTERVAL 1 MONTH; + + DROP TEMPORARY TABLE tTicketList; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clean` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49295,7 +49285,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `clean`() BEGIN /** * Purges outdated data to optimize performance. @@ -49315,15 +49305,17 @@ BEGIN DELETE FROM workerActivity WHERE created < v2Years; DELETE FROM ticketParking WHERE created < v2Months; DELETE FROM routesMonitor WHERE dated < v2Months; - DELETE FROM workerTimeControlLog WHERE created < v2Months; DELETE FROM `message` WHERE sendDate < v2Months; DELETE FROM messageInbox WHERE sendDate < v2Months; DELETE FROM messageInbox WHERE sendDate < v2Months; DELETE FROM workerTimeControl WHERE timed < v4Years; DELETE FROM itemShelving WHERE created < util.VN_CURDATE() AND visible = 0; DELETE FROM ticketDown WHERE created < util.yesterday(); - DELETE FROM entryLog WHERE creationDate < v2Months; DELETE IGNORE FROM expedition WHERE created < v26Months; + DELETE cs + FROM sms s + JOIN clientSms cs ON cs.smsFk = s.id + WHERE s.created < v18Months; DELETE FROM sms WHERE created < v18Months; DELETE FROM saleTracking WHERE created < v1Years; DELETE FROM productionError WHERE dated < v1Years; @@ -49353,11 +49345,8 @@ BEGIN DELETE b FROM buy b JOIN entryConfig e ON e.defaultEntry = b.entryFk WHERE b.created < v2Months; - DELETE FROM itemShelvingLog WHERE created < v2Months; DELETE FROM stockBuyed WHERE creationDate < v2Months; - DELETE FROM itemCleanLog WHERE created < util.VN_NOW() - INTERVAL 1 YEAR; DELETE FROM printQueue WHERE statusCode = 'printed' AND created < v2Months; - DELETE FROM ticketLog WHERE creationDate <= v5Years; -- Equipos duplicados DELETE w.* FROM workerTeam w @@ -49382,7 +49371,7 @@ BEGIN WHERE cs.description = 'Anulado' AND c.created < v2Months; - DELETE FROM expeditionTruck WHERE eta < v3Months; + DELETE FROM roadmapStop WHERE eta < v3Months; DELETE FROM XDiario WHERE FECHA < v3Months OR FECHA IS NULL; -- Borrar travels sin entradas @@ -49466,7 +49455,6 @@ BEGIN -- Borra los registros de collection y ticketcollection DELETE FROM collection WHERE created < v2Months; - DELETE FROM travelLog WHERE creationDate < v3Months; CALL shelving_clean(); @@ -49535,7 +49523,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `clean_logiflora`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `clean_logiflora`() BEGIN /** * Elimina las compras y los artículos residuales de logiflora. @@ -49621,27 +49609,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `clearShelvingList` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `clearShelvingList`(vShelvingFk VARCHAR(8)) -BEGIN - UPDATE vn.itemShelving - SET visible = 0 - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk COLLATE utf8_unicode_ci; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `clientDebtSpray` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49650,7 +49617,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `clientDebtSpray`(vClientFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `clientDebtSpray`(vClientFk INT) BEGIN /* Reparte el saldo de un cliente en greuge en la cartera que corresponde, y desasigna el comercial @@ -49692,7 +49659,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `clientFreeze`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `clientFreeze`() BEGIN /** * Congela diariamente aquellos clientes que son morosos sin recobro, @@ -49749,7 +49716,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `clientGetDebtDiary`(vClientFK INT, vCompanyFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `clientGetDebtDiary`(vClientFK INT, vCompanyFk INT) BEGIN /** * Devuelve el registro de deuda @@ -49879,7 +49846,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `clientGreugeSpray`(IN vClientFk INT, IN onlyForHisOwner BOOL, IN vWorkerCode VARCHAR(3), IN vWithMana BOOLEAN) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `clientGreugeSpray`(IN vClientFk INT, IN onlyForHisOwner BOOL, IN vWorkerCode VARCHAR(3), IN vWithMana BOOLEAN) BEGIN DECLARE vGreuge DECIMAL(10,2); @@ -49965,7 +49932,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `clientPackagingOverstock`(vClientFk INT, vGraceDays INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `clientPackagingOverstock`(vClientFk INT, vGraceDays INT) BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.clientPackagingOverstock; CREATE TEMPORARY TABLE tmp.clientPackagingOverstock @@ -50070,7 +50037,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `clientPackagingOverstockReturn`(vClientFk INT, vGraceDays INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `clientPackagingOverstockReturn`(vClientFk INT, vGraceDays INT) BEGIN DECLARE vNewTicket INT DEFAULT 0; DECLARE vWarehouseFk INT; @@ -50123,7 +50090,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `clientRemoveWorker`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `clientRemoveWorker`() BEGIN DECLARE vDone BOOL DEFAULT FALSE; DECLARE vClientFk INT; @@ -50176,7 +50143,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `clientRisk_update`(vClientId INT, vCompanyId INT, vAmount DECIMAL(10,2)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `clientRisk_update`(vClientId INT, vCompanyId INT, vAmount DECIMAL(10,2)) BEGIN IF vAmount IS NOT NULL THEN @@ -50204,7 +50171,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `client_checkBalance`(IN vDateTo DATETIME, IN vIsConciliated BOOL) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `client_checkBalance`(IN vDateTo DATETIME, IN vIsConciliated BOOL) BEGIN /** * Compara los datos de nuestros clientes con @@ -50276,16 +50243,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `client_create` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `client_create`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `client_create`( vFirstname VARCHAR(50), vSurnames VARCHAR(50), vFi VARCHAR(9), @@ -50320,20 +50287,25 @@ BEGIN DECLARE vIsTaxDataChecked TINYINT(1); DECLARE vHasCoreVnl BOOLEAN; DECLARE vMandateTypeFk INT; + DECLARE vHasDailyInvoice BOOLEAN; - SELECT defaultPayMethodFk, - defaultDueDay, - defaultCredit, - defaultIsTaxDataChecked, - defaultHasCoreVnl, - defaultMandateTypeFk + SELECT cc.defaultPayMethodFk, + cc.defaultDueDay, + cc.defaultCredit, + cc.defaultIsTaxDataChecked, + cc.defaultHasCoreVnl, + cc.defaultMandateTypeFk, + c.hasDailyInvoice INTO vPayMethodFk, vDueDay, vDefaultCredit, vIsTaxDataChecked, vHasCoreVnl, - vMandateTypeFk - FROM clientConfig; + vMandateTypeFk, + vHasDailyInvoice + FROM clientConfig cc + LEFT JOIN province p ON p.id = vProvinceFk + LEFT JOIN country c ON c.id = p.countryFk; INSERT INTO `client` SET id = vUserFk, @@ -50351,7 +50323,8 @@ BEGIN credit = vDefaultCredit, isTaxDataChecked = vIsTaxDataChecked, hasCoreVnl = vHasCoreVnl, - isEqualizated = FALSE + isEqualizated = FALSE, + hasDailyInvoice = vHasDailyInvoice ON duplicate KEY UPDATE payMethodFk = vPayMethodFk, dueDay = vDueDay, @@ -50385,7 +50358,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `client_getDebt`(vDate DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `client_getDebt`(vDate DATE) BEGIN /** * Calculates the risk for active clients @@ -50460,7 +50433,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `client_getMana`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `client_getMana`() BEGIN /** * Devuelve el mana de los clientes de la tabla tmp.client(id) @@ -50530,7 +50503,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `client_getRisk`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `client_getRisk`( vDate DATE ) BEGIN @@ -50553,7 +50526,7 @@ BEGIN c.credit, CAST(r.risk AS DECIMAL (10,2)) risk, CAST(c.credit - r.risk AS DECIMAL (10,2)) difference, - co.country + co.name country FROM client c JOIN tmp.risk r ON r.clientFk = c.id JOIN country co ON co.id = c.countryFk @@ -50578,7 +50551,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `client_RandomList`(vNumber INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `client_RandomList`(vNumber INT) BEGIN DECLARE i INT DEFAULT 0; @@ -50650,7 +50623,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `client_unassignSalesPerson`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `client_unassignSalesPerson`() BEGIN /** * Elimina la asignación de salesPersonFk de la ficha del clientes @@ -50677,6 +50650,7 @@ BEGIN JOIN province p ON p.id = c.provinceFk LEFT JOIN autonomy a ON a.id = p.autonomyFk JOIN country co ON co.id = p.countryFk + JOIN bs.clientDiedPeriod cdp ON cdp.countryFk = co.id WHERE cd.warning = 'third' AND cp.clientFk IS NULL AND sp.salesPersonFk IS NULL @@ -50706,6 +50680,53 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `client_userDisable` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `client_userDisable`() +BEGIN +/** +* Desactiva los clientes inactivos en los últimos X meses. +*/ + DECLARE vMonths INT; + + SELECT monthsToDisableUser INTO vMonths + FROM clientConfig; + + IF vMonths IS NULL THEN + CALL util.throw('Config parameter not set'); + END IF; + + UPDATE account.user u + JOIN client c ON c.id = u.id + LEFT JOIN account.account a ON a.id = u.id + SET u.active = FALSE + WHERE c.typeFk = 'normal' + AND a.id IS NULL + AND u.active + AND c.created < util.VN_CURDATE() - INTERVAL vMonths MONTH + AND NOT u.role = (SELECT id FROM `role` WHERE name = 'supplier') + AND u.id NOT IN ( + SELECT DISTINCT c.id + FROM client c + LEFT JOIN ticket t ON t.clientFk = c.id + WHERE c.salesPersonFk IS NOT NULL + OR t.created > util.VN_CURDATE() - INTERVAL vMonths MONTH + OR shipped > util.VN_CURDATE() - INTERVAL vMonths MONTH + ); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `cmrPallet_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -50714,7 +50735,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `cmrPallet_add`(vExpeditionPalletFk INT, vCmrFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `cmrPallet_add`(vExpeditionPalletFk INT, vCmrFk INT) BEGIN /** * Añade registro a tabla cmrPallet. @@ -50764,7 +50785,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collectionPlacement_get`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collectionPlacement_get`( vParamFk INT(11), vIsPicker bool) BEGIN @@ -50820,24 +50841,20 @@ BEGIN SELECT ts.saleFk, ts.itemFk, CAST(0 AS DECIMAL(10,0)) saleOrder, - IF(ish.visible > 0 OR iss.id, 1, 100000) * - IFNULL(p2.pickingOrder, p.pickingOrder) `order`, - TO_SECONDS(IF(iss.id, - iss.created - INTERVAL vCurrentYear YEAR, - ish.created - INTERVAL YEAR(ish.created) YEAR)) priority, + (IF(ish.visible > 0 OR iss.id, 1, 100000) * + COALESCE(p2.pickingOrder, p.pickingOrder)) `order`, + TO_SECONDS(COALESCE(iss.created, ish.created)) - TO_SECONDS(MAKEDATE(IFNULL(YEAR(iss.created), YEAR(ish.created)), 1)) priority, CONCAT( - IF(iss.id, - CONCAT('< ', IFNULL(wk.`code`, '---'),' > '), - ''), - p.`code`) COLLATE utf8_general_ci placement, + IF(iss.id, CONCAT('< ', COALESCE(wk.`code`, '---'),' > '), ''), + p.`code` + ) COLLATE utf8_general_ci placement, sh.priority shelvingPriority, sh.code COLLATE utf8_general_ci shelving, ish.created, ish.visible, - IFNULL( - IF(st.code = 'previousByPacking', ish.packing, g.`grouping`), - 1) `grouping`, - st.code = 'previousPrepared' isPreviousPrepared, + COALESCE( + IF(st.code = 'previousByPacking', ish.packing, g.`grouping`),1) `grouping`, + (st.code = 'previousPrepared') isPreviousPrepared, iss.id itemShelvingSaleFk, ts.ticketFk, iss.id, @@ -50845,11 +50862,12 @@ BEGIN iss.userFk, ts.quantity FROM tSale ts - LEFT JOIN (SELECT DISTINCT saleFk - FROM saleTracking st - JOIN state s ON s.id = st.stateFk - WHERE st.isChecked - AND s.semaphore = 1) st ON st.saleFk = ts.saleFk + LEFT JOIN (SELECT st.saleFk + FROM saleTracking st + JOIN state s ON s.id = st.stateFk + WHERE st.isChecked + AND s.semaphore = 1 + GROUP BY st.saleFk) st ON st.saleFk = ts.saleFk JOIN itemShelving ish ON ish.itemFk = ts.itemFk JOIN shelving sh ON sh.code = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk @@ -50858,14 +50876,14 @@ BEGIN JOIN warehouse w ON w.id = sc.warehouseFk LEFT JOIN tGrouping g ON g.itemFk = ts.itemFk LEFT JOIN itemShelvingSale iss ON iss.saleFk = ts.saleFk - AND iss.itemShelvingFk = ish.id + AND iss.itemShelvingFk = ish.id LEFT JOIN worker wk ON wk.id = iss.userFk LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = ts.saleFk LEFT JOIN saleGroup sg ON sg.id = sgd.saleGroupFk LEFT JOIN parking p2 ON p2.id = sg.parkingFk WHERE w.id = vWarehouseFk - AND NOT sc.isHideForPickers - HAVING (iss.id AND st.saleFk) OR salePreviousPrepared IS NULL; + AND NOT sc.isHideForPickers + AND ((iss.id AND st.saleFk) OR st.saleFk IS NULL); CREATE OR REPLACE TEMPORARY TABLE tSalePlacementList2 (INDEX(saleFk), INDEX(olderPriority)) @@ -50927,7 +50945,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_addItem`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_addItem`( vBarccodeFk INT, vQuantity INT, vTicketFk INT @@ -50993,6 +51011,109 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `collection_addWithReservation` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_addWithReservation`( + vItemFk INT, + vQuantity INT, + vTicketFk INT, + vSaleGroupFk INT, + vSectorFk INT +) +BEGIN +/** + * En el ámbito de las colecciones se añade una línea de sale a un ticket + * de una colección en caso de tener disponible y se realiza la reserva. + * + * @param vItemFk id of item + * @param vQuantity quantity to be added to the ticket + * @param vTicketFk ticket to which the sales line is added + * @param vSaleGroupFk saleGroupFk id to add saleGroupDetail + */ + + DECLARE vWarehouseFk INT; + DECLARE vCacheAvailableFk INT; + DECLARE vAvailable INT; + DECLARE vSaleFk INT; + DECLARE vConcept VARCHAR(50); + DECLARE vItemName VARCHAR(50); + DECLARE vHasThrow BOOLEAN DEFAULT FALSE; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + SELECT t.warehouseFk INTO vWarehouseFk + FROM ticket t + JOIN ticketCollection tc ON tc.ticketFk = t.id + WHERE t.id = vTicketFk; + + CALL cache.available_refresh( + vCacheAvailableFk, + FALSE, + vWarehouseFk, + util.VN_CURDATE()); + + SELECT available INTO vAvailable + FROM cache.available + WHERE calc_id = vCacheAvailableFk + AND item_id = vItemFk; + + IF vAvailable < vQuantity THEN + SET vHasThrow = TRUE; + ELSE + SELECT `name`, + CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name) + INTO vItemName, vConcept + FROM item + WHERE id = vItemFk; + + START TRANSACTION; + + INSERT INTO sale + SET itemFk = vItemFk, + ticketFk = vTicketFk, + concept = vConcept, + quantity = vQuantity, + isAdded = TRUE; + + SELECT LAST_INSERT_ID() INTO vSaleFk; + + CALL sale_calculateComponent(vSaleFk, NULL); + CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk); + + IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN + SET vHasThrow = TRUE; + END IF; + END IF; + + IF vHasThrow THEN + CALL util.throw("There is no available for the selected item"); + END IF; + + IF vSaleGroupFk THEN + INSERT INTO saleGroupDetail + SET saleFk = vSaleFk, + saleGroupFk = vSaleGroupFk; + END IF; + + COMMIT; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `collection_assign` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51001,7 +51122,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_assign`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_assign`( vUserFk INT, OUT vCollectionFk INT ) @@ -51013,6 +51134,196 @@ BEGIN * * @param vUserFk Id de usuario * @param vCollectionFk Id de colección + */ + DECLARE vHasTooMuchCollections BOOL; + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vCollectionWorker INT; + DECLARE vMaxNotAssignedCollectionLifeTime TIME; + + DECLARE vCollections CURSOR FOR + WITH collections AS ( + SELECT tc.collectionFk, + SUM(sv.volume) volume, + c.saleTotalCount, + c.itemPackingTypeFk, + c.trainFk, + c.warehouseFk, + c.wagons + FROM vn.ticketCollection tc + JOIN vn.collection c ON c.id = tc.collectionFk + JOIN vn.saleVolume sv ON sv.ticketFk = tc.ticketFk + WHERE c.workerFk IS NULL + AND sv.shipped >= util.VN_CURDATE() + GROUP BY tc.collectionFk + ) SELECT c.collectionFk + FROM collections c + JOIN vn.operator o + WHERE o.workerFk = vUserFk + AND (c.saleTotalCount <= o.linesLimit OR o.linesLimit IS NULL) + AND (c.itemPackingTypeFk = o.itemPackingTypeFk OR o.itemPackingTypeFk IS NULL) + AND o.numberOfWagons = c.wagons + AND o.trainFk = c.trainFk + AND o.warehouseFk = c.warehouseFk; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + -- Si hay colecciones sin terminar, sale del proceso + + CALL collection_get(vUserFk); + + SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, pc.maxNotAssignedCollectionLifeTime + INTO vHasTooMuchCollections, vMaxNotAssignedCollectionLifeTime + FROM productionConfig pc + LEFT JOIN tmp.collection ON TRUE; + + DROP TEMPORARY TABLE tmp.collection; + + IF vHasTooMuchCollections THEN + CALL util.throw('Hay colecciones pendientes'); + END IF; + + -- Se eliminan las colecciones sin asignar que estan obsoletas + + INSERT INTO ticketTracking(stateFk, ticketFk) + SELECT s.id, tc.ticketFk + FROM `collection` c + JOIN ticketCollection tc ON tc.collectionFk = c.id + JOIN `state` s ON s.code = 'PRINTED_AUTO' + WHERE c.workerFk IS NULL + AND TIMEDIFF(util.VN_NOW(), c.created) > vMaxNotAssignedCollectionLifeTime; + + DELETE FROM `collection` + WHERE workerFk IS NULL + AND TIMEDIFF(util.VN_NOW(), created) > vMaxNotAssignedCollectionLifeTime; + + -- Se añade registro al semillero + + INSERT INTO collectionHotbed(userFk) VALUES(vUserFk); + + -- Comprueba si hay colecciones disponibles que se ajustan a su configuracion + + OPEN vCollections; + l: LOOP + SET vDone = FALSE; + FETCH vCollections INTO vCollectionFk; + + IF vDone THEN + LEAVE l; + END IF; + + BEGIN + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + SET vCollectionFk = NULL; + RESIGNAL; + END; + + START TRANSACTION; + + SELECT workerFk INTO vCollectionWorker + FROM `collection` + WHERE id = vCollectionFk FOR UPDATE; + + IF vCollectionWorker IS NULL THEN + UPDATE `collection` + SET workerFk = vUserFk + WHERE id = vCollectionFk; + + COMMIT; + LEAVE l; + END IF; + + ROLLBACK; + END; + END LOOP; + CLOSE vCollections; + + IF vCollectionFk IS NULL THEN + CALL collection_new(vUserFk, vCollectionFk); + + UPDATE `collection` + SET workerFk = vUserFk + WHERE id = vCollectionFk; + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `collection_get` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_get`(vWorkerFk INT) +BEGIN +/** + * Obtiene colección del sacador si tiene líneas pendientes. + * + * @param vWorkerFk id del worker. + * @table Devuelve tabla temporal con las colecciones pendientes + */ + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + RESIGNAL; + END; + + CREATE OR REPLACE TEMPORARY TABLE tmp.collection + ENGINE = MEMORY + SELECT c.id collectionFk, + DATE(c.created) created, + COUNT(DISTINCT tc.ticketFk) ticketTotalCount + FROM collection c + JOIN ticketCollection tc ON tc.collectionFk = c.id + JOIN sale s ON s.ticketFk = tc.ticketFk + JOIN ticketState ts ON ts.ticketFk = tc.ticketFk + JOIN state s2 ON s2.id = ts.stateFk + JOIN productionConfig pc + JOIN vn.state ss ON ss.code = 'PREPARED' + LEFT JOIN vn.saleTracking st ON st.saleFk = s.id + AND st.stateFk = ss.id + WHERE c.workerFk = vWorkerFk + AND TIMESTAMPDIFF(HOUR, c.created , util.VN_NOW()) < pc.pendingCollectionsAge + AND s.quantity + AND s2.order < pc.pendingCollectionsOrder + GROUP BY c.id + HAVING COUNT(*) > COUNT(DISTINCT st.id); + + SELECT * FROM tmp.collection; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `collection_getAssigned` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_getAssigned`( + vUserFk INT, + OUT vCollectionFk INT +) +BEGIN +/** + * Comprueba si existen colecciones libres que se ajustan al perfil del usuario + * y le asigna la más antigua. + * Añade un registro al semillero de colecciones y hace la reserva para la colección + * + * @param vUserFk Id de usuario + * @param vCollectionFk Id de colección */ DECLARE vHasTooMuchCollections BOOL; DECLARE vItemPackingTypeFk VARCHAR(1); @@ -51032,17 +51343,17 @@ BEGIN -- Si hay colecciones sin terminar, sale del proceso CALL collection_get(vUserFk); - SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, - collection_assign_lockname + SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, + pc.collection_assign_lockname INTO vHasTooMuchCollections, vLockName - FROM productionConfig pc - LEFT JOIN tCollection ON TRUE; + FROM tmp.collection c + JOIN productionConfig pc; - DROP TEMPORARY TABLE tCollection; + DROP TEMPORARY TABLE tmp.collection; IF vHasTooMuchCollections THEN - CALL util.throw('Hay colecciones pendientes'); + CALL util.throw('There are pending collections'); END IF; SELECT warehouseFk, itemPackingTypeFk @@ -51063,52 +51374,44 @@ BEGIN -- Se eliminan las colecciones sin asignar que estan obsoletas INSERT INTO ticketTracking(stateFk, ticketFk) SELECT s.id, tc.ticketFk - FROM `collection` c + FROM collection c JOIN ticketCollection tc ON tc.collectionFk = c.id - JOIN `state` s ON s.code = 'PRINTED_AUTO' + JOIN state s ON s.code = 'PRINTED_AUTO' JOIN productionConfig pc WHERE c.workerFk IS NULL AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime; - DELETE c.* - FROM `collection` c + DELETE c + FROM collection c JOIN productionConfig pc WHERE c.workerFk IS NULL AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime; -- Se añade registro al semillero - INSERT INTO collectionHotbed(userFk) - VALUES(vUserFk); + INSERT INTO collectionHotbed + SET userFk = vUserFk; -- Comprueba si hay colecciones disponibles que se ajustan a su configuracion - SELECT MIN(c.id) - INTO vCollectionFk - FROM `collection` c - JOIN operator o - ON (o.itemPackingTypeFk = c.itemPackingTypeFk OR c.itemPackingTypeFk IS NULL) + SELECT MIN(c.id) INTO vCollectionFk + FROM collection c + JOIN operator o ON (o.itemPackingTypeFk = c.itemPackingTypeFk + OR c.itemPackingTypeFk IS NULL) AND o.numberOfWagons = c.wagons AND o.trainFk = c.trainFk AND o.warehouseFk = c.warehouseFk AND c.workerFk IS NULL - AND (c.saleTotalCount <= o.linesLimit OR o.linesLimit IS NULL) - JOIN ( - SELECT tc.collectionFk, SUM(sv.volume) volume - FROM ticketCollection tc - JOIN saleVolume sv ON sv.ticketFk = tc.ticketFk - WHERE sv.shipped >= util.VN_CURDATE() - GROUP BY tc.collectionFk - ) sub ON sub.collectionFk = c.id - AND (volume <= o.volumeLimit OR o.volumeLimit IS NULL) WHERE o.workerFk = vUserFk; IF vCollectionFk IS NULL THEN CALL collection_new(vUserFk, vCollectionFk); END IF; - UPDATE `collection` + UPDATE collection SET workerFk = vUserFk WHERE id = vCollectionFk; + CALL itemShelvingSale_addByCollection(vCollectionFk); + DO RELEASE_LOCK(vLockName); END ;; DELIMITER ; @@ -51118,160 +51421,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collection_assign2` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_assign2`( - vUserFk INT, - OUT vCollectionFk INT -) -proc:BEGIN -/** - * Comprueba si existen colecciones libres que se ajustan - * al perfil del usuario y le asigna la más antigua. - * Añade un registro al semillero de colecciones. - * - * @param vUserFk Id de usuario - * @param vCollectionFk Id de colección - */ - DECLARE vHasTooMuchCollections BOOL; - DECLARE vLockTime INT DEFAULT 15; - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - DO RELEASE_LOCK('collection_assign2'); - - RESIGNAL; - END; - - -- Si hay colecciones sin terminar, sale del proceso - CALL collection_get(vUserFk); - - SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0 - INTO vHasTooMuchCollections - FROM tCollection - JOIN productionConfig pc ; - - DROP TEMPORARY TABLE tCollection; - - IF vHasTooMuchCollections THEN - CALL util.throw('Hay colecciones pendientes'); - LEAVE proc; - END IF; - - IF NOT GET_LOCK('collection_assign2',vLockTime) THEN - LEAVE proc; - END IF; - - -- Se eliminan las colecciones sin asignar que estan obsoletas - INSERT INTO ticketTracking(stateFk, ticketFk) - SELECT s.id, tc.ticketFk - FROM `collection` c - JOIN ticketCollection tc ON tc.collectionFk = c.id - JOIN `state` s ON s.code = 'PRINTED_AUTO' - JOIN productionConfig pc - WHERE c.workerFk IS NULL - AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime; - - DELETE c.* - FROM `collection` c - JOIN productionConfig pc - WHERE c.workerFk IS NULL - AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime; - - -- Se añade registro al semillero - INSERT INTO collectionHotbed(userFk) - VALUES(vUserFk); - - -- Comprueba si hay colecciones disponibles que se ajustan a su configuracion - SELECT MIN(c.id) - INTO vCollectionFk - FROM `collection` c - JOIN operator o - ON (o.itemPackingTypeFk = c.itemPackingTypeFk OR c.itemPackingTypeFk IS NULL) - AND o.numberOfWagons = c.wagons - AND o.trainFk = c.trainFk - AND o.warehouseFk = c.warehouseFk - AND c.workerFk IS NULL - AND (c.saleTotalCount <= o.linesLimit OR o.linesLimit IS NULL) - JOIN ( - SELECT tc.collectionFk, SUM(sv.volume) volume - FROM ticketCollection tc - JOIN saleVolume sv ON sv.ticketFk = tc.ticketFk - WHERE sv.shipped >= util.VN_CURDATE() - GROUP BY tc.collectionFk - ) sub ON sub.collectionFk = c.id - AND (volume <= o.volumeLimit OR o.volumeLimit IS NULL) - WHERE o.workerFk = vUserFk; - - IF vCollectionFk IS NULL THEN - CALL collection_new(vUserFk, vCollectionFk); - END IF; - - UPDATE `collection` - SET workerFk = vUserFk - WHERE id = vCollectionFk; - - DO RELEASE_LOCK('collection_assign2'); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collection_get` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_get`(vWorkerFk INT) -BEGIN -/** - * Obtiene colección del sacador si tiene líneas pendientes. - * - * @param vWorkerFk id del worker. - * @table Devuelve tabla temporal con las colecciones pendientes - */ - DROP TEMPORARY TABLE IF EXISTS tCollection; - - CREATE TEMPORARY TABLE tCollection - SELECT c.id collectionFk, - date(c.created) created, - COUNT(DISTINCT tc.ticketFk) ticketTotalCount - FROM collection c - JOIN ticketCollection tc ON tc.collectionFk = c.id - JOIN sale s ON s.ticketFk = tc.ticketFk - JOIN ticketState ts ON ts.ticketFk = tc.ticketFk - JOIN state s2 ON s2.id = ts.stateFk - JOIN productionConfig pc - JOIN vn.state ss on ss.code = 'PREPARED' - LEFT JOIN vn.saleTracking st on st.saleFk = s.id AND st.stateFk = ss.id - WHERE c.workerFk = vWorkerFk - AND TIMESTAMPDIFF(HOUR, c.created , util.VN_NOW()) < pc.pendingCollectionsAge - AND s.quantity != 0 - AND s2.order < pc.pendingCollectionsOrder - GROUP BY c.id - HAVING COUNT(*) > COUNT(DISTINCT st.id); - - SELECT * FROM tCollection; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `collection_getTickets` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51280,65 +51429,92 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_getTickets`(vParamFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_getTickets`(vParamFk INT) BEGIN /** - * Selecciona los tickets de una colección/ticket - * @param vParamFk ticketFk/collectionFk - * @return Retorna ticketFk, level, agencyName, warehouseFk, salesPersonFk, observaciones + * Selecciona los tickets de una colección/ticket/sectorCollection + * @param vParamFk ticketFk/collectionFk/sectorCollection + * @return Retorna ticketFk, level, agencyName, warehouseFk, salesPersonFk, observation */ DECLARE vItemPackingTypeFk VARCHAR(1); + DECLARE vYesterday DATE; -- Si los sacadores son los de pruebas, pinta los colores - SELECT itemPackingTypeFk INTO vItemPackingTypeFk - FROM vn.collection + SELECT itemPackingTypeFk + INTO vItemPackingTypeFk + FROM collection WHERE id = vParamFk; + + SET vYesterday = util.yesterday(); - SELECT t.id ticketFk, - IF (!(vItemPackingTypeFk <=> 'V'), cc.code,CONCAT(SUBSTRING('ABCDEFGH',tc.wagon, 1),'-',tc.`level` )) `level`, - am.name agencyName, - t.warehouseFk, - w.id salesPersonFk, - IFNULL(tob.description,'') observaciones, - cc.rgb - FROM vn.ticket t - LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk - LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk -- PAK 23/12/21 - LEFT JOIN vn.collectionColors cc - ON cc.wagon = tc.wagon - AND cc.shelve = tc.`level` - AND cc.trainFk = c2.trainFk -- PAK 23/12/21 - LEFT JOIN vn.zone z ON z.id = t.zoneFk - LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk - LEFT JOIN vn.client c ON c.id = t.clientFk - LEFT JOIN vn.worker w ON w.id = c.salesPersonFk - LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id - AND tob.observationTypeFk = 1 - WHERE t.id = vParamFk - AND t.shipped >= util.yesterday() - UNION ALL + WITH observation AS ( + SELECT tob.ticketFk, tob.description + FROM vn.ticketObservation tob + JOIN vn.ticketCollection tc ON tc.ticketFk = tob.ticketFk + LEFT JOIN vn.observationType ot ON ot.id = tob.observationTypeFk + WHERE ot.`code` = 'itemPicker' + AND tc.collectionFk = vParamFk OR tc.ticketFk = vParamFk + ) SELECT t.id ticketFk, IF(!(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`, am.name agencyName, t.warehouseFk, - w.id salesPersonFk, - IFNULL(tob.description, '') observaciones, - IF(!(vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb` + w.id salesPersonFk, + IFNULL(ob.description,'') observaciones, + cc.rgb FROM vn.ticket t - JOIN vn.ticketCollection tc ON t.id = tc.ticketFk - LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk -- PAK 23/12/21 + LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk + LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk LEFT JOIN vn.collectionColors cc ON cc.wagon = tc.wagon - AND cc.shelve = tc.`level` - AND cc.trainFk = c2.trainFk -- PAK 23/12/21 + AND cc.shelve = tc.`level` + AND cc.trainFk = c2.trainFk LEFT JOIN vn.zone z ON z.id = t.zoneFk LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk LEFT JOIN vn.client c ON c.id = t.clientFk LEFT JOIN vn.worker w ON w.id = c.salesPersonFk - LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id - AND tob.observationTypeFk = 1 - WHERE tc.collectionFk = vParamFk; - + LEFT JOIN observation ob ON ob.ticketFk = t.id + WHERE t.id = vParamFk + AND t.shipped >= vYesterday + UNION ALL + SELECT t.id ticketFk, + IF(NOT(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`, + am.name agencyName, + t.warehouseFk, + w.id salesPersonFk, + ob.description, + IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb` + FROM vn.ticket t + JOIN vn.ticketCollection tc ON t.id = tc.ticketFk + LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk + LEFT JOIN vn.collectionColors cc + ON cc.wagon = tc.wagon + AND cc.shelve = tc.`level` + AND cc.trainFk = c2.trainFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN vn.worker w ON w.id = c.salesPersonFk + LEFT JOIN observation ob ON ob.ticketFk = t.id + WHERE tc.collectionFk = vParamFk + UNION ALL + SELECT sg.ticketFk, + NULL `level`, + am.name agencyName, + t.warehouseFk, + c.salesPersonFk, + ob.description, + NULL `rgb` + FROM vn.sectorCollection sc + JOIN vn.sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id + JOIN vn.saleGroup sg ON sg.id = ss.saleGroupFk + JOIN vn.ticket t ON t.id = sg.ticketFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN observation ob ON ob.ticketFk = t.id + LEFT JOIN vn.client c ON c.id = t.clientFk + WHERE sc.id = vParamFk + AND t.shipped >= vYesterday; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -51355,7 +51531,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_kill`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_kill`(vSelf INT) BEGIN /** * Elimina una coleccion y coloca sus tickets en OK @@ -51384,7 +51560,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_make`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_make`() proc:BEGIN /** * Genera colecciones de tickets sin asignar trabajador a partir de la tabla @@ -51457,6 +51633,48 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `collection_mergeSales` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_mergeSales`(vCollectionFk INT) +BEGIN + DECLARE vDone BOOL; + DECLARE vTicketFk INT; + + DECLARE vTickets CURSOR FOR + SELECT ticketFk + FROM ticketCollection + WHERE collectionFk = vCollectionFk; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + OPEN vTickets; + l: LOOP + SET vDone = FALSE; + + FETCH vTickets INTO vTicketFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL ticket_mergeSales(vTicketFk); + END LOOP; + CLOSE vTickets; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `collection_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51465,7 +51683,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_new`(vUserFk INT, OUT vCollectionFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_new`(vUserFk INT, OUT vCollectionFk INT) BEGIN /** * Genera colecciones de tickets sin asignar trabajador. @@ -51475,10 +51693,11 @@ BEGIN DECLARE vWarehouseFk INT; DECLARE vWagons INT; DECLARE vTrainFk INT; - DECLARE vLinesLimit INT DEFAULT NULL; + DECLARE vLinesLimit INT; DECLARE vTicketLines INT; - DECLARE vVolumeLimit DECIMAL DEFAULT NULL; + DECLARE vVolumeLimit DECIMAL; DECLARE vTicketVolume DECIMAL; + DECLARE vSizeLimit INT; DECLARE vMaxTickets INT; DECLARE vStateFk VARCHAR(45); DECLARE vFirstTicketFk INT; @@ -51494,6 +51713,8 @@ BEGIN DECLARE vLockName VARCHAR(215); DECLARE vLockTime INT DEFAULT 30; DECLARE vFreeWagonFk INT; + DECLARE vErrorNumber INT; + DECLARE vErrorMsg TEXT; DECLARE c1 CURSOR FOR SELECT ticketFk, `lines`, m3 @@ -51513,10 +51734,21 @@ BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN + GET DIAGNOSTICS CONDITION 1 + vErrorNumber = MYSQL_ERRNO, + vErrorMsg = MESSAGE_TEXT; + + CALL util.debugAdd('collection_new', JSON_OBJECT( + 'errorNumber', vErrorNumber, + 'errorMsg', vErrorMsg, + 'lockName', vLockName, + 'userFk', vUserFk, + 'ticketFk', vTicketFk + )); -- Tmp + IF vLockName IS NOT NULL THEN DO RELEASE_LOCK(vLockName); END IF; - RESIGNAL; END; @@ -51530,6 +51762,7 @@ BEGIN o.trainFk, o.linesLimit, o.volumeLimit, + o.sizeLimit, pc.collection_new_lockname INTO vMaxTickets, vHasUniqueCollectionTime, @@ -51541,6 +51774,7 @@ BEGIN vTrainFk, vLinesLimit, vVolumeLimit, + vSizeLimit, vLockName FROM productionConfig pc JOIN worker w ON w.id = vUserFk @@ -51625,6 +51859,14 @@ BEGIN JOIN state s ON s.id = pb.state JOIN agencyMode am ON am.id = pb.agencyModeFk JOIN agency a ON a.id = am.agencyFk + LEFT JOIN ( + SELECT pb.ticketFk, MAX(i.`size`) maxSize + FROM tmp.productionBuffer pb + JOIN ticket t ON t.id = pb.ticketfk + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + GROUP BY pb.ticketFk + ) sub ON sub.ticketFk = pb.ticketFk JOIN productionConfig pc WHERE pb.shipped <> util.VN_CURDATE() OR (pb.ubicacion IS NULL AND a.isOwn) @@ -51636,8 +51878,10 @@ BEGIN OR (NOT pb.V AND vItemPackingTypeFk = 'V') OR (pc.isPreviousPreparationRequired AND pb.previousWithoutParking) OR LENGTH(pb.problem) > 0 - OR (pb.lines >= vLinesLimit AND vLinesLimit IS NOT NULL) - OR (pb.m3 >= vVolumeLimit AND vVolumeLimit IS NOT NULL); + OR pb.lines > vLinesLimit + OR pb.m3 > vVolumeLimit + OR sub.maxSize > vSizeLimit + OR pb.hasPlantTray; END IF; -- Es importante que el primer ticket se coja en todos los casos @@ -51824,7 +52068,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_printSticker`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_printSticker`( vSelf INT, vLabelCount INT ) @@ -51870,18 +52114,21 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_setParking`(IN `vCollectionFk` VARCHAR(8), IN `vParkingFk` INT) -proc: BEGIN +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_setParking`( + vSelf INT, + vParkingFk INT +) +BEGIN /** * Aparca una colección en un parking. * - * @param vCollectionFk Id de la colección - * @param vParkingFk Id del parking + * @param vSelf Id colección + * @param vParkingFk Id parking */ - REPLACE vn.ticketParking(ticketFk, parkingFk) + REPLACE ticketParking(ticketFk, parkingFk) SELECT tc.ticketFk, vParkingFk - FROM vn.ticketCollection tc - WHERE tc.collectionFk = vCollectionFk; + FROM ticketCollection tc + WHERE tc.collectionFk = vSelf; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -51898,7 +52145,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_setState`(vSelf INT, vStateCode VARCHAR(255) COLLATE utf8_general_ci) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_setState`(vSelf INT, vStateCode VARCHAR(255) COLLATE utf8_general_ci) BEGIN /** * Modifica el estado de los tickets de una colección. @@ -51955,7 +52202,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `company_getFiscaldata`(workerFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `company_getFiscaldata`(workerFk INT) BEGIN DECLARE vCompanyFk INT; @@ -51963,7 +52210,7 @@ DECLARE vCompanyFk INT; SELECT IFNULL(uc.companyFk, rc.defaultCompanyFk) INTO vCompanyFk FROM vn.routeConfig rc - LEFT JOIN userConfig uc ON uc.userFk = workerFk; + LEFT JOIN userMultiConfig uc ON uc.userFk = workerFk; SELECT @@ -51993,7 +52240,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `company_getSuppliersDebt`(vSelf INT, vMonthsAgo INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `company_getSuppliersDebt`(vSelf INT, vMonthsAgo INT) BEGIN /** * Generates a temporary table containing outstanding payments to suppliers. @@ -52182,11 +52429,12 @@ BEGIN FROM tPendingDuedates vp LEFT JOIN supplier s ON s.id = vp.supplierFk LEFT JOIN client c ON c.fi = s.nif - LEFT JOIN clientRisk cr ON cr.clientFk = c.id + LEFT JOIN clientRisk cr ON cr.clientFk = c.id AND cr.companyFk = vp.companyFk LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk - LEFT JOIN country co ON co.id = be.countryFk; + LEFT JOIN country co ON co.id = be.countryFk + GROUP BY vp.id; DROP TEMPORARY TABLE tOpeningBalances; DROP TEMPORARY TABLE tPendingDuedates; @@ -52207,7 +52455,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `comparative_add`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `comparative_add`() BEGIN /** * Inserts sales records less than one month old in comparative. @@ -52279,7 +52527,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `confection_controlSource`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `confection_controlSource`( vDated DATE, vScopeDays INT, vMaxAlertLevel INT, @@ -52395,7 +52643,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `conveyorExpedition_Add`(vStarted DATETIME, vEnded DATETIME) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `conveyorExpedition_Add`(vStarted DATETIME, vEnded DATETIME) BEGIN @@ -52420,7 +52668,7 @@ BEGIN 10 * p.height as height, IFNULL(t.routeFk,am.agencyFk) routeFk, hour(e.created) * 60 + minute(e.created), - IFNULL(et.description , a.name), + IFNULL(rs.description , a.name), IFNULL(t.routeFk,am.agencyFk) criterion, IFNULL(p.conveyorBuildingClassFk , pc.defaultConveyorBuildingClass) FROM vn.expedition e @@ -52430,7 +52678,7 @@ BEGIN LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk LEFT JOIN vn.agency a ON a.id = am.agencyFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk JOIN vn.packagingConfig pc WHERE t.warehouseFk IN (60,1,44) AND e.created BETWEEN vStarted AND vEnded @@ -52460,7 +52708,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `copyComponentsFromSaleList`(vTargetTicketFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `copyComponentsFromSaleList`(vTargetTicketFk INT) BEGIN /* Copy sales and components to the target ticket @@ -52477,9 +52725,9 @@ BEGIN SET @order = 0; - DROP TEMPORARY TABLE IF EXISTS tmp.newSaleList; + DROP TEMPORARY TABLE IF EXISTS tNewSaleList; - CREATE TEMPORARY TABLE tmp.newSaleList + CREATE TEMPORARY TABLE tNewSaleList SELECT id as saleFk, @order := @order + 1 as orden FROM vn.sale WHERE ticketFk = vTargetTicketFk @@ -52489,8 +52737,9 @@ BEGIN SELECT ns.saleFk, sc.componentFk, sc.value FROM vn.saleComponent sc JOIN tmp.saleList s ON s.saleFk = sc.saleFk - JOIN tmp.newSaleList ns ON ns.orden = s.orden; + JOIN tNewSaleList ns ON ns.orden = s.orden; + DROP TEMPORARY TABLE tNewSaleList; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -52507,7 +52756,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `createPedidoInterno`(vItemFk INT,vQuantity INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `createPedidoInterno`(vItemFk INT,vQuantity INT) BEGIN @@ -52529,7 +52778,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `creditInsurance_getRisk`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `creditInsurance_getRisk`() BEGIN /** * Devuelve el riesgo de los clientes que estan asegurados @@ -52540,7 +52789,7 @@ BEGIN SELECT * FROM ( SELECT cc.client clientFk, ci.grade FROM creditClassification cc - JOIN creditInsurance ci ON cc.id = ci.creditClassification + JOIN creditInsurance ci ON cc.id = ci.creditClassificationFk WHERE dateEnd IS NULL ORDER BY ci.creationDate DESC LIMIT 10000000000000000000) t1 @@ -52557,7 +52806,7 @@ BEGIN cac.invoiced billedAnnually, c.dueDay, cgd.grade, - c2.country + c2.name country FROM tmp.clientGetDebt cgd LEFT JOIN tmp.risk r ON r.clientFk = cgd.clientFk JOIN client c ON c.id = cgd.clientFk @@ -52584,7 +52833,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `creditRecovery`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `creditRecovery`() BEGIN /** * Actualiza el crédito de los clientes @@ -52651,7 +52900,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `crypt`(vText VARCHAR(255), vKey VARCHAR(255), OUT vResult VARCHAR(255) ) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `crypt`(vText VARCHAR(255), vKey VARCHAR(255), OUT vResult VARCHAR(255) ) BEGIN DECLARE vEncryptedText VARCHAR(255) DEFAULT ''; @@ -52721,7 +52970,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `cryptOff`(vText VARCHAR(255), vKey VARCHAR(255), OUT vResult VARCHAR(255)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `cryptOff`(vText VARCHAR(255), vKey VARCHAR(255), OUT vResult VARCHAR(255)) BEGIN DECLARE vUncryptedText VARCHAR(255) DEFAULT ''; @@ -52788,7 +53037,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `department_calcTree`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `department_calcTree`() BEGIN /** * Calculates the #path, #lft, #rgt, #sons and #depth columns of @@ -52832,7 +53081,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `department_calcTreeRec`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `department_calcTreeRec`( vSelf INT, vPath VARCHAR(255), vDepth INT, @@ -52914,7 +53163,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `department_doCalc`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `department_doCalc`() proc: BEGIN /** * Recalculates the department tree. @@ -52956,7 +53205,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `department_getHasMistake`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `department_getHasMistake`() BEGIN /** @@ -52985,7 +53234,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `department_getLeaves`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `department_getLeaves`( vParentFk INT, vSearch VARCHAR(255) ) @@ -53076,7 +53325,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `deviceLog_add`(vWorkerFk INT, vAppName VARCHAR(45), vAppVersion VARCHAR(45), vAndroid_id VARCHAR(64)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `deviceLog_add`(vWorkerFk INT, vAppName VARCHAR(45), vAppVersion VARCHAR(45), vAndroid_id VARCHAR(64)) BEGIN /** * Inserta registro en tabla devicelog el log del usuario conectado. @@ -53104,7 +53353,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `deviceProductionUser_exists`(vUserFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `deviceProductionUser_exists`(vUserFk INT) BEGIN /* SELECT COUNT(*) AS UserExists @@ -53128,7 +53377,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `deviceProductionUser_getWorker`(vAndroid_id VARCHAR(64)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `deviceProductionUser_getWorker`(vAndroid_id VARCHAR(64)) BEGIN /** * Selecciona si hay registrado un device con un android_id @@ -53155,7 +53404,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `deviceProduction_getnameDevice`(vAndroid_id VARCHAR(64)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `deviceProduction_getnameDevice`(vAndroid_id VARCHAR(64)) BEGIN /** * Selecciona el id del dispositivo que corresponde al vAndroid_id. @@ -53181,7 +53430,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `device_checkLogin`(vUserFk INT, vAndroidID VARCHAR(50)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `device_checkLogin`(vUserFk INT, vAndroidID VARCHAR(50)) BEGIN /* @@ -53237,7 +53486,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `duaEntryValueUpdate`(vDuaFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `duaEntryValueUpdate`(vDuaFk INT) BEGIN UPDATE duaEntry de @@ -53278,19 +53527,22 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `duaInvoiceInBooking`(vDuaFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `duaInvoiceInBooking`( + vDuaFk INT +) BEGIN /** * Genera el asiento de un DUA y marca las entradas como confirmadas * * @param vDuaFk Id del dua a recalcular */ - DECLARE done BOOL DEFAULT FALSE; + DECLARE vDone BOOL DEFAULT FALSE; DECLARE vInvoiceFk INT; - DECLARE vASIEN BIGINT DEFAULT 0; - DECLARE vCounter INT DEFAULT 0; + DECLARE vBookEntry INT; + DECLARE vFiscalYear INT; + DECLARE vIncorrectInvoiceInDueDay INT; - DECLARE rs CURSOR FOR + DECLARE vInvoicesIn CURSOR FOR SELECT DISTINCT e.invoiceInFk FROM entry e JOIN duaEntry de ON de.entryFk = e.id @@ -53299,9 +53551,20 @@ BEGIN AND de.customsValue AND ii.isBooked = FALSE; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - OPEN rs; + SELECT GROUP_CONCAT(ii.id) INTO vIncorrectInvoiceInDueDay + FROM invoiceInDueDay iidd + JOIN invoiceIn ii ON iidd.invoiceInFk = ii.id + JOIN `entry` e ON e.invoiceInFk = ii.id + JOIN duaEntry de ON de.entryFk = e.id + JOIN invoiceInConfig iic + WHERE de.duaFk = vDuaFk + AND iidd.dueDated < util.VN_CURDATE() + INTERVAL iic.dueDateMarginDays DAY; + + IF vIncorrectInvoiceInDueDay THEN + CALL util.throw(CONCAT('Incorrect due date, invoice: ', vIncorrectInvoiceInDueDay)); + END IF; UPDATE invoiceIn ii JOIN entry e ON e.invoiceInFk = ii.id @@ -53310,49 +53573,68 @@ BEGIN SET ii.booked = IFNULL(ii.booked, d.booked), ii.operated = IFNULL(ii.operated, d.operated), ii.issued = IFNULL(ii.issued, d.issued), - ii.bookEntried = IFNULL(ii.bookEntried, d.bookEntried), - e.isBooked = TRUE, - e.isConfirmed = TRUE + ii.bookEntried = IFNULL(ii.bookEntried, d.bookEntried) WHERE d.id = vDuaFk; - SELECT IFNULL(ASIEN,0) INTO vASIEN - FROM dua - WHERE id = vDuaFk; + SELECT ASIEN INTO vBookEntry FROM dua WHERE id = vDuaFk; - FETCH rs INTO vInvoiceFk; + IF vBookEntry IS NULL THEN + SELECT YEAR(IFNULL(ii.bookEntried, d.bookEntried)) INTO vFiscalYear + FROM invoiceIn ii + JOIN `entry` e ON e.invoiceInFk = ii.id + JOIN duaEntry de ON de.entryFk = e.id + JOIN dua d ON d.id = de.duaFk + WHERE d.id = vDuaFk + LIMIT 1; + CALL ledger_nextTx(vFiscalYear, vBookEntry); + END IF; - WHILE NOT done DO + OPEN vInvoicesIn; - CALL invoiceIn_booking(vInvoiceFk); - - IF vCounter > 0 OR vASIEN > 0 THEN - - UPDATE XDiario x - JOIN ledgerConfig lc ON lc.lastBookEntry = x.ASIEN - SET x.ASIEN = vASIEN; - - ELSE - - SELECT lastBookEntry INTO vASIEN FROM ledgerConfig; + l: LOOP + SET vDone = FALSE; + FETCH vInvoicesIn INTO vInvoiceFk; + IF vDone THEN + LEAVE l; END IF; - SET vCounter = vCounter + 1; + CALL invoiceIn_booking(vInvoiceFk, vBookEntry); + END LOOP; - FETCH rs INTO vInvoiceFk; - - END WHILE; - - CLOSE rs; + CLOSE vInvoicesIn; UPDATE dua - SET ASIEN = vASIEN + SET ASIEN = vBookEntry WHERE id = vDuaFk; UPDATE invoiceIn ii JOIN duaInvoiceIn dii ON dii.invoiceInFk = ii.id SET ii.isBooked = TRUE WHERE dii.duaFk = vDuaFk; + + UPDATE `entry` e + JOIN ( + WITH entries AS ( + SELECT e.id, de.duaFk + FROM vn.`entry` e + JOIN vn.duaEntry de ON de.entryFk = e.id + WHERE de.duaFk = vDuaFk + AND (NOT e.isBooked OR NOT e.isConfirmed) + ), + notBookedEntries AS ( + SELECT entryFk + FROM vn.duaEntry + WHERE duaFk = vDuaFk + AND NOT customsValue + ) + SELECT e.id + FROM entries e + LEFT JOIN notBookedEntries nbe ON nbe.entryFk = e.id + WHERE nbe.entryFk IS NULL + ) sub ON sub.id = e.id + SET e.isBooked = TRUE, + e.isConfirmed = TRUE; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -53369,7 +53651,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `duaParcialMake`(vDuaFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `duaParcialMake`(vDuaFk INT) BEGIN DECLARE vNewDuaFk INT; @@ -53403,130 +53685,124 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `duaTaxBooking`(vDuaFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `duaTaxBooking`(vDuaFk INT) BEGIN DECLARE vBookNumber INT; - DECLARE vBookDated DATE; - DECLARE vDiff DECIMAL(10,2); - DECLARE vApunte BIGINT; - - SELECT ASIEN, IFNULL(bookEntried, util.VN_CURDATE()) INTO vBookNumber, vBookDated - FROM dua + DECLARE vBookDated DATE; + DECLARE vDiff DECIMAL(10,2); + DECLARE vApunte BIGINT; + + SELECT ASIEN, IFNULL(bookEntried, util.VN_CURDATE()) + INTO vBookNumber, vBookDated + FROM dua WHERE id = vDuaFk; - + IF vBookNumber IS NULL OR NOT vBookNumber THEN - CALL ledger_next(vBookNumber); + CALL ledger_nextTx(YEAR(vBookDated), vBookNumber); END IF; -- Apunte de la aduana - INSERT INTO XDiario( - ASIEN, - FECHA, - SUBCTA, - CONCEPTO, - EUROHABER, - SERIE, - empresa_id, - CLAVE, - FACTURA) + ASIEN, + FECHA, + SUBCTA, + CONCEPTO, + EUROHABER, + SERIE, + empresa_id, + CLAVE, + FACTURA) + SELECT vBookNumber, + d.bookEntried, + '4700000999', + CONCAT('DUA ',d.`code`), + sum(dt.base * dt.rate / 100) EUROHABER, + 'R', + d.companyFk, + vDuaFk, + vDuaFk + FROM duaTax dt + JOIN dua d ON d.id = dt.duaFk + WHERE dt.duaFk = vDuaFk; - SELECT - vBookNumber, - d.bookEntried, - '4700000999', - CONCAT('DUA ',d.`code`), - sum(dt.base * dt.rate / 100) EUROHABER, - 'R', - d.companyFk, - vDuaFk, - vDuaFk - FROM duaTax dt - JOIN dua d ON d.id = dt.duaFk - WHERE dt.duaFk = vDuaFk; - - -- Apuntes por tipo de IVA y proveedor - - INSERT INTO XDiario( - ASIEN, - FECHA, - SUBCTA, - CONTRA, - EURODEBE, - BASEEURO, - CONCEPTO, - FACTURA, - IVA, - AUXILIAR, - SERIE, - FECHA_EX, - FECHA_OP, - FACTURAEX, - NFACTICK, - L340, - LDIFADUAN, - TIPOCLAVE, - TIPOEXENCI, - TIPONOSUJE, - TIPOFACT, - TIPORECTIF, - TERIDNIF, - TERNIF, - TERNOM, - empresa_id, - FECREGCON - ) - - SELECT - vBookNumber ASIEN, - vBookDated FECHA, - tr.account SUBCTA, - '4330002067' CONTRA, - sum(dt.tax) EURODEBE, - sum(dt.base) BASEEURO, - CONCAT('DUA nº',d.code) CONCEPTO, - d.id FACTURA, - dt.rate IVA, - '*' AUXILIAR, - 'D' SERIE, - d.issued FECHA_EX, - d.operated FECHA_OP, - d.code FACTURAEX, - 1 NFACTICK, - 1 L340, - TRUE LDIFADUAN, - 1 TIPOCLAVE, - 1 TIPOEXENCI, - 1 TIPONOSUJE, - 5 TIPOFACT, - 1 TIPORECTIF, - IF(c.code = 'ES', 1, 4) TERIDNIF, - s.nif TERNIF, - s.name TERNOM, - d.companyFk, - d.booked FECREGCON - FROM duaTax dt - JOIN dua d ON dt.duaFk = d.id - JOIN (SELECT account, rate - FROM - (SELECT rate, account - FROM invoiceInTaxBookingAccount ta - WHERE ta.effectived <= vBookDated - AND taxAreaFk = 'WORLD' - ORDER BY ta.effectived DESC - LIMIT 10000000000000000000 - ) tba - GROUP BY rate + -- Apuntes por tipo de IVA y proveedor + INSERT INTO XDiario( + ASIEN, + FECHA, + SUBCTA, + CONTRA, + EURODEBE, + BASEEURO, + CONCEPTO, + FACTURA, + IVA, + AUXILIAR, + SERIE, + FECHA_EX, + FECHA_OP, + FACTURAEX, + NFACTICK, + L340, + LDIFADUAN, + TIPOCLAVE, + TIPOEXENCI, + TIPONOSUJE, + TIPOFACT, + TIPORECTIF, + TERIDNIF, + TERNIF, + TERNOM, + empresa_id, + FECREGCON) + SELECT vBookNumber ASIEN, + vBookDated FECHA, + tr.account SUBCTA, + '4330002067' CONTRA, + SUM(dt.tax) EURODEBE, + SUM(dt.base) BASEEURO, + CONCAT('DUA nº',d.code) CONCEPTO, + d.id FACTURA, + dt.rate IVA, + '*' AUXILIAR, + 'D' SERIE, + d.issued FECHA_EX, + d.operated FECHA_OP, + d.code FACTURAEX, + 1 NFACTICK, + 1 L340, + TRUE LDIFADUAN, + 1 TIPOCLAVE, + 1 TIPOEXENCI, + 1 TIPONOSUJE, + 5 TIPOFACT, + 1 TIPORECTIF, + IF(c.code = 'ES', 1, 4) TERIDNIF, + s.nif TERNIF, + s.name TERNOM, + d.companyFk, + d.booked FECREGCON + FROM duaTax dt + JOIN dua d ON dt.duaFk = d.id + JOIN (SELECT account, rate + FROM + (SELECT rate, account + FROM invoiceInTaxBookingAccount ta + WHERE ta.effectived <= vBookDated + AND taxAreaFk = 'WORLD' + ORDER BY ta.effectived DESC + LIMIT 10000000000000000000 + ) tba + GROUP BY rate ) tr ON tr.rate = dt.rate - JOIN supplier s ON s.id = d.companyFk - JOIN country c ON c.id = s.countryFk - WHERE d.id = vDuaFk - GROUP BY dt.rate; + JOIN supplier s ON s.id = d.companyFk + JOIN country c ON c.id = s.countryFk + WHERE d.id = vDuaFk + GROUP BY dt.rate; SELECT SUM(EURODEBE) -SUM(EUROHABER), MAX(id) INTO vDiff, vApunte FROM XDiario WHERE ASIEN = vBookNumber; - + UPDATE XDiario SET BASEEURO = 100 * (EURODEBE - vDiff) / IVA, EURODEBE = EURODEBE - vDiff @@ -53535,7 +53811,6 @@ BEGIN UPDATE dua SET ASIEN = vBookNumber WHERE id = vDuaFk; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -53552,7 +53827,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `duaTax_doRecalc`(vDuaFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `duaTax_doRecalc`(vDuaFk INT) BEGIN /** * Borra los valores de duaTax y los vuelve a crear en base a la tabla duaEntry @@ -53619,7 +53894,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ediTables_Update`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ediTables_Update`() BEGIN INSERT IGNORE INTO vn.genus(name) @@ -53645,7 +53920,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ektEntryAssign_setEntry`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ektEntryAssign_setEntry`() BEGIN DECLARE done INT DEFAULT FALSE; @@ -53770,7 +54045,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `energyMeter_record`(vInput INT, vActiveTime INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `energyMeter_record`(vInput INT, vActiveTime INT) BEGIN DECLARE vConsumption INT; @@ -53803,7 +54078,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entryDelivered`(vDated DATE, vEntryFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entryDelivered`(vDated DATE, vEntryFk INT) BEGIN DECLARE vTravelFk INT; @@ -53847,7 +54122,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entryWithItem`(vShipmentWarehouse INT, vLandingWarehouse INT,vSale INT, vVolume INT, netCost DECIMAL(10,2), vInOutDate DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entryWithItem`(vShipmentWarehouse INT, vLandingWarehouse INT,vSale INT, vVolume INT, netCost DECIMAL(10,2), vInOutDate DATE) BEGIN DECLARE vTravel INT; @@ -53906,7 +54181,7 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `entry_checkBooked` */; +/*!50003 DROP PROCEDURE IF EXISTS `entry_checkPackaging` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -53914,42 +54189,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_checkBooked`( - vSelf INT -) -BEGIN -/** - * Comprueba si una entrada está contabilizada, - * y si lo está retorna un throw. - * - * @param vSelf Id de entrada - */ - DECLARE vIsBooked BOOL; - - SELECT isBooked INTO vIsBooked - FROM `entry` - WHERE id = vSelf; - - IF vIsBooked AND NOT IFNULL(@isModeInventory, FALSE) THEN - CALL util.throw('Entry is already booked'); - END IF; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `entry_checkPackaging` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_checkPackaging`(vEntryFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_checkPackaging`(vEntryFk INT) BEGIN /** * Comprueba que los campos package y packaging no sean nulos @@ -53982,7 +54222,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_clone`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_clone`(vSelf INT) BEGIN /** * clones an entry. @@ -54015,7 +54255,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_cloneHeader`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_cloneHeader`( vSelf INT, OUT vNewEntryFk INT, vTravelFk INT @@ -54025,8 +54265,8 @@ BEGIN * Clones an entry header. * * @param vSelf The entry id + * @param OUT vNewEntryFk The new entry id * @param vTravelFk Travel for the new entry or %NULL to use the source entry travel - * @param vNewEntryFk The new entry id */ INSERT INTO entry( travelFk, @@ -54070,7 +54310,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_cloneWithoutBuy`(vSelf INT, OUT vNewEntryFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_cloneWithoutBuy`(vSelf INT, OUT vNewEntryFk INT) BEGIN /** * Clona una entrada sin compras @@ -54104,62 +54344,21 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_copyBuys`(vSelf INT, vCopyTo INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_copyBuys`(vSelf INT, vDestinationEntryFk INT) BEGIN /** - * Copies an entry buys to another buy. + * Copies all buys from an entry to an entry. * * @param vSelf The entry id - * @param vCopyTo The destination entry id + * @param vDestinationEntryFk The destination entry id */ - INSERT INTO buy( - entryFk, - itemFk, - quantity, - buyingValue, - freightValue, - isIgnored, - stickers, - packing, - `grouping`, - groupingMode, - containerFk, - comissionValue, - packageValue, - packagingFk, - price1, - price2, - price3, - minPrice, - isChecked, - location, - weight, - itemOriginalFk - ) - SELECT vCopyTo, - itemFk, - quantity, - buyingValue, - freightValue, - isIgnored, - stickers, - packing, - `grouping`, - groupingMode, - containerFk, - comissionValue, - packageValue, - packagingFk, - price1, - price2, - price3, - minPrice, - isChecked, - location, - weight, - itemOriginalFk + CREATE OR REPLACE TEMPORARY TABLE tmp.buy + SELECT id FROM buy WHERE entryFk = vSelf; + + CALL buy_clone(vDestinationEntryFk); + DROP TEMPORARY TABLE tmp.buy; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -54176,7 +54375,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_fixMisfit`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_fixMisfit`( vSelf INT ) BEGIN @@ -54203,7 +54402,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, location, @@ -54223,7 +54421,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, location, @@ -54254,7 +54451,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_getRate`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_getRate`(vSelf INT) BEGIN /** * Prepara una tabla con las tarifas aplicables en funcion de la fecha @@ -54288,7 +54485,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_getTransfer`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_getTransfer`( vSelf INT ) BEGIN @@ -54386,7 +54583,7 @@ BEGIN FROM tmp.itemList; END IF; - CALL buyUltimateFromInterval(vWarehouseIn,vInventoryDate, vDateLanded); + CALL buy_getUltimateFromInterval(NULL, vWarehouseIn,vInventoryDate, vDateLanded); CREATE OR REPLACE TEMPORARY TABLE tTransfer ENGINE = MEMORY @@ -54499,6 +54696,43 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `entry_isEditable` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_isEditable`( + vSelf INT +) +BEGIN +/** + * Comprueba si una entrada se puede actualizar + * si no se puede retorna un throw. + * + * @param vSelf Id de entrada + */ + DECLARE vIsEditable BOOL; + + SELECT e.isBooked INTO vIsEditable + FROM `entry` e + JOIN entryType et ON et.code = e.typeFk + WHERE NOT et.isInformal + AND e.id = vSelf; + + IF vIsEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN + CALL util.throw(CONCAT('Entry ', vSelf, ' is not editable')); + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `entry_lock` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54507,7 +54741,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_lock`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_lock`(vSelf INT) BEGIN /** * Lock the indicated entry @@ -54533,7 +54767,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_moveNotPrinted`(vSelf INT, +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_moveNotPrinted`(vSelf INT, vDays INT, vChangeEntry BOOL, OUT vNewEntryFk INT) @@ -54590,7 +54824,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, packagingFk, @@ -54611,7 +54844,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, packagingFk, @@ -54648,7 +54880,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, location, @@ -54667,7 +54898,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, location, @@ -54723,7 +54953,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_notifyChanged`(vSelf INT, vBuyFk INT, vOldValues VARCHAR(512), vNewValues VARCHAR(512)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_notifyChanged`(vSelf INT, vBuyFk INT, vOldValues VARCHAR(512), vNewValues VARCHAR(512)) BEGIN DECLARE vEmail VARCHAR(255); DECLARE vFields VARCHAR(100); @@ -54768,7 +54998,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_recalc`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_recalc`() BEGIN /** * Comprueba que las ventas creadas entre un rango de fechas tienen componentes @@ -54815,7 +55045,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_splitByShelving`(vShelvingFk VARCHAR(3), vFromEntryFk INT, vToEntryFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_splitByShelving`(vShelvingFk VARCHAR(3), vFromEntryFk INT, vToEntryFk INT) BEGIN /** * Divide las compras entre dos entradas de acuerdo con lo ubicado en una matr�cula @@ -54829,60 +55059,44 @@ BEGIN DECLARE vBuyStickers INT; DECLARE vDone BOOLEAN DEFAULT FALSE; - DECLARE cur CURSOR FOR + DECLARE cur CURSOR FOR SELECT bb.id buyFk, - FLOOR(ish.visible / ish.packing) ishStickers, + LEAST(bb.stickers, FLOOR(ish.visible / ish.packing)) ishStickers, bb.stickers buyStickers - FROM vn.itemShelving ish + FROM itemShelving ish JOIN (SELECT b.id, b.itemFk, b.stickers - FROM vn.buy b - WHERE b.entryFk = vFromEntryFk - ORDER BY b.stickers DESC - LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk - AND bb.stickers >= FLOOR(ish.visible / ish.packing) - WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci - GROUP BY ish.id; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - -- Cantidades de la matrícula que exceden la de las entradas - SELECT ish.itemFk, - i.longName, - FLOOR(ish.visible / ish.packing) AS etiEnMatricula, - bb.stickers etiEnEntrada - FROM vn.itemShelving ish - JOIN vn.item i ON i.id = ish.itemFk - LEFT JOIN (SELECT b.id, b.itemFk, b.stickers - FROM vn.buy b + FROM buy b WHERE b.entryFk = vFromEntryFk ORDER BY b.stickers DESC LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk - WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci - AND IFNULL(bb.stickers,0) < FLOOR(ish.visible / ish.packing) + WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci + AND NOT ish.isSplit GROUP BY ish.id; - + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + OPEN cur; read_loop: LOOP SET vDone = FALSE; FETCH cur INTO vBuyFk, vIshStickers, vBuyStickers; - + IF vDone THEN LEAVE read_loop; END IF; - + IF vIshStickers = vBuyStickers THEN - UPDATE vn.buy + UPDATE buy SET entryFk = vToEntryFk WHERE id = vBuyFk; ELSE - UPDATE vn.buy + UPDATE buy SET stickers = stickers - vIshStickers, quantity = stickers * packing WHERE id = vBuyFk; - - INSERT INTO vn.buy(entryFk, + + INSERT INTO buy(entryFk, itemFk, quantity, buyingValue, @@ -54892,7 +55106,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, location, @@ -54919,7 +55132,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, location, @@ -54935,13 +55147,16 @@ BEGIN weight, deliveryFk, itemOriginalFk - FROM vn.buy + FROM buy WHERE id = vBuyFk; UPDATE buy SET printedStickers = vIshStickers WHERE id = LAST_INSERT_ID(); END IF; - END LOOP; + UPDATE itemShelving + SET isSplit = TRUE + WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci; + END LOOP; CLOSE cur; END ;; DELIMITER ; @@ -54959,7 +55174,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_splitMisfit`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_splitMisfit`(vSelf INT) BEGIN /* Divide una entrada, pasando los registros que ha insertado vn.entry_fixMisfit de la entrada original @@ -55006,7 +55221,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_unlock`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_unlock`(vSelf INT) BEGIN /** * Unlock the indicated entry @@ -55032,7 +55247,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_updateComission`(vCurrency INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `entry_updateComission`(vCurrency INT) BEGIN /** * Actualiza la comision de las entradas de hoy a futuro y las recalcula @@ -55056,7 +55271,8 @@ BEGIN JOIN vn.travel t ON t.id = e.travelFk JOIN vn.warehouse w ON w.id = t.warehouseInFk WHERE t.shipped >= util.VN_CURDATE() - AND e.currencyFk = vCurrency; + AND e.currencyFk = vCurrency + AND NOT e.isBooked; SET vComission = currency_getCommission(vCurrency); @@ -55095,7 +55311,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionGetFromRoute`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `expeditionGetFromRoute`( vExpeditionFk INT) BEGIN /** @@ -55140,7 +55356,12 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_build`(IN vExpeditions JSON, IN vArcId INT, IN vWorkerFk INT, OUT vPalletFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `expeditionPallet_build`( + vExpeditions JSON, + vArcId INT, + vWorkerFk INT, + OUT vPalletFk INT +) BEGIN /** Construye un pallet de expediciones. * @@ -55148,28 +55369,22 @@ BEGIN * en cuyo caso actualiza ese pallet. * * @param vExpeditions JSON_ARRAY con esta estructura [exp1, exp2, exp3, ...] - * @param vArcId INT Identificador de vn.arcRead - * @param vWorkerFk INT Identificador de vn.worker - * @param out vPalletFk Identificador de vn.expeditionPallet + * @param vArcId INT Identificador de arcRead + * @param vWorkerFk INT Identificador de worker + * @param out vPalletFk Identificador de expeditionPallet */ DECLARE vCounter INT; DECLARE vExpeditionFk INT; DECLARE vTruckFk INT; DECLARE vPrinterFk INT; + DECLARE vExpeditionStateTypeFk INT; - DROP TEMPORARY TABLE IF EXISTS tExpedition; - CREATE TEMPORARY TABLE tExpedition - SELECT - e.id expeditionFk, - r.id routeFk, - ep.id palletFk - FROM - vn.expedition e, - vn.route r, - vn.expeditionPallet ep - LIMIT 0; - - ALTER TABLE tExpedition ADD PRIMARY KEY (expeditionFk); + CREATE OR REPLACE TEMPORARY TABLE tExpedition ( + expeditionFk INT, + routeFk INT, + palletFk INT, + PRIMARY KEY (expeditionFk) + ); SET vCounter = JSON_LENGTH(vExpeditions); @@ -55180,53 +55395,58 @@ BEGIN INSERT IGNORE INTO tExpedition(expeditionFk, routeFk, palletFk) SELECT vExpeditionFk, t.routeFk, es.palletFk - FROM vn.expedition e - LEFT JOIN vn.ticket t ON t.id = e.ticketFk - LEFT JOIN vn.expeditionScan es ON es.expeditionFk = e.id + FROM expedition e + LEFT JOIN ticket t ON t.id = e.ticketFk + LEFT JOIN expeditionScan es ON es.expeditionFk = e.id WHERE e.id = vExpeditionFk; END WHILE; SELECT palletFk INTO vPalletFk FROM ( - SELECT palletFk, count(*) n - FROM tExpedition - WHERE palletFk > 0 - GROUP BY palletFk - ORDER BY n DESC - LIMIT 100 ) sub + SELECT palletFk, count(*) n + FROM tExpedition + WHERE palletFk > 0 + GROUP BY palletFk + ORDER BY n DESC + LIMIT 100 + ) sub LIMIT 1; IF vPalletFk IS NULL THEN - SELECT expeditionTruckFk - INTO vTruckFk - FROM ( - SELECT rm.expeditionTruckFk, count(*) n - FROM vn.routesMonitor rm - JOIN tExpedition e ON e.routeFk = rm.routeFk - GROUP BY expeditionTruckFk - ORDER BY n DESC - LIMIT 1) sub; + SELECT roadmapStopFk INTO vTruckFk + FROM ( + SELECT rm.roadmapStopFk, count(*) n + FROM routesMonitor rm + JOIN tExpedition e ON e.routeFk = rm.routeFk + GROUP BY roadmapStopFk + ORDER BY n DESC + LIMIT 1 + ) sub; IF vTruckFk IS NULL THEN CALL util.throw ('TRUCK_NOT_AVAILABLE'); END IF; - INSERT INTO vn.expeditionPallet(truckFk) - VALUES(vTruckFk); + INSERT INTO expeditionPallet SET truckFk = vTruckFk; SET vPalletFk = LAST_INSERT_ID(); END IF; - INSERT INTO vn.expeditionScan(expeditionFk, palletFk, workerFk) + INSERT INTO expeditionScan(expeditionFk, palletFk, workerFk) SELECT expeditionFk, vPalletFk, vWorkerFk FROM tExpedition ON DUPLICATE KEY UPDATE palletFk = vPalletFk, workerFk = vWorkerFk; - SELECT printerFk INTO vPrinterFk - FROM vn.arcRead - WHERE id = vArcId; + SELECT id INTO vExpeditionStateTypeFk + FROM expeditionStateType + WHERE code = 'PALLETIZED'; - CALL vn.report_print( + INSERT INTO expeditionState(expeditionFk, typeFk) + SELECT expeditionFk, vExpeditionStateTypeFk FROM tExpedition; + + SELECT printerFk INTO vPrinterFk FROM arcRead WHERE id = vArcId; + + CALL report_print( 'LabelPalletExpedition', vPrinterFk, account.myUser_getId(), @@ -55234,7 +55454,7 @@ BEGIN 'high' ); - UPDATE vn.expeditionPallet SET isPrint = TRUE WHERE id = vPalletFk; + UPDATE expeditionPallet SET isPrint = TRUE WHERE id = vPalletFk; DROP TEMPORARY TABLE tExpedition; END ;; @@ -55253,7 +55473,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_Del`(vPalletFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `expeditionPallet_Del`(vPalletFk INT) BEGIN DELETE FROM vn.expeditionPallet @@ -55275,7 +55495,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_List`(vTruckFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `expeditionPallet_List`(vTruckFk INT) BEGIN SELECT ep.id Pallet, @@ -55295,16 +55515,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expeditionPallet_printLabel` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_printLabel`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `expeditionPallet_printLabel`(vSelf INT) BEGIN /** * Calls the report_print procedure and passes it @@ -55314,7 +55534,16 @@ BEGIN */ DECLARE vPrinterFk INT; DECLARE vUserFk INT DEFAULT account.myUser_getId(); - + DECLARE vIsInExpeditionPallet BOOL; + + SELECT COUNT(id) INTO vIsInExpeditionPallet + FROM expeditionPallet + WHERE id = vSelf; + + IF NOT vIsInExpeditionPallet THEN + CALL util.throw("ExpeditionPallet not exists"); + END IF; + SELECT o.labelerFk INTO vPrinterFk FROM operator o WHERE o.workerFk = vUserFk; @@ -55337,16 +55566,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expeditionPallet_View` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_View`(vPalletFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `expeditionPallet_View`(vPalletFk INT) BEGIN SELECT ep.id Pallet, @@ -55375,7 +55604,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionScan_Add`(vPalletFk INT, vTruckFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `expeditionScan_Add`(vPalletFk INT, vTruckFk INT) BEGIN DECLARE vTotal INT DEFAULT 0; @@ -55415,7 +55644,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionScan_Del`(vScanFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `expeditionScan_Del`(vScanFk INT) BEGIN DELETE FROM vn.expeditionScan @@ -55437,7 +55666,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionScan_List`(vPalletFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `expeditionScan_List`(vPalletFk INT) BEGIN SELECT es.id, @@ -55467,14 +55696,21 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionScan_Put`(vPalletFk INT, vExpeditionFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `expeditionScan_Put`( + vPalletFk INT, + vExpeditionFk INT +) BEGIN - - REPLACE vn.expeditionScan(expeditionFk, palletFk) - VALUES(vExpeditionFk, vPalletFk); - - SELECT LAST_INSERT_ID() INTO vPalletFk; - + IF NOT (SELECT TRUE FROM expedition WHERE id = vExpeditionFk LIMIT 1) THEN + CALL util.throw('Expedition not exists'); + END IF; + + IF NOT (SELECT TRUE FROM expeditionPallet WHERE id = vPalletFk LIMIT 1) THEN + CALL util.throw('Pallet not exists'); + END IF; + + REPLACE expeditionScan(expeditionFk, palletFk) + VALUES(vExpeditionFk, vPalletFk); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -55491,7 +55727,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_add`(vParam INT, vStateCode VARCHAR(100)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `expeditionState_add`(vParam INT, vStateCode VARCHAR(100)) BEGIN /** @@ -55535,7 +55771,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_addByAdress`(vAdressFk INT, vRouteFk INT, vStateCode VARCHAR(100)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `expeditionState_addByAdress`(vAdressFk INT, vRouteFk INT, vStateCode VARCHAR(100)) BEGIN /** @@ -55569,7 +55805,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_addByExpedition`(vExpeditionFk INT, vStateCode VARCHAR(100)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `expeditionState_addByExpedition`(vExpeditionFk INT, vStateCode VARCHAR(100)) BEGIN /** @@ -55600,7 +55836,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_addByPallet`(vPalletFk INT, vStateCode VARCHAR(100)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `expeditionState_addByPallet`(vPalletFk INT, vStateCode VARCHAR(100)) BEGIN /** * Inserta nuevos registros en la tabla vn.expeditionState @@ -55644,7 +55880,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionState_addByRoute`(vRouteFk INT, vStateCode VARCHAR(100)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `expeditionState_addByRoute`(vRouteFk INT, vStateCode VARCHAR(100)) BEGIN /** @@ -55669,53 +55905,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `expeditionTruck_Add` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionTruck_Add`(vHour VARCHAR(5), vDescription VARCHAR(45)) -BEGIN - - INSERT INTO vn.expeditionTruck(eta,description) - VALUES(CONCAT(util.VN_CURDATE(), ' ', vHour), vDescription); - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `expeditionTruck_List` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionTruck_List`() -BEGIN - - SELECT id truckFk, - eta, - description Destino - FROM expeditionTruck - WHERE eta BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) - ORDER BY eta; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `expedition_getFromRoute` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55724,7 +55913,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expedition_getFromRoute`(vRouteFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `expedition_getFromRoute`(vRouteFk INT) BEGIN /** * Obtiene las expediciones a partir de una ruta @@ -55740,7 +55929,8 @@ BEGIN t.addressFk, a.nickname, sub2.itemPackingTypeConcat, - est.code + est.code, + es.isScanned FROM expedition e JOIN ticket t ON t.id = e.ticketFk JOIN ticketState ts ON ts.ticketFk = e.ticketFk @@ -55758,6 +55948,10 @@ BEGIN GROUP BY sub.ticketFk ) sub2 ON sub2.ticketFk = t.id LEFT JOIN expeditionStateType est ON est.id = e.stateTypeFk + LEFT JOIN expeditionState es ON es.id = ( + SELECT MAX(id) + FROM expeditionState es + WHERE expeditionFk = e.id) WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE ORDER BY r.created, t.priority DESC; END ;; @@ -55776,7 +55970,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expedition_getState`(vExpeditionFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `expedition_getState`(vExpeditionFk INT) BEGIN DECLARE vTicketsPendientes INT; @@ -55814,8 +56008,8 @@ BEGIN am.name zonaRuta, t.routeFk ruta, rm.beachFk ubicacion, - et.eta , - et.description camion, + rs.eta , + rs.description camion, vTicketsPendientes AS ticketsPendientes, vEtiquetasTotales AS etiquetasTotales, vEtiquetasEscaneadas AS etiquetasEscaneadas @@ -55827,7 +56021,7 @@ BEGIN LEFT JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id - LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk WHERE e.id = vExpeditionFk; END ;; @@ -55846,7 +56040,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expedition_StateGet`(vExpeditionFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `expedition_StateGet`(vExpeditionFk INT) BEGIN /* Devuelve una "ficha" con todos los datos relativos a la expedición @@ -55900,8 +56094,8 @@ BEGIN am.name zonaRuta, t.routeFk ruta, rm.beachFk ubicacion, - et.eta , - et.description camion, + rs.eta , + rs.description camion, vTicketsPendientes AS ticketsPendientes, vEtiquetasTotales AS etiquetasTotales, vEtiquetasEscaneadas AS etiquetasEscaneadas, @@ -55914,7 +56108,7 @@ BEGIN LEFT JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id - LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk WHERE e.id = vExpeditionFk; END ;; @@ -55933,7 +56127,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `freelance_getInfo`(workerFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `freelance_getInfo`(workerFk INT) BEGIN SELECT s.name, s.street, s.city, s.nif, s.postCode FROM route r @@ -55944,120 +56138,6 @@ BEGIN WHERE r.workerFk = workerFk ORDER BY r.id DESC LIMIT 1; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `fv_pca` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `fv_pca`() -BEGIN - -DECLARE done INT DEFAULT FALSE; - -DECLARE vTicketFk INT; -DECLARE vSaleFk INT; -DECLARE vClonTicket INT DEFAULT 0; - -DECLARE cur1 CURSOR FOR -SELECT s.ticketFk, s.id - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - WHERE t.shipped BETWEEN '2020-10-18' AND '2020-10-31' - AND it.code IN ('ANT','ANS','ORQ','TRO') - and t.warehouseFk = 1; - -DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - -OPEN cur1; - -FETCH cur1 INTO vTicketFk, vSaleFk; - - WHILE done = 0 DO - - SELECT t.id INTO vClonTicket - FROM vn.ticket t - JOIN (SELECT addressFk, shipped FROM vn.ticket WHERE id = vTicketFk) sub USING(addressFk, shipped) - WHERE t.warehouseFk = 44 - LIMIT 1; - - SELECT vTicketFk, vClonTicket; - - IF vClonTicket = 0 THEN - - INSERT INTO ticket ( - clientFk, - shipped, - addressFk, - agencyModeFk, - nickname, - warehouseFk, - companyFk, - landed, - zoneFk, - zonePrice, - zoneBonus, - routeFk - ) - SELECT - clientFk, - shipped, - addressFk, - agencyModeFk, - nickname, - 44, - companyFk, - landed, - zoneFk, - zonePrice, - zoneBonus, - routeFk - - FROM ticket - WHERE id = vTicketFk; - - SET vClonTicket = LAST_INSERT_ID(); - - SELECT 'lstID', vClonTicket; - /* - INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) - SELECT vTicketFk, ao.observationTypeFk, ao.description - FROM addressObservation ao - JOIN ticket t ON t.addressFk = ao.addressFk - WHERE t.id = vClonTicket; -*/ - INSERT INTO ticketLog - SET originFk = vTicketFk, userFk = account.myUser_getId(), `action` = 'insert', - description = CONCAT('Ha creado el ticket:', ' ', vClonTicket, ' clonando el ', vTicketFk); - - END IF; - - UPDATE vn.sale - SET ticketFk = vClonTicket - WHERE id = vSaleFk; - - SET vClonTicket = 0; - - SET done = 0; - FETCH cur1 INTO vTicketFk, vSaleFk; - - END WHILE; - - CLOSE cur1; - - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -56074,7 +56154,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `getDayExpeditions`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `getDayExpeditions`() BEGIN SELECT @@ -56102,7 +56182,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `getInfoDelivery`(vRouteFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `getInfoDelivery`(vRouteFk INT) BEGIN SELECT s.name, s.street, s.city, s.nif, s.postCode FROM vn.route r JOIN vn.agencyMode am ON r.agencyModeFk = am.id @@ -56125,7 +56205,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `getPedidosInternos`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `getPedidosInternos`() BEGIN SELECT id,name as description,upToDown as quantity FROM vn.item WHERE upToDown; @@ -56137,16 +56217,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `getTaxBases` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `getTaxBases`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `getTaxBases`() BEGIN /** * Calcula y devuelve en número de bases imponibles postivas y negativas @@ -56191,7 +56271,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `greuge_add`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `greuge_add`() BEGIN /** * Group inserts into vn.greuge and then deletes the records just inserted @@ -56226,7 +56306,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `greuge_notifyEvents`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `greuge_notifyEvents`() BEGIN /** * Notify to detect wrong greuges. @@ -56311,7 +56391,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `inventoryFailureAdd`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `inventoryFailureAdd`() BEGIN DECLARE done BOOL DEFAULT FALSE; @@ -56372,7 +56452,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `inventoryMake`(vInventoryDate DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `inventoryMake`(vInventoryDate DATE) BEGIN /** * Recalculate the inventories @@ -56655,7 +56735,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `inventoryMakeLauncher`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `inventoryMakeLauncher`() BEGIN /** * Recalculate the inventories of all warehouses @@ -56680,7 +56760,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `inventory_repair`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `inventory_repair`() BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.lastEntry; @@ -56799,7 +56879,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceExpenseMake`(IN vInvoice INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceExpenseMake`(IN vInvoice INT) BEGIN /* Inserta las partidas de gasto correspondientes a la factura * REQUIERE tabla tmp.ticketToInvoice @@ -56842,7 +56922,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceFromAddress`(vMaxTicketDate DATETIME,vAddress INT,vCompany INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceFromAddress`(vMaxTicketDate DATETIME,vAddress INT,vCompany INT) BEGIN DECLARE vMinDateTicket DATE DEFAULT TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()); @@ -56877,7 +56957,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceFromClient`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceFromClient`( IN vMaxTicketDate datetime, IN vClientFk INT, IN vCompanyFk INT) @@ -56912,7 +56992,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceFromTicket`(IN vTicket INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceFromTicket`(IN vTicket INT) BEGIN DROP TEMPORARY TABLE IF EXISTS `tmp`.`ticketToInvoice`; @@ -56939,7 +57019,9 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInDueDay_calculate`(vInvoiceInFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceInDueDay_calculate`( + vInvoiceInFk INT +) BEGIN /** * Calcula los vctos. de una factura recibida @@ -56996,12 +57078,13 @@ BEGIN COUNT(DISTINCT(pdd.detail)) cont, s.payDay, ii.issued, - DATE(ii.created) + INTERVAL 2 DAY created + DATE(ii.created) + INTERVAL iic.dueDateMarginDays DAY created FROM invoiceIn ii JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id LEFT JOIN sage.TiposIva ti ON ti.CodigoIva= iit.taxTypeSageFk JOIN supplier s ON s.id = ii.supplierFk - JOIN payDemDetail pdd ON pdd.id = s.payDemFk + JOIN payDemDetail pdd ON pdd.id = s.payDemFk + JOIN invoiceInConfig iic WHERE ii.id = vInvoiceInFk GROUP BY ii.id )sub @@ -57025,7 +57108,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInDueDay_recalc`(vInvoiceInFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceInDueDay_recalc`(vInvoiceInFk INT) BEGIN DELETE FROM invoiceInDueDay @@ -57049,7 +57132,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInTaxMakeByDua`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceInTaxMakeByDua`( vDuaFk INT ) BEGIN @@ -57100,7 +57183,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInTax_afterUpsert`(vInvoiceInFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceInTax_afterUpsert`(vInvoiceInFk INT) BEGIN /** * Triggered actions when a invoiceInTax is updated or inserted. @@ -57109,7 +57192,6 @@ BEGIN */ DECLARE vTaxRowLimit INT; DECLARE vLines INT; - DECLARE vHasDistinctTransactions INT; SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig; @@ -57121,18 +57203,6 @@ BEGIN IF vLines >= vTaxRowLimit THEN CALL util.throw (CONCAT('The maximum number of lines is ', vTaxRowLimit)); END IF; - - SELECT COUNT(DISTINCT transactionTypeSageFk) INTO vHasDistinctTransactions - FROM invoiceIn ii - JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id - JOIN invoiceInSerial iis ON iis.code = ii.serial - WHERE ii.id = vInvoiceInFk - AND iis.taxAreaFk = 'CEE' - AND transactionTypeSageFk; - - IF vHasDistinctTransactions > 1 THEN - CALL util.throw ('This invoice does not allow different types of transactions'); - END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -57149,7 +57219,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInTax_getFromDua`(vDuaFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceInTax_getFromDua`(vDuaFk INT) BEGIN /** * Borra los valores de duaTax y sus vctos. y los vuelve a crear en base a la tabla duaEntry @@ -57197,26 +57267,26 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInTax_getFromEntries`(IN vInvoiceInFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceInTax_getFromEntries`( + IN vInvoiceInFk INT +) BEGIN DECLARE vRate DOUBLE DEFAULT 1; - DECLARE vDated DATE; DECLARE vExpenseFk VARCHAR(10); - SELECT MAX(rr.dated) INTO vDated - FROM referenceRate rr - JOIN invoiceIn ii ON ii.id = vInvoiceInFk - WHERE rr.dated <= ii.issued - AND rr.currencyFk = ii.currencyFk ; - - IF vDated THEN - SELECT `value` INTO vRate - FROM referenceRate - WHERE dated = vDated; - END IF; + WITH rate AS( + SELECT MAX(rr.dated) dated, ii.currencyFk + FROM vn.invoiceIn ii + JOIN vn.referenceRate rr ON rr.currencyFk = ii.currencyFk + WHERE ii.id = vInvoiceInFk + AND rr.dated <= ii.issued + ) SELECT `value` INTO vRate + FROM vn.referenceRate rr + JOIN rate r ON r.dated = rr.dated + AND r.currencyFk = rr.currencyFk; SELECT id INTO vExpenseFk - FROM vn.expense + FROM expense WHERE `name` = 'Adquisición mercancia Extracomunitaria' GROUP BY id LIMIT 1; @@ -57224,19 +57294,25 @@ BEGIN DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk; - INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, foreignValue, taxTypeSageFk, transactionTypeSageFk) - SELECT ii.id, - SUM(b.buyingValue * b.quantity) / IFNULL(vRate,1) taxableBase, - vExpenseFk, - IF(ii.currencyFk = 1,NULL,SUM(b.buyingValue * b.quantity )) divisa, - taxTypeSageFk, + INSERT INTO invoiceInTax( + invoiceInFk, + taxableBase, + expenseFk, + foreignValue, + taxTypeSageFk, transactionTypeSageFk + )SELECT ii.id, + SUM(b.buyingValue * b.quantity) / vRate taxableBase, + vExpenseFk, + IF(ii.currencyFk = 1, + NULL, + SUM(b.buyingValue * b.quantity )), + taxTypeSageFk, + transactionTypeSageFk FROM invoiceIn ii JOIN entry e ON e.invoiceInFk = ii.id JOIN supplier s ON s.id = e.supplierFk JOIN buy b ON b.entryFk = e.id - LEFT JOIN referenceRate rr ON rr.currencyFk = ii.currencyFk - AND rr.dated = ii.issued WHERE ii.id = vInvoiceInFk HAVING taxableBase IS NOT NULL; END ;; @@ -57255,7 +57331,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInTax_recalc`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceInTax_recalc`( vInvoiceInFk INT ) BEGIN @@ -57325,9 +57401,33 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceIn_booking`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceIn_booking`( + vSelf INT, + vBookNumber INT +) BEGIN - DECLARE vBookNumber INT; +/** + * Genera la contabilidad para una factura y la marca como contabilizada + * Cuadra el asiento generado en si encuentra problemas derivados + * de los calculos con decimales + * + * @param vSelf Id invoiceIn + * @param vBookEntry Id de asiento, si es NULL se genera uno nuevo + */ + DECLARE vFiscalYear INT; + DECLARE vHasRepeatedTransactions BOOL; + + SELECT TRUE INTO vHasRepeatedTransactions + FROM invoiceInTax iit + JOIN invoiceIn ii ON ii.id = iit.invoiceInFk + WHERE ii.id = vSelf + AND ii.serial = 'E' + HAVING COUNT(DISTINCT iit.transactionTypeSageFk) > 1 + LIMIT 1; + + IF vHasRepeatedTransactions THEN + CALL util.throw ('This invoice contains different types of transactions'); + END IF; CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn ENGINE = MEMORY @@ -57382,7 +57482,11 @@ BEGIN LEFT JOIN sage.taxType tt ON tt.id = ti.CodigoIva WHERE ii.id = vSelf; - CALL vn.ledger_next(vBookNumber); + SELECT YEAR(bookEntried) INTO vFiscalYear FROM tInvoiceIn LIMIT 1; + + IF vBookNumber IS NULL THEN + CALL ledger_nextTx(vFiscalYear, vBookNumber); + END IF; -- Apunte del proveedor INSERT INTO XDiario( @@ -57511,7 +57615,7 @@ BEGIN LEFT JOIN ( SELECT e.id FROM tInvoiceIn tii - JOIN expense e ON e.id = tii.expenseFk + JOIN expense e ON e.id = tii.expenseFk WHERE e.isWithheld LIMIT 1 ) eWithheld ON TRUE @@ -57621,7 +57725,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceIn_checkBooked`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceIn_checkBooked`( vSelf INT ) BEGIN @@ -57656,7 +57760,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutAgain`(IN vInvoiceRef VARCHAR(15), vTaxArea VARCHAR(25)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceOutAgain`(IN vInvoiceRef VARCHAR(15), vTaxArea VARCHAR(25)) BEGIN /* Para tickets ya facturados, vuelve a repetir el proceso de facturación. @@ -57726,24 +57830,26 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutBooking`(IN vInvoice INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceOutBooking`(IN vInvoice INT) BEGIN -/* Asienta la factura emitida -* -* param vInvoice factura_id -*/ +/** + * Asienta una factura emitida + * + * @param vInvoice Id invoiceOut + */ DECLARE vBookNumber INT; - DECLARE vExpenseConcept VARCHAR(50); - DECLARE vSpainCountryFk INT; - DECLARE vOldBookNumber INT; + DECLARE vExpenseConcept VARCHAR(50); + DECLARE vSpainCountryFk INT; + DECLARE vOldBookNumber INT; + DECLARE vFiscalYear INT; - SELECT id INTO vSpainCountryFk FROM country WHERE code = 'ES'; + SELECT id INTO vSpainCountryFk FROM country WHERE `code` = 'ES'; - SELECT ASIEN + SELECT ASIEN INTO vOldBookNumber FROM XDiario x JOIN invoiceOut io ON io.id = vInvoice - WHERE x.SERIE = io.serial + WHERE x.SERIE = io.serial AND x.FACTURA = RIGHT(io.ref, LENGTH(io.ref) - 1) LIMIT 1; @@ -57753,140 +57859,133 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS rs; CREATE TEMPORARY TABLE rs - SELECT - c.accountingAccount AS clientBookingAccount, - io.amount as totalAmount, - CONCAT('n/fra ', io.ref) as simpleConcept, - CONCAT('n/fra ', io.ref, ' ', c.name) as Concept, - io.serial AS SERIE, - io.issued AS FECHA_EX, - io.issued AS FECHA_OP, - io.issued AS FECHA, - 1 AS NFACTICK, - IF(ic.correctingFk,'D','') AS TIPOOPE, - io.siiTrascendencyInvoiceOutFk AS TIPOCLAVE, - io.cplusTaxBreakFk AS TIPOEXENCI, - io.cplusSubjectOpFk AS TIPONOSUJE, - io.siiTypeInvoiceOutFk AS TIPOFACT, - ic.cplusRectificationTypeFk AS TIPORECTIF, + SELECT c.accountingAccount clientBookingAccount, + io.amount totalAmount, + CONCAT('n/fra ', io.ref) simpleConcept, + CONCAT('n/fra ', io.ref, ' ', c.name) Concept, + io.serial SERIE, + io.issued FECHA_EX, + io.issued FECHA_OP, + io.issued FECHA, + 1 NFACTICK, + IF(ic.correctingFk,'D','') TIPOOPE, + io.siiTrascendencyInvoiceOutFk TIPOCLAVE, + io.cplusTaxBreakFk TIPOEXENCI, + io.cplusSubjectOpFk TIPONOSUJE, + io.siiTypeInvoiceOutFk TIPOFACT, + ic.cplusRectificationTypeFk TIPORECTIF, io.companyFk, - RIGHT(io.ref, LENGTH(io.ref) - 1) AS invoiceNum, - IF(c.countryFk = vSpainCountryFk, vSpainCountryFk, IF(ct.isUeeMember,2,4)) AS TERIDNIF, - CONCAT(IF(ct.isUeeMember AND c.countryFk <> vSpainCountryFk,ct.code,''),c.fi) AS TERNIF, - c.socialName AS TERNOM, - ior.serial AS SERIE_RT, - RIGHT(ior.ref, LENGTH(ior.ref) - 1) AS FACTU_RT, - ior.issued AS FECHA_RT, - IF(ior.id,TRUE,FALSE) AS RECTIFICA + RIGHT(io.ref, LENGTH(io.ref) - 1) invoiceNum, + IF(c.countryFk = vSpainCountryFk, vSpainCountryFk, IF(ct.isUeeMember,2,4)) TERIDNIF, + CONCAT(IF(ct.isUeeMember AND c.countryFk <> vSpainCountryFk,ct.code,''),c.fi) TERNIF, + c.socialName TERNOM, + ior.serial SERIE_RT, + RIGHT(ior.ref, LENGTH(ior.ref) - 1) FACTU_RT, + ior.issued FECHA_RT, + IF(ior.id,TRUE,FALSE) RECTIFICA FROM invoiceOut io JOIN invoiceOutSerial ios ON ios.code = io.serial JOIN client c ON c.id = io.clientFk JOIN country ct ON ct.id = c.countryFk LEFT JOIN invoiceCorrection ic ON ic.correctingFk = io.id - LEFT JOIN invoiceOut ior ON ior.id = ic.correctedFk + LEFT JOIN invoiceOut ior ON ior.id = ic.correctedFk WHERE io.id = vInvoice; - CALL vn.ledger_next(vBookNumber); - + SELECT YEAR(FECHA) INTO vFiscalYear FROM rs LIMIT 1; + CALL ledger_nextTx(vFiscalYear, vBookNumber); -- Linea del cliente INSERT INTO XDiario( - ASIEN, - FECHA, - SUBCTA, - EURODEBE, - CONCEPTO, - FECHA_EX, - FECHA_OP, - empresa_id - ) - SELECT - vBookNumber AS ASIEN, + ASIEN, + FECHA, + SUBCTA, + EURODEBE, + CONCEPTO, + FECHA_EX, + FECHA_OP, + empresa_id) + SELECT vBookNumber, rs.FECHA, - rs.clientBookingAccount AS SUBCTA, - rs.totalAmount AS EURODEBE, - rs.simpleConcept AS CONCEPTO, + rs.clientBookingAccount, + rs.totalAmount, + rs.simpleConcept, rs.FECHA_EX, rs.FECHA_OP, - rs.companyFk AS empresa_id + rs.companyFk FROM rs; -- Lineas de gasto INSERT INTO XDiario( - ASIEN, - FECHA, - SUBCTA, - CONTRA, - EUROHABER, - CONCEPTO, - FECHA_EX, - FECHA_OP, - empresa_id - ) - SELECT - vBookNumber AS ASIEN, - rs.FECHA, - ioe.expenseFk AS SUBCTA, - rs.clientBookingAccount AS CONTRA, - ioe.amount AS EUROHABER, - rs.Concept AS CONCEPTO, - rs.FECHA_EX, - rs.FECHA_OP, - rs.companyFk AS empresa_id - FROM rs - JOIN invoiceOutExpense ioe - WHERE ioe.invoiceOutFk = vInvoice; + ASIEN, + FECHA, + SUBCTA, + CONTRA, + EUROHABER, + CONCEPTO, + FECHA_EX, + FECHA_OP, + empresa_id) + SELECT vBookNumber, + rs.FECHA, + ioe.expenseFk, + rs.clientBookingAccount, + ioe.amount, + rs.Concept, + rs.FECHA_EX, + rs.FECHA_OP, + rs.companyFk + FROM rs + JOIN invoiceOutExpense ioe + WHERE ioe.invoiceOutFk = vInvoice; - SELECT GROUP_CONCAT(`name` SEPARATOR ',') - INTO vExpenseConcept - FROM expense e - JOIN invoiceOutExpense ioe ON ioe.expenseFk = e.id - WHERE ioe.invoiceOutFk = vInvoice; + SELECT GROUP_CONCAT(`name` SEPARATOR ',') + INTO vExpenseConcept + FROM expense e + JOIN invoiceOutExpense ioe ON ioe.expenseFk = e.id + WHERE ioe.invoiceOutFk = vInvoice; - -- Lineas de IVA + -- Lineas de IVA INSERT INTO XDiario( - ASIEN, - FECHA, - SUBCTA, - CONTRA, - EUROHABER, - BASEEURO, - CONCEPTO, - FACTURA, - IVA, - RECEQUIV, - AUXILIAR, - SERIE, - SERIE_RT, - FACTU_RT, - RECTIFICA, - FECHA_RT, - FECHA_OP, - FECHA_EX, - TIPOOPE, - NFACTICK, - TERIDNIF, - TERNIF, - TERNOM, - L340, - TIPOCLAVE, - TIPOEXENCI, - TIPONOSUJE, - TIPOFACT, - TIPORECTIF, - empresa_id - ) - SELECT - vBookNumber AS ASIEN, + ASIEN, + FECHA, + SUBCTA, + CONTRA, + EUROHABER, + BASEEURO, + CONCEPTO, + FACTURA, + IVA, + RECEQUIV, + AUXILIAR, + SERIE, + SERIE_RT, + FACTU_RT, + RECTIFICA, + FECHA_RT, + FECHA_OP, + FECHA_EX, + TIPOOPE, + NFACTICK, + TERIDNIF, + TERNIF, + TERNOM, + L340, + TIPOCLAVE, + TIPOEXENCI, + TIPONOSUJE, + TIPOFACT, + TIPORECTIF, + empresa_id) + SELECT vBookNumber ASIEN, rs.FECHA, - iot.pgcFk AS SUBCTA, - rs.clientBookingAccount AS CONTRA, - iot.vat AS EUROHABER, - iot.taxableBase AS BASEEURO, - CONCAT(vExpenseConcept,' : ',rs.Concept) AS CONCEPTO, - rs.invoiceNum AS FACTURA, - IF(pe2.equFk,0,pgc.rate) AS IVA, - IF(pe2.equFk,0,pgce.rate) AS RECEQUIV, - IF(pgc.mod347,'','*') AS AUXILIAR, + iot.pgcFk SUBCTA, + rs.clientBookingAccount CONTRA, + iot.vat EUROHABER, + iot.taxableBase BASEEURO, + CONCAT(vExpenseConcept,' : ',rs.Concept) CONCEPTO, + rs.invoiceNum FACTURA, + IF(pe2.equFk,0,pgc.rate) IVA, + IF(pe2.equFk,0,pgce.rate) RECEQUIV, + IF(pgc.mod347,'','*') AUXILIAR, rs.SERIE, rs.SERIE_RT, rs.FACTU_RT, @@ -57895,28 +57994,28 @@ BEGIN rs.FECHA_OP, rs.FECHA_EX, rs.TIPOOPE, - rs.NFACTICK, + rs.NFACTICK, rs.TERIDNIF, rs.TERNIF, rs.TERNOM, - pgc.mod340 AS L340, - pgc.siiTrascendencyInvoiceOutFk AS TIPOCLAVE, - pgc.cplusTaxBreakFk as TIPOEXENCI, + pgc.mod340 L340, + pgc.siiTrascendencyInvoiceOutFk TIPOCLAVE, + pgc.cplusTaxBreakFk TIPOEXENCI, rs.TIPONOSUJE, rs.TIPOFACT, rs.TIPORECTIF, - rs.companyFk AS empresa_id + rs.companyFk FROM rs JOIN invoiceOutTax iot JOIN pgc ON pgc.code = iot.pgcFk LEFT JOIN pgcEqu pe ON pe.vatFk = iot.pgcFk -- --------------- Comprueba si la linea es de iva con rec.equiv. asociado LEFT JOIN pgc pgce ON pgce.code = pe.equFk - LEFT JOIN pgcEqu pe2 ON pe2.equFk = iot.pgcFk -- --------------- Comprueba si la linea es de rec.equiv. + LEFT JOIN pgcEqu pe2 ON pe2.equFk = iot.pgcFk -- --------------- Comprueba si la linea es de rec.equiv. WHERE iot.invoiceOutFk = vInvoice; - - UPDATE invoiceOut - SET booked = util.VN_CURDATE() - WHERE id = vInvoice; + + UPDATE invoiceOut + SET booked = util.VN_CURDATE() + WHERE id = vInvoice; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -57933,7 +58032,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutBookingRange`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceOutBookingRange`() BEGIN /* Reasentar facturas @@ -57993,7 +58092,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutListByCompany`(vCompany INT, vStarted DATE, vEnded DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceOutListByCompany`(vCompany INT, vStarted DATE, vEnded DATE) BEGIN SELECT @@ -58033,7 +58132,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutTaxAndExpense`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceOutTaxAndExpense`() BEGIN /* Para tickets ya facturados, vuelve a repetir el proceso de facturación. @@ -58122,7 +58221,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_exportationFromClient`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceOut_exportationFromClient`( vMaxTicketDate DATETIME, vClientFk INT, vCompanyFk INT) @@ -58167,7 +58266,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_new`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceOut_new`( vSerial VARCHAR(255), vInvoiceDate DATE, vTaxArea VARCHAR(25), @@ -58248,8 +58347,8 @@ BEGIN OR t.isDeleted OR c.hasToInvoice = FALSE OR itc.id IS NULL - OR a.id IS NULL - OR (vTaxArea = 'WORLD' + OR a.id IS NULL + OR (vTaxArea = 'WORLD' AND (a.customsAgentFk IS NULL OR a.incotermsFk IS NULL)); SELECT SUM(s.quantity * s.price * (100 - s.discount)/100) <> 0 @@ -58265,7 +58364,7 @@ BEGIN AND (vCorrectingSerial = vSerial OR NOT hasAnyNegativeBase()) THEN - -- el trigger añade el siguiente Id_Factura correspondiente a la vSerial + -- el trigger añade el siguiente ref correspondiente a la vSerial INSERT INTO invoiceOut( ref, serial, @@ -58321,7 +58420,9 @@ BEGIN FROM tmp.ticketToInvoice ti LEFT JOIN ticketState ts ON ti.id = ts.ticketFk JOIN state s - WHERE IFNULL(ts.alertLevel, 0) < 3 and s.`code` = getAlert3State(ti.id); + JOIN alertLevel al ON al.code = 'DELIVERED' + WHERE (ts.alertLevel IS NULL OR ts.alertLevel < al.id) + AND s.`code` = getAlert3State(ti.id); INSERT INTO ticketTracking(stateFk, ticketFk, userFk) SELECT * FROM tmp.updateInter; @@ -58382,7 +58483,7 @@ BEGIN i.transactionTypeSageFk, @vTaxCodeGeneral := i.taxClassCodeFk FROM tmp.ticketServiceTax tst - JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tst.code + JOIN invoiceOutTaxMultiConfig i ON i.taxClassCodeFk = tst.code WHERE i.isService HAVING taxableBase ) sub; @@ -58395,7 +58496,7 @@ BEGIN i.taxTypeSageFk , i.transactionTypeSageFk FROM tmp.ticketTax tt - JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tt.code + JOIN invoiceOutTaxMultiConfig i ON i.taxClassCodeFk = tt.code WHERE !i.isService GROUP BY tt.pgcFk HAVING taxableBase @@ -58457,7 +58558,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_newFromClient`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceOut_newFromClient`( IN vClientFk INT, IN vSerial CHAR(2), IN vMaxShipped DATE, @@ -58526,7 +58627,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOut_newFromTicket`(IN vTicketFk int, IN vSerial char(2), IN vTaxArea varchar(25), +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceOut_newFromTicket`(IN vTicketFk int, IN vSerial char(2), IN vTaxArea varchar(25), IN vRef varchar(25), OUT vInvoiceId int) BEGIN /** @@ -58573,7 +58674,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceTaxMake`(vInvoice INT, vTaxArea VARCHAR(25)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `invoiceTaxMake`(vInvoice INT, vTaxArea VARCHAR(25)) BEGIN /** * Factura un conjunto de tickets. @@ -58630,7 +58731,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemBarcode_update`(vItemFk INT,vCode VARCHAR(22), vDelete BOOL) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemBarcode_update`(vItemFk INT,vCode VARCHAR(22), vDelete BOOL) BEGIN IF vDelete THEN DELETE FROM vn.itemBarcode WHERE itemFk = vItemFk AND code = vCode; @@ -58646,7 +58747,7 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `itemFuentesBalance` */; +/*!50003 DROP PROCEDURE IF EXISTS `itemMinimumQuantity_check` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -58654,82 +58755,31 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemFuentesBalance`(vDaysInFuture INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemMinimumQuantity_check`( + vSelf INT, + vItemFk INT, + vStarted DATE, + vEnded DATE, + vWarehouseFk INT +) BEGIN + DECLARE vHasCollision BOOL; - /* Se utiliza para calcular la necesidad de mover mercancia entre el almacén de fuentes y el nuestro - * - * @param vDaysInFuture Rango de dias para calcular entradas y salidas - * - */ - - DECLARE vWarehouseFk INT; + IF vStarted IS NULL THEN + CALL util.throw('The field "started" cannot be null'); + END IF; - SELECT s.warehouseFk INTO vWarehouseFk - FROM vn.sector s - WHERE s.code = 'FUENTES_PICASSE'; - - CALL cache.stock_refresh(FALSE); - - SELECT i.id itemFk, - i.longName, - i.size, - i.subName, - v.amount - IFNULL(fue.Fuentes,0) - IFNULL(alb.albenfruit,0) as visible, - fue.Fuentes, - alb.Albenfruit, - sale.venta, - IFNULL(buy.compra,0) + IFNULL(mov.traslado,0) as compra, - IFNULL(v.amount,0) + IFNULL(sale.venta,0) + IFNULL(buy.compra,0) + IFNULL(mov.traslado,0) - - IFNULL(fue.Fuentes,0) - IFNULL(alb.albenfruit,0) as saldo - FROM vn.item i - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN ( - SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS Fuentes - FROM vn.itemShelving ish - JOIN vn.shelving sh ON sh.code = ish.shelvingFk - JOIN vn.parking p ON p.id = sh.parkingFk - JOIN vn.sector s ON s.id = p.sectorFk - WHERE s.code = 'FUENTES_PICASSE' - GROUP BY ish.itemFk - ) fue ON fue.itemFk = i.id - LEFT JOIN ( - SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS Albenfruit - FROM vn.itemShelving ish - JOIN vn.shelving sh ON sh.code = ish.shelvingFk - JOIN vn.parking p ON p.id = sh.parkingFk - JOIN vn.sector s ON s.id = p.sectorFk - WHERE s.code = 'ALBENFRUIT' - GROUP BY ish.itemFk - ) alb ON alb.itemFk = i.id - LEFT JOIN cache.stock v ON i.id = v.item_id AND v.warehouse_id = vWarehouseFk - LEFT JOIN ( - SELECT itemFk item_id, CAST(sum(quantity)AS DECIMAL(10,0)) as venta - FROM itemTicketOut - WHERE shipped BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE())) - AND warehouseFk = vWarehouseFk - GROUP BY itemFk - ) sale ON sale.item_id = i.id - LEFT JOIN ( - SELECT itemFk item_id, CAST(sum(quantity)AS DECIMAL(10,0)) as compra - FROM itemEntryIn - WHERE landed BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE())) - AND warehouseInFk = vWarehouseFk - AND isVirtualStock = FALSE - GROUP BY itemFk - ) buy ON buy.item_id = i.id - LEFT JOIN ( - SELECT itemFk item_id, CAST(sum(quantity)AS DECIMAL(10,0)) as traslado - FROM itemEntryOut - WHERE shipped BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE())) - AND warehouseOutFk = vWarehouseFk - GROUP BY itemFk - ) mov ON mov.item_id = i.id - WHERE (v.amount OR fue.Fuentes OR alb.Albenfruit) - AND i.itemPackingTypeFk = 'H' - AND ic.shortLife; + SELECT COUNT(*) INTO vHasCollision + FROM itemMinimumQuantity + WHERE vItemFk = itemFk + AND ((vStarted <= ended OR ended IS NULL) + AND (vStarted >= `started` OR vEnded IS NULL)) + AND (vWarehouseFk <=> warehouseFk) + AND vSelf <> id; + IF vHasCollision THEN + CALL util.throw('A line with the same configuration already exists'); + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -58746,7 +58796,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementFromTicket`(vTicket INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemPlacementFromTicket`(vTicket INT) BEGIN /** * Llama a itemPlacementUpdateVisible @@ -58783,7 +58833,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementSupplyAiming`(vShelvingFk VARCHAR(10), quantity INT, vItemFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemPlacementSupplyAiming`(vShelvingFk VARCHAR(10), quantity INT, vItemFk INT) BEGIN SELECT ish.itemFk, @@ -58826,7 +58876,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementSupplyCloseOrder`(vId INT, vQuantity INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemPlacementSupplyCloseOrder`(vId INT, vQuantity INT) BEGIN UPDATE vn.itemPlacementSupply @@ -58849,7 +58899,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementSupplyGetOrder`(vSector INT ) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemPlacementSupplyGetOrder`(vSector INT ) BEGIN DECLARE vId INT; @@ -58899,7 +58949,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemPlacementSupplyStockGetTargetList`(vItemFk INT,vSectorFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemPlacementSupplyStockGetTargetList`(vItemFk INT,vSectorFk INT) BEGIN /** * Devuelve la lista de ubicaciones para itemFk en ese sector. Se utiliza en la preparación previa. @@ -58918,11 +58968,12 @@ BEGIN JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.sector sc ON sc.id = p.sectorFk JOIN vn.warehouse w ON w.id = sc.warehouseFk - WHERE sc.id = vSectorFk - AND ish.visible > 0 + WHERE ish.visible > 0 AND ish.itemFk = vItemFk GROUP BY ish.id - ORDER BY sh.priority DESC, + ORDER BY + (sc.id = vSectorFk) DESC, + sh.priority DESC, ish.created, p.pickingOrder; END ;; @@ -58941,7 +58992,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemRefreshTags`(IN vItem INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemRefreshTags`(IN vItem INT) BEGIN /** * Crea la tabla temporal necesaria para el procedimiento item_refreshTags @@ -58974,7 +59025,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemSale_byWeek`(vWeek INT, IN vYear INT, vItemFk INT, vWarehouseFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemSale_byWeek`(vWeek INT, IN vYear INT, vItemFk INT, vWarehouseFk INT) BEGIN DECLARE vStarted DATE; @@ -59032,7 +59083,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemSaveMin`(min INT,vBarcode VARCHAR(22)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemSaveMin`(min INT,vBarcode VARCHAR(22)) BEGIN DECLARE vItemFk INT; @@ -59058,7 +59109,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemSearchShelving`(`vShelvingFk` VARCHAR(3)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemSearchShelving`(`vShelvingFk` VARCHAR(3)) BEGIN SELECT p.`column` AS col , p.`row` FROM vn.shelving s @@ -59080,7 +59131,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingDelete`(vId INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingDelete`(vId INT) BEGIN DELETE FROM vn.itemShelving WHERE id = vId; @@ -59101,7 +59152,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingLog_get`(vShelvingFk VARCHAR(10) ) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingLog_get`(vShelvingFk VARCHAR(10) ) BEGIN /** @@ -59133,77 +59184,6 @@ BEGIN WHERE shelvingFk = vShelvingFk OR isl.itemFk = vShelvingFk ORDER BY isl.created DESC; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingMakeFromDate` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingMakeFromDate`(IN `vShelvingFk` VARCHAR(8), IN `vBarcode` VARCHAR(22), IN `vQuantity` INT, IN `vPackagingFk` VARCHAR(10), IN `vGrouping` INT, IN `vPacking` INT, IN `vWarehouseFk` INT, `vCreated` VARCHAR(22)) -BEGIN - - DECLARE vItemFk INT; - - SELECT vn.barcodeToItem(vBarcode) INTO vItemFk; - - SELECT itemFk INTO vItemFk - FROM vn.buy b - WHERE b.id = vItemFk; - - IF (SELECT COUNT(*) FROM vn.shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN - - INSERT IGNORE INTO vn.parking(`code`) VALUES(vShelvingFk); - INSERT INTO vn.shelving(`code`, parkingFk) - SELECT vShelvingFk, id - FROM vn.parking - WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci; - - END IF; - - IF (SELECT COUNT(*) FROM vn.itemShelving - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk - AND itemFk = vItemFk - AND packing = vPacking) = 1 THEN - - UPDATE vn.itemShelving - SET visible = visible+vQuantity, - created = vCreated - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk - AND itemFk = vItemFk - AND packing = vPacking; - - ELSE - CALL cache.last_buy_refresh(FALSE); - INSERT INTO itemShelving( itemFk, - shelvingFk, - visible, - created, - `grouping`, - packing, - packagingFk) - SELECT vItemFk, - vShelvingFk, - vQuantity, - vCreated, - IF(vGrouping = 0, IFNULL(b.packing, vPacking), vGrouping) `grouping`, - IF(vPacking = 0, b.packing, vPacking) packing, - IF(vPackagingFk = '', b.packagingFk, vPackagingFk) packaging - FROM vn.item i - LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk - LEFT JOIN vn.buy b ON b.id = lb.buy_id - WHERE i.id = vItemFk; - END IF; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -59220,7 +59200,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingMatch`(vEntryFk INT, vAllTravel BOOLEAN, vFromTimed DATETIME, vToTimed DATETIME) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingMatch`(vEntryFk INT, vAllTravel BOOLEAN, vFromTimed DATETIME, vToTimed DATETIME) BEGIN DECLARE vTravelFk INT; @@ -59248,39 +59228,6 @@ BEGIN ) ish ON ish.itemFk = id WHERE b.stickers OR ish.etiquetas; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingPlacementSupplyAdd` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingPlacementSupplyAdd`(vItemShelvingFk INT, vItemPlacementSupplyFk INT, vQuantity INT) -BEGIN - - INSERT INTO vn.itemShelvingPlacementSupply( itemShelvingFk, - itemPlacementSupplyFk, - quantity, - userFk) - VALUES (vItemShelvingFk, - vItemPlacementSupplyFk, - vQuantity, - getUser()); - - UPDATE vn.itemShelving - SET visible = visible - vQuantity - WHERE id = vItemShelvingFk; - - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -59297,7 +59244,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingProblem`(vSectorFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingProblem`(vSectorFk INT) BEGIN DECLARE vVisibleCache INT; @@ -59336,7 +59283,7 @@ BEGIN AND IFNULL(sub3.transit,0) < s.quantity AND s.isPicked = FALSE AND s.reserved = FALSE - AND t.shipped BETWEEN util.VN_CURDATE() AND MIDNIGHT(util.VN_CURDATE()) + AND t.shipped BETWEEN util.VN_CURDATE() AND util.midnight() AND tst.isPreviousPreparable = TRUE AND t.warehouseFk = vWarehouseFk AND iss.sectorFk = vSectorFk @@ -59359,10 +59306,10 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingRadar`( vSectorFk INT ) -proc:BEGIN +BEGIN /** * Calcula la información detallada respecto un sector. * @@ -59375,37 +59322,24 @@ proc:BEGIN DECLARE vWarehouseFk INT DEFAULT 0; DECLARE vSonSectorFk INT; DECLARE vWorkerFk INT; - - SELECT s.workerFk - INTO vWorkerFk - FROM vn.sector s + + SELECT s.workerFk INTO vWorkerFk + FROM sector s WHERE s.id = vSectorFk; - SELECT w.id, s.warehouseFk INTO vBuyerFk, vWarehouseFk - FROM vn.worker w - JOIN vn.sector s ON s.code = w.code - WHERE s.id = vSectorFk; - - SELECT s.id INTO vSectorFk - FROM vn.sector s - WHERE s.warehouseFk = vWarehouseFk - AND s.isMain; - SELECT COUNT(*) INTO hasFatherSector - FROM vn.sector + FROM sector WHERE sonFk = vSectorFk; - + SELECT warehouseFk, sonFk INTO vWarehouseFk, vSonSectorFk - FROM vn.sector + FROM sector WHERE id = vSectorFk; - + CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk); CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE()); - - DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadar; - + IF hasFatherSector THEN - CREATE TEMPORARY TABLE tmp.itemShelvingRadar + CREATE OR REPLACE TEMPORARY TABLE tItemShelvingRadar (PRIMARY KEY (itemFk)) ENGINE = MEMORY SELECT * @@ -59414,57 +59348,77 @@ proc:BEGIN i.longName, i.size, i.subName producer, - IFNULL(a.available,0) available, - SUM(IF(s.sonFk = vSectorFk, IFNULL(iss.visible,0), 0)) upstairs, - SUM(IF(iss.sectorFk = vSectorFk, IFNULL(iss.visible,0), 0)) downstairs, - IF(it.isPackaging, NULL, IFNULL(v.visible,0)) as visible, - vSectorFk sectorFk - FROM vn.itemShelvingStock iss - JOIN vn.sector s ON s.id = iss.sectorFk - JOIN vn.item i on i.id = iss.itemFk - JOIN vn.itemType it ON it.id = i.typeFk AND vBuyerFk IN (0,it.workerFk) - LEFT JOIN cache.available a ON a.item_id = iss.itemFk AND a.calc_id = vCalcAvailableFk - LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk + IFNULL(a.available, 0) available, + SUM(IF(s.sonFk = vSectorFk, IFNULL(iss.visible, 0), 0)) upstairs, + SUM(IF(iss.sectorFk = vSectorFk, IFNULL(iss.visible, 0), 0)) downstairs, + IF(it.isPackaging, NULL, IFNULL(v.visible, 0)) visible, + vSectorFk sectorFk, + ish.isChecked, + sub.isAllChecked + FROM itemShelvingStock iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + LEFT JOIN ( + SELECT itemFk, + IF( + COUNT(*) = SUM(IF(isChecked >= 0, 1, 0)), + TRUE, + FALSE + ) isAllChecked + FROM itemShelving is2 + GROUP BY itemFk + ) sub ON sub.itemFk = ish.itemFk + JOIN sector s ON s.id = iss.sectorFk + JOIN item i ON i.id = iss.itemFk + JOIN itemType it ON it.id = i.typeFk + LEFT JOIN cache.available a ON a.item_id = iss.itemFk + AND a.calc_id = vCalcAvailableFk + LEFT JOIN cache.visible v ON v.item_id = iss.itemFk + AND v.calc_id = vCalcVisibleFk WHERE vSectorFk IN (iss.sectorFk, s.sonFk) GROUP BY iss.itemFk - UNION ALL - - SELECT v.item_id, + SELECT v.item_id, i.longName, i.size, - i.subName producer, - IFNULL(a.available,0) as available, - 0 upstairs, - 0 downstairs, - IF(it.isPackaging, NULL, v.visible) visible, - vSectorFk as sectorFk + i.subName, + IFNULL(a.available, 0), + 0, + 0, + IF(it.isPackaging, NULL, v.visible), + vSectorFk, + NULL, + NULL FROM cache.visible v - JOIN vn.item i on i.id = v.item_id - JOIN vn.itemType it ON it.id = i.typeFk AND vBuyerFk IN (0,it.workerFk) - LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = v.item_id AND iss.warehouseFk = vWarehouseFk - LEFT JOIN cache.available a ON a.item_id = v.item_id AND a.calc_id = vCalcAvailableFk + JOIN item i ON i.id = v.item_id + JOIN itemType it ON it.id = i.typeFk + LEFT JOIN itemShelvingStock iss ON iss.itemFk = v.item_id + AND iss.warehouseFk = vWarehouseFk + LEFT JOIN cache.available a ON a.item_id = v.item_id + AND a.calc_id = vCalcAvailableFk WHERE v.calc_id = vCalcVisibleFk AND iss.itemFk IS NULL AND it.isInventory - ) sub GROUP BY itemFk; + ) sub + GROUP BY itemFk; SELECT ishr.*, - CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) AS nicho, - CAST(downstairs - IFNULL(notPickedYed,0) AS DECIMAL(10,0)) as pendiente - FROM tmp.itemShelvingRadar ishr - JOIN vn.item i ON i.id = ishr.itemFk - LEFT JOIN (SELECT s.itemFk, sum(s.quantity) as notPickedYed - FROM vn.ticket t - JOIN vn.ticketStateToday tst ON tst.ticketFk = t.id - JOIN vn.sale s ON s.ticketFk = t.id - WHERE t.warehouseFk = vWarehouseFk - AND tst.alertLevel = 0 - GROUP BY s.itemFk - ) sub ON sub.itemFk = ishr.itemFk - ORDER BY i.typeFk, i.longName; + CAST(visible - upstairs - downstairs AS DECIMAL(10, 0)) nicho, + CAST(downstairs - IFNULL(notPickedYed, 0) AS DECIMAL(10, 0)) pendiente + FROM tItemShelvingRadar ishr + JOIN item i ON i.id = ishr.itemFk + LEFT JOIN ( + SELECT s.itemFk, SUM(s.quantity) notPickedYed + FROM ticket t + JOIN ticketStateToday tst ON tst.ticketFk = t.id + JOIN alertLevel al ON al.id = tst.alertLevel + JOIN sale s ON s.ticketFk = t.id + WHERE t.warehouseFk = vWarehouseFk + AND al.code = 'FREE' + GROUP BY s.itemFk + ) sub ON sub.itemFk = ishr.itemFk + ORDER BY i.typeFk, i.longName; ELSE - CREATE TEMPORARY TABLE tmp.itemShelvingRadar + CREATE OR REPLACE TEMPORARY TABLE tItemShelvingRadar (PRIMARY KEY (itemFk)) ENGINE = MEMORY SELECT iss.itemFk, @@ -59475,80 +59429,86 @@ proc:BEGIN i.size, i.subName producer, i.upToDown, - IFNULL(a.available,0) available, - IFNULL(v.visible - iss.visible,0) dayEndVisible, - IFNULL(v.visible - iss.visible,0) firstNegative, - IFNULL(v.visible - iss.visible,0) itemPlacementVisible, - IFNULL(i.minimum * b.packing,0) itemPlacementSize, + IFNULL(a.available, 0) available, + IFNULL(v.visible - iss.visible, 0) dayEndVisible, + IFNULL(v.visible - iss.visible, 0) firstNegative, + IFNULL(v.visible - iss.visible, 0) itemPlacementVisible, + IFNULL(i.minimum * b.packing, 0) itemPlacementSize, ips.onTheWay, iss.visible itemShelvingStock, - IFNULL(v.visible,0) visible, + IFNULL(v.visible, 0) visible, b.isPickedOff, iss.sectorFk - FROM vn.itemShelvingStock iss - JOIN vn.item i on i.id = iss.itemFk - LEFT JOIN cache.last_buy lb ON lb.item_id = iss.itemFk AND lb.warehouse_id = vWarehouseFk - LEFT JOIN vn.buy b ON b.id = lb.buy_id - LEFT JOIN cache.available a ON a.item_id = iss.itemFk AND a.calc_id = vCalcAvailableFk - LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk - LEFT JOIN (SELECT itemFk, sum(saldo) as onTheWay - FROM vn.itemPlacementSupplyList - WHERE saldo > 0 - GROUP BY itemFk - ) ips ON ips.itemFk = i.id - WHERE IFNULL(iss.sectorFk,0) IN (0, vSectorFk) - OR iss.sectorFk = vSectorFk; + FROM itemShelvingStock iss + JOIN item i ON i.id = iss.itemFk + LEFT JOIN cache.last_buy lb ON lb.item_id = iss.itemFk + AND lb.warehouse_id = vWarehouseFk + LEFT JOIN buy b ON b.id = lb.buy_id + LEFT JOIN cache.available a ON a.item_id = iss.itemFk + AND a.calc_id = vCalcAvailableFk + LEFT JOIN cache.visible v ON v.item_id = iss.itemFk + AND v.calc_id = vCalcVisibleFk + LEFT JOIN ( + SELECT itemFk, SUM(saldo) onTheWay + FROM itemPlacementSupplyList + WHERE saldo > 0 + GROUP BY itemFk + ) ips ON ips.itemFk = i.id + WHERE iss.sectorFk = vSectorFk + OR iss.sectorFk IS NULL; - DROP TEMPORARY TABLE IF EXISTS tmp.itemOutTime; - CREATE TEMPORARY TABLE tmp.itemOutTime - SELECT *,SUM(amount) quantity - FROM - (SELECT io.itemFk, - io.quantity amount, - IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) as hours, - IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) as minutes - FROM itemTicketOut io - JOIN tmp.itemShelvingRadar isr ON isr.itemFk = io.itemFk - JOIN vn.ticket t on t.id= io.ticketFk - JOIN vn.ticketState ts on ts.ticketFk = io.ticketFk - JOIN vn.state s ON s.id = ts.stateFk - LEFT JOIN vn.zone z ON z.id = t.zoneFk - LEFT JOIN (SELECT DISTINCT saleFk - FROM vn.saleTracking st - WHERE st.created > util.VN_CURDATE() - AND st.isChecked - ) stPrevious ON `stPrevious`.`saleFk` = io.saleFk - WHERE t.warehouseFk = vWarehouseFk - AND s.isPicked = 0 - AND NOT io.reserved - AND stPrevious.saleFk IS NULL - AND io.shipped >= util.VN_CURDATE() - AND io.shipped < util.VN_CURDATE() + INTERVAL 1 DAY - ) sub - GROUP BY itemFk, hours, minutes; + CREATE OR REPLACE TEMPORARY TABLE tmp.itemOutTime + SELECT *, SUM(amount) quantity + FROM ( + SELECT io.itemFk, + io.quantity amount, + IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) `hours`, + IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) `minutes` + FROM itemTicketOut `io` + JOIN tItemShelvingRadar isr ON isr.itemFk = io.itemFk + JOIN ticket t ON t.id= io.ticketFk + JOIN ticketState ts ON ts.ticketFk = io.ticketFk + JOIN `state` s ON s.id = ts.stateFk + LEFT JOIN `zone` z ON z.id = t.zoneFk + LEFT JOIN ( + SELECT DISTINCT saleFk + FROM saleTracking st + WHERE st.created > util.VN_CURDATE() + AND st.isChecked + ) stPrevious ON stPrevious.saleFk = io.saleFk + WHERE t.warehouseFk = vWarehouseFk + AND NOT s.isPicked + AND NOT io.reserved + AND stPrevious.saleFk IS NULL + AND io.shipped >= util.VN_CURDATE() + AND io.shipped < util.VN_CURDATE() + INTERVAL 1 DAY + ) sub + GROUP BY itemFk, `hours`, `minutes`; - INSERT INTO tmp.itemShelvingRadar (itemFk) + INSERT INTO tItemShelvingRadar (itemFk) SELECT itemFk FROM tmp.itemOutTime - ON DUPLICATE KEY UPDATE dayEndVisible = dayEndVisible + quantity, - firstNegative = if (firstNegative < 0, firstNegative, firstNegative + quantity), - `hour` = ifnull(if (firstNegative > 0 , `hour`, hours),0), - `minute` = ifnull(if (firstNegative > 0, `minute`, minutes),0); + ON DUPLICATE KEY UPDATE dayEndVisible = dayEndVisible + quantity, + firstNegative = IF(firstNegative < 0, firstNegative, firstNegative + quantity), + `hour` = IFNULL(IF(firstNegative > 0 , `hour`, `hours`), 0), + `minute` = IFNULL(IF(firstNegative > 0, `minute`, `minutes`), 0); - UPDATE tmp.itemShelvingRadar isr - JOIN (SELECT s.itemFk, sum(s.quantity) amount - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - JOIN ticketLastState tls ON tls.ticketFk = t.id - WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) - AND tls.name = 'Prep Camara' - GROUP BY s.itemFk) sub ON sub.itemFk = isr.itemFk + UPDATE tItemShelvingRadar isr + JOIN ( + SELECT s.itemFk, SUM(s.quantity) amount + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN ticketState ts ON ts.ticketFk = t.id + WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) + AND ts.code = 'COOLER_PREPARATION' + GROUP BY s.itemFk + ) sub ON sub.itemFk = isr.itemFk SET isr.dayEndVisible = dayEndVisible + sub.amount, firstNegative = firstNegative + sub.amount; - SELECT * FROM tmp.itemShelvingRadar; + SELECT * FROM tItemShelvingRadar; END IF; - DROP TEMPORARY TABLE tmp.itemShelvingRadar; + DROP TEMPORARY TABLE tItemShelvingRadar; END ;; DELIMITER ; @@ -59566,7 +59526,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar_Entry`(vEntryFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingRadar_Entry`(vEntryFk INT) BEGIN DECLARE vWarehouseFk INT DEFAULT 1; @@ -59631,7 +59591,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar_Entry_State_beta`(vEntryFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingRadar_Entry_State_beta`(vEntryFk INT) BEGIN DECLARE vWarehouseFk INT DEFAULT 1; @@ -59682,7 +59642,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSale_Add`(vItemShelvingFk INT, vSaleFk INT, vQuantity INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_Add`(vItemShelvingFk INT, vSaleFk INT, vQuantity INT) BEGIN /** * Añade línea a itemShelvingSale y regulariza el carro @@ -59701,7 +59661,8 @@ BEGIN getUser()); UPDATE itemShelving - SET visible = visible - vQuantity + SET visible = visible - vQuantity, + available = available - vQuantity WHERE id = vItemShelvingFk; UPDATE vn.saleTracking @@ -59716,7 +59677,7 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_reserve` */; +/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_addByCollection` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -59724,302 +59685,53 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSale_reserve`() -BEGIN -/** - * Reserva cantidades con ubicaciones para un conjunto de sales del mismo - * almacen. - * - * @table tmp.sale(saleFk, userFk) - */ - DECLARE vCalcFk INT; - DECLARE vWarehouseFk INT; - DECLARE vCurrentYear INT DEFAULT YEAR(util.VN_NOW()); - DECLARE vLastPickingOrder INT; - - SELECT t.warehouseFk, MAX(p.pickingOrder) - INTO vWarehouseFk, vLastPickingOrder - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN tmp.sale ts ON ts.saleFk = s.id - LEFT JOIN itemShelvingSale iss ON iss.saleFk = ts.saleFk - LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - LEFT JOIN shelving sh ON sh.code = ish.shelvingFk - LEFT JOIN parking p ON p.id = sh.parkingFk - WHERE t.warehouseFk IS NOT NULL; - - IF vWarehouseFk IS NULL THEN - CALL util.throw('Warehouse not set'); - END IF; - - CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk); - - SET @outstanding = 0; - SET @oldsaleFk = 0; - - CREATE OR REPLACE TEMPORARY TABLE tSalePlacementQuantity - (INDEX(saleFk)) - ENGINE = MEMORY - SELECT saleFk, userFk, quantityToReserve, itemShelvingFk - FROM( SELECT saleFk, - sub.userFk, - itemShelvingFk , - IF(saleFk <> @oldsaleFk, @outstanding := quantity, @outstanding), - @qtr := LEAST(@outstanding, available) quantityToReserve, - @outStanding := @outStanding - @qtr, - @oldsaleFk := saleFk - FROM( - SELECT ts.saleFk, - ts.userFk, - s.quantity, - ish.id itemShelvingFk, - ish.visible - IFNULL(ishr.reservedQuantity, 0) available - FROM tmp.sale ts - JOIN sale s ON s.id = ts.saleFk - JOIN itemShelving ish ON ish.itemFk = s.itemFk - LEFT JOIN ( - SELECT itemShelvingFk, SUM(quantity) reservedQuantity - FROM itemShelvingSale - WHERE NOT isPicked - GROUP BY itemShelvingFk) ishr ON ishr.itemShelvingFk = ish.id - JOIN shelving sh ON sh.code = ish.shelvingFk - JOIN parking p ON p.id = sh.parkingFk - JOIN sector sc ON sc.id = p.sectorFk - JOIN warehouse w ON w.id = sc.warehouseFk - JOIN productionConfig pc - WHERE w.id = vWarehouseFk - AND NOT sc.isHideForPickers - ORDER BY - s.id, - p.pickingOrder >= vLastPickingOrder, - sh.priority DESC, - ish.visible >= s.quantity DESC, - s.quantity MOD ish.grouping = 0 DESC, - ish.grouping DESC, - IF(pc.orderMode = 'Location', p.pickingOrder, ish.created) - )sub - )sub2 - WHERE quantityToReserve > 0; - - INSERT INTO itemShelvingSale( - itemShelvingFk, - saleFk, - quantity, - userFk) - SELECT itemShelvingFk, - saleFk, - quantityToReserve, - IFNULL(userFk, getUser()) - FROM tSalePlacementQuantity spl; - - DROP TEMPORARY TABLE tmp.sale; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_reserveByCollection` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSale_reserveByCollection`( - vCollectionFk INT(11) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_addByCollection`( + vCollectionFk INT(11) ) -BEGIN -/** - * Reserva cantidades con ubicaciones para el contenido de una colección - * - * @param vCollectionFk Identificador de collection - */ - CREATE OR REPLACE TEMPORARY TABLE tmp.sale - (INDEX(saleFk)) - ENGINE = MEMORY - SELECT s.id saleFk, NULL userFk - FROM ticketCollection tc - JOIN sale s ON s.ticketFk = tc.ticketFk - LEFT JOIN ( - SELECT DISTINCT saleFk - FROM saleTracking st - JOIN state s ON s.id = st.stateFk - WHERE st.isChecked - AND s.semaphore = 1)st ON st.saleFk = s.id - WHERE tc.collectionFk = vCollectionFk - AND st.saleFk IS NULL - AND NOT s.isPicked; - - CALL itemShelvingSale_reserve(); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_reserveBySale` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSale_reserveBySale`( - vSelf INT , - vQuantity INT, - vUserFk INT -) -BEGIN -/** - * Reserva cantida y ubicación para una saleFk - * - * @param vSelf Identificador de la venta - * @param vQuantity Cantidad a reservar - * @param vUserFk Id de usuario que realiza la reserva - */ - CREATE OR REPLACE TEMPORARY TABLE tmp.sale - ENGINE = MEMORY - SELECT vSelf saleFk, vUserFk userFk; - - CALL itemShelvingSale_reserve(); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_setQuantity` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSale_setQuantity`( - vItemShelvingSaleFk INT(10), - vQuantity DECIMAL(10,0), - vIsItemShelvingSaleEmpty BOOLEAN -) -BEGIN -/** - * Gestiona la reserva de un itemShelvingFk, actualizando isPicked y quantity - * en vn.itemShelvingSale y vn.sale.isPicked en caso necesario. - * Si la reserva de la ubicación es fallida, se regulariza la situación - * - * @param vItemShelvingSaleFk Id itemShelvingSaleFK - * @param vQuantity Cantidad real que se ha cogido de la ubicación - * @param vIsItemShelvingSaleEmpty determina si ka ubicación itemShelvingSale se ha - * quedado vacio tras el movimiento - */ - DECLARE vSaleFk INT; - DECLARE vCursorSaleFk INT; - DECLARE vItemShelvingFk INT; - DECLARE vReservedQuantity INT; - DECLARE vRemainingQuantity INT; - DECLARE vItemFk INT; - DECLARE vUserFk INT; - DECLARE vDone BOOLEAN DEFAULT FALSE; - DECLARE vSales CURSOR FOR - SELECT iss.saleFk, iss.userFk - FROM itemShelvingSale iss - JOIN sale s ON s.id = iss.saleFk - WHERE iss.id = vItemShelvingSaleFk - AND s.itemFk = vItemFk - AND NOT iss.isPicked; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - IF (SELECT isPicked FROM itemShelvingSale WHERE id = vItemShelvingSaleFk) THEN - CALL util.throw('Booking completed'); - END IF; - - SELECT s.itemFk, iss.saleFk, iss.itemShelvingFk - INTO vItemFk, vSaleFk, vItemShelvingFk - FROM itemShelvingSale iss - JOIN sale s ON s.id = iss.saleFk - WHERE iss.id = vItemShelvingSaleFk - AND NOT iss.isPicked; - - UPDATE itemShelvingSale - SET isPicked = TRUE, - quantity = vQuantity - WHERE id = vItemShelvingSaleFk; - - UPDATE itemShelving - SET visible = IF(vIsItemShelvingSaleEmpty, 0, GREATEST(0,visible - vQuantity)) - WHERE id = vItemShelvingFk; - - IF vIsItemShelvingSaleEmpty THEN - OPEN vSales; -l: LOOP - SET vDone = FALSE; - FETCH vSales INTO vCursorSaleFk, vUserFk; - IF vDone THEN - LEAVE l; - END IF; - - CREATE OR REPLACE TEMPORARY TABLE tmp.sale - (INDEX(saleFk, userFk)) - ENGINE = MEMORY - SELECT vCursorSaleFk, vUserFk; - - CALL itemShelvingSale_reserveWhitUser(); - DROP TEMPORARY TABLE tmp.sale; - - END LOOP; - CLOSE vSales; - - DELETE iss - FROM itemShelvingSale iss - JOIN sale s ON s.id = iss.saleFk - WHERE iss.id = vItemShelvingSaleFk - AND s.itemFk = vItemFk - AND NOT iss.isPicked; - END IF; - - SELECT SUM(quantity) INTO vRemainingQuantity - FROM itemShelvingSale - WHERE saleFk = vSaleFk - AND NOT isPicked; - - IF vRemainingQuantity THEN - CALL itemShelvingSale_reserveBySale (vSaleFk, vRemainingQuantity, NULL); - - SELECT SUM(quantity) INTO vRemainingQuantity - FROM itemShelvingSale - WHERE saleFk = vSaleFk - AND NOT isPicked; - - IF NOT vRemainingQuantity <=> 0 THEN - SELECT SUM(iss.quantity) - INTO vReservedQuantity - FROM itemShelvingSale iss - WHERE iss.saleFk = vSaleFk; - - CALL saleTracking_new( - vSaleFk, - TRUE, - vReservedQuantity, - `account`.`myUser_getId`(), - NULL, - 'PREPARED', - TRUE); - - UPDATE sale s - SET s.quantity = vReservedQuantity - WHERE s.id = vSaleFk ; - END IF; - END IF; +BEGIN +/** + * Reserva cantidades con ubicaciones para el contenido de una colección + * + * @param vCollectionFk Identificador de collection + */ + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vSaleFk INT; + DECLARE vSales CURSOR FOR + WITH sales AS ( + SELECT s.id saleFk, s.quantity, SUM(IFNULL(iss.quantity, 0)) quantityReserved + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id + WHERE tc.collectionFk = vCollectionFk + GROUP BY s.id + HAVING quantity <> quantityReserved + ), trackedSales AS ( + SELECT sa.saleFk + FROM sales sa + JOIN vn.saleTracking st ON st.saleFk = sa.saleFk + JOIN vn.`state` s ON s.id = st.stateFk + WHERE st.isChecked + AND s.`code` IN ('PREVIOUS_PREPARATION', 'OK PREVIOUS', 'OK STOWAWAY') + GROUP BY sa.saleFk + ) SELECT s.saleFk + FROM sales s + LEFT JOIN trackedSales ts ON ts.saleFk = s.saleFk + WHERE ts.saleFk IS NULL; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vSales; + l: LOOP + SET vDone = FALSE; + FETCH vSales INTO vSaleFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL itemShelvingSale_addBySale(vSaleFk, NULL); + END LOOP; + CLOSE vSales; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -60028,7 +59740,7 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingTransfer` */; +/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_addBySale` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -60036,48 +59748,629 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingTransfer`(vItemShelvingFk INT, vShelvingFk VARCHAR(3)) -BEGIN +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_addBySale`( + vSaleFk INT, + vSectorFk INT +) +proc: BEGIN /** - * Transfiere producto de una ubicación a otra, fusionando si coincide el - * packing y la fecha. + * Reserva una línea de venta en la ubicación más óptima * - * @param vItemShelvingFk Identificador de itemShelving - * @param vShelvingFk Identificador de shelving + * @param vSaleFk Id de sale + * @param vItemShelvingSaleFk Id de reserva + * @param vSectorFk Id del sector del operator */ - DECLARE vNewItemShelvingFk INT DEFAULT 0; + DECLARE vLastPickingOrder INT; + DECLARE vDone INT DEFAULT FALSE; + DECLARE vItemShelvingFk INT; + DECLARE vAvailable INT; + DECLARE vReservedQuantity INT; + DECLARE vOutStanding INT; + DECLARE vUserFk INT; + DECLARE vTotalReservedQuantity INT; + DECLARE vSaleQuantity INT; - SELECT MAX(ish.id) - INTO vNewItemShelvingFk - FROM itemShelving ish - JOIN ( - SELECT - itemFk, - packing, - created - FROM itemShelving - WHERE id = vItemShelvingFk - ) ish2 - ON ish2.itemFk = ish.itemFk - AND ish2.packing = ish.packing - AND date(ish2.created) = date(ish.created) - WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci; + DECLARE vItemShelvingAvailable CURSOR FOR + SELECT ish.id itemShelvingFk, + ish.available + FROM sale s + JOIN itemShelving ish ON ish.itemFk = s.itemFk + JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN parking p ON p.id = sh.parkingFk + JOIN sector sc ON sc.id = p.sectorFk + JOIN productionConfig pc + WHERE s.id = vSaleFk + AND NOT sc.isHideForPickers + AND (sc.id = vSectorFk OR vSectorFk IS NULL) + ORDER BY s.id, + p.pickingOrder >= vLastPickingOrder, + sh.priority DESC, + ish.available >= s.quantity DESC, + s.quantity MOD ish.grouping = 0 DESC, + ish.grouping DESC, + IF(pc.orderMode = 'Location', p.pickingOrder, ish.created); - IF vNewItemShelvingFk THEN - UPDATE itemShelving ish - JOIN itemShelving ish2 ON ish2.id = vItemShelvingFk - SET ish.visible = ish.visible + ish2.visible - WHERE ish.id = vNewItemShelvingFk; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + SELECT id INTO vSaleFk + FROM sale + WHERE id = vSaleFk + FOR UPDATE; - DELETE FROM itemShelving - WHERE id = vItemShelvingFk; - ELSE - UPDATE itemShelving - SET shelvingFk = vShelvingFk - WHERE id = vItemShelvingFk; + SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)), s.quantity + INTO vLastPickingOrder, vOutStanding, vSaleQuantity + FROM sale s + LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id + LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + LEFT JOIN shelving sh ON sh.code = ish.shelvingFk + LEFT JOIN parking p ON p.id = sh.parkingFk + WHERE s.id = vSaleFk; + + IF vOutStanding <= 0 THEN + COMMIT; + LEAVE proc; END IF; - SELECT true; + SELECT getUser() INTO vUserFk; + + OPEN vItemShelvingAvailable; + l: LOOP + SET vDone = FALSE; + FETCH vItemShelvingAvailable INTO vItemShelvingFk, vAvailable; + + IF vOutStanding <= 0 OR vDone THEN + SELECT SUM(IFNULL(quantity, 0)) + INTO vTotalReservedQuantity + FROM itemShelvingSale + WHERE saleFk = vSaleFk; + + IF vTotalReservedQuantity <> vSaleQuantity THEN + CALL util.debugAdd('itemShelvingSale_addBySale', + CONCAT(vSaleFk, ' - ', vSaleQuantity,' - ', vTotalReservedQuantity,'-', vOutStanding,'-', account.myUser_getId())); + + UPDATE sale + SET quantity = vTotalReservedQuantity + WHERE id = vSaleFk; + END IF; + LEAVE l; + END IF; + + SELECT id INTO vItemShelvingFk + FROM itemShelving + WHERE id = vItemShelvingFk + FOR UPDATE; + + SELECT LEAST(vOutStanding, vAvailable) INTO vReservedQuantity; + SET vOutStanding = vOutStanding - vReservedQuantity; + + IF vReservedQuantity > 0 THEN + CALL util.debugAdd('itemShelvingSale_addBySale_reservedQuantity', + CONCAT(vSaleFk, ' - ', vReservedQuantity, ' - ', vOutStanding, account.myUser_getId())); + INSERT INTO itemShelvingSale( + itemShelvingFk, + saleFk, + quantity, + userFk, + isPicked) + SELECT vItemShelvingFk, + vSaleFk, + vReservedQuantity, + vUserFk, + FALSE; + + UPDATE itemShelving + SET available = available - vReservedQuantity + WHERE id = vItemShelvingFk; + + END IF; + END LOOP; + CLOSE vItemShelvingAvailable; + COMMIT; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_addBySaleGroup` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_addBySaleGroup`( + vSaleGroupFk INT(11) +) +BEGIN +/** + * Reserva cantidades con ubicaciones para el contenido de una preparación previa + * a través del saleGroup + * + * @param vSaleGroupFk Identificador de saleGroup + */ + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vSaleFk INT; + DECLARE vSectorFk INT; + DECLARE vSales CURSOR FOR + SELECT s.id + FROM saleGroupDetail sgd + JOIN sale s ON sgd.saleFk = s.id + JOIN saleTracking str ON str.saleFk = s.id + JOIN `state` st ON st.id = str.stateFk + AND st.code = 'PREVIOUS_PREPARATION' + LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id + WHERE sgd.saleGroupFk = vSaleGroupFk + AND str.workerFk = account.myUser_getId() + AND iss.id IS NULL; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + SELECT sectorFk INTO vSectorFk + FROM operator + WHERE workerFk = account.myUser_getId(); + + OPEN vSales; + l: LOOP + SET vDone = FALSE; + FETCH vSales INTO vSaleFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk); + END LOOP; + CLOSE vSales; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_addBySectorCollection` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_addBySectorCollection`(vSectorCollectionFk INT(11)) +BEGIN +/** + * Reserva cantidades con ubicaciones para el contenido de una preparación previa + * de la cual ya tiene generada la asociación del saleGroup con sectorCollection + * + * @param vSectorCollectionFk Identificador de sectorCollection + */ + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vSaleFk INT; + DECLARE vSectorFk INT; + DECLARE vSales CURSOR FOR + SELECT DISTINCT s.id + FROM sectorCollectionSaleGroup sc + JOIN saleGroupDetail sg ON sg.saleGroupFk = sc.saleGroupFk + JOIN sale s ON sg.saleFk = s.id + JOIN saleTracking str ON str.saleFk = s.id + JOIN `state` st ON st.id = str.stateFk + AND st.code = 'PREVIOUS_PREPARATION' + LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id + WHERE sc.sectorCollectionFk = vSectorCollectionFk + AND str.workerFk = account.myUser_getId() + AND iss.id IS NULL; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + SELECT sectorFk INTO vSectorFk + FROM operator + WHERE workerFk = account.myUser_getId(); + + CALL util.debugAdd('itemShelvingSale_addBySectorCollection',CONCAT(vSectorCollectionFk,' - ', account.myUser_getId())); + + OPEN vSales; + l: LOOP + SET vDone = FALSE; + FETCH vSales INTO vSaleFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk); + END LOOP; + CLOSE vSales; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_doReserve` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_doReserve`() +proc: BEGIN +/** + * Genera reservas de la tabla vn.itemShelvingSaleReserve + */ + DECLARE vDone BOOL; + DECLARE vSaleFk INT; + DECLARE vSectorFk INT; + + DECLARE vSales CURSOR FOR + SELECT DISTINCT saleFk, sectorFk FROM tSale; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION + BEGIN + DO RELEASE_LOCK('vn.itemShelvingSale_doReserve'); + ROLLBACK; + RESIGNAL; + END; + + IF !GET_LOCK('vn.itemShelvingSale_doReserve', 0) THEN + LEAVE proc; + END IF; + + CREATE OR REPLACE TEMPORARY TABLE tSale + ENGINE = MEMORY + SELECT id, saleFk, sectorFk FROM itemShelvingSaleReserve; + + OPEN vSales; + + myLoop: LOOP + SET vDone = FALSE; + FETCH vSales INTO vSaleFk, vSectorFk; + + IF vDone THEN + LEAVE myLoop; + END IF; + + CALL itemShelvingSale_addBySale (vSaleFk, vSectorFk); + END LOOP; + + CLOSE vSales; + + DELETE iss FROM itemShelvingSaleReserve iss + JOIN tSale s ON s.id = iss.id AND s.sectorFk = iss.sectorFk; + + DROP TEMPORARY TABLE tSale; + + DO RELEASE_LOCK('vn.itemShelvingSale_doReserve'); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_reallocate` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_reallocate`( + vItemShelvingFk INT(10), + vItemFk INT(10), + vSectorFk INT +) +BEGIN +/** + * Elimina reservas de un itemShelving e intenta reservar en otra ubicación + * + * @param vItemShelvingFk Id itemShelving + * @param vItemFk Id del artículo + * @param vSectorFk Id del sector + */ + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + UPDATE itemShelving + SET visible = 0, + available = 0 + WHERE id = vItemShelvingFk + AND itemFk = vItemFk; + + SELECT iss.id + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND ish.itemFk = vItemFk + AND NOT iss.isPicked + FOR UPDATE; + + INSERT INTO itemShelvingSaleReserve (saleFk, sectorFk) + SELECT DISTINCT iss.saleFk, vSectorFk + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND ish.itemFk = vItemFk + AND NOT iss.isPicked; + + DELETE iss + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND ish.itemFk = vItemFk + AND NOT iss.isPicked; + COMMIT; + + CALL itemShelvingSale_doReserve(); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_setPicked` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_setPicked`( + vSaleGroupFk INT(10) +) +BEGIN +/** + * Gestiona la reserva de un vn.saleGroup actualizando vn.itemShelvingSale.isPicked + * y cambiando el estado de la vn.sale + * + * @param vSaleGroupFk Id saleGroupFk + */ + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + IF NOT (SELECT COUNT(*) FROM saleGroup WHERE id = vSaleGroupFk) THEN + CALL util.throw('Sale group not exists'); + END IF; + + START TRANSACTION; + + UPDATE itemShelvingSale iss + JOIN sale s ON s.id = iss.saleFk + JOIN saleGroupDetail sg ON sg.saleFk = s.id + SET iss.isPicked = TRUE + WHERE sg.saleGroupFk = vSaleGroupFk; + + CALL saleTracking_addPreparedSaleGroup(vSaleGroupFk); + + COMMIT; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_setQuantity` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_setQuantity`( + vItemShelvingSaleFk INT(10), + vQuantity DECIMAL(10,0), + vIsItemShelvingSaleEmpty BOOLEAN, + vSectorFk INT +) +BEGIN +/** + * Gestiona la reserva de un itemShelvingFk, actualizando isPicked y quantity + * en itemShelvingSale y sale.isPicked en caso necesario. + * Si la reserva de la ubicación es fallida, se regulariza la situación + * + * @param vItemShelvingSaleFk Id itemShelvingSaleFK + * @param vQuantity Cantidad real que se ha cogido de la ubicación + * @param vIsItemShelvingSaleEmpty determina si la ubicación itemShelvingSale se ha + * quedado vacio tras el movimiento + * @param vSectorFk Id del sector + */ + DECLARE vSaleFk INT; + DECLARE vItemShelvingFk INT; + DECLARE vReservedQuantity INT; + DECLARE vRemainingQuantity INT; + DECLARE vItemFk INT; + DECLARE vTotalQuantity INT; + DECLARE vStateCode VARCHAR(45); + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + IF vQuantity > vReservedQuantity + OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty) + OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN + CALL util.throw('The quantity cannot be different from the reserved'); + END IF; + + IF (SELECT isPicked FROM itemShelvingSale WHERE id = vItemShelvingSaleFk) THEN + CALL util.throw('Reservation completed'); + END IF; + + SELECT s.itemFk, + iss.saleFk, + iss.itemShelvingFk, + SUM(IFNULL(iss.quantity,0)), + IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED') + INTO vItemFk, + vSaleFk, + vItemShelvingFk, + vReservedQuantity, + vStateCode + FROM itemShelvingSale iss + JOIN sale s ON s.id = iss.saleFk + LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = iss.saleFk + WHERE iss.id = vItemShelvingSaleFk + AND NOT iss.isPicked; + + IF vQuantity > vReservedQuantity + OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty) + OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN + CALL util.throw('The quantity cannot be different from the reserved'); + END IF; + + START TRANSACTION; + + UPDATE itemShelvingSale + SET isPicked = TRUE, + quantity = vQuantity + WHERE id = vItemShelvingSaleFk; + + SELECT id INTO vItemShelvingFk + FROM itemShelving + WHERE id = vItemShelvingFk + FOR UPDATE; + + UPDATE itemShelving + SET visible = GREATEST(0, visible - vQuantity) + WHERE id = vItemShelvingFk; + + SELECT SUM(IF(isPicked OR id = vItemShelvingSaleFk, 0, quantity)), SUM(quantity) + INTO vRemainingQuantity, vTotalQuantity + FROM itemShelvingSale + WHERE saleFk = vSaleFk; + + IF vRemainingQuantity = 0 AND NOT vIsItemShelvingSaleEmpty THEN + CALL saleTracking_new( + vSaleFk, + TRUE, + vTotalQuantity, + `account`.`myUser_getId`(), + NULL, + vStateCode, + TRUE); + + UPDATE sale s + SET s.quantity = vTotalQuantity, + isPicked = TRUE + WHERE s.id = vSaleFk; + END IF; + + COMMIT; + + IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN + INSERT INTO itemShelvingSaleReserve (saleFk, sectorFk) + SELECT vSaleFk, vSectorFk; + CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk, vSectorFk); + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_unpicked` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_unpicked`( + vSelf INT(11) +) +BEGIN +/** + * Desmarca una línea que ya estaba sacada, devolviendo la cantidad al itemShelving + * + * @param vSelf Identificador del itemShelvingSale + */ + DECLARE vSaleFk INT; + DECLARE vReservedQuantity INT; + DECLARE vIsSaleGroup BOOL; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + IF (SELECT NOT isPicked FROM itemShelvingSale WHERE id = vSelf) THEN + CALL util.throw('Reserva no completada'); + END IF; + + SELECT ish.saleFk, ish.quantity, IF(sg.id, TRUE, FALSE) + INTO vSaleFk, vReservedQuantity, vIsSaleGroup + FROM itemShelvingSale ish + LEFT JOIN saleGroupDetail sg ON sg.saleFk = ish.saleFk + WHERE ish.id = vSelf; + + /*IF vIsSaleGroup THEN + CALL util.throw('Can not unpicked a sale group'); + END IF;*/ + + START TRANSACTION; + + UPDATE itemShelvingSale + SET isPicked = FALSE + WHERE id = vSelf; + + UPDATE sale s + JOIN itemShelvingSale ish ON ish.saleFk = s.id + SET s.isPicked = FALSE + WHERE ish.id = vSelf; + + UPDATE itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + SET ish.visible = ish.visible + iss.quantity + WHERE iss.id = vSelf; + + CALL saleTracking_new( + vSaleFk, + FALSE, + vReservedQuantity, + `account`.`myUser_getId`(), + NULL, + 'ON_PREPARATION', + TRUE); + COMMIT; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -60094,10 +60387,16 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_add`( + vShelvingFk VARCHAR(8), + vBarcode VARCHAR(22), + vQuantity INT, + vPackagingFk VARCHAR(10), + vGrouping INT, + vPacking INT, + vWarehouseFk INT +) BEGIN - - /** * Añade registro o lo actualiza si ya existe. * @@ -60110,11 +60409,18 @@ BEGIN * @param vWarehouseFk indica el sector * **/ - DECLARE vItemFk INT; + DECLARE vBuyFk INT; + + SELECT id INTO vBuyFk + FROM buy WHERE id = vBarcode; SELECT barcodeToItem(vBarcode) INTO vItemFk; + IF vBuyFk IS NULL THEN + CALL util.throw('The buy is required'); + END IF; + IF vPacking IS NULL THEN SET vPacking = itemPacking(vBarcode, vWarehouseFk); @@ -60124,32 +60430,34 @@ BEGIN IF (SELECT COUNT(*) FROM itemShelving WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk - AND packing = vPacking) = 1 THEN + AND packing = vPacking + AND buyFk = vBuyFk) THEN UPDATE itemShelving - SET visible = visible+vQuantity + SET visible = visible + vQuantity, + available = available + vQuantity WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking; ELSE - CALL cache.last_buy_refresh(FALSE); - INSERT INTO itemShelving( itemFk, - shelvingFk, - visible, - grouping, - packing, - packagingFk) - SELECT vItemFk, - vShelvingFk, - vQuantity, - IFNULL(vGrouping, b.grouping), - IFNULL(vPacking, b.packing), - IFNULL(vPackagingFk, b.packagingFk) - FROM item i - LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk - LEFT JOIN buy b ON b.id = lb.buy_id - WHERE i.id = vItemFk; - END IF; + INSERT INTO itemShelving( + itemFk, + shelvingFk, + visible, + grouping, + packing, + packagingFk, + buyFk) + SELECT vItemFk, + vShelvingFk, + vQuantity, + IFNULL(vGrouping, b.grouping), + IFNULL(vPacking, b.packing), + IFNULL(vPackagingFk, b.packagingFk), + id + FROM buy b + WHERE id = vBuyFk; + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -60166,7 +60474,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_addByClaim`(vClaimFk INT, vShelvingFk VARCHAR(3)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_addByClaim`(vClaimFk INT, vShelvingFk VARCHAR(3)) BEGIN /** * Insert items of claim into itemShelving. @@ -60182,7 +60490,7 @@ BEGIN JOIN ticket t ON t.id = c.ticketFk WHERE c.id = vClaimFk; - CALL buyUltimate (vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(NULL, vWarehouseFk, util.VN_CURDATE()); INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible) SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible @@ -60209,7 +60517,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_addList`(vShelvingFk VARCHAR(3), vList TEXT, vIsChecking BOOL, vWarehouseFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_addList`(vShelvingFk VARCHAR(3), vList TEXT, vIsChecking BOOL, vWarehouseFk INT) BEGIN /* Recorre cada elemento en la colección vList. * Si el parámetro isChecking = FALSE, llama a itemShelving_add. @@ -60269,7 +60577,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_filterBuyer`(vBuyerFk INT, vWarehouseFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_filterBuyer`(vBuyerFk INT, vWarehouseFk INT) proc:BEGIN /** * Lista de articulos filtrados por comprador @@ -60291,7 +60599,8 @@ proc:BEGIN sub.downstairs, sub.visible, CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) nicho, - sub.name itemColour + sub.name itemColour, + CAST(sub2.pendiente AS DECIMAL(10,0)) pendingAmount FROM (SELECT iss.itemFk, CONCAT(i.longName, ' ', IFNULL(i.size, ''),' ', IFNULL(i.subName, '') ) longName, '' size, @@ -60328,7 +60637,8 @@ proc:BEGIN 0, v.visible, v.visible nicho, - ik.name itemColour + ik.name itemColour, + CAST(sub5.pendiente AS DECIMAL(10,0)) pendingAmount FROM cache.visible v JOIN item i ON i.id = v.item_id LEFT JOIN ink ik ON ik.id = i.inkFk @@ -60366,7 +60676,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_get`(IN vSelf VARCHAR(8)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_get`(IN vSelf VARCHAR(8)) BEGIN /** * Lista artículos de itemshelving @@ -60383,7 +60693,8 @@ BEGIN ish.id, s.priority, ish.isChecked, - ic.url + ic.url, + ish.available FROM itemShelving ish JOIN item i ON i.id = ish.itemFk JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci @@ -60406,7 +60717,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_getAlternatives`(vShelvingFk VARCHAR(10)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_getAlternatives`(vShelvingFk VARCHAR(10)) BEGIN /** * Devuelve un listado de posibles ubicaciones alternativas a ubicar los item de la matricula @@ -60441,7 +60752,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_getInfo`(vItemFk VARCHAR(22)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_getInfo`(vItemFk VARCHAR(22)) BEGIN /** * Muestra información realtiva a la ubicación de un item @@ -60470,6 +60781,74 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_getItemDetails` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_getItemDetails`( + vBarcodeItem INT, + vShelvingFK VARCHAR(10) +) +BEGIN +/** + * Obtiene el precio y visible de un item + * + * @param vBarcodeItem barcode de artículo + * @param vShelvingFK Ubicación actual del artículo + */ + DECLARE vIsItem BOOL; + DECLARE vBuyFk INT; + DECLARE vWarehouseFk INT; + + SELECT COUNT(*) > 0 INTO vIsItem + FROM item + WHERE id = vBarcodeItem; + + IF vIsItem THEN + SELECT warehouseFk INTO vWarehouseFk + FROM operator + WHERE workerFk = account.myUser_getId(); + + CALL buy_getUltimate(vBarcodeItem, vWarehouseFk, util.VN_CURDATE()); + + SELECT buyFk INTO vBuyFk + FROM tmp.buyUltimate + WHERE itemFk = vBarcodeItem + AND warehouseFk = vWarehouseFk; + + DELETE FROM tmp.buyUltimate; + ELSE + SELECT vBarcodeItem INTO vBuyFk; + END IF; + + WITH visible AS( + SELECT itemFk, + IFNULL(buyingValue, 0) + + IFNULL(freightValue, 0) + + IFNULL(comissionValue, 0) + + IFNULL(packageValue, 0) itemCost + FROM vn.buy b + WHERE b.id = vBuyFk + ) SELECT v.itemFk, + vShelvingFK, + v.itemCost, + SUM(ish.visible) visible + FROM vn.itemShelving ish + JOIN visible v + WHERE ish.shelvingFK = vShelvingFK COLLATE utf8mb3_general_ci + AND ish.itemFk = v.itemFk; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelving_getSaleDate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60478,7 +60857,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_getSaleDate`(vShelvingFk VARCHAR(3)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_getSaleDate`(vShelvingFk VARCHAR(3)) BEGIN /* Devuelve la mínima fecha en que se necesita cada producto en esa matrícula. @@ -60656,7 +61035,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_inventory`(vParkingFromFk VARCHAR(8), vParkingToFk VARCHAR(8)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_inventory`(vParkingFromFk VARCHAR(8), vParkingToFk VARCHAR(8)) BEGIN /** * Devuelve un listado de ubicaciones a revisar @@ -60716,6 +61095,8 @@ BEGIN WHERE p.pickingOrder BETWEEN vPickingOrderFrom AND vPickingOrderTo AND p.sectorFk = vSectorFk ORDER BY p.pickingOrder; + + DROP TEMPORARY TABLE tmp.stockMisfit; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -60732,19 +61113,19 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_selfConsumption`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_selfConsumption`( vShelvingFk VARCHAR(10) COLLATE utf8_general_ci, vItemFk INT, vQuantity INT ) BEGIN /** - * Leave the indicated amount on the shelf + * Leave the indicated amount on the shelve * and create a ticket with the difference. * - * @param vShelvingFk id of the shelf where the item is located. + * @param vShelvingFk id of the shelve where the item is located. * @param vItemFk article of which the self-consumption ticket is to be created. - * @param vQuantity amount that will stay on the shelf + * @param vQuantity amount that will stay on the shelve */ DECLARE vVisible INT; DECLARE vClientFk INT; @@ -60813,7 +61194,8 @@ BEGIN WHERE id = vItemFk; UPDATE itemShelving - SET visible = IF(id = vItemShelvingFk, vQuantity, 0) + SET visible = IF(id = vItemShelvingFk, vQuantity, 0), + available = IF(id = vItemShelvingFk, vQuantity, 0) WHERE shelvingFk = vShelvingFk AND itemFk = vItemFk; @@ -60826,6 +61208,72 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_transfer` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_transfer`( + vItemShelvingFk INT, + vShelvingFk VARCHAR(10) +) +BEGIN +/** + * Transfiere producto de una ubicación a otra + * fusionando si coincide el packing y la fecha. + * + * @param vItemShelvingFk Identificador de itemShelving + * @param vShelvingFk Identificador de shelving + */ + DECLARE vNewItemShelvingFk INT; + + SELECT MAX(ish.id) INTO vNewItemShelvingFk + FROM itemShelving ish + JOIN ( + SELECT itemFk, + packing, + created, + buyFk + FROM itemShelving + WHERE id = vItemShelvingFk + ) ish2 ON ish2.itemFk = ish.itemFk + AND ish2.packing = ish.packing + AND DATE(ish2.created) = DATE(ish.created) + AND ish2.buyFk = ish.buyFk + WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci; + + IF vNewItemShelvingFk THEN + UPDATE itemShelving ish + JOIN itemShelving ish2 ON ish2.id = vItemShelvingFk + SET ish.visible = ish.visible + ish2.visible, + ish.available = ish.available + ish2.available + WHERE ish.id = vNewItemShelvingFk; + + DELETE FROM itemShelving + WHERE id = vItemShelvingFk; + ELSE + IF (SELECT EXISTS(SELECT id FROM shelving + WHERE code = vShelvingFk COLLATE utf8_unicode_ci)) THEN + + UPDATE itemShelving + SET shelvingFk = vShelvingFk + WHERE id = vItemShelvingFk; + ELSE + CALL util.throw('The shelving not exists'); + END IF; + END IF; + SELECT TRUE; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelving_update` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60834,7 +61282,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_update`(vVisible INT, vPacking INT, vShelf INT ,vGrouping INT ) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_update`(vVisible INT, vPacking INT, vShelf INT ,vGrouping INT ) BEGIN /** * Actualiza itemShelving. @@ -60866,7 +61314,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTagMake`(vItemFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemTagMake`(vItemFk INT) BEGIN /* * Crea los tags usando la tabla plantilla itemTag @@ -60926,16 +61374,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemTagReorder` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTagReorder`(itemTypeFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemTagReorder`(itemTypeFk INT) BEGIN SET @isTriggerDisabled = TRUE; @@ -60975,7 +61423,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTagReorderByName`(vName VARCHAR(255)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemTagReorderByName`(vName VARCHAR(255)) BEGIN SET @isTriggerDisabled = TRUE; @@ -61015,7 +61463,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTag_replace`(vItemFromFk INT, vItemToFk INT, vPicture VARCHAR(100)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemTag_replace`(vItemFromFk INT, vItemToFk INT, vPicture VARCHAR(100)) BEGIN /* Reemplaza los tags de un artículo por los de otro, así como su imagen @@ -61063,7 +61511,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTopSeller`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemTopSeller`() BEGIN DECLARE vCategoryFk INTEGER; DECLARE vDone INT DEFAULT FALSE; @@ -61131,75 +61579,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `itemTrash` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTrash`( - vItemFk INT, - vWarehouseFk INT, - vQuantity INT, - vIsTrash BOOLEAN) -BEGIN - DECLARE vTicketFk INT; - DECLARE vClientFk INT; - DECLARE vCompanyVnlFk INT DEFAULT 442; - DECLARE vCalc INT; - - SELECT barcodeToItem(vItemFk) INTO vItemFk; - - SELECT IF(vIsTrash, 200, 400) INTO vClientFk; - - SELECT t.id INTO vTicketFk - FROM ticket t - JOIN address a ON a.id=t.addressFk - WHERE t.warehouseFk = vWarehouseFk - AND t.clientFk = vClientFk - AND DATE(t.shipped) = util.VN_CURDATE() - AND a.isDefaultAddress - LIMIT 1; - - CALL cache.visible_refresh(vCalc, TRUE, vWarehouseFk); - - IF vTicketFk IS NULL THEN - CALL ticket_add( - vClientFk, - util.VN_CURDATE(), - vWarehouseFk, - vCompanyVnlFk, - NULL, - NULL, - NULL, - util.VN_CURDATE(), - account.myUser_getId(), - FALSE, - vTicketFk); - END IF; - - INSERT INTO sale(ticketFk, itemFk, concept, quantity) - SELECT vTicketFk, - vItemFk, - CONCAT(longName,' ',worker_getCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)), - vQuantity - FROM item - WHERE id = vItemFk; - - UPDATE cache.visible - SET visible = visible - vQuantity - WHERE calc_id = vCalc - AND item_id = vItemFk; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemUpdateTag` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61208,7 +61587,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemUpdateTag`(IN vItem BIGINT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemUpdateTag`(IN vItem BIGINT) BEGIN @@ -61246,6 +61625,81 @@ SET tag8 = t.name, value8 = it.value WHERE it.priority = 4 AND (vItem IS NULL OR vItem = it.itemFk); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `item_calcVisible` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_calcVisible`( + vSelf INT, + vWarehouseFk INT +) +BEGIN +/** + * Calcula el visible de un artículo o de todos. + * + * @param vWarehouse Warehouse id + * @param vSelf Item id + * @param tmp.itemVisible(item_id, stock, visible) + */ + DECLARE vDated DATE DEFAULT util.VN_CURDATE(); + DECLARE vTomorrow DATETIME DEFAULT util.tomorrow(); + + INSERT INTO tmp.itemVisible(item_id, visible) + SELECT itemFk, SUM(quantity) + FROM ( + SELECT i.itemFk, i.quantity + FROM itemTicketOut i + LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk + JOIN `state` s ON s.id = ts.stateFk + JOIN warehouse w ON w.id = i.warehouseFk + LEFT JOIN ( + SELECT DISTINCT st.saleFk + FROM saleTracking st + JOIN state s ON s.id = st.stateFk + WHERE st.created > vDated + AND (s.isPicked OR st.isChecked) + ) stPrevious ON `stPrevious`.`saleFk` = i.saleFk + WHERE (vWarehouseFk IS NULL OR i.warehouseFk = vWarehouseFk) + AND (vSelf IS NULL OR i.itemFk = vSelf) + AND (s.isPicked OR i.reserved OR stPrevious.saleFk) + AND i.shipped >= vDated AND i.shipped < vTomorrow + AND w.isComparative + UNION ALL + SELECT iei.itemFk, iei.quantity + FROM itemEntryIn iei + JOIN warehouse w ON w.id = iei.warehouseInFk + WHERE iei.isReceived + AND iei.landed >= vDated AND iei.landed < vTomorrow + AND (vWarehouseFk IS NULL OR iei.warehouseInFk = vWarehouseFk) + AND (vSelf IS NULL OR iei.itemFk = vSelf) + AND NOT iei.isVirtualStock + AND w.isComparative + UNION ALL + SELECT ieo.itemFk, ieo.quantity + FROM itemEntryOut ieo + JOIN warehouse w ON w.id = ieo.warehouseOutFk + WHERE ieo.isDelivered + AND ieo.shipped >= vDated + AND ieo.shipped < vTomorrow + AND (vWarehouseFk IS NULL OR ieo.warehouseOutFk = vWarehouseFk) + AND (vSelf IS NULL OR ieo.itemFk = vSelf) + AND w.isComparative + ) t + GROUP BY itemFk + ON DUPLICATE KEY UPDATE + visible = IFNULL(stock, 0) + VALUES(visible); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -61262,7 +61716,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_cleanFloramondo`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_cleanFloramondo`() BEGIN /** * Elimina todos los items repetidos de floramondo @@ -61475,28 +61929,28 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_comparative`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_comparative`( vDate DATETIME, vDayRange TINYINT, vWarehouseFk TINYINT, vAvailableSince DATE, vBuyerFk INT, vIsFloramondo BOOL, - vCountryFk INT + vCountryFk INT ) proc: BEGIN /** - * Genera una tabla de comparativa de artículos por itemType/comprador/fecha. - * Los datos se calculan en función de los parámetros proporcionados. + * Generates a comparison table of items by itemType/buyer/date. + * The data is calculated based on the provided parameters. * - * @param vDate La fecha para la cual se generará la comparativa. - * @param vDayRange El rango de días a considerar para la comparativa. - * @param vWarehouseFk El identificador del almacén para filtrar los artículos. - * @param vAvailableSince La fecha de disponibilidad desde la cual se consideran los artículos disponibles. - * @param vBuyerFk El identificador del comprador para filtrar los artículos. - * @param vIsFloramondo Indica si se deben incluir solo los artículos de Floramondo (opcional). - * @param vCountryFk El identificador del país. - * @param tmp.comparativeFilterType(filterFk INT ,itemTypeFk INT) + * @param vDate The date for which the comparison will be generated. + * @param vDayRange The range of days to consider for the comparison. + * @param vWarehouseFk The warehouse identifier to filter the items. + * @param vAvailableSince The availability date from which the items are considered available. + * @param vBuyerFk The buyer identifier to filter the items. + * @param vIsFloramondo Indicates whether only Floramondo items should be included (optional). + * @param vCountryFk The country identifier. + * @param tmp.comparativeFilterType(filterFk INT, itemTypeFk INT) * @return tmp.comparative */ @@ -61535,14 +61989,14 @@ proc: BEGIN END IF; SELECT MIN(dated) INTO vDayRangeStart - FROM vn.time + FROM `time` WHERE dated <= vDate GROUP BY period ORDER BY dated desc LIMIT 1 OFFSET vWeekRange; SELECT MAX(dated) INTO vDayRangeEnd - FROM vn.time + FROM `time` WHERE dated >= vDate GROUP BY period ORDER BY dated ASC @@ -61559,12 +62013,11 @@ proc: BEGIN JOIN itemType t ON t.id = i.typeFk JOIN itemCategory c ON c.id = t.categoryFk LEFT JOIN worker w ON w.id = t.workerFk - WHERE (NOT vHasTypeFilter - OR t.id IN (SELECT itemTypeFk FROM tmp.comparativeFilterType)) - AND (vBuyerFk IS NULL - OR t.workerFk = vBuyerFk) - AND (vIsFloramondo IS NULL - OR i.isFloramondo = vIsFloramondo); + WHERE (NOT vHasTypeFilter OR t.id IN ( + SELECT itemTypeFk FROM tmp.comparativeFilterType + )) + AND (vBuyerFk IS NULL OR t.workerFk = vBuyerFk) + AND (vIsFloramondo IS NULL OR i.isFloramondo = vIsFloramondo); IF vDate < util.VN_CURDATE() THEN ALTER TABLE tmp.itemInventory @@ -61591,10 +62044,11 @@ proc: BEGIN SET i = i + 1; SELECT t.period INTO vPeriod - FROM vn.`time` t + FROM `time` t WHERE t.dated = vDayRangeStart + INTERVAL (vWeekCount * (i - 1)) DAY; - INSERT IGNORE INTO tTable(cy, ly, zy) VALUES(vPeriod, vPeriod - 100, vPeriod - 200); + INSERT IGNORE INTO tTable(cy, ly, zy) + VALUES(vPeriod, vPeriod - 100, vPeriod - 200); UNTIL i = vWeekCount END REPEAT; SELECT cy, ly, zy INTO w1, y1, z1 FROM tTable LIMIT 1; @@ -61606,7 +62060,6 @@ proc: BEGIN SELECT cy, ly, zy INTO w7, y7, z7 FROM tTable WHERE cy > w6 LIMIT 1; -- Genera una tabla con los datos del año pasado. - CREATE OR REPLACE TEMPORARY TABLE tLastYear (KEY (lItemFk)) ENGINE = MEMORY @@ -61627,15 +62080,14 @@ proc: BEGIN SUM(IF(c.timePeriod = y7, c.price, 0)) lprice7 FROM tmp.itemInventory ai JOIN comparative c ON c.itemFk = ai.id - JOIN warehouse w on w.id = c.warehouseFk + JOIN warehouse w ON w.id = c.warehouseFk JOIN tTable wt ON c.timePeriod = wt.ly - WHERE IFNULL(vWarehouseFk, c.warehouseFk) = c.warehouseFk + WHERE (vWarehouseFk IS NULL OR vWarehouseFk = c.warehouseFk) AND w.isComparative AND (vCountryFk IS NULL OR c.countryFk = vCountryFk) GROUP BY ai.id; - -- Genera una tabla con los datos de hace DOS años. - + -- Genera una tabla con los datos de hace 2 años CREATE OR REPLACE TEMPORARY TABLE tTwoYearsAgo (KEY (tItemFk)) ENGINE = MEMORY @@ -61656,73 +62108,72 @@ proc: BEGIN SUM(IF(c.timePeriod = z7, c.price, 0)) vlprice7 FROM tmp.itemInventory ai JOIN comparative c ON c.itemFk = ai.id - JOIN warehouse w on w.id = c.warehouseFk + JOIN warehouse w ON w.id = c.warehouseFk JOIN tTable wt ON c.timePeriod = wt.zy - WHERE IFNULL(vWarehouseFk, c.warehouseFk) = c.warehouseFk + WHERE (vWarehouseFk IS NULL OR vWarehouseFk = c.warehouseFk) AND w.isComparative AND (vCountryFk IS NULL OR c.countryFk = vCountryFk) GROUP BY ai.id; - -- Genera una tabla con los datos de este año.ss - + -- Genera una tabla con los datos de este año CREATE OR REPLACE TEMPORARY TABLE tCurrentYear (KEY (cItemFk)) ENGINE = MEMORY SELECT t.itemFk cItemFk, - SUM(IF(week = w1, total, 0)) cweek1, - SUM(IF(week = w2, total, 0)) cweek2, - SUM(IF(week = w3, total, 0)) cweek3, - SUM(IF(week = w4, total, 0)) cweek4, - SUM(IF(week = w5, total, 0)) cweek5, - SUM(IF(week = w6, total, 0)) cweek6, - SUM(IF(week = w7, total, 0)) cweek7, - SUM(IF(week = w1, price, 0)) cprice1, - SUM(IF(week = w2, price, 0)) cprice2, - SUM(IF(week = w3, price, 0)) cprice3, - SUM(IF(week = w4, price, 0)) cprice4, - SUM(IF(week = w5, price, 0)) cprice5, - SUM(IF(week = w6, price, 0)) cprice6, - SUM(IF(week = w7, price, 0)) cprice7 + SUM(IF(`week` = w1, total, 0)) cweek1, + SUM(IF(`week` = w2, total, 0)) cweek2, + SUM(IF(`week` = w3, total, 0)) cweek3, + SUM(IF(`week` = w4, total, 0)) cweek4, + SUM(IF(`week` = w5, total, 0)) cweek5, + SUM(IF(`week` = w6, total, 0)) cweek6, + SUM(IF(`week` = w7, total, 0)) cweek7, + SUM(IF(`week` = w1, price, 0)) cprice1, + SUM(IF(`week` = w2, price, 0)) cprice2, + SUM(IF(`week` = w3, price, 0)) cprice3, + SUM(IF(`week` = w4, price, 0)) cprice4, + SUM(IF(`week` = w5, price, 0)) cprice5, + SUM(IF(`week` = w6, price, 0)) cprice6, + SUM(IF(`week` = w7, price, 0)) cprice7 FROM ( SELECT s.itemFk, ti.period `week`, SUM(s.quantity) total, - TRUNCATE(SUM(s.quantity * s.priceFixed),0) price - FROM ticket t + TRUNCATE(SUM(s.quantity * s.priceFixed), 0) price + FROM ticket t FORCE INDEX (Fecha) JOIN sale s ON t.id = s.ticketFk - JOIN tmp.itemInventory it ON it.id = s.itemFk - JOIN time ti ON ti.dated = DATE(t.shipped) + JOIN tmp.itemInventory it ON it.id = s.itemFk + JOIN `time` ti ON ti.dated = DATE(t.shipped) JOIN item i ON i.id = s.itemFk JOIN itemType tp ON tp.id = i.typeFk JOIN itemCategory ic ON ic.id = tp.categoryFk JOIN warehouse w ON w.id = t.warehouseFk - STRAIGHT_JOIN address ad ON ad.id = t.addressFk - JOIN province p ON p.id = ad.provinceFk + JOIN `address` ad ON ad.id = t.addressFk + JOIN province p ON p.id = ad.provinceFk JOIN `client` c ON c.id = ad.clientFk WHERE t.shipped BETWEEN vDayRangeStart AND util.dayEnd(vDayRangeEnd) - AND c.typeFk IN ('Normal','handMaking') - AND w.id = COALESCE(vWarehouseFk, w.id) + AND c.typeFk IN ('normal', 'handMaking') + AND (vWarehouseFk IS NULL OR vWarehouseFk = w.id) + AND (vCountryFk IS NULL OR p.countryFk = vCountryFk) AND w.isComparative - AND (vCountryFk IS NULL OR p.countryFk = vCountryFk) - GROUP BY i.id, week + GROUP BY i.id, `week` ) t GROUP BY t.itemFk; - -- Genera la tabla con la comparativa. + -- Genera la tabla con la comparativa CREATE OR REPLACE TEMPORARY TABLE tmp.comparative ENGINE = MEMORY - SELECT it.subName productor, - b.packing, + SELECT it.subName productor, + b.packing, b.buyingValue costefijo, b.groupingMode caja, it.image ArticleImage, - IFNULL(it.inkFk,"?") color, + IFNULL(it.inkFk, '?') color, tp.code tipo, it.typeFk tipo_id, o.code origen, it.category categoria, it.stems tallos, - it.size medida, + it.`size` medida, it.name article, w.code codigoTrabajador, tp.categoryFk reino_id, @@ -61733,24 +62184,27 @@ proc: BEGIN it.id Id_Article, i.buy_id, tp.life, - IFNULL(i.sd,0) sd, + IFNULL(i.sd, 0) sd, i.avalaible, i.visible, i.buy_date, e.id provider_id, it.comment comments, it.description itemDescription, - IF(cy.cItemFk IS NULL AND i.visible = 0 AND i.avalaible = 0 - AND IFNULL(i.sd, 0) = 0, FALSE, TRUE) filtret, + IF(cy.cItemFk IS NULL AND i.visible = 0 + AND i.avalaible = 0 AND (i.sd IS NULL OR i.sd = 0), + FALSE, + TRUE + ) filtret, IF(it.hasMinPrice, FORMAT(it.minPrice, 2), "") pvp, s.company_name FROM tmp.itemInventory i JOIN item it ON it.id = i.id - LEFT JOIN itemType tp ON tp.id = it.typeFk - LEFT JOIN worker w ON w.id = tp.workerFk + JOIN itemType tp ON tp.id = it.typeFk + JOIN worker w ON w.id = tp.workerFk LEFT JOIN buy b ON b.id = i.buy_id - LEFT JOIN entry e ON e.id = b.entryFk - LEFT JOIN origin o ON o.id = it.originFk + LEFT JOIN `entry` e ON e.id = b.entryFk + JOIN origin o ON o.id = it.originFk LEFT JOIN tLastYear ly ON ly.lItemFk = it.id LEFT JOIN tCurrentYear cy ON cy.cItemFk = it.id LEFT JOIN tTwoYearsAgo zy ON zy.tItemFk = it.id @@ -61763,8 +62217,8 @@ proc: BEGIN OR ly.lweek1 OR ly.lweek2 OR ly.lweek3 OR ly.lweek4 OR ly.lweek5 OR ly.lweek6 OR ly.lweek7 OR zy.vlweek1 OR zy.vlweek2 OR zy.vlweek3 OR zy.vlweek4 OR zy.vlweek5 OR zy.vlweek6 OR zy.vlweek7; - -- Elimina las tablas temporales creadas... - DROP TEMPORARY TABLE IF EXISTS tmp.itemInventory, + DROP TEMPORARY TABLE IF EXISTS + tmp.itemInventory, tTwoYearsAgo, tLastYear, tCurrentYear, @@ -61785,7 +62239,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_deactivateUnused`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_deactivateUnused`() BEGIN /** * Cambia a false el campo isActive de la tabla vn.item para todos aquellos @@ -61821,6 +62275,428 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `item_devalueA2` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_devalueA2`( + vSelf INT, + vShelvingFK VARCHAR(10), + vBuyingValue DECIMAL(10,4), + vQuantity INT +) +BEGIN +/** + * Devalua un item modificando su calidad de A1 a A2. + * Si no existe el item A2 lo crea y genera los movimientos de las entradas + * de almacén y shelvings correspondientes + * + * @param vSelf Id de artículo a devaluar + * @param vShelvingFK Ubicación actual del artículo + * @param vBuyingValue Nuevo precio de coste + * @param vQuantity Cantidad del ítem a pasar a A2 + */ + DECLARE vItemA2Fk INT; + DECLARE vLastBuyFk BIGINT; + DECLARE vA1BuyFk INT; + DECLARE vA2BuyFk INT; + DECLARE vTargetEntryFk INT; + DECLARE vTargetEntryDate DATE; + DECLARE vTargetItemShelvingFk BIGINT; + DECLARE vWarehouseFk INT; + DECLARE vCacheFk INT; + DECLARE vLastEntryFk INT; + DECLARE vCurrentVisible INT; + DECLARE vDevalueTravelFk INT; + DECLARE vCurdate DATE; + DECLARE vBuyingValueOriginal DECIMAL(10,4); + + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + IF (SELECT TRUE FROM item WHERE id = vSelf AND (category <> 'A1' OR category IS NULL)) THEN + CALL util.throw('Item has not category A1'); + END IF; + + SELECT warehouseFk INTO vWarehouseFk + FROM userMultiConfig + WHERE userFk = account.myUser_getId(); + + IF NOT vWarehouseFk OR vWarehouseFk IS NULL THEN + CALL util.throw ('Operator has not a valid warehouse'); + END IF; + + IF vQuantity <= 0 OR vQuantity IS NULL THEN + CALL util.throw ('The quantity is incorrect'); + END IF; + + SELECT util.VN_CURDATE() INTO vCurdate; + + SELECT t.id INTO vDevalueTravelFk + FROM travel t + JOIN travelConfig tc + WHERE t.shipped = vCurdate + AND t.landed = vCurdate + AND t.warehouseInFk = vWarehouseFk + AND t.warehouseOutFk = tc.devalueWarehouseOutFk + AND t.agencyModeFk = tc.devalueAgencyModeFk + LIMIT 1; + + IF NOT vDevalueTravelFk OR vDevalueTravelFk IS NULL THEN + INSERT INTO travel ( + shipped, + landed, + warehouseInFk, + warehouseOutFk, + `ref`, + isReceived, + agencyModeFk) + SELECT vCurdate, + vCurdate, + vWarehouseFk, + tc.devalueWarehouseOutFk, + tc.devalueRef, + TRUE, + tc.devalueAgencyModeFk + FROM travelConfig tc; + SET vDevalueTravelFk = LAST_INSERT_ID(); + END IF; + + SELECT id, DATE(dated) INTO vTargetEntryFk, vTargetEntryDate + FROM `entry` e + WHERE DATE(dated) = vCurdate + AND typeFk = 'devaluation' + AND travelFk = vDevalueTravelFk + ORDER BY created DESC + LIMIT 1; + + CALL buy_getUltimate(vSelf, vWarehouseFk, vCurdate); + + SELECT b.entryFk, bu.buyFk,IFNULL(b.buyingValue, 0) INTO vLastEntryFk, vLastBuyFk, vBuyingValueOriginal + FROM tmp.buyUltimate bu + JOIN vn.buy b ON b.id = bu.buyFk + WHERE bu.itemFk = vSelf + AND bu.warehouseFk = vWarehouseFk; + + IF vBuyingValue > vBuyingValueOriginal THEN + CALL util.throw ('Price not valid'); + END IF; + + IF vLastEntryFk IS NULL OR vLastBuyFk IS NULL THEN + CALL util.throw ('The item has not a buy'); + END IF; + + SELECT id,visible INTO vTargetItemShelvingFk, vCurrentVisible + FROM itemShelving + WHERE shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci + AND itemFk = vSelf + LIMIT 1; + + IF vCurrentVisible IS NULL THEN + CALL util.throw ('The shelving has not a visible for this item'); + END IF; + + IF vQuantity > vCurrentVisible THEN + CALL util.throw('Quantity is greater than visible'); + END IF; + + START TRANSACTION; + + IF NOT vTargetEntryFk OR vTargetEntryFk IS NULL + OR NOT vTargetEntryDate <=> vCurdate THEN + INSERT INTO entry( + travelFk, + supplierFk, + dated, + commission, + currencyFk, + companyFk, + clonedFrom, + typeFk + ) + SELECT vDevalueTravelFk, + supplierFk, + vCurdate, + commission, + currencyFk, + companyFk, + vLastEntryFk, + 'devaluation' + FROM entry + WHERE id = vLastEntryFk; + + SET vTargetEntryFk = LAST_INSERT_ID(); + END IF; + + SELECT i.id INTO vItemA2Fk + FROM item i + JOIN ( + SELECT i.id, + i.name, + i.subname, + i.value5, + i.value6, + i.value7, + i.value8, + i.value9, + i.value10, + i.NumberOfItemsPerCask, + i.EmbalageCode, + i.quality + FROM item i + WHERE i.id = vSelf + )i2 ON i2.name <=> i.name + AND i2.subname <=> i.subname + AND i2.value5 <=> i.value5 + AND i2.value6 <=> i.value6 + AND i2.value8 <=> i.value8 + AND i2.value9 <=> i.value9 + AND i2.value10 <=> i.value10 + AND i2.NumberOfItemsPerCask <=> i.NumberOfItemsPerCask + AND i2.EmbalageCode <=> i.EmbalageCode + AND i2.quality <=> i.quality + WHERE i.id <> i2.id + AND i.category = 'A2' + LIMIT 1; + + IF vItemA2Fk IS NULL THEN + INSERT INTO item ( + equivalent, + name, + `size`, + stems, + minPrice, + isToPrint, + family, + box, + category, + originFk, + doPhoto, + image, + inkFk, + intrastatFk, + hasMinPrice, + created, + comment, + typeFk, + generic, + producerFk, + description, + density, + relevancy, + expenseFk, + isActive, + longName, + subName, + minimum, + upToDown, + supplyResponseFk, + hasKgPrice, + isFloramondo, + isFragile, + numberOfItemsPerCask, + embalageCode, + quality, + stemMultiplier, + itemPackingTypeFk, + packingOut, + genericFk, + isLaid, + lastUsed, + weightByPiece, + editorFk, + recycledPlastic, + nonRecycledPlastic) + SELECT equivalent, + name, + `size`, + stems, + minPrice, + isToPrint, + family, + box, + 'A2', + originFk, + doPhoto, + image, + inkFk, + intrastatFk, + hasMinPrice, + created, + comment, + typeFk, + generic, + producerFk, + description, + density, + relevancy, + expenseFk, + isActive, + longName, + subName, + minimum, + upToDown, + supplyResponseFk, + hasKgPrice, + isFloramondo, + isFragile, + numberOfItemsPerCask, + embalageCode, + quality, + stemMultiplier, + itemPackingTypeFk, + packingOut, + genericFk, + isLaid, + lastUsed, + weightByPiece, + editorFk, + recycledPlastic, + nonRecycledPlastic + FROM item + WHERE id = vSelf; + + SET vItemA2Fk = LAST_INSERT_ID(); + + INSERT INTO itemTag (itemFk, tagFk, `value`, intValue, priority, editorFk) + SELECT vItemA2Fk, tagFk, `value`, intValue, priority, editorFk + FROM itemTag + WHERE id = vSelf; + + UPDATE itemTaxCountry itc + JOIN itemTaxCountry itc2 ON itc2.itemFk = vSelf + AND itc2.countryFk = itc.countryFk + SET itc2.taxClassFk = itc.taxClassFk + WHERE itc.id = vItemA2Fk; + + INSERT INTO itemBotanical (itemFk, genusFk, specieFk) + SELECT vItemA2Fk, genusFk, specieFk + FROM itemBotanical + WHERE itemFk = vSelf; + END IF; + + IF vQuantity = vCurrentVisible THEN + DELETE FROM itemShelving + WHERE id = vTargetItemShelvingFk; + ELSE + UPDATE itemShelving + SET visible = vCurrentVisible - vQuantity, + available = GREATEST(0, available - vQuantity) + WHERE id = vTargetItemShelvingFk; + END IF; + + INSERT INTO buy( + entryFk, + itemFk, + quantity, + buyingValue, + freightValue, + isIgnored, + stickers, + packagingFk, + packing, + `grouping`, + groupingMode, + comissionValue, + packageValue, + price1, + price2, + price3, + minPrice, + isChecked, + location, + weight, + itemOriginalFk) + SELECT vTargetEntryFk, + itemFk, + - LEAST(vQuantity, vCurrentVisible), + buyingValue, + freightValue, + TRUE, + stickers, + packagingFk, + packing, + `grouping`, + groupingMode, + comissionValue, + packageValue, + price1, + price2, + price3, + minPrice, + isChecked, + location, + weight, + itemOriginalFk + FROM vn.buy + WHERE id = vLastBuyFk + UNION + SELECT vTargetEntryFk, + vItemA2Fk, + vQuantity, + vBuyingValue, + freightValue, + TRUE, + stickers, + packagingFk, + packing, + `grouping`, + groupingMode, + comissionValue, + packageValue, + price1, + price2, + price3, + minPrice, + isChecked, + location, + weight, + itemOriginalFk + FROM vn.buy + WHERE id = vLastBuyFk; + + INSERT IGNORE INTO itemShelving ( + itemFk, + shelvingFk, + visible, + `grouping`, + packing, + packagingFk, + userFk, + isChecked) + SELECT vItemA2Fk, + shelvingFk, + vQuantity , + `grouping`, + packing, + packagingFk, + account.myUser_getId(), + isChecked + FROM itemShelving + WHERE itemFK = vSelf + AND shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci + ON DUPLICATE KEY UPDATE + visible = vQuantity + VALUES(visible); + + COMMIT; + CALL cache.visible_refresh(vCacheFk, TRUE, vWarehouseFk); + CALL cache.available_refresh(vCacheFk, TRUE, vWarehouseFk, vCurdate); + CALL buy_recalcPricesByBuy(vA2BuyFk); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_getAtp` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61829,7 +62705,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getAtp`(vDated DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_getAtp`(vDated DATE) BEGIN /** * Calcula el valor mínimo acumulado para cada artículo ordenado por fecha y @@ -61890,169 +62766,219 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getBalance`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_getBalance`( vItemFk INT, vWarehouseFk INT, - vDate DATETIME + vDated DATETIME ) BEGIN /** - * @vItemFk item a buscar - * @vWarehouseFk almacen donde buscar - * @vDate Si la fecha es null, muestra el histórico desde el inventario. - * Si la fecha no es null, muestra histórico desde la fecha pasada. + * Calcula el balance de un artículo. + * + * @vItemFk Id de artículo + * @vWarehouseFk Id de almacén + * @vDated Fecha a calcular, si es NULL muestra el histórico desde el inventario */ - DECLARE vDateInventory DATETIME; + DECLARE vDateInventory DATETIME + DEFAULT ( + SELECT IF(vDated, uc.mockUtcTime, c.inventoried) + FROM config c + JOIN util.config uc + ); + DECLARE vSupplierInventoryFk INT + DEFAULT (SELECT supplierFk FROM inventoryConfig); - IF vDate IS NULL THEN - SELECT inventoried INTO vDateInventory - FROM config; - ELSE - SELECT mockUtcTime INTO vDateInventory - FROM util.config; + IF NOT vSupplierInventoryFk OR NOT vDateInventory THEN + CALL util.throw('Config variables are not set'); END IF; - CREATE OR REPLACE TEMPORARY TABLE tItemDiary( - shipped DATE, - `in` INT(11), - `out` INT(11), - alertLevel INT(11), - stateName VARCHAR(20), - `name` VARCHAR(50), - reference VARCHAR(50), - origin INT(11), - clientFk INT(11), - isPicked INT(11), - isTicket TINYINT(1), - lineFk INT(11), - `order` TINYINT(3) UNSIGNED, - clientType VARCHAR(20), - claimFk INT(10) UNSIGNED, - inventorySupplierFk INT(10) - ); - - INSERT INTO tItemDiary - SELECT tr.landed shipped, - b.quantity `in`, - NULL `out`, - st.alertLevel , - st.name stateName, - s.name `name`, - e.invoiceNumber reference, - e.id origin, - s.id clientFk, - IF(st.`code` = 'DELIVERED', TRUE, FALSE) isPicked, - FALSE isTicket, - b.id lineFk, - NULL `order`, - NULL clientType, - NULL claimFk, - ec.inventorySupplierFk - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel tr ON tr.id = e.travelFk - JOIN supplier s ON s.id = e.supplierFk - JOIN state st ON st.`code` = IF( tr.landed < util.VN_CURDATE() - OR (util.VN_CURDATE() AND tr.isReceived), - 'DELIVERED', - 'FREE') - JOIN entryConfig ec - WHERE tr.landed >= vDateInventory - AND vWarehouseFk = tr.warehouseInFk - AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL) - AND b.itemFk = vItemFk - AND e.isExcludedFromAvailable = FALSE - AND e.isRaid = FALSE - UNION ALL - SELECT tr.shipped, - NULL, - b.quantity, - st.alertLevel, - st.name, - s.name, - e.invoiceNumber, - e.id, - s.id, - IF(st.`code` = 'DELIVERED' , TRUE, FALSE), - FALSE, - b.id, - NULL, - NULL, - NULL, - ec.inventorySupplierFk - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel tr ON tr.id = e.travelFk - JOIN warehouse w ON w.id = tr.warehouseOutFk - JOIN supplier s ON s.id = e.supplierFk - JOIN state st ON st.`code` = IF(tr.shipped < util.VN_CURDATE() + CREATE OR REPLACE TEMPORARY TABLE tItemDiary + ENGINE = MEMORY + WITH entriesIn AS ( + SELECT 'entry' originType, + e.id originId, + tr.landed shipped, + b.quantity `in`, + NULL `out`, + st.alertLevel , + st.name stateName, + e.invoiceNumber reference, + 'supplier' entityType, + s.id entityId, + s.name entityName, + IF(st.`code` = 'DELIVERED', TRUE, FALSE) isPicked, + FALSE isTicket, + b.id lineFk, + NULL `order`, + NULL clientType, + NULL claimFk, + vSupplierInventoryFk inventorySupplierFk + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel tr ON tr.id = e.travelFk + JOIN vn.supplier s ON s.id = e.supplierFk + JOIN vn.state st ON st.`code` = IF(tr.landed < util.VN_CURDATE() + OR (util.VN_CURDATE() AND tr.isReceived), + 'DELIVERED', + 'FREE') + WHERE tr.landed >= vDateInventory + AND tr.warehouseInFk = vWarehouseFk + AND (s.id <> vSupplierInventoryFk OR vDated IS NULL) + AND b.itemFk = vItemFk + AND NOT e.isExcludedFromAvailable + AND NOT e.isRaid + ), + entriesOut AS ( + SELECT 'entry', + e.id originType, + tr.shipped, + NULL, + b.quantity, + st.alertLevel, + st.name stateName, + e.invoiceNumber, + 'supplier' entityType, + s.id entityId, + s.name, + IF(st.`code` = 'DELIVERED' , TRUE, FALSE), + FALSE isTicket, + b.id, + NULL `order`, + NULL clientType, + NULL claimFk, + vSupplierInventoryFk + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel tr ON tr.id = e.travelFk + JOIN vn.warehouse w ON w.id = tr.warehouseOutFk + JOIN vn.supplier s ON s.id = e.supplierFk + JOIN vn.state st ON st.`code` = IF(tr.shipped < util.VN_CURDATE() OR (tr.shipped = util.VN_CURDATE() AND tr.isReceived), - 'DELIVERED', - 'FREE') - JOIN entryConfig ec - WHERE tr.shipped >= vDateInventory - AND vWarehouseFk = tr.warehouseOutFk - AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL) - AND b.itemFk = vItemFk - AND e.isExcludedFromAvailable = FALSE - AND w.isFeedStock = FALSE - AND e.isRaid = FALSE - UNION ALL - SELECT DATE(t.shipped), - NULL, - s.quantity, - st2.alertLevel, - st2.name, - t.nickname, - t.refFk, - t.id, - t.clientFk, - stk.id, - TRUE, - s.id, - st.`order`, - c.typeFk, - cb.claimFk, - NULL - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - LEFT JOIN ticketState ts ON ts.ticketFk = t.id - LEFT JOIN state st ON st.`code` = ts.`code` - JOIN client c ON c.id = t.clientFk - JOIN state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(), - 'DELIVERED', - IF (t.shipped > util.dayEnd(util.VN_CURDATE()), - 'FREE', - IFNULL(ts.code, 'FREE'))) - LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED' - LEFT JOIN saleTracking stk ON stk.saleFk = s.id - AND stk.stateFk = stPrep.id - LEFT JOIN claimBeginning cb ON s.id = cb.saleFk - WHERE t.shipped >= vDateInventory - AND s.itemFk = vItemFk - AND vWarehouseFk =t.warehouseFk - ORDER BY shipped, - (inventorySupplierFk = clientFk) DESC, - alertLevel DESC, - isTicket, - `order` DESC, - isPicked DESC, - `in` DESC, - `out` DESC; + 'DELIVERED', + 'FREE') + WHERE tr.shipped >= vDateInventory + AND tr.warehouseOutFk = vWarehouseFk + AND (s.id <> vSupplierInventoryFk OR vDated IS NULL) + AND b.itemFk = vItemFk + AND NOT e.isExcludedFromAvailable + AND NOT w.isFeedStock + AND NOT e.isRaid + ), + sales AS ( + WITH itemSales AS ( + SELECT DATE(t.shipped) shipped, + s.quantity, + st2.alertLevel, + st2.name, + t.refFk, + t.id ticketFk, + 'client' entityType, + t.clientFk entityId, + t.nickname, + s.id saleFk, + st.`order`, + c.typeFk, + cb.claimFk + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id + LEFT JOIN vn.state st ON st.code = ts.code + JOIN vn.client c ON c.id = t.clientFk + JOIN vn.state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(), + 'DELIVERED', + IF (t.shipped > util.dayEnd(util.VN_CURDATE()), + 'FREE', + IFNULL(st.code, 'FREE'))) + LEFT JOIN vn.claimBeginning cb ON cb.saleFk = s.id + WHERE t.shipped >= vDateInventory + AND s.itemFk = vItemFk + AND t.warehouseFk = vWarehouseFk + ) + SELECT 'ticket', + s.ticketFk, + s.shipped, + NULL `in`, + s.quantity, + s.alertLevel, + s.name, + s.refFk, + s.entityType, + s.entityId, + s.nickname, + IF(stk.saleFk, TRUE, FALSE), + TRUE, + s.saleFk, + s.`order`, + s.typeFk, + s.claimFk, + NULL + FROM itemSales s + LEFT JOIN vn.state stPrep ON stPrep.`code` = 'PREPARED' + LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.saleFk + AND stk.stateFk = stPrep.id + GROUP BY s.saleFk + ), + orders AS ( + SELECT 'order' originType, + o.id originId, + r.shipment, + NULL 'in', + r.amount, + NULL alertLevel, + NULL stateName, + NULL invoiceNumber, + 'client' entityType, + c.id, + c.name, + FALSE, + FALSE isTicket, + NULL buyFk, + NULL 'order', + c.typeFk, + NULL claimFk, + NULL + FROM hedera.orderRow r + JOIN hedera.`order` o ON o.id = r.orderFk + JOIN vn.client c ON c.id = o.customer_id + WHERE r.shipment >= vDateInventory + AND r.warehouseFk = vWarehouseFk + AND r.created >= ( + SELECT SUBTIME(util.VN_NOW(), reserveTime) + FROM hedera.orderConfig + ) + AND NOT o.confirmed + AND r.itemFk = vItemFk + ) + SELECT * FROM entriesIn + UNION ALL + SELECT * FROM entriesOut + UNION ALL + SELECT * FROM sales + UNION ALL + SELECT * FROM orders + ORDER BY shipped, + (inventorySupplierFk = entityId) DESC, + alertLevel DESC, + isTicket, + `order` DESC, + isPicked DESC, + `in` DESC, + `out` DESC; - IF vDate IS NULL THEN - + IF vDated IS NULL THEN SET @a := 0; SET @currentLineFk := 0; SET @shipped := ''; - SELECT DATE(@shipped:= t.shipped) shipped, + SELECT t.originType, + t.originId, + DATE(@shipped:= t.shipped) shipped, t.alertLevel, t.stateName, - t.origin, t.reference, - t.clientFk, - t.name, + t.entityType, + t.entityId, + t.entityName, t.`in` invalue, t.`out`, @a := @a + IFNULL(t.`in`, 0) - IFNULL(t.`out`, 0) balance, @@ -62068,37 +62994,41 @@ BEGIN t.`order` FROM tItemDiary t LEFT JOIN alertLevel a ON a.id = t.alertLevel; - ELSE SELECT IFNULL(SUM(IFNULL(`in`, 0)) - SUM(IFNULL(`out`, 0)), 0) INTO @a FROM tItemDiary - WHERE shipped < vDate; + WHERE shipped < vDated; - SELECT vDate shipped, - 0 alertLevel, - 0 stateName, - 0 origin, - '' reference, - 0 clientFk, - 'Inventario calculado', + SELECT NULL originType, + NULL originId, + vDated shipped, + NULL alertLevel, + NULL stateName, + NULL reference, + NULL entityType, + NULL entityId, + 'Inventario calculado' entityName, @a invalue, NULL `out`, @a balance, - 0 lastPreparedLineFk, - 0 isTicket, - 0 lineFk, - 0 isPicked, - 0 clientType, - 0 claimFk, + NULL lastPreparedLineFk, + NULL isTicket, + NULL lineFk, + NULL isPicked, + NULL clientType, + NULL claimFk, NULL `order` UNION ALL - SELECT shipped, + SELECT originType, + originId, + shipped, alertlevel, stateName, - origin, - reference, - clientFk, - name, `in`, + reference, + entityType, + entityId, + entityName, + `in`, `out`, @a := @a + IFNULL(`in`, 0) - IFNULL(`out`, 0), 0, @@ -62109,9 +63039,9 @@ BEGIN claimFk, `order` FROM tItemDiary - WHERE shipped >= vDate; + WHERE shipped >= vDated; END IF; - + DROP TEMPORARY TABLE tItemDiary; END ;; DELIMITER ; @@ -62129,7 +63059,10 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getInfo`(IN `vBarcode` VARCHAR(22), IN `vWarehouseFk` INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_getInfo`( + `vBarcode` VARCHAR(22), + `vWarehouseFk` INT +) BEGIN /** * Devuelve información relativa al item correspondiente del vBarcode pasado @@ -62141,12 +63074,14 @@ BEGIN DECLARE vCacheAvailableFk INT; DECLARE vVisibleItemShelving INT; DECLARE vItemFk INT; + DECLARE vDated DATE; + + SELECT barcodeToItem(vBarcode), util.VN_CURDATE() INTO vItemFk, vDated; CALL cache.visible_refresh(vCacheVisibleFk, FALSE, vWarehouseFk); - CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE()); - CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); - - SELECT barcodeToItem(vBarcode) INTO vItemFk; + CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, vDated); + CALL buy_getUltimate(vItemFk, vWarehouseFk, vDated); + SELECT SUM(visible) INTO vVisibleItemShelving FROM itemShelvingStock WHERE itemFk = vItemFk @@ -62214,7 +63149,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getLack`(IN vForce BOOLEAN, IN vDays INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_getLack`(IN vForce BOOLEAN, IN vDays INT) BEGIN /** * Calcula una tabla con el máximo negativo visible para cada producto y almacen @@ -62284,38 +63219,42 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getMinacum`(IN vWarehouseFk TINYINT, IN vDatedFrom DATETIME, IN vRange INT, IN vItemFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_getMinacum`( + vWarehouseFk TINYINT, + vDated DATE, + vRange INT, + vItemFk INT +) BEGIN /** - * Cálculo del mínimo acumulado, para un item/almacén especificado, en caso de - * NULL para todo. + * Cálculo del mínimo acumulado, para un item/almacén + * especificado, en caso de NULL para todos. * - * @param vWarehouseFk -> warehouseFk - * @param vDatedFrom -> fecha inicio - * @param vRange -> número de días a considerar - * @param vItemFk -> Identificador de item + * @param vWarehouseFk Id warehouse + * @param vDated Fecha inicio + * @param vRange Número de días a considerar + * @param vItemFk Id de artículo * @return tmp.itemMinacum */ - DECLARE vDatedTo DATETIME; + DECLARE vDatedTo DATETIME DEFAULT util.dayEnd(vDated + INTERVAL vRange DAY); - SET vDatedFrom = TIMESTAMP(DATE(vDatedFrom), '00:00:00'); - SET vDatedTo = TIMESTAMP(TIMESTAMPADD(DAY, vRange, vDatedFrom), '23:59:59'); - - DROP TEMPORARY TABLE IF EXISTS tmp.itemCalc; - CREATE TEMPORARY TABLE tmp.itemCalc + CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc (INDEX (itemFk, warehouseFk)) + ENGINE = MEMORY SELECT sub.itemFk, sub.dated, CAST(SUM(sub.quantity) AS SIGNED) quantity, sub.warehouseFk - FROM (SELECT s.itemFk, + FROM ( + SELECT s.itemFk, DATE(t.shipped) dated, -s.quantity quantity, t.warehouseFk FROM sale s JOIN ticket t ON t.id = s.ticketFk - WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo - AND s.quantity != 0 + WHERE t.shipped BETWEEN vDated AND vDatedTo + AND t.warehouseFk + AND s.quantity <> 0 AND (vItemFk IS NULL OR s.itemFk = vItemFk) AND (vWarehouseFk IS NULL OR t.warehouseFk = vWarehouseFk) UNION ALL @@ -62325,11 +63264,11 @@ BEGIN t.warehouseInFk FROM buy b JOIN entry e ON e.id = b.entryFk - LEFT JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vDatedFrom AND vDatedTo + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vDated AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND !e.isExcludedFromAvailable - AND b.quantity != 0 + AND NOT e.isExcludedFromAvailable + AND b.quantity <> 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) UNION ALL SELECT b.itemFk, @@ -62338,28 +63277,47 @@ BEGIN t.warehouseOutFk FROM buy b JOIN entry e ON e.id = b.entryFk - LEFT JOIN travel t ON t.id = e.travelFk - WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo + JOIN travel t ON t.id = e.travelFk + WHERE t.shipped BETWEEN vDated AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk) - AND !e.isExcludedFromAvailable - AND b.quantity != 0 + AND NOT e.isExcludedFromAvailable + AND b.quantity <> 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) - AND !e.isRaid + AND NOT e.isRaid + UNION ALL + SELECT r.itemFk, + r.shipment, + -r.amount, + r.warehouseFk + FROM hedera.orderRow r + JOIN hedera.`order` o ON o.id = r.orderFk + JOIN client c ON c.id = o.customer_id + WHERE r.shipment BETWEEN vDated AND vDatedTo + AND (vWarehouseFk IS NULL OR r.warehouseFk = vWarehouseFk) + AND r.created >= ( + SELECT util.VN_NOW() - INTERVAL TIME_TO_SEC(reserveTime) SECOND + FROM hedera.orderConfig + ) + AND NOT o.confirmed + AND (vItemFk IS NULL OR r.itemFk = vItemFk) + AND r.amount <> 0 ) sub GROUP BY sub.itemFk, sub.warehouseFk, sub.dated; - CALL item_getAtp(vDatedFrom); - DROP TEMPORARY TABLE tmp.itemCalc; + CALL item_getAtp(vDated); - DROP TEMPORARY TABLE IF EXISTS tmp.itemMinacum; - CREATE TEMPORARY TABLE tmp.itemMinacum + CREATE OR REPLACE TEMPORARY TABLE tmp.itemMinacum (INDEX(itemFk)) ENGINE = MEMORY - SELECT i.itemFk, - i.warehouseFk, - i.quantity amount - FROM tmp.itemAtp i - HAVING amount != 0; + SELECT itemFk, + warehouseFk, + quantity amount + FROM tmp.itemAtp + WHERE quantity <> 0; + + DROP TEMPORARY TABLE + tmp.itemAtp, + tmp.itemCalc; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -62376,7 +63334,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getMinETD`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_getMinETD`() BEGIN /* Devuelve una tabla temporal con la primera ETD, para todos los artículos con salida hoy. @@ -62413,27 +63371,28 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getSimilar`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_getSimilar`( vSelf INT, vWarehouseFk INT, vDated DATE, - vShowType BOOL + vShowType BOOL, + vDaysInForward INT ) BEGIN /** -* Propone articulos disponibles ordenados, con la cantidad +* Propone articulos ordenados, con la cantidad * de veces usado y segun sus caracteristicas. * * @param vSelf Id de artículo * @param vWarehouseFk Id de almacen * @param vDated Fecha * @param vShowType Mostrar tipos +* @param vDaysInForward Días de alcance para las ventas */ - DECLARE vCalcFk INT; - DECLARE vTypeFk INT; + DECLARE vAvailableCalcFk INT; DECLARE vPriority INT DEFAULT 1; - CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated); + CALL cache.available_refresh(vAvailableCalcFk, FALSE, vWarehouseFk, vDated); WITH itemTags AS ( SELECT i.id, @@ -62453,8 +63412,25 @@ BEGIN AND it.priority = vPriority LEFT JOIN vn.tag t ON t.id = it.tagFk WHERE i.id = vSelf + ), + stock AS ( + SELECT itemFk, SUM(visible) stock + FROM vn.itemShelvingStock + WHERE warehouseFk = vWarehouseFk + GROUP BY itemFk + ), + sold AS ( + SELECT SUM(s.quantity) quantity, s.itemFk + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id + WHERE t.shipped >= CURDATE() + INTERVAL vDaysInForward DAY + AND iss.saleFk IS NULL + AND t.warehouseFk = vWarehouseFk + GROUP BY s.itemFk ) SELECT i.id itemFk, + LEAST(CAST(sd.quantity AS INT), sk.stock) advanceable, i.longName, i.subName, i.tag5, @@ -62475,37 +63451,38 @@ BEGIN WHEN b.groupingMode = 'grouping' THEN b.grouping WHEN b.groupingMode = 'packing' THEN b.packing ELSE 1 - END AS minQuantity, - iss.visible located, + END minQuantity, + sk.stock located, b.price2 FROM vn.item i + LEFT JOIN sold sd ON sd.itemFk = i.id JOIN cache.available a ON a.item_id = i.id - AND a.calc_id = vCalcFk + AND a.calc_id = vAvailableCalcFk + LEFT JOIN stock sk ON sk.itemFk = i.id + LEFT JOIN cache.last_buy lb ON lb.item_id = i.id + AND lb.warehouse_id = vWarehouseFk LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id AND ip.itemFk = vSelf LEFT JOIN vn.itemTag it ON it.itemFk = i.id AND it.priority = vPriority LEFT JOIN vn.tag t ON t.id = it.tagFk - LEFT JOIN cache.last_buy lb ON lb.item_id = i.id - AND lb.warehouse_id = vWarehouseFk LEFT JOIN vn.buy b ON b.id = lb.buy_id - LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = i.id - AND iss.warehouseFk = vWarehouseFk JOIN itemTags its - WHERE a.available > 0 + WHERE (a.available > 0 OR sd.quantity < sk.stock) AND (i.typeFk = its.typeFk OR NOT vShowType) AND i.id <> vSelf - ORDER BY `counter` DESC, - (t.name = its.name) DESC, - (it.value = its.value) DESC, - (i.tag5 = its.tag5) DESC, - match5 DESC, - (i.tag6 = its.tag6) DESC, - match6 DESC, - (i.tag7 = its.tag7) DESC, - match7 DESC, - (i.tag8 = its.tag8) DESC, - match8 DESC + ORDER BY (a.available > 0) DESC, + `counter` DESC, + (t.name = its.name) DESC, + (it.value = its.value) DESC, + (i.tag5 = its.tag5) DESC, + match5 DESC, + (i.tag6 = its.tag6) DESC, + match6 DESC, + (i.tag7 = its.tag7) DESC, + match7 DESC, + (i.tag8 = its.tag8) DESC, + match8 DESC LIMIT 100; END ;; DELIMITER ; @@ -62523,7 +63500,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getStock`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_getStock`( vWarehouseFk SMALLINT, vDated DATE, vItemFk INT @@ -62600,62 +63577,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `item_GetVisible` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_GetVisible`(vWarehouse SMALLINT, vItem INT) -BEGIN - DECLARE vTomorrow DATETIME DEFAULT TIMESTAMPADD(DAY, 1, util.VN_CURDATE()); - - INSERT INTO tmp.itemVisible (item_id, visible) - SELECT item_id, SUM(amount) amount - FROM ( - SELECT i.itemFk AS item_id, quantity AS amount - FROM itemTicketOut i - LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk - JOIN state s ON s.id = ts.stateFk - LEFT JOIN (SELECT DISTINCT saleFk - FROM saleTracking st - JOIN state s ON s.id = st.stateFk - WHERE st.created > util.VN_CURDATE() - AND (s.isPicked OR st.isChecked) - ) stPrevious ON `stPrevious`.`saleFk` = i.saleFk - WHERE i.warehouseFk = vWarehouse - AND (vItem IS NULL OR i.itemFk = vItem) - AND (s.isPicked OR i.reserved OR stPrevious.saleFk ) - AND i.shipped >= util.VN_CURDATE() AND i.shipped < vTomorrow - UNION ALL - SELECT iei.itemFk, quantity - FROM itemEntryIn iei - WHERE (iei.isReceived != FALSE /*OR ip.modificationDate > util.VN_CURDATE()*/) - AND iei.landed >= util.VN_CURDATE() AND iei.landed < vTomorrow - AND iei.warehouseInFk = vWarehouse - AND (vItem IS NULL OR iei.itemFk = vItem) - AND iei.isVirtualStock is FALSE - UNION ALL - SELECT itemFk, quantity - FROM itemEntryOut - WHERE isDelivered != FALSE - AND shipped >= util.VN_CURDATE() AND shipped < vTomorrow - AND warehouseOutFk = vWarehouse - AND (vItem IS NULL OR itemFk = vItem) - ) t - GROUP BY item_id - ON DUPLICATE KEY UPDATE - visible = IFNULL(stock,0) + VALUES(visible); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_multipleBuy` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -62664,7 +63585,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_multipleBuy`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_multipleBuy`( vDate DATETIME, vWarehouseFk INT ) @@ -62678,7 +63599,7 @@ BEGIN */ ALTER TABLE tmp.itemInventory ADD IF NOT EXISTS buy_id INT; - CALL buyUltimate(vWarehouseFk, vDate); + CALL buy_getUltimate (NULL, vWarehouseFk, vDate); CREATE OR REPLACE TEMPORARY TABLE tmp (KEY (itemFk)) @@ -62713,7 +63634,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_multipleBuyByDate`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_multipleBuyByDate`( vDated DATETIME, vWarehouseFk TINYINT(3) ) @@ -62766,7 +63687,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_refreshFromTags`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_refreshFromTags`(vSelf INT) BEGIN /** * Updates item attributes with its corresponding tags. @@ -62813,12 +63734,18 @@ BEGIN i.tag8 = JSON_VALUE(vTags, '$.8'), i.tag9 = JSON_VALUE(vTags, '$.9'), i.tag10 = JSON_VALUE(vTags, '$.10'), + i.tag11 = JSON_VALUE(vTags, '$.11'), + i.tag12 = JSON_VALUE(vTags, '$.12'), + i.tag13 = JSON_VALUE(vTags, '$.13'), i.value5 = JSON_VALUE(vValues, '$.5'), i.value6 = JSON_VALUE(vValues, '$.6'), i.value7 = JSON_VALUE(vValues, '$.7'), i.value8 = JSON_VALUE(vValues, '$.8'), i.value9 = JSON_VALUE(vValues, '$.9'), i.value10 = JSON_VALUE(vValues, '$.10'), + i.value11 = JSON_VALUE(vValues, '$.11'), + i.value12 = JSON_VALUE(vValues, '$.12'), + i.value13 = JSON_VALUE(vValues, '$.13'), i.producerFk = p.id, i.inkFk = k.id, i.originFk = IFNULL(o.id, i.originFk) @@ -62841,7 +63768,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_refreshTags`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_refreshTags`() BEGIN /** * Update item table, tag "cache" fields @@ -62883,7 +63810,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_saveReference`(vBarcode VARCHAR(22), vReference VARCHAR(150)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_saveReference`(vBarcode VARCHAR(22), vReference VARCHAR(150)) BEGIN /** @@ -62915,7 +63842,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_setGeneric`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_setGeneric`(vSelf INT) BEGIN /** * Asigna el código genérico a un item, salvo que sea un código de item genérico. @@ -62984,14 +63911,15 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_setVisibleDiscard`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_setVisibleDiscard`( vItemFk INT, vWarehouseFk INT, vQuantity INT, vAddressFk INT) BEGIN /** - * Procedimiento para dar dar de baja/alta un item, si vAddressFk es NULL se entiende que se da de alta y se toma el addressFk de la configuración + * Procedimiento para dar dar de baja/alta un item, si vAdressFk es NULL + * se entiende que se da de alta y se toma el addressFk de la configuración * * @param vItemFk Identificador del ítem * @param vWarehouseFk id del warehouse @@ -63076,7 +64004,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_updatePackingType`(vItem INT, vItemPackingTypeFk VARCHAR(1)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_updatePackingType`(vItem INT, vItemPackingTypeFk VARCHAR(1)) BEGIN /** * Update the packing type of an item @@ -63094,7 +64022,7 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `item_ValuateInventory` */; +/*!50003 DROP PROCEDURE IF EXISTS `item_valuateInventory` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -63102,7 +64030,11 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_ValuateInventory`(vDated DATE, vIsDetailed BOOLEAN) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_valuateInventory`( + vDated DATE, + vItemTypeFk INT, + vItemCategoryFk INT +) BEGIN DECLARE vInventoried DATE; DECLARE vHasNotInventory BOOLEAN DEFAULT FALSE; @@ -63118,8 +64050,7 @@ BEGIN SELECT tr.landed INTO vInventoried FROM travel tr JOIN `entry` e ON e.travelFk = tr.id - JOIN entryConfig ec - WHERE landed <= vDateDayEnd + WHERE tr.landed <= vDateDayEnd AND e.supplierFk = vInventorySupplierFk ORDER BY tr.landed DESC LIMIT 1; @@ -63130,8 +64061,7 @@ BEGIN SELECT landed INTO vInventoryClone FROM travel tr JOIN `entry` e ON e.travelFk = tr.id - JOIN entryConfig ec - WHERE landed >= vDated + WHERE tr.landed >= vDated AND e.supplierFk = vInventorySupplierFk ORDER BY landed ASC LIMIT 1; @@ -63141,13 +64071,14 @@ BEGIN END IF; CREATE OR REPLACE TEMPORARY TABLE tInventory( - warehouseFk SMALLINT, - itemFk BIGINT, - quantity INT, - cost DOUBLE DEFAULT 0, - total DOUBLE DEFAULT 0, - warehouseInventory VARCHAR(20), - PRIMARY KEY (warehouseInventory, itemFk) USING HASH + warehouseFk SMALLINT, + itemFk BIGINT, + quantity INT, + volume DECIMAL(10,2), + cost DOUBLE DEFAULT 0, + total DOUBLE DEFAULT 0, + warehouseInventory VARCHAR(20), + PRIMARY KEY (warehouseInventory, itemFk) USING HASH ) ENGINE = MEMORY; @@ -63163,12 +64094,14 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN itemType t ON t.id = i.typeFk - JOIN warehouse w ON w.id = warehouseInFk - JOIN entryConfig ec - WHERE landed = vDateDayEnd + JOIN itemCategory ic ON ic.id = t.categoryFk + JOIN warehouse w ON w.id = tr.warehouseInFk + WHERE tr.landed = vDateDayEnd AND e.supplierFk = vInventorySupplierFk AND w.valuatedInventory AND t.isInventory + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) GROUP BY tr.warehouseInFk, b.itemFk; ELSE INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) @@ -63181,12 +64114,14 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN itemType t ON t.id = i.typeFk - JOIN warehouse w ON w.id = warehouseInFk - JOIN entryConfig ec - WHERE landed = vInventoried + JOIN itemCategory ic ON ic.id = t.categoryFk + JOIN warehouse w ON w.id = tr.warehouseInFk + WHERE tr.landed = vInventoried AND e.supplierFk = vInventorySupplierFk AND w.valuatedInventory AND t.isInventory + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) GROUP BY tr.warehouseInFk, b.itemFk; END IF; @@ -63201,14 +64136,16 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN itemType t ON t.id = i.typeFk + JOIN itemCategory ic ON ic.id = t.categoryFk JOIN warehouse w ON w.id = tr.warehouseInFk - JOIN entryConfig ec WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE) AND NOT e.isRaid AND w.valuatedInventory AND t.isInventory AND e.supplierFk <> vInventorySupplierFk + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity * IF(vHasNotInventory, -1, 1)); -- Descontamos las salidas @@ -63222,11 +64159,14 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN itemType t ON t.id = i.typeFk + JOIN itemCategory ic ON ic.id = t.categoryFk JOIN warehouse w ON w.id = tr.warehouseOutFk WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd AND NOT e.isRaid AND w.valuatedInventory AND t.isInventory + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity * IF(vHasNotInventory,1,-1)); -- Descontamos las lineas de venta @@ -63240,10 +64180,13 @@ BEGIN JOIN `client` c ON c.id = t.clientFk JOIN item i ON i.id = s.itemFk JOIN itemType it ON it.id = i.typeFk + JOIN itemCategory ic ON ic.id = it.categoryFk JOIN warehouse w ON w.id = t.warehouseFk WHERE t.shipped BETWEEN vInventoried AND vDateDayEnd AND w.valuatedInventory AND it.isInventory + AND (it.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 1, -1); -- Volver a poner lo que esta aun en las estanterias @@ -63258,11 +64201,14 @@ BEGIN JOIN `client` c ON c.id = t.clientFk JOIN item i ON i.id = s.itemFk JOIN itemType it ON it.id = i.typeFk + JOIN itemCategory ic ON ic.id = it.categoryFk JOIN warehouse w ON w.id = t.warehouseFk WHERE t.shipped BETWEEN vDated AND vDateDayEnd AND NOT (s.isPicked OR t.isLabeled) AND w.valuatedInventory AND it.isInventory + AND (it.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 0, 1); END IF; @@ -63277,6 +64223,7 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN itemType t ON t.id = i.typeFk + JOIN itemCategory ic ON ic.id = t.categoryFk JOIN warehouse wIn ON wIn.id = tr.warehouseInFk JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk WHERE vDated >= tr.shipped AND vDated < tr.landed @@ -63284,54 +64231,42 @@ BEGIN AND wIn.valuatedInventory AND t.isInventory AND e.isConfirmed + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity); - CALL vn.buyUltimate(NULL, vDateDayEnd); + CALL buy_getUltimate (NULL, NULL, vDateDayEnd); + + DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity; UPDATE tInventory i JOIN tmp.buyUltimate bu ON i.warehouseFk = bu.warehouseFk AND i.itemFk = bu.itemFk JOIN buy b ON b.id = bu.buyFk - SET total = i.quantity * (IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0)), - cost = IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0) - WHERE i.quantity; + LEFT JOIN itemCost ic ON ic.itemFk = i.itemFk + AND ic.warehouseFk = i.warehouseFk + SET i.total = i.quantity * (IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0)), + i.cost = IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0), + i.volume = i.quantity * ic.cm3delivery / 1000000; - DELETE FROM tInventory - WHERE quantity IS NULL OR NOT quantity; - - IF vIsDetailed THEN - SELECT ti.warehouseFk, - i.id itemFk, - i.longName, - i.size, - ti.quantity, - tp.name Tipo, - ic.name Reino, - ti.cost, - CAST(ti.total AS DECIMAL(10, 2)) total, - ti.warehouseInventory almacen - FROM tInventory ti - JOIN warehouse w ON w.id = warehouseFk - JOIN item i ON i.id = ti.itemFk - JOIN itemType tp ON tp.id = i.typeFk - JOIN itemCategory ic ON ic.id = tp.categoryFk - WHERE w.valuatedInventory - AND ti.total > 0 - ORDER BY ti.total DESC; - ELSE - SELECT i.warehouseInventory Almacen, - ic.name Reino, - CAST(i.total AS DECIMAL(10, 2)) Euros, - w.code Comprador, - it.id - FROM tInventory i - JOIN warehouse wh ON wh.id = warehouseFk - JOIN item it ON it.id = i.itemFk - JOIN itemType itp ON itp.id = it.typeFk - LEFT JOIN worker w ON w.id = itp.workerFk - JOIN itemCategory ic ON ic.id = itp.categoryFk - WHERE wh.valuatedInventory - AND i.total > 0; - END IF; + SELECT ti.warehouseFk, + i.id, + i.longName, + i.size, + ti.quantity, + ti.volume, + tp.name itemTypeName, + ic.name itemCategoryName, + ti.cost, + ti.total, + ti.warehouseInventory, + ic.display + FROM tInventory ti + JOIN warehouse w ON w.id = warehouseFk + JOIN item i ON i.id = ti.itemFk + JOIN itemType tp ON tp.id = i.typeFk + JOIN itemCategory ic ON ic.id = tp.categoryFk + WHERE w.valuatedInventory + AND ti.total > 0; DROP TEMPORARY TABLE tmp.buyUltimate, @@ -63352,7 +64287,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_zoneClosure`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `item_zoneClosure`() BEGIN /* Devuelve una tabla temporal con la hora minima de un ticket sino tiene el de la zoneClosure y @@ -63390,7 +64325,15 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ledger_doCompensation`(vDated DATE, vCompensationAccount VARCHAR(10) , vBankFk VARCHAR(10), vConcept VARCHAR(255), vAmount DECIMAL(10,2), vCompanyFk INT, vOriginalAccount VARCHAR(10)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ledger_doCompensation`( + vDated DATE, + vCompensationAccount VARCHAR(10), + vBankFk VARCHAR(10), + vConcept VARCHAR(255), + vAmount DECIMAL(10,2), + vCompanyFk INT, + vOriginalAccount VARCHAR(10) +) BEGIN /** * Compensa un pago o un recibo insertando en contabilidad @@ -63400,29 +64343,31 @@ BEGIN * @param vBankFk banco de la compensacion * @param vConcept descripcion * @param vAmount cantidad que se compensa - * @param vCompany empresa + * @param vCompanyFk empresa * @param vOriginalAccount cuenta contable desde la cual se compensa * - */ + */ DECLARE vNewBookEntry INT; - DECLARE vIsClientCompensation INT; + DECLARE vIsClientCompensation INT; DECLARE vClientFk INT; - DECLARE vSupplierFk INT; - DECLARE vIsOriginalAClient BOOL; - DECLARE vPayMethodCompensation INT; - - CALL ledger_next(vNewBookEntry); + DECLARE vSupplierFk INT; + DECLARE vIsOriginalAClient BOOL; + DECLARE vPayMethodCompensation INT; - SELECT COUNT(id) INTO vIsOriginalAClient FROM client WHERE accountingAccount LIKE vOriginalAccount COLLATE utf8_general_ci; + CALL ledger_nextTx(YEAR(vDated), vNewBookEntry); + + SELECT COUNT(id) INTO vIsOriginalAClient + FROM client + WHERE accountingAccount LIKE vOriginalAccount COLLATE utf8_general_ci; SELECT id, COUNT(id) INTO vClientFk, vIsClientCompensation FROM client WHERE accountingAccount LIKE vCompensationAccount COLLATE utf8_general_ci; - + SET @vAmount1:= 0.0; SET @vAmount2:= 0.0; - INSERT INTO XDiario (ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, empresa_id) + INSERT INTO XDiario (ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, empresa_id) VALUES ( vNewBookEntry, vDated, vOriginalAccount, @@ -63440,31 +64385,52 @@ BEGIN ), vCompanyFk ), - ( vNewBookEntry, - vDated, - vCompensationAccount, - vOriginalAccount, - vConcept, - @vAmount2, + ( vNewBookEntry, + vDated, + vCompensationAccount, + vOriginalAccount, + vConcept, + @vAmount2, @vAmount1, - vCompanyFk); - - IF vIsClientCompensation THEN - IF vIsOriginalAClient THEN - SET vAmount = -vAmount; - END IF; - INSERT INTO receipt(invoiceFk, amountPaid, payed, bankFk, companyFk, clientFk, isConciliate) - VALUES (vConcept, vAmount, vDated, vBankFk, vCompanyFk, vClientFk, TRUE); - ELSE - IF NOT vIsOriginalAClient THEN - SET vAmount = -vAmount; - END IF; - SELECT id INTO vSupplierFk FROM supplier WHERE `account` LIKE vCompensationAccount COLLATE utf8_general_ci; - SELECT id INTO vPayMethodCompensation FROM payMethod WHERE `code` = 'compensation'; - - INSERT INTO payment (received, dueDated, supplierFk, amount, bankFk, payMethodFk, concept, companyFk, isConciliated) - VALUES(vDated, vDated, vSupplierFk, vAmount, vBankFk, vPayMethodCompensation, vConcept, vCompanyFk, TRUE); - END IF; + vCompanyFk); + + IF vIsClientCompensation THEN + IF vIsOriginalAClient THEN + SET vAmount = -vAmount; + END IF; + + INSERT INTO receipt + SET invoiceFk = vConcept, + amountPaid = vAmount, + payed = vDated, + bankFk = vBankFk, + companyFk = vCompanyFk, + clientFk = vClientFk, + isConciliate = TRUE; + ELSE + IF NOT vIsOriginalAClient THEN + SET vAmount = -vAmount; + END IF; + + SELECT id INTO vSupplierFk + FROM supplier + WHERE `account` LIKE vCompensationAccount COLLATE utf8_general_ci; + + SELECT id INTO vPayMethodCompensation + FROM payMethod + WHERE `code` = 'compensation'; + + INSERT INTO payment + SET received = vDated, + dueDated = vDated, + supplierFk = vSupplierFk, + amount = vAmount, + bankFk = vBankFk, + payMethodFk = vPayMethodCompensation, + concept = vConcept, + companyFk = vCompanyFk, + isConciliated = TRUE; + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -63481,12 +64447,65 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ledger_next`(OUT vNewBookEntry INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ledger_next`( + IN vFiscalYear INT, + OUT vLastBookEntry INT +) BEGIN - - UPDATE vn.ledgerConfig SET lastBookEntry = LAST_INSERT_ID(lastBookEntry + 1); - SET vNewBookEntry = LAST_INSERT_ID(); - + IF vFiscalYear IS NULL THEN + CALL util.throw('Fiscal year is required'); + END IF; + + SELECT bookEntry + 1 INTO vLastBookEntry + FROM ledgerCompany + WHERE fiscalYear = vFiscalYear + FOR UPDATE; + + IF vLastBookEntry IS NULL THEN + INSERT INTO ledgerCompany + SET fiscalYear = vFiscalYear, + bookEntry = 1; + SET vLastBookEntry = 1; + END IF; + + UPDATE ledgerCompany + SET bookEntry = vLastBookEntry + WHERE fiscalYear = vFiscalYear; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ledger_nextTx` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ledger_nextTx`( + IN vFiscalYear INT, + OUT vLastBookEntry INT +) +BEGIN + DECLARE vIsRequiredTx BOOL DEFAULT NOT @@in_transaction; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + CALL util.tx_rollback(vIsRequiredTx); + RESIGNAL; + END; + + IF vFiscalYear IS NULL THEN + CALL util.throw('Fiscal year is required'); + END IF; + + CALL util.tx_start(vIsRequiredTx); + CALL ledger_next(vFiscalYear, vLastBookEntry); + CALL util.tx_commit(vIsRequiredTx); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -63503,7 +64522,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `logShow`(vOriginFk INT, vEntity VARCHAR(45)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `logShow`(vOriginFk INT, vEntity VARCHAR(45)) BEGIN /** * Muestra las acciones realizadas por el usuario @@ -63539,7 +64558,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `lungSize_generator`(vDate DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `lungSize_generator`(vDate DATE) BEGIN SET @buildingOrder := 0; @@ -63600,7 +64619,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `machineWorker_add`(vPlate VARCHAR(10), vWorkerFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `machineWorker_add`(vPlate VARCHAR(10), vWorkerFk INT) BEGIN /** @@ -63635,7 +64654,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `machineWorker_getHistorical`(vPlate VARCHAR(20), vWorkerFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `machineWorker_getHistorical`(vPlate VARCHAR(20), vWorkerFk INT) BEGIN /** * Obtiene historial de la matrícula vPlate que el trabajador vWorkerFk escanea, @@ -63669,7 +64688,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `machineWorker_update`(vPlate VARCHAR(10), vWorkerFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `machineWorker_update`(vPlate VARCHAR(10), vWorkerFk INT) BEGIN /** @@ -63720,7 +64739,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `machine_getWorkerPlate`(vWorkerFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `machine_getWorkerPlate`(vWorkerFk INT) BEGIN /** * Selecciona la matrícula del vehículo del workerfk @@ -63749,7 +64768,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `mail_insert`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `mail_insert`( vReceiver VARCHAR(255), vReplyTo VARCHAR(50), vSubject VARCHAR(100), @@ -63800,7 +64819,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `makeNewItem`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `makeNewItem`() BEGIN DECLARE newItemFk INT; @@ -63829,7 +64848,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `makePCSGraf`(vDated DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `makePCSGraf`(vDated DATE) BEGIN @@ -63881,7 +64900,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `manaSpellersRequery`(vWorkerFk INTEGER) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `manaSpellersRequery`(vWorkerFk INTEGER) `whole_proc`: BEGIN /** @@ -63930,7 +64949,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `multipleInventory`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `multipleInventory`( vDate DATE, vWarehouseFk TINYINT, vMaxDays TINYINT @@ -63941,6 +64960,7 @@ proc: BEGIN DECLARE vDateTo DATETIME; DECLARE vDateToTomorrow DATETIME; DECLARE vDefaultDayRange INT; + DECLARE vCalcFk INT; IF vDate < util.VN_CURDATE() THEN LEAVE proc; @@ -63967,9 +64987,11 @@ proc: BEGIN ADD `life` TINYINT NOT NULL DEFAULT '0'; -- Calculo del inventario - UPDATE tmp.itemInventory ai - JOIN ( - SELECT itemFk Id_Article, SUM(quantity) Subtotal + CREATE OR REPLACE TEMPORARY TABLE tItemInventoryCalc + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT itemFk, + SUM(quantity) quantity FROM ( SELECT s.itemFk, - s.quantity quantity FROM sale s @@ -64000,56 +65022,26 @@ proc: BEGIN AND w.isComparative AND NOT e.isExcludedFromAvailable AND NOT e.isRaid - ) sub2 - GROUP BY itemFk - ) sub ON ai.id = sub.Id_Article - SET ai.inventory = sub.Subtotal, - ai.visible = sub.Subtotal, - ai.avalaible = sub.Subtotal, - ai.sd = sub.Subtotal; + ) sub + GROUP BY itemFk; -- Cálculo del visible - UPDATE tmp.itemInventory ai - JOIN ( - SELECT itemFk Id_Article, SUM(quantity) Subtotal - FROM ( - SELECT s.itemFk, s.quantity - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - JOIN warehouse w ON w.id = t.warehouseFk - WHERE t.shipped >= vDate - AND t.shipped < vDateTomorrow - AND (NOT isPicked AND NOT t.isLabeled AND t.refFk IS NULL) - AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk - AND w.isComparative - UNION ALL - SELECT b.itemFk, - b.quantity - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseInFk - WHERE t.landed = vDate - AND NOT t.isReceived - AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid - AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk - AND w.isComparative - UNION ALL - SELECT b.itemFk, b.quantity - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseOutFk - WHERE t.shipped = vDate - AND NOT t.isReceived - AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid - AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk - AND w.isComparative - ) sub2 - GROUP BY itemFk - ) sub ON ai.id = sub.Id_Article - SET ai.visible = ai.visible + sub.Subtotal; + CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk); + + CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc + (PRIMARY KEY (item_id)) + ENGINE = MEMORY + SELECT item_id, visible + FROM cache.visible + WHERE calc_id = vCalcFk; + + UPDATE tmp.itemInventory it + LEFT JOIN tItemInventoryCalc iic ON iic.itemFk = it.id + LEFT JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id + SET it.inventory = iic.quantity, + it.visible = ivc.visible, + it.avalaible = iic.quantity, + it.sd = iic.quantity; -- Calculo del disponible CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc @@ -64097,30 +65089,36 @@ proc: BEGIN CALL item_getAtp(vDate); CALL travel_upcomingArrivals(vWarehouseFk, vDate); - UPDATE tmp.itemInventory ai - JOIN ( - SELECT it.itemFk, - SUM(it.quantity) quantity, - im.quantity minQuantity - FROM tmp.itemCalc it - JOIN tmp.itemAtp im ON im.itemFk = it.itemFk - JOIN item i ON i.id = it.itemFk - LEFT JOIN origin o ON o.id = i.originFk - LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk - WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL, - t.landing, - vDateToTomorrow) - GROUP BY it.itemFk - ) sub ON sub.itemFk = ai.id - SET ai.avalaible = IF(sub.minQuantity > 0, - ai.avalaible, - ai.avalaible + sub.minQuantity), - ai.sd = ai.inventory + sub.quantity; + CREATE OR REPLACE TEMPORARY TABLE tItemAvailableCalc + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT it.itemFk, + SUM(it.quantity) quantity, + im.quantity minQuantity + FROM tmp.itemCalc it + JOIN tmp.itemAtp im ON im.itemFk = it.itemFk + JOIN item i ON i.id = it.itemFk + LEFT JOIN origin o ON o.id = i.originFk + LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk + WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL, + t.landing, + vDateToTomorrow) + GROUP BY it.itemFk; + + UPDATE tmp.itemInventory it + JOIN tItemAvailableCalc iac ON iac.itemFk = it.id + SET it.avalaible = IF(iac.minQuantity > 0, + it.avalaible, + it.avalaible + iac.minQuantity), + it.sd = it.inventory + iac.quantity; DROP TEMPORARY TABLE tmp.itemTravel, tmp.itemCalc, - tmp.itemAtp; + tmp.itemAtp, + tItemInventoryCalc, + tItemVisibleCalc, + tItemAvailableCalc; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -64159,7 +65157,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqlConnectionsSorter_kill`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `mysqlConnectionsSorter_kill`() BEGIN /** @@ -64209,7 +65207,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqlPreparedCount_check`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `mysqlPreparedCount_check`() BEGIN DECLARE vPreparedCount INTEGER; @@ -64243,7 +65241,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `nextShelvingCodeMake`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `nextShelvingCodeMake`() BEGIN DECLARE newShelving VARCHAR(3); @@ -64297,7 +65295,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `observationAdd`(vOriginFk INT, vTableCode VARCHAR(45), vDescription TEXT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `observationAdd`(vOriginFk INT, vTableCode VARCHAR(45), vDescription TEXT) BEGIN /** * Guarda las observaciones realizadas por el usuario @@ -64338,7 +65336,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `orderCreate`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `orderCreate`( vLanded DATE, vAgencyMode INT, vAddress INT, @@ -64378,7 +65376,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `orderDelete`(IN vId INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `orderDelete`(IN vId INT) BEGIN DELETE FROM hedera.`order` where id = vId; @@ -64399,7 +65397,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `orderListCreate`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `orderListCreate`( vLanded DATE, vAgencyMode INT, vAddress INT, @@ -64426,7 +65424,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `orderListVolume`(IN vOrderId INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `orderListVolume`(IN vOrderId INT) BEGIN SELECT @@ -64447,140 +65445,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `packageInvoicing` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `packageInvoicing`( - IN vClient INT, - IN vDate DATE, - IN vCompany INT, - IN vIsAllInvoiceable BOOLEAN, - OUT vNewTicket INT(11) - ) -BEGIN - - DECLARE vGraceDays INT; - DECLARE vDateStart DATE DEFAULT '2017-11-21'; - DECLARE vIsInvoiceable BOOLEAN; - DECLARE vWarehouse INT DEFAULT 13; - DECLARE vComponentCost INT DEFAULT 28; - DECLARE vGraceDate DATE; - DECLARE vDateEnd DATE; - - SET vGraceDays = IF(vIsAllInvoiceable ,0, 30); - SET vGraceDate = TIMESTAMPADD(DAY, - vGraceDays, vDate); - - /* Clientes especiales: - 3240 MADEFLOR - 992 JAVIER FELIU - 4 TONI VENDRELL - */ - - IF vClient IN (992, 3240, 4) THEN - - SET vGraceDays = 365; - - END IF; - /* Fin clientes especiales */ - - SET vDateEnd = DATE_ADD(vDate, INTERVAL 1 DAY); - - DROP TEMPORARY TABLE IF EXISTS tmp.packageToInvoice; - - CREATE TEMPORARY TABLE tmp.packageToInvoice - SELECT p.itemFk, - tp.packagingFk, - IF(tp.quantity < 0 OR t.shipped < vGraceDate, tp.quantity, 0) quantity, - tp.ticketFk, - p.price - FROM ticketPackaging tp - JOIN packaging p ON p.id = tp.packagingFk - JOIN ticket t ON t.id = tp.ticketFk - WHERE t.shipped BETWEEN vDateStart AND vDateEnd - AND t.clientFk = vClient; - - DROP TEMPORARY TABLE IF EXISTS tmp.packageToInvoicePositives; - - CREATE TEMPORARY TABLE tmp.packageToInvoicePositives - SELECT itemFk, sum(quantity) as totalQuantity - FROM tmp.packageToInvoice - GROUP BY itemFk - HAVING totalQuantity > 0; - - SELECT COUNT(*) - INTO vIsInvoiceable - FROM tmp.packageToInvoicePositives; - - IF vIsInvoiceable THEN - - CALL ticket_add(vClient, - vDateEnd, - vWarehouse, - vCompany, - NULL, - NULL, - NULL, - vDateEnd, - account.myUser_getId(), - TRUE, - vNewTicket); - - INSERT INTO ticketPackaging( - ticketFk, - packagingFk, - quantity, - pvp) - SELECT vNewTicket, - pti.packagingFk, - - SUM(pti.quantity) AS totalQuantity, - pti.price - FROM tmp.packageToInvoice pti - LEFT JOIN tmp.packageToInvoicePositives ptip ON pti.itemFk = ptip.itemFk - WHERE ptip.itemFK IS NOT NULL - OR vIsAllInvoiceable - GROUP BY packagingFk - HAVING totalQuantity; - - INSERT INTO sale( - ticketFk, - itemFk, - concept, - quantity, - price - ) - SELECT vNewTicket, - pti.itemFk, - i.name as concept, - sum(pti.quantity) as totalQuantity, - pti.price - FROM tmp.packageToInvoice pti - JOIN item i ON i.id = pti.itemFk - LEFT JOIN tmp.packageToInvoicePositives ptip ON pti.itemFk = ptip.itemFk - WHERE ptip.itemFK IS NOT NULL - OR vIsAllInvoiceable - GROUP BY pti.itemFk - HAVING totalQuantity; - - INSERT INTO saleComponent(saleFk, componentFk, value) - SELECT id, vComponentCost, price - FROM sale - WHERE ticketFk = vNewTicket; - - END IF; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `packingListSwitch` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64589,7 +65453,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `packingListSwitch`(saleFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `packingListSwitch`(saleFk INT) BEGIN DECLARE valueFk INT; @@ -64613,16 +65477,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `packingSite_startCollection` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `packingSite_startCollection`(vSelf INT, vTicketFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `packingSite_startCollection`(vSelf INT, vTicketFk INT) proc: BEGIN /** * @param vSelf packingSite id @@ -64686,7 +65550,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `parking_add`(vFromColumn INT, vToColumn INT, vFromRow INT, vToRow INT, vSectorFk INT, vIsLetterMode BOOLEAN) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `parking_add`(vFromColumn INT, vToColumn INT, vFromRow INT, vToRow INT, vSectorFk INT, vIsLetterMode BOOLEAN) BEGIN DECLARE vColumn INT; @@ -64740,7 +65604,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `parking_algemesi`(vFromRow INT, vToRow INT, vSectorFk INT, vLetter VARCHAR(1), vPickingOrder INT, vTrolleysByLine INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `parking_algemesi`(vFromRow INT, vToRow INT, vSectorFk INT, vLetter VARCHAR(1), vPickingOrder INT, vTrolleysByLine INT) BEGIN DECLARE vRow INT; @@ -64815,7 +65679,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `parking_new`(vStart INT, vEnd INT, vSectorFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `parking_new`(vStart INT, vEnd INT, vSectorFk INT) BEGIN DECLARE vRow INT; @@ -64860,7 +65724,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `parking_setOrder`(vWarehouseFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `parking_setOrder`(vWarehouseFk INT) BEGIN /* @@ -64900,7 +65764,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `payment_add`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `payment_add`( vDated DATE, vSupplierFk INT, vAmount DOUBLE, @@ -64997,7 +65861,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `prepareClientList`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `prepareClientList`() BEGIN /* @@ -65026,21 +65890,23 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `prepareTicketList`(vStartingDate DATETIME, vEndingDate DATETIME) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `prepareTicketList`(vStartingDate DATETIME, vEndingDate DATETIME) BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.productionTicket; CREATE TEMPORARY TABLE tmp.productionTicket (PRIMARY KEY (ticketFk)) ENGINE = MEMORY SELECT t.id ticketFk, t.clientFk - FROM vn.ticket t - LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id - JOIN vn.client c ON c.id = t.clientFk + FROM ticket t + JOIN alertLevel al ON al.code = 'DELIVERED' + LEFT JOIN ticketState ts ON ts.ticketFk = t.id + JOIN client c ON c.id = t.clientFk + WHERE c.typeFk IN ('normal','handMaking','internalUse') AND ( t.shipped BETWEEN util.VN_CURDATE() AND vEndingDate OR ( - ts.alertLevel < 3 + ts.alertLevel < al.id AND t.shipped >= vStartingDate AND t.shipped < util.VN_CURDATE() ) @@ -65061,60 +65927,66 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `previousSticker_get`(vSaleGroupFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `previousSticker_get`( + vSaleGroupFk INT +) BEGIN /** * Devuelve los campos a imprimir en una etiqueta de preparación previa. - * Actualiza el valor de vn.saleGroup.parkingFk en el caso de que exista un + * Actualiza el valor de saleGroup.parkingFk en el caso de que exista un * saleGroup del mismo ticket con parking, del mismo sector, para que todos se * pongan juntos. * - * @param vSaleGroupFk Identificador de vn.saleGroup + * @param vSaleGroupFk Identificador de saleGroup */ DECLARE vTicketFk INT; DECLARE vParkingFk INT; DECLARE vSectorFk INT; + DECLARE vTicketLines INT; - SELECT s.ticketFk - INTO vTicketFk - FROM vn.saleGroupDetail sgd - JOIN vn.sale s ON s.id = sgd.saleFk - WHERE sgd.saleGroupFk = vSaleGroupFk - LIMIT 1; + WITH ticketData AS( + SELECT DISTINCT s.ticketFk + FROM vn.saleGroupDetail sgd + JOIN vn.sale s ON s.id = sgd.saleFk + WHERE sgd.saleGroupFk = vSaleGroupFk + ) + SELECT COUNT(*), s.ticketFk INTO vTicketLines, vTicketFk + FROM vn.sale s + JOIN ticketData td ON td.ticketFk = s.ticketFk; SELECT sg.parkingFk, sc.sectorFk INTO vParkingFk, vSectorFk - FROM vn.saleGroup sg - JOIN vn.sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sg.id - JOIN vn.sectorCollection sc ON sc.id = scsg.sectorCollectionFk - JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = sg.id - JOIN vn.sale s ON s.id = sgd.saleFk + FROM saleGroup sg + JOIN sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sg.id + JOIN sectorCollection sc ON sc.id = scsg.sectorCollectionFk + JOIN saleGroupDetail sgd ON sgd.saleGroupFk = sg.id + JOIN sale s ON s.id = sgd.saleFk WHERE s.ticketFk = vTicketFk AND sg.parkingFk IS NOT NULL LIMIT 1; - UPDATE vn.saleGroup sg + UPDATE saleGroup sg SET sg.parkingFk = vParkingFk WHERE sg.id = vSaleGroupFk AND sg.sectorFk = vSectorFk; SELECT sgd.saleGroupFk, t.id ticketFk, - p.code as location, - t.observations, + COUNT(*) previousLines, IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) shippingHour, IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) shippingMinute , IFNULL(MAX(i.itemPackingTypeFk),'H') itemPackingTypeFk , - count(*) items, + vTicketLines ticketLines, + p.code `location`, sc.description sector - FROM vn.sale s - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id - JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk - JOIN vn.sector sc ON sc.id = sg.sectorFk - JOIN vn.ticket t ON t.id = s.ticketFk - LEFT JOIN vn.parking p ON p.id = sg.parkingFk - LEFT JOIN vn.`zone` z ON z.id = t.zoneFk + FROM sale s + JOIN item i ON i.id = s.itemFk + JOIN saleGroupDetail sgd ON sgd.saleFk = s.id + JOIN saleGroup sg ON sg.id = sgd.saleGroupFk + JOIN sector sc ON sc.id = sg.sectorFk + JOIN ticket t ON t.id = s.ticketFk + LEFT JOIN parking p ON p.id = sg.parkingFk + LEFT JOIN `zone` z ON z.id = t.zoneFk WHERE sgd.saleGroupFk = vSaleGroupFk; END ;; DELIMITER ; @@ -65132,7 +66004,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `printer_checkSector`(vLabelerFk tinyint(3) unsigned, vSector INT(11)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `printer_checkSector`(vLabelerFk tinyint(3) unsigned, vSector INT(11)) BEGIN /** * Comprueba si la impresora pertenece al sector @@ -65167,8 +66039,8 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `productionControl`( - vWarehouseFk INT, +CREATE DEFINER=`vn`@`localhost` PROCEDURE `productionControl`( + vWarehouseFk INT, vScopeDays INT ) proc: BEGIN @@ -65199,7 +66071,8 @@ proc: BEGIN CALL prepareClientList(); CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems - (INDEX (ticketFk)) ENGINE = MEMORY + (INDEX (ticketFk)) + ENGINE = MEMORY SELECT tt.ticketFk, tt.clientFk, t.warehouseFk, t.shipped FROM tmp.productionTicket tt JOIN ticket t ON t.id = tt.ticketFk; @@ -65235,7 +66108,7 @@ proc: BEGIN wk.code salesPersonCode, p.id provinceFk, tls.productionOrder, - IFNULL(tls.alertLevel, 0) alertLevel, + IFNULL(tls.alertLevel, al.id) alertLevel, t.isBoxed palletized, IF(rm.isPickingAllowed, rm.bufferFk, NULL) ubicacion, tlu.lastUpdated, @@ -65249,6 +66122,7 @@ proc: BEGIN rm.bufferFk FROM tmp.productionTicket tt JOIN ticket t ON tt.ticketFk = t.id + JOIN alertLevel al ON al.code = 'FREE' LEFT JOIN ticketStateToday tst ON tst.ticketFk = t.id LEFT JOIN `state` st ON st.id = tst.state LEFT JOIN client c ON c.id = t.clientFk @@ -65269,7 +66143,7 @@ proc: BEGIN LEFT JOIN parking pk ON pk.id = tp.parkingFk WHERE t.warehouseFk = vWarehouseFk AND dm.code IN ('AGENCY', 'DELIVERY', 'PICKUP'); - + UPDATE tmp.productionBuffer pb JOIN ( SELECT pb.ticketFk, GROUP_CONCAT(p.code) previaParking @@ -65277,12 +66151,12 @@ proc: BEGIN JOIN sale s ON s.ticketFk = pb.ticketFk JOIN saleGroupDetail sgd ON sgd.saleFk = s.id JOIN saleGroup sg ON sg.id = sgd.saleGroupFk - JOIN parking p ON p.id = sg.parkingFk + JOIN parking p ON p.id = sg.parkingFk GROUP BY pb.ticketFk ) t ON t.ticketFk = pb.ticketFk SET pb.previaParking = t.previaParking; - -- Problemas por ticket + -- Problemas por ticket ALTER TABLE tmp.productionBuffer CHANGE COLUMN `problem` `problem` VARCHAR(255), ADD COLUMN `collectionH` INT, @@ -65313,13 +66187,19 @@ proc: BEGIN -- Líneas y volumen por ticket UPDATE tmp.productionBuffer pb JOIN ( - SELECT tt.ticketFk, - COUNT(*) `lines`, - SUM(sv.volume) m3, - IFNULL(SUM(IF(sv.isPicked, sv.volume, 0)) / SUM(sv.volume), 0) rate - FROM tmp.productionTicket tt - JOIN saleVolume sv ON sv.ticketFk = tt.ticketFk - GROUP BY tt.ticketFk + SELECT tt.ticketFk, + COUNT(*) `lines`, + SUM(s.quantity * ic.cm3delivery / 1000000) m3, + IFNULL(SUM(IF(s.isPicked, + (s.quantity * ic.cm3delivery / 1000000), + 0)) / SUM(s.quantity * ic.cm3delivery / 1000000), + 0) rate + FROM tmp.productionTicket tt + JOIN sale s ON s.ticketFk = tt.ticketFk + AND s.quantity > 0 + JOIN itemCost ic ON ic.itemFk = s.itemFk + AND ic.warehouseFk = vWarehouseFk + GROUP BY tt.ticketFk ) m ON m.ticketFk = pb.ticketFk SET pb.`lines` = m.`lines`, pb.m3 = m.m3, @@ -65329,27 +66209,30 @@ proc: BEGIN WHERE NOT `lines`; -- Lineas por linea de encajado + CREATE OR REPLACE TEMPORARY TABLE tItemPackingType + (PRIMARY KEY(ticketFk)) + ENGINE = MEMORY + SELECT ticketFk, + SUM(sub.H) H, + SUM(sub.V) V, + SUM(sub.N) N + FROM ( + SELECT t.ticketFk, + SUM(i.itemPackingTypeFk = 'H') H, + SUM(i.itemPackingTypeFk = 'V') V, + SUM(i.itemPackingTypeFk IS NULL) N + FROM tmp.productionTicket t + JOIN sale s ON s.ticketFk = t.ticketFk + JOIN item i ON i.id = s.itemFk + GROUP BY t.ticketFk, i.itemPackingTypeFk + ) sub + GROUP BY ticketFk; + UPDATE tmp.productionBuffer pb - JOIN ( - SELECT ticketFk, - SUM(sub.H) H, - SUM(sub.V) V, - SUM(sub.N) N - FROM ( - SELECT t.ticketFk, - SUM(i.itemPackingTypeFk = 'H') H, - SUM(i.itemPackingTypeFk = 'V') V, - SUM(i.itemPackingTypeFk IS NULL) N - FROM tmp.productionTicket t - JOIN sale s ON s.ticketFk = t.ticketFk - JOIN item i ON i.id = s.itemFk - GROUP BY t.ticketFk, i.itemPackingTypeFk - ) sub - GROUP BY ticketFk - ) sub2 ON sub2.ticketFk = pb.ticketFk - SET pb.H = sub2.H, - pb.V = sub2.V, - pb.N = sub2.N; + JOIN tItemPackingType ti ON ti.ticketFk = pb.ticketFk + SET pb.H = ti.H, + pb.V = ti.V, + pb.N = ti.N; -- Colecciones segun tipo de encajado UPDATE tmp.productionBuffer pb @@ -65368,8 +66251,6 @@ proc: BEGIN salesInParkingCount INT DEFAULT 0) ENGINE = MEMORY; - -- Insertamos todos los tickets que tienen productos parkineados - -- en sectores de previa, segun el sector CREATE OR REPLACE TEMPORARY TABLE tItemShelvingStock (PRIMARY KEY(itemFk, sectorFk)) ENGINE = MEMORY @@ -65386,6 +66267,8 @@ proc: BEGIN AND ish.visible GROUP BY ish.itemFk, p.sectorFk; + CREATE INDEX idxItem ON tItemShelvingStock (itemFk); + INSERT INTO tmp.ticketWithPrevia(ticketFk, salesCount) SELECT pb.ticketFk, COUNT(DISTINCT s.id) FROM tmp.productionBuffer pb @@ -65400,7 +66283,6 @@ proc: BEGIN AND s.quantity > 0 GROUP BY pb.ticketFk; - -- Se calcula la cantidad de productos que estan ya preparados porque su saleGroup está aparcado UPDATE tmp.ticketWithPrevia twp JOIN ( SELECT pb.ticketFk, COUNT(DISTINCT s.id) salesInParkingCount @@ -65414,19 +66296,35 @@ proc: BEGIN ) sub ON twp.ticketFk = sub.ticketFk SET twp.salesInParkingCount = sub.salesInParkingCount; - -- Marcamos como pendientes aquellos que no coinciden las cantidades UPDATE tmp.productionBuffer pb JOIN tmp.ticketWithPrevia twp ON twp.ticketFk = pb.ticketFk SET pb.previousWithoutParking = TRUE WHERE twp.salesCount > twp.salesInParkingCount; + -- hasPlantTray + ALTER TABLE tmp.productionBuffer + ADD hasPlantTray BOOL DEFAULT FALSE; + + UPDATE tmp.productionBuffer pb + JOIN sale s ON s.ticketFk = pb.ticketFk + JOIN item i ON i.id = s.itemFk + JOIN cache.last_buy lb ON lb.warehouse_id = vWarehouseFk + AND lb.item_id = s.itemFk + JOIN buy b ON b.id = lb.buy_id + JOIN packaging p ON p.id = b.packagingFk + JOIN productionConfig pc + SET pb.hasPlantTray = TRUE + WHERE p.isPlantTray + AND s.quantity >= b.packing + AND pb.isOwn; + DROP TEMPORARY TABLE tmp.productionTicket, tmp.ticket, - tmp.risk, tmp.ticket_problems, tmp.ticketWithPrevia, - tItemShelvingStock; + tItemShelvingStock, + tItemPackingType; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -65443,7 +66341,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `productionError_add`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `productionError_add`() BEGIN DECLARE vDatedFrom DATETIME; DECLARE vDatedTo DATETIME; @@ -65620,7 +66518,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `productionError_addCheckerPackager`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `productionError_addCheckerPackager`( vDatedFrom DATETIME, vDatedTo DATETIME, vRol VARCHAR(50)) @@ -65680,7 +66578,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `productionSectorList`(vSectorFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `productionSectorList`(vSectorFk INT) BEGIN /** * Devuelve el listado de sale que se puede preparar en previa para ese sector @@ -65736,7 +66634,6 @@ BEGIN i.itemPackingTypeFk, isa.`size`, isa.Estado, - isa.sectorProdPriority, isa.available, isa.sectorFk, isa.matricula, @@ -65785,6 +66682,7 @@ BEGIN ) sub; DROP TEMPORARY TABLE tmp.whiteTicket; DROP TEMPORARY TABLE tmp.sectorTypeTicket; + DROP TEMPORARY TABLE tmp.productionBuffer; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -65801,7 +66699,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `raidUpdate`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `raidUpdate`() BEGIN /** * Actualiza el travel de las entradas de redadas @@ -65845,7 +66743,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `rangeDateInfo`(vStarted DATE, vEnded DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `rangeDateInfo`(vStarted DATE, vEnded DATE) BEGIN /** * Crea una tabla temporal con las fechas @@ -65895,7 +66793,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `rateView`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `rateView`() BEGIN /** * Muestra información sobre tasas de cambio de Dolares @@ -65946,7 +66844,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `rate_getPrices`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `rate_getPrices`( vDated DATE, vWarehouseFk INT ) @@ -66004,7 +66902,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `recipe_Plaster`(vItemFk INT, vTicketFk INT, vQuantity INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `recipe_Plaster`(vItemFk INT, vTicketFk INT, vQuantity INT) BEGIN DECLARE vLastCost DECIMAL(10,2); @@ -66052,7 +66950,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `remittance_calc`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `remittance_calc`( vDated DATE ) BEGIN @@ -66135,7 +67033,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `reportLabelCollection_get`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `reportLabelCollection_get`( vParam INT, vLabelCount INT ) @@ -66156,7 +67054,7 @@ BEGIN CONCAT(tc.collectionFk, ' ', LEFT(cc.code, 4)) color, CONCAT(tc.collectionFk, ' ', SUBSTRING('ABCDEFGH',tc.wagon, 1), '-', tc.level) levelV, tc.ticketFk, - LEFT(COALESCE(et.description, zo.name, am.name),12) agencyDescription, + LEFT(COALESCE(rs.description, zo.name, am.name),12) agencyDescription, am.name, t.clientFk, CONCAT(CAST(SUM(sv.volume) AS DECIMAL(5, 2)), 'm³') m3 , @@ -66183,7 +67081,7 @@ BEGIN LEFT JOIN ticketTrolley tt ON tt.ticket = t.id LEFT JOIN zone zo ON t.zoneFk = zo.id LEFT JOIN routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN expeditionTruck et ON et.id = rm.expeditionTruckFk + LEFT JOIN roadmapStop rs ON rs.id = rm.roadmapStopFk WHERE IF(vIsCollection, tc.collectionFk = vParam, tc.ticketFk = vParam) GROUP BY t.id ORDER BY cc.code; @@ -66203,7 +67101,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `report_print`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `report_print`( vReportName VARCHAR(100), vPrinterFk INT, vUserFk INT, @@ -66299,7 +67197,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `routeGuessPriority`(IN vRuta INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `routeGuessPriority`(IN vRuta INT) BEGIN /* Usa los valores del ultimo año para adivinar el orden de los tickets en la ruta * vRuta id ruta @@ -66332,7 +67230,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `routeInfo`(vRouteFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `routeInfo`(vRouteFk INT) BEGIN DECLARE vPackages INT; @@ -66378,7 +67276,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `routeMonitor_calculate`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `routeMonitor_calculate`( vDate DATE, vDaysAgo INT ) @@ -66485,8 +67383,8 @@ BEGIN SET rm.m3boxes = sub.m3boxes; UPDATE routesMonitor rm - JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk - SET rm.etd = et.eta; + JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk + SET rm.etd = rs.eta; DROP TEMPORARY TABLE tmp.routesMonitor; END ;; @@ -66505,7 +67403,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `routeSetOk`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `routeSetOk`( vRouteFk INT) BEGIN @@ -66529,7 +67427,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `routeUpdateM3`(vRoute INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `routeUpdateM3`(vRoute INT) BEGIN /** * @deprecated Use vn.route_updateM3() @@ -66551,7 +67449,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `route_calcCommission`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `route_calcCommission`( vSelf INT ) BEGIN @@ -66658,7 +67556,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `route_doRecalc`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `route_doRecalc`() proc: BEGIN /** * Recalculates modified route. @@ -66719,7 +67617,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `route_getTickets`(vRouteFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `route_getTickets`(vRouteFk INT) BEGIN /** * Pasado un RouteFk devuelve la información @@ -66804,17 +67702,21 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `route_updateM3`(vRoute INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `route_updateM3`( + vSelf INT +) BEGIN +/** + * Actualiza el volumen de la ruta. + * + * @param vSelf Id ruta + */ + DECLARE vVolume DECIMAL(10,1) + DEFAULT (SELECT SUM(volume) FROM saleVolume WHERE routeFk = vSelf); - UPDATE vn.route r - LEFT JOIN ( - SELECT routeFk, SUM(volume) AS m3 - FROM saleVolume - WHERE routeFk = vRoute - ) v ON v.routeFk = r.id - SET r.m3 = IFNULL(v.m3,0) - WHERE r.id =vRoute; + UPDATE `route` + SET m3 = IFNULL(vVolume, 0) + WHERE id = vSelf; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -66831,7 +67733,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleBuy_Add`(vSaleFk INT, vBuyFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `saleBuy_Add`(vSaleFk INT, vBuyFk INT) BEGIN /* Añade un registro a la tabla saleBuy en el caso de que sea posible mantener la trazabilidad @@ -66870,7 +67772,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleGroup_add`(vSectorFk INT,vTicketFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `saleGroup_add`(vSectorFk INT,vTicketFk INT) BEGIN /** * Añade un nuevo registro a la tabla y devuelve su id. @@ -66899,20 +67801,23 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleGroup_setParking`(IN `vSaleGroupFk` VARCHAR(8), IN `vParkingFk` INT) -proc: BEGIN +CREATE DEFINER=`vn`@`localhost` PROCEDURE `saleGroup_setParking`( + vSaleGroupFk VARCHAR(8), + vParkingFk INT +) +BEGIN /** - * Aparca una preparación previa en un parking + * Aparca una preparación previa en un parking. * * @param vSaleGroupFk id de la preparación previa * @param vParkingFk id del parking */ - UPDATE vn.saleGroup sg + UPDATE saleGroup sg SET sg.parkingFk = vParkingFk - WHERE sg.id = vSaleGroupFk - AND sg.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); + WHERE sg.id = vSaleGroupFk + AND sg.created >= util.VN_CURDATE() - INTERVAL 1 WEEK; - CALL vn.ticket_setNextState(vn.ticket_get(vSaleGroupFk)); + CALL ticket_setNextState(ticket_get(vSaleGroupFk)); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -66929,7 +67834,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleMistake_Add`(vSaleFk INT, vUserFk INT, vTypeFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `saleMistake_Add`(vSaleFk INT, vUserFk INT, vTypeFk INT) BEGIN INSERT INTO vn.saleMistake(saleFk, userFk, typeFk) @@ -66951,7 +67856,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `salePreparingList`(IN vTicketFk BIGINT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `salePreparingList`(IN vTicketFk BIGINT) BEGIN /** * Devuelve un listado con las lineas de vn.sale y los distintos estados de prepacion @@ -67010,7 +67915,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleSplit`(vSaleFk INT, vQuantity INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `saleSplit`(vSaleFk INT, vQuantity INT) BEGIN @@ -67058,58 +67963,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `sales_merge` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sales_merge`(vTicketFk INT) -BEGIN - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - CREATE OR REPLACE TEMPORARY TABLE tSalesToPreserve - SELECT s.id, s.itemFk, SUM(s.quantity) newQuantity - FROM sale s - JOIN item i ON i.id = s.itemFk - JOIN itemType it ON it.id = i.typeFk - WHERE s.ticketFk = vTicketFk - AND it.isMergeable - GROUP BY s.itemFk, s.price, s.discount; - - START TRANSACTION; - - UPDATE sale s - JOIN tSalesToPreserve stp ON stp.id = s.id - SET quantity = newQuantity - WHERE s.ticketFk = vTicketFk; - - DELETE s.* - FROM sale s - LEFT JOIN tSalesToPreserve stp ON stp.id = s.id - JOIN item i ON i.id = s.itemFk - JOIN itemType it ON it.id = i.typeFk - WHERE s.ticketFk = vTicketFk - AND stp.id IS NULL - AND it.isMergeable; - - COMMIT; - - DROP TEMPORARY TABLE tSalesToPreserve; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sales_mergeByCollection` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -67118,7 +67971,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sales_mergeByCollection`(vCollectionFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sales_mergeByCollection`(vCollectionFk INT) BEGIN DECLARE vDone BOOL; @@ -67145,7 +67998,7 @@ BEGIN LEAVE myLoop; END IF; - CALL vn.sales_merge(vTicketFk); + CALL ticket_mergeSales(vTicketFk); END LOOP; @@ -67167,7 +68020,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_add`(vSaleGroupFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `saleTracking_add`(vSaleGroupFk INT) BEGIN /** Inserta en vn.saleTracking las lineas de una previa * @@ -67202,7 +68055,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_addPreparedSaleGroup`(vSaleGroupFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `saleTracking_addPreparedSaleGroup`(vSaleGroupFk INT) BEGIN /** * Inserta lineas de vn.saleTracking para un saleGroup (previa) que escanea un sacador @@ -67230,7 +68083,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_addPrevOK`(vSectorCollectionFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `saleTracking_addPrevOK`(vSectorCollectionFk INT) BEGIN /** * Inserta los registros de la colección de sector con el estado PREVIA OK @@ -67268,7 +68121,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_del`(vSaleFk INT, vState VARCHAR(50)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `saleTracking_del`(vSaleFk INT, vState VARCHAR(50)) BEGIN DELETE FROM itemShelvingSale @@ -67296,7 +68149,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_new`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `saleTracking_new`( vSaleFK INT, vIsChecked BOOLEAN, vOriginalQuantity INT, @@ -67347,7 +68200,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleTracking_updateIsChecked`(vSaleFK INT, vIsChecked BOOL, vIsScanned BOOL) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `saleTracking_updateIsChecked`(vSaleFK INT, vIsChecked BOOL, vIsScanned BOOL) BEGIN /** @@ -67388,7 +68241,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_boxPickingPrint`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sale_boxPickingPrint`( IN vPrinterFk INT, IN vSaleFk INT, IN vPacking INT, @@ -67548,7 +68401,10 @@ w1: WHILE vQuantity >= vPacking DO UPDATE sale SET quantity = quantity - vPacking WHERE id = vSaleFk; - UPDATE itemShelving SET visible = visible - vPacking WHERE id = vItemShelvingFk; + UPDATE itemShelving + SET visible = visible - vPacking, + available = available - vPacking + WHERE id = vItemShelvingFk; SET vNewSaleFk = NULL; @@ -67677,16 +68533,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sale_calculateComponent` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_calculateComponent`(vSelf INT, vOption VARCHAR(25)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sale_calculateComponent`(vSelf INT, vOption VARCHAR(25)) proc: BEGIN /** * Crea tabla temporal para vn.sale_recalcComponent() para recalcular los componentes @@ -67718,7 +68574,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getBoxPickingList`(vSectorFk INT, vDated DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sale_getBoxPickingList`(vSectorFk INT, vDated DATE) BEGIN /** * Returns a suitable boxPicking sales list @@ -67738,21 +68594,20 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.sale (saleFk INT PRIMARY KEY) - SELECT - s.ticketFk, - s.id saleFk, - s.itemFk, - s.concept, - s.quantity, - MAKETIME(pb.HH,pb.mm,0) etd, - pb.routeFk, - FLOOR(s.quantity / IF(i.isBoxPickingMode, ish.packing, i.packingOut)) stickers, - IF(i.isBoxPickingMode, ish.packing, i.packingOut) packing, - b.packagingFk + SELECT s.ticketFk, + s.id saleFk, + s.itemFk, + s.concept, + s.quantity, + MAKETIME(pb.HH,pb.mm,0) etd, + pb.routeFk, + FLOOR(s.quantity / IF(i.isBoxPickingMode, ish.packing, i.packingOut)) stickers, + IF(i.isBoxPickingMode, ish.packing, i.packingOut) packing, + IF(pa.isPackageReturnable, pc.defaultBigPackageFk, b.packagingFk) packagingFk FROM sale s JOIN item i ON i.id = s.itemFk JOIN itemShelving ish ON ish.itemFk = s.itemFk - LEFT JOIN ( SELECT iss.itemShelvingFk, + LEFT JOIN ( SELECT iss.itemShelvingFk, s.itemFk, SUM(iss.quantity) reserve FROM itemShelvingSale iss @@ -67771,6 +68626,8 @@ BEGIN LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk LEFT JOIN buy b ON b.id = lb.buy_id + LEFT JOIN packaging pa ON pa.id = b.packagingFk + JOIN packagingConfig pc WHERE IF(i.isBoxPickingMode, ish.packing, i.packingOut) <= LEAST(s.quantity, ish.visible - IFNULL(tISS.reserve,0)) AND NOT pb.problem @@ -67806,7 +68663,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getFromTicketOrCollection`(vParam INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sale_getFromTicketOrCollection`(vParam INT) BEGIN /** * Visualizar lineas de la tabla sale a través del parámetro vParam que puede @@ -67936,42 +68793,36 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getProblems`(IN vIsTodayRelative tinyint(1)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sale_getProblems`( + vIsTodayRelative tinyint(1) +) BEGIN /** * Calcula los problemas de cada venta para un conjunto de tickets. * * @param vIsTodayRelative Indica si se calcula el disponible como si todo saliera hoy - * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular + * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Tickets a calcular * @return tmp.sale_problems */ - DECLARE vWarehouseFk INT; + DECLARE vWarehouseFk INT; DECLARE vDate DATE; - DECLARE vAvailableCache INT; + DECLARE vAvailableCache INT; DECLARE vVisibleCache INT; DECLARE vDone BOOL; - DECLARE vComponentCount INT; - - DECLARE vCursor CURSOR FOR - SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, util.VN_CURDATE(), DATE(tt.shipped)) - FROM tmp.sale_getProblems tt - WHERE DATE(tt.shipped) BETWEEN util.VN_CURDATE() - AND util.VN_CURDATE() + INTERVAL IF(vIsTodayRelative, 9.9, 1.9) DAY; + DECLARE vCursor CURSOR FOR + SELECT DISTINCT warehouseFk, IF(vIsTodayRelative, util.VN_CURDATE(), DATE(shipped)) + FROM tmp.sale_getProblems + WHERE shipped BETWEEN util.VN_CURDATE() + AND util.dayEnd(util.VN_CURDATE() + INTERVAL IF(vIsTodayRelative, 9.9, 1.9) DAY); DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DELETE tt.* - FROM tmp.sale_getProblems tt - JOIN ticketObservation tto ON tto.ticketFk = tt.ticketFk - JOIN observationType ot ON ot.id = tto.observationTypeFk - WHERE ot.code = 'administrative' - AND tto.description = 'Miriam'; - CREATE OR REPLACE TEMPORARY TABLE tmp.sale_problems ( ticketFk INT(11), saleFk INT(11), isFreezed INTEGER(1) DEFAULT 0, - risk DECIMAL(10,2) DEFAULT 0, + risk DECIMAL(10,1) DEFAULT 0, + hasRisk TINYINT(1) DEFAULT 0, hasHighRisk TINYINT(1) DEFAULT 0, hasTicketRequest INTEGER(1) DEFAULT 0, itemShortage VARCHAR(255), @@ -67981,97 +68832,47 @@ BEGIN hasComponentLack INTEGER(1), hasRounding VARCHAR(255), isTooLittle BOOL DEFAULT FALSE, + isVip BOOL DEFAULT FALSE, PRIMARY KEY (ticketFk, saleFk) ) ENGINE = MEMORY; - CREATE OR REPLACE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (ticketFk)) - ENGINE = MEMORY - SELECT ticketFk, clientFk - FROM tmp.sale_getProblems; + INSERT INTO tmp.sale_problems(ticketFk, + saleFk, + isFreezed, + risk, + hasRisk, + hasHighRisk, + hasTicketRequest, + isTaxDataChecked, + hasComponentLack, + isTooLittle) + SELECT sgp.ticketFk, + s.id, + IF(FIND_IN_SET('isFreezed', t.problem), TRUE, FALSE) isFreezed, + t.risk, + IF(FIND_IN_SET('hasRisk', t.problem), TRUE, FALSE) hasRisk, + IF(FIND_IN_SET('hasHighRisk', t.problem), TRUE, FALSE) hasHighRisk, + IF(FIND_IN_SET('hasTicketRequest', t.problem), TRUE, FALSE) hasTicketRequest, + IF(FIND_IN_SET('isTaxDataChecked', t.problem), FALSE, TRUE) isTaxDataChecked, + IF(FIND_IN_SET('hasComponentLack', s.problem), TRUE, FALSE) hasComponentLack, + IF(FIND_IN_SET('isTooLittle', t.problem) + AND util.VN_NOW() < (util.VN_CURDATE() + INTERVAL HOUR(zc.`hour`) HOUR) + INTERVAL MINUTE(zc.`hour`) MINUTE, + TRUE, FALSE) isTooLittle + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk + LEFT JOIN sale s ON s.ticketFk = t.id + LEFT JOIN item i ON i.id = s.itemFk + LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk + AND zc.dated = util.VN_CURDATE() + WHERE s.problem <> '' OR t.problem <> '' OR t.risk + GROUP BY t.id, s.id; - SELECT COUNT(*) INTO vComponentCount - FROM component - WHERE isRequired; - - -- Too Little - INSERT INTO tmp.sale_problems(ticketFk, isTooLittle) - SELECT tp.ticketFk, TRUE - FROM tmp.sale_getProblems tp - JOIN ticket t ON t.id = tp.ticketFk - JOIN ( - SELECT t.addressFk, SUM(sv.litros) litros, t.totalWithoutVat - FROM tmp.ticket_list tl - JOIN saleVolume sv ON sv.ticketFk = tl.ticketFk - JOIN ticket t ON t.id = tl.ticketFk - JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk - AND zc.dated = util.VN_CURDATE() - JOIN agencyMode am ON am.id = t.agencyModeFk - JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk - WHERE util.VN_NOW() < (util.VN_CURDATE() + INTERVAL HOUR(zc.`hour`) HOUR) + INTERVAL MINUTE(zc.`hour`) MINUTE - AND dm.code IN ('AGENCY','DELIVERY','PICKUP') - AND t.shipped BETWEEN util.VN_CURDATE() AND util.midnight() - GROUP BY t.addressFk - ) sub ON sub.addressFk = t.addressFk - JOIN volumeConfig vc - WHERE sub.litros < vc.minTicketVolume - AND sub.totalWithoutVat < vc.minTicketValue; - - -- Faltan componentes - INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk) - SELECT ticketFk, (vComponentCount > nComp) hasComponentLack, saleFk - FROM ( - SELECT COUNT(s.id) nComp, tl.ticketFk, s.id saleFk - FROM tmp.ticket_list tl - JOIN vn.sale s ON s.ticketFk = tl.ticketFk - LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id - LEFT JOIN vn.component c ON c.id = sc.componentFk AND c.isRequired - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.agencyMode am ON am.id = t.agencyModeFk - JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk - WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP') - AND s.quantity > 0 - GROUP BY s.id - ) sub - HAVING hasComponentLack; - - -- Cliente congelado - INSERT INTO tmp.sale_problems(ticketFk, isFreezed) - SELECT DISTINCT tl.ticketFk, TRUE - FROM tmp.ticket_list tl - JOIN client c ON c.id = tl.clientFk - WHERE c.isFreezed - ON DUPLICATE KEY UPDATE isFreezed = c.isFreezed; - - -- Credit exceeded - CREATE OR REPLACE TEMPORARY TABLE tmp.clientGetDebt - (PRIMARY KEY (clientFk)) - ENGINE = MEMORY - SELECT DISTINCT clientFk - FROM tmp.ticket_list; - - CALL client_getDebt(util.VN_CURDATE()); - - INSERT INTO tmp.sale_problems(ticketFk, risk, hasHighRisk) - SELECT DISTINCT tl.ticketFk, r.risk, ((r.risk - cc.riskTolerance) > c.credit + 10) - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk - JOIN agencyMode a ON t.agencyModeFk = a.id - JOIN tmp.risk r ON r.clientFk = t.clientFk - JOIN client c ON c.id = t.clientFk - JOIN clientConfig cc - WHERE r.risk > c.credit + 10 - AND NOT a.isRiskFree - ON DUPLICATE KEY UPDATE - risk = r.risk, hasHighRisk = ((r.risk - cc.riskTolerance) > c.credit + 10); - - -- Antiguo COD 100, son peticiones de compra sin terminar - INSERT INTO tmp.sale_problems(ticketFk, hasTicketRequest) - SELECT DISTINCT tl.ticketFk, TRUE - FROM tmp.ticket_list tl - JOIN ticketRequest tr ON tr.ticketFk = tl.ticketFk - WHERE tr.isOK IS NULL - ON DUPLICATE KEY UPDATE hasTicketRequest = TRUE; + INSERT INTO tmp.sale_problems(ticketFk, isVip) + SELECT sgp.ticketFk, TRUE + FROM tmp.sale_getProblems sgp + JOIN client c ON c.id = sgp.clientFk + WHERE c.businessTypeFk = 'VIP' + ON DUPLICATE KEY UPDATE isVIP = TRUE; CREATE OR REPLACE TEMPORARY TABLE tItemShelvingStock_byWarehouse (INDEX (itemFk, warehouseFk)) @@ -68083,10 +68884,9 @@ BEGIN JOIN shelving sh ON sh.code = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk JOIN sector s ON s.id = p.sectorFk - GROUP BY ish.itemFk, - s.warehouseFk; + GROUP BY ish.itemFk, s.warehouseFk; - -- Disponible, Faltas, Inventario y Retrasos + -- Disponible, faltas, inventario y retrasos OPEN vCursor; l: LOOP SET vDone = FALSE; @@ -68105,14 +68905,14 @@ BEGIN INSERT INTO tmp.sale_problems(ticketFk, itemShortage, saleFk) SELECT ticketFk, problem, saleFk FROM ( - SELECT tl.ticketFk, - LEFT(CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')),250) problem, - s.id AS saleFk - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk + SELECT sgp.ticketFk, + LEFT(CONCAT('F: ', GROUP_CONCAT(i.id, ' ', i.longName, ' ')), 250) problem, + s.id saleFk + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk - JOIN itemType it on it.id = i.typeFk + JOIN itemType it ON it.id = i.typeFk JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.visible v ON v.item_id = i.id AND v.calc_id = vVisibleCache @@ -68120,8 +68920,8 @@ BEGIN AND av.calc_id = vAvailableCache LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk - WHERE IFNULL(v.visible,0) < s.quantity - AND IFNULL(av.available ,0) < s.quantity + WHERE IFNULL(v.visible, 0) < s.quantity + AND IFNULL(av.available, 0) < s.quantity AND IFNULL(issw.visible, 0) < s.quantity AND NOT s.isPicked AND NOT s.reserved @@ -68130,27 +68930,27 @@ BEGIN AND NOT i.generic AND util.VN_CURDATE() = vDate AND t.warehouseFk = vWarehouseFk - GROUP BY tl.ticketFk) sub + GROUP BY sgp.ticketFk) sub ON DUPLICATE KEY UPDATE itemShortage = sub.problem, saleFk = sub.saleFk; -- Inventario: Visible suficiente, pero ubicado menor a la cantidad vendida INSERT INTO tmp.sale_problems(ticketFk, itemLost, saleFk) SELECT ticketFk, problem, saleFk FROM ( - SELECT tl.ticketFk, + SELECT sgp.ticketFk, LEFT(GROUP_CONCAT('I: ', i.id, ' ', i.longName, ' '), 250) problem, s.id saleFk - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk - JOIN itemType it on it.id = i.typeFk + JOIN itemType it ON it.id = i.typeFk JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk - WHERE IFNULL(v.visible,0) >= s.quantity + WHERE IFNULL(v.visible, 0) >= s.quantity AND IFNULL(issw.visible, 0) < s.quantity AND s.quantity > 0 AND NOT s.isPicked @@ -68160,22 +68960,22 @@ BEGIN AND NOT i.generic AND util.VN_CURDATE() = vDate AND t.warehouseFk = vWarehouseFk - GROUP BY tl.ticketFk + GROUP BY sgp.ticketFk ) sub - ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; + ON DUPLICATE KEY UPDATE itemLost = sub.problem, saleFk = sub.saleFk; -- Retraso: Disponible suficiente, pero no visible ni ubicado INSERT INTO tmp.sale_problems(ticketFk, itemDelay, saleFk) SELECT ticketFk, problem, saleFk FROM ( - SELECT tl.ticketFk, + SELECT sgp.ticketFk, LEFT(GROUP_CONCAT('R: ', i.id, ' ', i.longName, ' '), 250) problem, s.id saleFk - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk - JOIN itemType it on it.id = i.typeFk + JOIN itemType it ON it.id = i.typeFk JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache @@ -68194,44 +68994,35 @@ BEGIN AND NOT i.generic AND util.VN_CURDATE() = vDate AND t.warehouseFk = vWarehouseFk - GROUP BY tl.ticketFk + GROUP BY sgp.ticketFk ) sub ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; - -- Redondeo: Cantidad pedida incorrecta en al grouping de la última compra - CALL buyUltimate(vWarehouseFk, vDate); + -- Redondeo: cantidad incorrecta con respecto al grouping + CALL buy_getUltimate(NULL, vWarehouseFk, vDate); INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) SELECT ticketFk, problem, saleFk FROM ( - SELECT tl.ticketFk, - s.id saleFk , - LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,''), ' '), 250) problem, - MOD(s.quantity, b.`grouping`) hasRounding - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk + SELECT sgp.ticketFk, + s.id saleFk, + LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250) problem + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk AND t.warehouseFk = vWarehouseFk - JOIN sale s ON s.ticketFk = tl.ticketFk + JOIN sale s ON s.ticketFk = sgp.ticketFk JOIN item i ON i.id = s.itemFk JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk JOIN buy b ON b.id = bu.buyFk - GROUP BY tl.ticketFk - HAVING hasRounding - ) sub + WHERE MOD(s.quantity, b.`grouping`) + GROUP BY sgp.ticketFk + )sub ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk; + + DROP TEMPORARY TABLE tmp.buyUltimate; END LOOP; CLOSE vCursor; - - INSERT INTO tmp.sale_problems(ticketFk, isTaxDataChecked) - SELECT DISTINCT tl.ticketFk, FALSE - FROM tmp.ticket_list tl - JOIN client c ON c.id = tl.clientFk - WHERE NOT c.isTaxDataChecked - ON DUPLICATE KEY UPDATE isTaxDataChecked = FALSE; - DROP TEMPORARY TABLE - tmp.clientGetDebt, - tmp.ticket_list, - tItemShelvingStock_byWarehouse; + DROP TEMPORARY TABLE tItemShelvingStock_byWarehouse; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -68248,7 +69039,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getProblemsByTicket`(IN vTicketFk INT, IN vIsTodayRelative TINYINT(1)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sale_getProblemsByTicket`(IN vTicketFk INT, IN vIsTodayRelative TINYINT(1)) BEGIN /** * Calcula los problemas de cada venta @@ -68256,8 +69047,7 @@ BEGIN * * @return Problems result */ - DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems; - CREATE TEMPORARY TABLE tmp.sale_getProblems + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems (INDEX (ticketFk)) ENGINE = MEMORY SELECT t.id ticketFk, t.clientFk, t.warehouseFk, t.shipped @@ -68287,7 +69077,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_PriceFix`(vTicketFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sale_PriceFix`(vTicketFk INT) BEGIN DELETE sc.* @@ -68296,7 +69086,7 @@ BEGIN JOIN vn.component c ON c.id = sc.componentFk JOIN vn.componentType ct ON ct.id = c.typeFk WHERE s.ticketFk = vTicketFk - AND ct.`type` = 'otros'; + AND ct.code = 'other'; UPDATE vn.sale s JOIN ( @@ -68313,16 +69103,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sale_recalcComponent` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_recalcComponent`(vOption VARCHAR(25)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sale_recalcComponent`(vOption VARCHAR(25)) proc: BEGIN /** * Este procedimiento recalcula los componentes de un conjunto de sales, @@ -68401,7 +69191,7 @@ proc: BEGIN DROP TEMPORARY TABLE tmp.zoneGetLanded; -- rellena la tabla buyUltimate con la ultima compra - CALL buyUltimate (vWarehouseFk, vShipped); + CALL buy_getUltimate(NULL, vWarehouseFk, vShipped); CREATE OR REPLACE TEMPORARY TABLE tmp.sale (PRIMARY KEY (saleFk)) ENGINE = MEMORY @@ -68450,7 +69240,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_replaceItem`(vSaleFk INT, vNewItemFk INT, vQuantity INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sale_replaceItem`(vSaleFk INT, vNewItemFk INT, vQuantity INT) BEGIN /** * Añade un nuevo articulo para sustituir a otro, y actualiza la memoria de sustituciones. @@ -68504,7 +69294,7 @@ BEGIN JOIN ticket t ON t.id = s.ticketFk WHERE s.id = vSaleFk; - CALL buyUltimate(vWarehouseFk, vDate); + CALL buy_getUltimate(vNewItemFk, vWarehouseFk, vDate); SELECT `grouping`, groupingMode, packing INTO vGrouping,vGroupingMode,vPacking @@ -68512,6 +69302,8 @@ BEGIN JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk; + DROP TEMPORARY TABLE tmp.buyUltimate; + IF vGroupingMode = 'packing' AND vPacking > 0 THEN SET vRoundQuantity = vPacking; END IF; @@ -68587,6 +69379,142 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `sale_setProblem` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sale_setProblem`( + vProblemCode VARCHAR(25) +) +BEGIN +/** + * Update column sale.problem with a problem code + * + * @param vProblemCode Code to set or unset + * @table tmp.sale(saleFk, hasProblem, isProblemCalcNeeded) + */ + DECLARE vSaleFk INT; + DECLARE vHasProblem INT; + DECLARE vIsProblemCalcNeeded BOOL; + DECLARE vDone BOOL; + DECLARE vSaleList CURSOR FOR + SELECT saleFk, hasProblem, isProblemCalcNeeded + FROM tmp.sale; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vSaleList; + l: LOOP + SET vDone = FALSE; + FETCH vSaleList INTO vSaleFk, vHasProblem, vIsProblemCalcNeeded; + + IF vDone THEN + LEAVE l; + END IF; + + UPDATE sale + SET problem = IF (vIsProblemCalcNeeded, + CONCAT( + IF(vHasProblem, + CONCAT(problem, ',', vProblemCode), + REPLACE(problem, vProblemCode , ''))), + NULL) + WHERE id = vSaleFk; + END LOOP; + CLOSE vSaleList; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `sale_setProblemComponentLack` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sale_setProblemComponentLack`( + vSelf INT +) +BEGIN +/** + * Update the problems for sales lines that have or no longer have problems with components, + * verify whether all mandatory components are present or not + * + * @param vSelf Id del sale + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.sale + (INDEX(saleFk, isProblemCalcNeeded)) + ENGINE = MEMORY + SELECT vSelf saleFk, + sale_hasComponentLack(vSelf) hasProblem, + (ticket_isProblemCalcNeeded(ticketFk) AND quantity > 0) isProblemCalcNeeded + FROM sale + WHERE id = vSelf; + + CALL sale_setProblem('hasComponentLack'); + + DROP TEMPORARY TABLE tmp.sale; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `sale_setProblemComponentLackByComponent` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sale_setProblemComponentLackByComponent`( + vComponentFk INT +) +BEGIN +/** + * Update the issues for sales lines that have or no longer have problems with components, verify + * whether all mandatory components are present or not resulting from changes in the table vn.component + * + * @param vComponentFk Id component + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.sale + (INDEX(saleFk, isProblemCalcNeeded)) + ENGINE = MEMORY + SELECT saleFk, + sale_hasComponentLack(saleFk) hasProblem, + (ticket_isProblemCalcNeeded(ticketFk) AND quantity > 0) isProblemCalcNeeded + FROM ( + SELECT s.id saleFk, s.ticketFk, s.quantity + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + WHERE t.shipped >= util.VN_CURDATE() + AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk) + GROUP BY s.id) sub; + + CALL sale_setProblem('hasComponentLack'); + + DROP TEMPORARY TABLE tmp.sale; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sectorCollectionSaleGroup_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68595,7 +69523,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollectionSaleGroup_add`(vSaleGroupFk INT, vSectorCollectionFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sectorCollectionSaleGroup_add`(vSaleGroupFk INT, vSectorCollectionFk INT) BEGIN /** * Inserta un nuevo registro en vn.sectorCollectionSaleGroup @@ -68665,7 +69593,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollection_get`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sectorCollection_get`() BEGIN /** * Devuelve las colecciones del sector que corresponden al usuario conectado, y que estan incompletas @@ -68692,6 +69620,37 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `sectorCollection_getMyPartial` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sectorCollection_getMyPartial`() +BEGIN +/** + * Devuelve las colecciones del sector que corresponden al usuario conectado, y que estan incompletas + * + */ + SELECT DISTINCT sc.id collectionFk, sc.created + FROM vn.sectorCollection sc + LEFT JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id + LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk + LEFT JOIN vn.sale sl ON sl.id = sgd.saleFk + LEFT JOIN itemShelvingSale iss ON iss.saleFk = sl.id + WHERE sc.userFk = account.myUser_getId() + AND (scsg.sectorCollectionFk IS NULL OR NOT iss.isPicked) + AND sc.created > util.VN_CURDATE() - INTERVAL 1 DAY; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sectorCollection_getSale` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68700,7 +69659,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollection_getSale`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sectorCollection_getSale`(vSelf INT) BEGIN /** * Devuelve las lineas de venta correspondientes a esa coleccion de sector @@ -68745,7 +69704,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollection_new`(vSectorFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sectorCollection_new`(vSectorFk INT) BEGIN /** * Inserta una nueva colección, si el usuario no tiene ninguna vacia. @@ -68786,7 +69745,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorProductivity_add`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sectorProductivity_add`() BEGIN DECLARE vDatedFrom DATETIME; DECLARE vDatedTo DATETIME; @@ -68873,7 +69832,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sector_getWarehouse`(vSectorFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sector_getWarehouse`(vSectorFk INT) BEGIN SELECT s.warehouseFk @@ -68896,8 +69855,11 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `setParking`(IN `vParam` VARCHAR(8), IN `vParkingCode` VARCHAR(8)) -proc: BEGIN +CREATE DEFINER=`vn`@`localhost` PROCEDURE `setParking`( + vParam VARCHAR(8), + vParkingCode VARCHAR(8) +) +BEGIN /** * Aparca una colección, un ticket, un saleGroup o un shelving en un parking * @@ -68905,55 +69867,32 @@ proc: BEGIN * @param vParkingCode código del parking */ DECLARE vParkingFk INT; - DECLARE vIsSaleGroup BOOL; - DECLARE vIsTicket BOOL; - DECLARE vIsCollection BOOL; + DECLARE vLastWeek DATE; - SET vParkingCode = replace(vParkingCode,' ',''); + SET vParkingCode = REPLACE(vParkingCode, ' ', ''); SELECT id INTO vParkingFk - FROM vn.parking + FROM parking WHERE code = vParkingCode COLLATE utf8_unicode_ci; IF vParkingFk IS NULL THEN CALL util.throw('parkingNotExist'); - LEAVE proc; END IF; - -- Se comprueba si es una preparación previa - SELECT COUNT(*) INTO vIsSaleGroup - FROM vn.saleGroup sg - WHERE sg.id = vParam; + SET vLastWeek = util.VN_CURDATE() - INTERVAL 1 WEEK; - IF vIsSaleGroup THEN - CALL vn.saleGroup_setParking(vParam, vParkingFk); - LEAVE proc; + -- Comprobamos si es una prep. previa, ticket, colección o shelving + IF (SELECT TRUE FROM saleGroup WHERE id = vParam) THEN + CALL saleGroup_setParking(vParam, vParkingFk); + ELSEIF (SELECT TRUE FROM ticket WHERE id = vParam AND shipped >= vLastWeek) THEN + CALL ticket_setParking(vParam, vParkingFk); + ELSEIF (SELECT TRUE FROM `collection` WHERE id = vParam AND created >= vLastWeek) THEN + CALL collection_setParking(vParam, vParkingFk); + ELSEIF (SELECT TRUE FROM shelving WHERE code = vParam COLLATE utf8_unicode_ci) THEN + CALL shelving_setParking(vParam, vParkingFk); + ELSE + CALL util.throw('paramNotExist'); END IF; - - -- Se comprueba si es un ticket - SELECT COUNT(*) INTO vIsTicket - FROM vn.ticket t - WHERE t.id = vParam - AND t.shipped >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); - - IF vIsTicket THEN - CALL vn.ticket_setParking(vParam, vParkingFk); - LEAVE proc; - END IF; - - -- Se comprueba si es una coleccion de tickets - SELECT COUNT(*) INTO vIsCollection - FROM vn.collection c - WHERE c.id = vParam - AND c.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); - - IF vIsCollection THEN - CALL vn.collection_setParking(vParam, vParkingFk); - LEAVE proc; - END IF; - - -- Por descarte, se considera una matrícula - CALL vn.shelving_setParking(vParam, vParkingFk); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -68970,7 +69909,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingChange`(IN `vShelvingO` VARCHAR(8), IN `vShelvingD` VARCHAR(8)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `shelvingChange`(IN `vShelvingO` VARCHAR(8), IN `vShelvingD` VARCHAR(8)) BEGIN UPDATE vn.itemShelving @@ -68994,7 +69933,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingLog_get`(shelvingFk VARCHAR(10)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `shelvingLog_get`(shelvingFk VARCHAR(10)) BEGIN /* Lista el log de un carro @@ -69025,7 +69964,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingParking_get`(vShelvingFk VARCHAR(10), vWarehouseFk INT, vDayRange INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `shelvingParking_get`(vShelvingFk VARCHAR(10), vWarehouseFk INT, vDayRange INT) BEGIN @@ -69061,7 +70000,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `shelvingPriority_update`(priority INT,vShelvingFk VARCHAR(10)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `shelvingPriority_update`(priority INT,vShelvingFk VARCHAR(10)) BEGIN UPDATE vn.shelving SET priority = priority WHERE code=vShelvingFk COLLATE utf8_unicode_ci; @@ -69082,7 +70021,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `shelving_clean`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `shelving_clean`() BEGIN DELETE FROM shelving @@ -69108,8 +70047,9 @@ UPDATE shelving sh AND ( sh.parked IS NULL OR - sh.parked < TIMESTAMPADD(MONTH,-1,util.VN_CURDATE()) - ) + sh.parked < util.VN_CURDATE() - INTERVAL 2 WEEK + ) + AND IF(code REGEXP '^[A-Za-z]{2}[0-9]', LEFT (code, 2) NOT IN ( SELECT DISTINCT LEFT(its.shelvingFk, 2) FROM itemShelving its @@ -69132,7 +70072,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `shelving_getSpam`(vDated DATE, vWarehouseFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `shelving_getSpam`(vDated DATE, vWarehouseFk INT) BEGIN /** * Devuelve las matrículas con productos que no son necesarios para la venta @@ -69229,22 +70169,25 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `shelving_setParking`(IN `vShelvingCode` VARCHAR(8), IN `vParkingFk` INT) -proc: BEGIN +CREATE DEFINER=`vn`@`localhost` PROCEDURE `shelving_setParking`( + `vShelvingCode` VARCHAR(8), + `vParkingFk` INT +) +BEGIN /** * Aparca una matrícula en un parking * * @param vShelvingCode code de la matrícula * @param vParkingFk id del parking */ - INSERT INTO vn.shelvingLog (originFk, userFk, action , description,changedModel,changedModelId) + INSERT INTO shelvingLog (originFk, userFk, action , description,changedModel,changedModelId) SELECT s.id, account.myUser_getId(), 'update', CONCAT("Cambio parking ",vShelvingCode," de ", p.code," a ", pNew.code),'Shelving',s.id FROM parking p JOIN shelving s ON s.parkingFk = p.id JOIN parking pNew ON pNew.id = vParkingFk WHERE s.code = vShelvingCode COLLATE utf8_unicode_ci; - UPDATE vn.shelving + UPDATE shelving SET parkingFk = vParkingFk, parked = util.VN_NOW(), isPrinted = TRUE @@ -69265,7 +70208,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `sleep_X_min`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `sleep_X_min`() BEGIN # Ernesto. 4.8.2020 # Para su uso en las tareas ejecutadas a las 2AM (visibles con: SELECT * FROM bs.nightTask order by started asc;) @@ -69278,16 +70221,91 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `stockBought_calculate` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `stockBought_calculate`( + vDated DATE +) +proc: BEGIN +/** + * Calculate the stock of the auction warehouse from the inventory date to vDated + * without taking into account the outputs of the same day vDated + * + * @param vDated Date to calculate the stock. + */ + IF vDated < util.VN_CURDATE() THEN + LEAVE proc; + END IF; + + CREATE OR REPLACE TEMPORARY TABLE tStockBought + SELECT workerFk, reserve + FROM stockBought + WHERE dated = vDated + AND reserve; + + DELETE FROM stockBought WHERE dated = vDated; + + CALL item_calculateStock(vDated); + + INSERT INTO stockBought(workerFk, bought, dated) + SELECT it.workerFk, + ROUND(SUM( + (ti.quantity / b.packing) * + buy_getVolume(b.id) + ) / vc.palletM3 / 1000000, 1) bought, + vDated + FROM itemType it + JOIN item i ON i.typeFk = it.id + LEFT JOIN tmp.item ti ON ti.itemFk = i.id + JOIN itemCategory ic ON ic.id = it.categoryFk + JOIN warehouse wh ON wh.code = 'VNH' + JOIN tmp.buyUltimate bu ON bu.itemFk = i.id + AND bu.warehouseFk = wh.id + JOIN buy b ON b.id = bu.buyFk + JOIN volumeConfig vc + WHERE ic.display + GROUP BY it.workerFk + HAVING bought; + + UPDATE stockBought s + JOIN tStockBought ts ON ts.workerFk = s.workerFk + SET s.reserve = ts.reserve + WHERE s.dated = vDated; + + INSERT INTO stockBought (workerFk, reserve, dated) + SELECT ts.workerFk, ts.reserve, vDated + FROM tStockBought ts + WHERE ts.workerFk NOT IN ( + SELECT workerFk + FROM stockBought + WHERE dated = vDated + ); + + DROP TEMPORARY TABLE tStockBought, tmp.item, tmp.buyUltimate; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `stockBuyedByWorker` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `stockBuyedByWorker`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `stockBuyedByWorker`( vDated DATE, vWorker INT ) @@ -69374,7 +70392,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `stockBuyed_add`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `stockBuyed_add`( vDated DATE ) BEGIN @@ -69418,7 +70436,7 @@ BEGIN INSERT INTO stockBuyed(buyed, dated, description) SELECT SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000), vDated, - IF(c.code = 'ES', p.name, c.country) destiny + IF(c.code = 'ES', p.name, c.name) destiny FROM itemTicketOut ito JOIN ticket t ON t.id = ito.ticketFk JOIN `address` a ON a.id = t.addressFk @@ -69457,7 +70475,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `stockTraslation`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `stockTraslation`( vDated DATE ) BEGIN @@ -69494,7 +70512,7 @@ BEGIN WHERE warehouse_id = vAuctionWarehouseFk ON DUPLICATE KEY UPDATE quantity = tmp.item.quantity + VALUES(quantity); - CALL buyUltimate(vAuctionWarehouseFk, vDated); + CALL buy_getUltimate(NULL, vAuctionWarehouseFk, vDated); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -69511,7 +70529,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `subordinateGetList`(vBossFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `subordinateGetList`(vBossFk INT) BEGIN -- deprecated usar vn.worker_GetHierarch @@ -69574,7 +70592,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `supplierExpenses`(vEnded DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `supplierExpenses`(vEnded DATE) BEGIN DROP TEMPORARY TABLE IF EXISTS openingBalance; @@ -69666,16 +70684,16 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `supplierPackaging_ReportSource`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `supplierPackaging_ReportSource`( vFromDated DATE, vSupplierFk INT ) BEGIN /** -* Selecciona los embalajes de un proveedor a partir de una fecha +* Create a report with packaging balance * -* @param vFromDated Fecha de la que partir -* @param vSupplierFk Id del proveedor +* @param vFromDated Starting date +* @param vSupplierFk Supplier ID */ SET @vBalance = 0; SET @vItemFk = NULL; @@ -69689,7 +70707,7 @@ BEGIN landed, `in`, `out`, - warehouse, + sref, buyingValue, IF ( NOT (@vItemFk <=> sub.itemFk), @@ -69698,34 +70716,119 @@ BEGIN ) balance, @vItemFk := sub.itemFk previousItemFk FROM ( - SELECT supplierFk, - itemFk, - longName, - supplier, - entryFk, - landed, - `in`, - `out`, - warehouse, - buyingValue - FROM supplierPackaging - WHERE supplierFk = vSupplierFk - AND landed >= vFromDated + SELECT sp.supplierFk, + sp.itemFk, + sp.longName, + sp.supplier, + CONCAT('E',sp.entryFk) entryFk, + sp.landed, + sp.`in`, + sp.`out`, + e.invoiceNumber sref, + sp.buyingValue + FROM supplierPackaging sp + JOIN entry e ON e.id = sp.entryFk + WHERE sp.supplierFk = vSupplierFk + AND sp.landed >= vFromDated UNION ALL SELECT vSupplierFk, itemFk, longName, supplier, - 'previous', + 'E previous', vFromDated, SUM(`in`), SUM(`out`), NULL, - buyingValue + AVG(buyingValue) FROM supplierPackaging WHERE supplierFk = vSupplierFk AND landed < vFromDated GROUP BY itemFk + UNION ALL + SELECT vSupplierFk, + s.itemFk, + i.longName, + c.name, + CONCAT('T',s.ticketFk), + DATE(t.shipped), + -LEAST(s.quantity,0) `in`, + GREATEST(s.quantity,0) `out`, + t.cmrFk, + s.price * (100 - s.discount) / 100 + FROM sale s + JOIN item i ON i.id = s.itemFk + JOIN packaging p ON p.itemFk = i.id + JOIN ticket t ON t.id = s.ticketFk + JOIN client c ON c.id = t.clientFk + JOIN supplier su ON su.nif = c.fi + WHERE su.id = vSupplierFk + AND t.shipped >= vFromDated + AND p.isPackageReturnable + UNION ALL + SELECT vSupplierFk, + s.itemFk, + i.longName, + c.name, + 'T previous', + vFromDated, + SUM(-LEAST(s.quantity,0)) `in`, + SUM(GREATEST(s.quantity,0)) `out`, + NULL, + AVG(s.price * (100 - s.discount) / 100) + FROM sale s + JOIN item i ON i.id = s.itemFk + JOIN packaging p ON p.itemFk = i.id + JOIN ticket t ON t.id = s.ticketFk + JOIN client c ON c.id = t.clientFk + JOIN supplier su ON su.nif = c.fi + WHERE su.id = vSupplierFk + AND t.shipped < vFromDated + AND p.isPackageReturnable + AND NOT t.isDeleted + GROUP BY s.itemFk + UNION ALL + SELECT vSupplierFk, + p.itemFk, + i.longName, + c.name, + CONCAT('TP',tp.ticketFk), + DATE(t.shipped), + -LEAST(tp.quantity,0) `in`, + GREATEST(tp.quantity,0) `out`, + t.cmrFk, + 0 + FROM ticketPackaging tp + JOIN packaging p ON p.id = tp.packagingFk + JOIN item i ON i.id = p.itemFk + JOIN ticket t ON t.id = tp.ticketFk + JOIN client c ON c.id = t.clientFk + JOIN supplier su ON su.nif = c.fi + WHERE su.id = vSupplierFk + AND t.shipped >= vFromDated + AND p.isPackageReturnable + UNION ALL + SELECT vSupplierFk, + p.itemFk, + i.longName, + c.name, + 'TP previous', + vFromDated, + SUM(-LEAST(tp.quantity,0)) `in`, + SUM(GREATEST(tp.quantity,0)) `out`, + NULL, + 0 + FROM ticketPackaging tp + JOIN packaging p ON p.id = tp.packagingFk + JOIN item i ON i.id = p.itemFk + JOIN ticket t ON t.id = tp.ticketFk + JOIN client c ON c.id = t.clientFk + JOIN supplier su ON su.nif = c.fi + WHERE su.id = vSupplierFk + AND t.shipped < vFromDated + AND p.isPackageReturnable + AND NOT t.isDeleted + GROUP BY p.itemFk ORDER BY itemFk, landed, entryFk ) sub WHERE `out` OR `in`; @@ -69736,9 +70839,9 @@ BEGIN supplier, entryFk, landed, - `in`, - `out`, - warehouse, + CAST(`in` AS DECIMAL(10,0)) `in`, + CAST(`out` AS DECIMAL(10,0)) `out`, + sref, buyingValue, balance FROM tSupplierPackaging @@ -69761,7 +70864,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `supplier_checkBalance`(IN vDateTo DATETIME, IN vIsConciliated BOOL) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `supplier_checkBalance`(IN vDateTo DATETIME, IN vIsConciliated BOOL) BEGIN /** * Compara los datos de nuestros proveedores con @@ -69848,7 +70951,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `supplier_checkIsActive`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `supplier_checkIsActive`(vSelf INT) BEGIN /** * Comprueba si un proveedor esta activo. @@ -69878,7 +70981,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `supplier_disablePayMethodChecked`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `supplier_disablePayMethodChecked`() BEGIN /* @@ -69908,7 +71011,7 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `supplier_statement` */; +/*!50003 DROP PROCEDURE IF EXISTS `supplier_statementWithEntries` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -69916,28 +71019,35 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `supplier_statement`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `supplier_statementWithEntries`( vSupplierFk INT, vCurrencyFk INT, vCompanyFk INT, vOrderBy VARCHAR(15), - vIsConciliated BOOL + vIsConciliated BOOL, + vHasEntries BOOL ) BEGIN /** - * Crea un estado de cuenta de proveedores calculando - * los saldos en euros y en la moneda especificada. - * - * @param vSupplierFk Id del proveedor - * @param vCurrencyFk Id de la moneda - * @param vCompanyFk Id de la empresa - * @param vOrderBy Criterio de ordenación - * @param vIsConciliated Indica si está conciliado o no - * @return tmp.supplierStatement - */ +* Creates a supplier statement, calculating balances in euros and the specified currency. +* +* @param vSupplierFk Supplier ID +* @param vCurrencyFk Currency ID +* @param vCompanyFk Company ID +* @param vOrderBy Order by criteria +* @param vIsConciliated Indicates whether it is reconciled or not +* @param vHasEntries Indicates if future entries must be shown +* @return tmp.supplierStatement +*/ + DECLARE vBalanceStartingDate DATETIME; + SET @euroBalance:= 0; SET @currencyBalance:= 0; + SELECT balanceStartingDate + INTO vBalanceStartingDate + FROM invoiceInConfig; + CREATE OR REPLACE TEMPORARY TABLE tmp.supplierStatement ENGINE = MEMORY SELECT *, @@ -69950,107 +71060,127 @@ BEGIN IFNULL(invoiceCurrency, 0), 2 ) currencyBalance FROM ( - SELECT * FROM - ( - SELECT NULL bankFk, - ii.companyFk, - ii.serial, - ii.id, - CASE - WHEN vOrderBy = 'issued' THEN ii.issued - WHEN vOrderBy = 'bookEntried' THEN ii.bookEntried - WHEN vOrderBy = 'booked' THEN ii.booked - WHEN vOrderBy = 'dueDate' THEN iid.dueDated - END dated, - CONCAT('S/Fra ', ii.supplierRef) sref, - IF(ii.currencyFk > 1, - ROUND(SUM(iid.foreignValue) / SUM(iid.amount), 3), - NULL - ) changeValue, - CAST(SUM(iid.amount) AS DECIMAL(10,2)) invoiceEuros, - CAST(SUM(iid.foreignValue) AS DECIMAL(10,2)) invoiceCurrency, - NULL paymentEuros, - NULL paymentCurrency, - ii.currencyFk, - ii.isBooked, - c.code, - 'invoiceIn' statementType - FROM invoiceIn ii - JOIN invoiceInDueDay iid ON iid.invoiceInFk = ii.id - JOIN currency c ON c.id = ii.currencyFk - WHERE ii.issued > '2014-12-31' - AND ii.supplierFk = vSupplierFk - AND vCurrencyFk IN (ii.currencyFk, 0) - AND vCompanyFk IN (ii.companyFk, 0) - AND (vIsConciliated = ii.isBooked OR NOT vIsConciliated) - GROUP BY iid.id - UNION ALL - SELECT p.bankFk, - p.companyFk, - NULL, - p.id, - CASE - WHEN vOrderBy = 'issued' THEN p.received - WHEN vOrderBy = 'bookEntried' THEN p.received - WHEN vOrderBy = 'booked' THEN p.received - WHEN vOrderBy = 'dueDate' THEN p.dueDated - END, - CONCAT(IFNULL(pm.name, ''), - IF(pn.concept <> '', - CONCAT(' : ', pn.concept), - '') - ), - IF(p.currencyFk > 1, p.divisa / p.amount, NULL), - NULL, - NULL, - p.amount, - p.divisa, - p.currencyFk, - p.isConciliated, - c.code, - 'payment' - FROM payment p - LEFT JOIN currency c ON c.id = p.currencyFk - LEFT JOIN accounting a ON a.id = p.bankFk - LEFT JOIN payMethod pm ON pm.id = p.payMethodFk - LEFT JOIN promissoryNote pn ON pn.paymentFk = p.id - WHERE p.received > '2014-12-31' - AND p.supplierFk = vSupplierFk - AND vCurrencyFk IN (p.currencyFk, 0) - AND vCompanyFk IN (p.companyFk, 0) - AND (vIsConciliated = p.isConciliated OR NOT vIsConciliated) - UNION ALL - SELECT NULL, - companyFk, - NULL, - se.id, - CASE - WHEN vOrderBy = 'issued' THEN se.dated - WHEN vOrderBy = 'bookEntried' THEN se.dated - WHEN vOrderBy = 'booked' THEN se.dated - WHEN vOrderBy = 'dueDate' THEN se.dueDated - END, - se.description, - 1, - amount, - NULL, - NULL, - NULL, - currencyFk, - isConciliated, - c.`code`, - 'expense' - FROM supplierExpense se - JOIN currency c ON c.id = se.currencyFk - WHERE se.supplierFk = vSupplierFk - AND vCurrencyFk IN (se.currencyFk,0) - AND vCompanyFk IN (se.companyFk,0) - AND (vIsConciliated = se.isConciliated OR NOT vIsConciliated) - ) sub - ORDER BY (dated IS NULL AND NOT isBooked), - dated, - IF(vOrderBy = 'dueDate', id, NULL) - LIMIT 10000000000000000000 + SELECT NULL bankFk, + ii.companyFk, + ii.serial, + ii.id, + CASE + WHEN vOrderBy = 'issued' THEN ii.issued + WHEN vOrderBy = 'bookEntried' THEN ii.bookEntried + WHEN vOrderBy = 'booked' THEN ii.booked + WHEN vOrderBy = 'dueDate' THEN iid.dueDated + END dated, + CONCAT('S/Fra ', ii.supplierRef) sref, + IF(ii.currencyFk > 1, + ROUND(SUM(iid.foreignValue) / SUM(iid.amount), 3), + NULL + ) changeValue, + CAST(SUM(iid.amount) AS DECIMAL(10,2)) invoiceEuros, + CAST(SUM(iid.foreignValue) AS DECIMAL(10,2)) invoiceCurrency, + NULL paymentEuros, + NULL paymentCurrency, + ii.currencyFk, + ii.isBooked, + c.code, + 'invoiceIn' statementType + FROM invoiceIn ii + LEFT JOIN invoiceInDueDay iid ON iid.invoiceInFk = ii.id + JOIN currency c ON c.id = ii.currencyFk + WHERE ii.issued >= vBalanceStartingDate + AND ii.supplierFk = vSupplierFk + AND vCurrencyFk IN (ii.currencyFk, 0) + AND vCompanyFk IN (ii.companyFk, 0) + AND (vIsConciliated = ii.isBooked OR NOT vIsConciliated) + GROUP BY iid.id, ii.id + UNION ALL + SELECT p.bankFk, + p.companyFk, + NULL, + p.id, + CASE + WHEN vOrderBy = 'issued' THEN p.received + WHEN vOrderBy = 'bookEntried' THEN p.received + WHEN vOrderBy = 'booked' THEN p.received + WHEN vOrderBy = 'dueDate' THEN p.dueDated + END, + CONCAT(IFNULL(pm.name, ''), + IF(pn.concept <> '', + CONCAT(' : ', pn.concept), + '') + ), + IF(p.currencyFk > 1, p.divisa / p.amount, NULL), + NULL, + NULL, + p.amount, + p.divisa, + p.currencyFk, + p.isConciliated, + c.code, + 'payment' + FROM payment p + LEFT JOIN currency c ON c.id = p.currencyFk + LEFT JOIN accounting a ON a.id = p.bankFk + LEFT JOIN payMethod pm ON pm.id = p.payMethodFk + LEFT JOIN promissoryNote pn ON pn.paymentFk = p.id + WHERE p.received >= vBalanceStartingDate + AND p.supplierFk = vSupplierFk + AND vCurrencyFk IN (p.currencyFk, 0) + AND vCompanyFk IN (p.companyFk, 0) + AND (vIsConciliated = p.isConciliated OR NOT vIsConciliated) + UNION ALL + SELECT NULL, + companyFk, + NULL, + se.id, + CASE + WHEN vOrderBy = 'issued' THEN se.dated + WHEN vOrderBy = 'bookEntried' THEN se.dated + WHEN vOrderBy = 'booked' THEN se.dated + WHEN vOrderBy = 'dueDate' THEN se.dueDated + END, + se.description, + 1, + amount, + NULL, + NULL, + NULL, + currencyFk, + isConciliated, + c.`code`, + 'expense' + FROM supplierExpense se + JOIN currency c ON c.id = se.currencyFk + WHERE se.supplierFk = vSupplierFk + AND vCurrencyFk IN (se.currencyFk,0) + AND vCompanyFk IN (se.companyFk,0) + AND (vIsConciliated = se.isConciliated OR NOT vIsConciliated) + UNION ALL + SELECT NULL bankFk, + e.companyFk, + 'E' serial, + e.invoiceNumber id, + tr.landed dated, + CONCAT('Ent. ',e.id) sref, + 1 / ((e.commission/100)+1) changeValue, + e.invoiceAmount * (1 + (e.commission/100)), + e.invoiceAmount, + NULL, + NULL, + e.currencyFk, + FALSE isBooked, + c.code, + 'order' + FROM entry e + JOIN travel tr ON tr.id = e.travelFk + JOIN currency c ON c.id = e.currencyFk + WHERE e.supplierFk = vSupplierFk + AND tr.landed >= CURDATE() + AND e.invoiceInFk IS NULL + AND vHasEntries + ORDER BY (dated IS NULL AND NOT isBooked), + dated, + IF(vOrderBy = 'dueDate', id, NULL) + LIMIT 10000000000000000000 ) t; END ;; DELIMITER ; @@ -70059,16 +71189,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketBoxesView` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketBoxesView`(IN vTicketFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketBoxesView`(IN vTicketFk INT) BEGIN SELECT s.id, @@ -70106,7 +71236,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketBuiltTime`(vDate DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketBuiltTime`(vDate DATE) BEGIN DECLARE vDateStart DATETIME DEFAULT DATE(vDate); @@ -70157,7 +71287,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculateClon`(IN vTicketNew INT, vTicketOld INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketCalculateClon`(IN vTicketNew INT, vTicketOld INT) BEGIN /* * Recalcula los componentes un ticket clonado, @@ -70207,7 +71337,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculateFromType`( vLanded DATE, +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketCalculateFromType`( vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vTypeFk INT) @@ -70238,7 +71368,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCalculatePurge`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketCalculatePurge`() BEGIN DROP TEMPORARY TABLE tmp.ticketCalculateItem, @@ -70262,7 +71392,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketClon`(vTicketFk INT, vNewShipped DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketClon`(vTicketFk INT, vNewShipped DATE) BEGIN DECLARE vNewTicketFk INT; @@ -70285,7 +71415,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketClon_OneYear`(vTicketFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketClon_OneYear`(vTicketFk INT) BEGIN DECLARE vShipped DATE; @@ -70320,7 +71450,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCollection_get`(vTicketFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketCollection_get`(vTicketFk INT) BEGIN SELECT tc.collectionFk @@ -70343,7 +71473,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketCollection_setUsedShelves`(vTicketFk INT, vUsedShelves INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketCollection_setUsedShelves`(vTicketFk INT, vUsedShelves INT) BEGIN /* @@ -70364,16 +71494,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketComponentUpdate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketComponentUpdate`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketComponentUpdate`( vTicketFk INT, vClientFk INT, vAgencyModeFk INT, @@ -70439,16 +71569,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketComponentUpdateSale` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketComponentUpdateSale`(vCode VARCHAR(25)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketComponentUpdateSale`(vCode VARCHAR(25)) BEGIN /** * A partir de la tabla tmp.sale, crea los Movimientos_componentes @@ -70572,7 +71702,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketDown_PrintableSelection`(vSectorFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketDown_PrintableSelection`(vSectorFk INT) BEGIN UPDATE vn.ticketDown td @@ -70607,7 +71737,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetTaxAdd`(vTicketFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketGetTaxAdd`(vTicketFk INT) BEGIN /** * Añade un ticket a la tabla tmp.ticket para calcular @@ -70651,7 +71781,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetTax_new`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketGetTax_new`() READS SQL DATA BEGIN /** @@ -70730,7 +71860,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetTotal`(vTaxArea VARCHAR(25)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketGetTotal`(vTaxArea VARCHAR(25)) BEGIN /** * Calcula el total con IVA para un conjunto de tickets. @@ -70770,7 +71900,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketGetVisibleAvailable`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketGetVisibleAvailable`( vTicket INT) BEGIN DECLARE vVisibleCalc INT; @@ -70778,13 +71908,16 @@ BEGIN DECLARE vShipped DATE; DECLARE vWarehouse TINYINT; DECLARE vAlertLevel INT; + DECLARE vAlertLevelFree INT; - SELECT t.warehouseFk, t.shipped, ts.alertLevel INTO vWarehouse, vShipped, vAlertLevel + SELECT t.warehouseFk, t.shipped, ts.alertLevel, al.id + INTO vWarehouse, vShipped, vAlertLevel, vAlertLevelFree FROM ticket t + JOIN alertLevel al ON al.code = 'FREE' LEFT JOIN ticketState ts ON ts.ticketFk = vTicket WHERE t.id = vTicket; - IF vAlertLevel IS NULL OR vAlertLevel = 0 THEN + IF vAlertLevel IS NULL OR vAlertLevel = vAlertLevelFree THEN IF vShipped >= util.VN_CURDATE() THEN CALL cache.available_refresh(vAvailableCalc, FALSE, vWarehouse, vShipped); END IF; @@ -70808,68 +71941,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketMissed_List` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketMissed_List`(vTicketFk INT) -BEGIN - - DECLARE vParkingFk INT; - DECLARE vParked DATETIME; - DECLARE vLevel INT; - DECLARE vCollectionFk INT; - - SELECT IFNULL(`level`,0), IFNULL(collectionFk,0) - INTO vLevel, vCollectionFk - FROM vn.ticketCollection - WHERE ticketFk = vTicketFk - LIMIT 1; - - SELECT created, parkingFk - INTO vParked, vParkingFk - FROM vn.ticketParking - WHERE ticketFk = vTicketFk; - - SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia - FROM vn.ticketParking tp - JOIN vn.parking p ON p.id = tp.parkingFk - JOIN vn.sector sc ON sc.id = p.sectorFk - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk - JOIN vn.ticketStateToday tst ON tst.ticketFk = tp.ticketFk - JOIN vn.ticket t ON t.id = tp.ticketFk - JOIN vn.zone z ON z.id = t.zoneFk - JOIN vn.agencyMode am ON am.id = z.agencyModeFk - JOIN vn.state s ON s.id = tst.state - WHERE (s.alertLevel < 2 - AND tp.parkingFk = vParkingFk - AND sc.isPackagingArea - AND ( - ( - ( IFNULL(tc.collectionFk,-1) != IFNULL(@vCollectionFk,0) AND tp.created < vParked ) - OR - ( tc.collectionFk = vCollectionFk AND LEFT(tc.level,1) < LEFT(vLevel,1) ) - ) - )) -- Etiquetas que no se han escaneado y ya estamos con una posterior - OR - (s.alertLevel > 1 - AND tp.parkingFk = vParkingFk - AND sc.isPackagingArea - AND tp.created < vParked - AND t.packages <=> 0); - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketNotInvoicedByClient` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -70878,7 +71949,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketNotInvoicedByClient`(vClientFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketNotInvoicedByClient`(vClientFk INT) BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket; @@ -70921,7 +71992,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketObservation_addNewBorn`(vTicketFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketObservation_addNewBorn`(vTicketFk INT) BEGIN /** @@ -70945,16 +72016,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketPackaging_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketPackaging_add`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketPackaging_add`( vClientFk INT, vDated DATE, vCompanyFk INT, @@ -70982,7 +72053,10 @@ BEGIN SELECT DISTINCT clientFk FROM ( SELECT clientFk, SUM(quantity) totalQuantity - FROM tmp.packagingToInvoice + FROM tmp.packagingToInvoice tpi + JOIN client c ON c.id = tpi.clientFk + LEFT JOIN supplier s ON s.nif = c.fi + WHERE s.id IS NULL GROUP BY itemFk, clientFk HAVING totalQuantity > 0)sub; @@ -71105,66 +72179,68 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketParking_findSkipped`(vTicketFk INT, vItemPackingTypeFk VARCHAR(1)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketParking_findSkipped`(vTicketFk INT, vItemPackingTypeFk VARCHAR(1)) BEGIN - + /** * Averigua los tickets que se han saltado por un error en el proceso encajado * @param vTicketFk Ticket * @param vItemPackingTypeFk Modo de encajado * @return un select con los tickets afectados - */ + */ DECLARE vParkingFk INT; DECLARE vParked DATETIME; DECLARE vLevel INT; DECLARE vWagon INT; DECLARE vCollectionFk INT; - - SELECT IFNULL(`level`,0), IFNULL(`wagon`,0),IFNULL(collectionFk,0) + + SELECT IFNULL(`level`,0), IFNULL(`wagon`,0),IFNULL(collectionFk,0) INTO vLevel, vWagon, vCollectionFk FROM vn.ticketCollection tc JOIN vn.collection c ON c.id = tc.collectionFk AND c.itemPackingTypeFk = vItemPackingTypeFk WHERE ticketFk = vTicketFk ORDER BY c.id DESC LIMIT 1; - - SELECT created, parkingFk + + SELECT created, parkingFk INTO vParked, vParkingFk FROM vn.ticketParking tp - JOIN vn.parking p ON p.id = tp.parkingFk - JOIN vn.sector s ON s.id = p.sectorFk + JOIN vn.parking p ON p.id = tp.parkingFk + JOIN vn.sector s ON s.id = p.sectorFk WHERE ticketFk = vTicketFk AND s.itemPackingTypeFk = vItemPackingTypeFk AND s.isPackagingArea ; - + SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' ', tc.wagon, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia FROM vn.ticketParking tp - JOIN vn.parking p ON p.id = tp.parkingFk - JOIN vn.sector sc ON sc.id = p.sectorFk - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk - JOIN vn.ticketStateToday tst ON tst.ticketFk = tp.ticketFk - JOIN vn.ticket t ON t.id = tp.ticketFk - JOIN vn.zone z ON z.id = t.zoneFk - JOIN vn.agencyMode am ON am.id = z.agencyModeFk - JOIN vn.state s ON s.id = tst.state - WHERE (s.alertLevel < 2 + JOIN vn.parking p ON p.id = tp.parkingFk + JOIN vn.sector sc ON sc.id = p.sectorFk + LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk + JOIN vn.ticketStateToday tst ON tst.ticketFk = tp.ticketFk + JOIN vn.ticket t ON t.id = tp.ticketFk + JOIN vn.zone z ON z.id = t.zoneFk + JOIN vn.agencyMode am ON am.id = z.agencyModeFk + JOIN vn.state s ON s.id = tst.state + JOIN vn.alertLevel alPacked ON alPacked.code = 'PACKED' + JOIN vn.alertLevel alOnPreparation ON alOnPreparation.code = 'ON_PREPARATION' + WHERE (s.alertLevel < alPacked.id AND tp.parkingFk = vParkingFk AND sc.isPackagingArea AND ( ( IFNULL(tc.collectionFk,-1) != IFNULL(@vCollectionFk,0) AND tp.created < vParked ) OR - ( tc.collectionFk = vCollectionFk + ( tc.collectionFk = vCollectionFk AND (LEFT(tc.wagon,1) < LEFT(vWagon,1) - OR (LEFT(tc.wagon,1) = LEFT(vWagon,1) AND LEFT(tc.level,1) < LEFT(vLevel,1))) + OR (LEFT(tc.wagon,1) = LEFT(vWagon,1) AND LEFT(tc.level,1) < LEFT(vLevel,1))) ) ) ) -- Etiquetas que no se han escaneado y ya estamos con una posterior OR - (s.alertLevel > 1 + (s.alertLevel > alOnPreparation.id AND tp.parkingFk = vParkingFk AND sc.isPackagingArea - AND tp.created < vParked + AND tp.created < vParked AND t.packages <=> 0); END ;; DELIMITER ; @@ -71174,37 +72250,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketRefund_beforeUpsert` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketRefund_beforeUpsert`(vRefundTicketFk INT, vOriginalTicketFk INT) -BEGIN - DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE; - - IF vRefundTicketFk = vOriginalTicketFk THEN - CALL util.throw('Original ticket and refund ticket has same id'); - END IF; - - SELECT COUNT(*) INTO vAlreadyExists - FROM ticketRefund - WHERE refundTicketFk = vOriginalTicketFk; - - IF vAlreadyExists > 0 THEN - CALL util.throw('This ticket is already a refund'); - END IF; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketStateToday_setState` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71213,66 +72258,30 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketStateToday_setState`(vTicketFk INT, vStateCode VARCHAR(45)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketStateToday_setState`(vTicketFk INT, vStateCode VARCHAR(45)) BEGIN - + /* Modifica el estado de un ticket de hoy - * + * * @param vTicketFk el id del ticket * @param vStateCode estado a modificar del ticket - * + * */ - + DECLARE vAlertLevel INT; - - SELECT s.alertLevel INTO vAlertLevel - FROM state s - JOIN ticketStateToday tst ON tst.state = s.id + DECLARE vAlertLevelPacked INT; + + SELECT s.alertLevel, al.id + INTO vAlertLevel, vAlertLevelPacked + FROM state s + JOIN ticketStateToday tst ON tst.state = s.id + JOIN alertLevel al ON al.code = 'PACKED' WHERE tst.ticketFk = vTicketFk LIMIT 1; - - IF vAlertLevel < 2 THEN - + + IF vAlertLevel < vAlertLevelPacked THEN + CALL vn.ticket_setState(vTicketFk, vStateCode); - - END IF; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketStateUpdate` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketStateUpdate`(vTicketFk INT, vStateCode VARCHAR(45)) -BEGIN - - /* - * @deprecated:utilizar ticket_setState - */ - - DECLARE vAlertLevel INT; - - SELECT s.alertLevel INTO vAlertLevel - FROM vn.state s - JOIN vn.ticketState ts ON ts.stateFk = s.id - WHERE ts.ticketFk = vTicketFk; - - IF !(vStateCode = 'ON_CHECKING' AND vAlertLevel > 1) THEN - - INSERT INTO ticketTracking(stateFk, ticketFk, userFk) - SELECT id, vTicketFk, account.myUser_getId() - FROM vn.state - WHERE `code` = vStateCode collate utf8_unicode_ci; END IF; @@ -71292,7 +72301,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketToInvoiceByAddress`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketToInvoiceByAddress`( vStarted DATE, vEnded DATETIME, vAddress INT, @@ -71328,7 +72337,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketToInvoiceByDate`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketToInvoiceByDate`( vStarted DATE, vEnded DATETIME, vClient INT, @@ -71364,7 +72373,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketToInvoiceByRef`(IN vInvoiceRef VARCHAR(15)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticketToInvoiceByRef`(IN vInvoiceRef VARCHAR(15)) BEGIN /* Para tickets ya facturados, vuelve a repetir el proceso de facturación. @@ -71415,16 +72424,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_add`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_add`( vClientId INT ,vShipped DATE ,vWarehouseFk INT @@ -71490,6 +72499,8 @@ BEGIN IF (vZoneFk IS NULL OR vZoneFk = 0) AND vIsRequiredZone THEN CALL util.throw ('NOT_ZONE_WITH_THIS_PARAMETERS'); END IF; + + DROP TEMPORARY TABLE tmp.zoneGetShipped; END IF; INSERT INTO ticket ( @@ -71560,7 +72571,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_administrativeCopy`(vOriginalTicket INT, OUT vNewTicket INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_administrativeCopy`(vOriginalTicket INT, OUT vNewTicket INT) BEGIN INSERT INTO vn.ticket(clientFk, addressFk, shipped, warehouseFk, companyFk, landed) @@ -71592,7 +72603,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) BEGIN /** * Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar. @@ -71612,8 +72623,7 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) - SELECT - origin.ticketFk futureId, + SELECT origin.ticketFk futureId, dest.ticketFk id, dest.state, origin.futureState, @@ -71644,48 +72654,48 @@ BEGIN origin.warehouseFk futureWarehouseFk, origin.companyFk futureCompanyFk, IFNULL(dest.nickname, origin.nickname) nickname, - dest.landed + dest.landed, + dest.preparation FROM ( - SELECT - s.ticketFk, - c.salesPersonFk workerFk, - t.shipped, - t.totalWithVat, - st.name futureState, - am.name futureAgency, - count(s.id) futureLines, - GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, - CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, - SUM(s.quantity <= (IFNULL(il.stock,0) + IFNULL(im.amount, 0))) hasStock, - z.id futureZoneFk, - z.name futureZoneName, - st.classColor, - t.clientFk, - t.nickname, - t.addressFk, - t.warehouseFk, - t.companyFk, - t.agencyModeFk - FROM ticket t - JOIN client c ON c.id = t.clientFk - JOIN sale s ON s.ticketFk = t.id - JOIN saleVolume sv ON sv.saleFk = s.id - JOIN item i ON i.id = s.itemFk - JOIN ticketState ts ON ts.ticketFk = t.id - JOIN state st ON st.id = ts.stateFk - JOIN agencyMode am ON t.agencyModeFk = am.id - JOIN zone z ON t.zoneFk = z.id - LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk - LEFT JOIN tmp.itemMinacum im ON im.itemFk = i.id - AND im.warehouseFk = vWarehouseFk - LEFT JOIN tmp.itemList il ON il.itemFk = i.id - WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) - AND t.warehouseFk = vWarehouseFk - GROUP BY t.id + SELECT s.ticketFk, + c.salesPersonFk workerFk, + t.shipped, + t.totalWithVat, + st.name futureState, + am.name futureAgency, + count(s.id) futureLines, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, + CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, + SUM(s.quantity <= (IFNULL(il.stock,0) + IFNULL(im.amount, 0))) hasStock, + z.id futureZoneFk, + z.name futureZoneName, + st.classColor, + t.clientFk, + t.nickname, + t.addressFk, + t.warehouseFk, + t.companyFk, + t.agencyModeFk + FROM ticket t + JOIN client c ON c.id = t.clientFk + JOIN sale s ON s.ticketFk = t.id + JOIN saleVolume sv ON sv.saleFk = s.id + JOIN item i ON i.id = s.itemFk + JOIN ticketState ts ON ts.ticketFk = t.id + JOIN `state` st ON st.id = ts.stateFk + JOIN agencyMode am ON t.agencyModeFk = am.id + JOIN `zone` z ON t.zoneFk = z.id + LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk + LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN tmp.itemMinacum im ON im.itemFk = i.id + AND im.warehouseFk = vWarehouseFk + LEFT JOIN tmp.itemList il ON il.itemFk = i.id + WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) + AND t.warehouseFk = vWarehouseFk + GROUP BY t.id ) origin LEFT JOIN ( - SELECT - t.id ticketFk, + SELECT t.id ticketFk, st.name state, GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, t.shipped, @@ -71701,18 +72711,25 @@ BEGIN t.warehouseFk, t.companyFk, t.landed, - t.agencyModeFk + t.agencyModeFk, + SEC_TO_TIME( + COALESCE(HOUR(t.shipped), HOUR(zc.hour), HOUR(z.hour)) * 3600 + + COALESCE(MINUTE(t.shipped), MINUTE(zc.hour), MINUTE(z.hour)) * 60 + ) preparation FROM ticket t JOIN sale s ON s.ticketFk = t.id JOIN saleVolume sv ON sv.saleFk = s.id JOIN item i ON i.id = s.itemFk JOIN ticketState ts ON ts.ticketFk = t.id - JOIN state st ON st.id = ts.stateFk + JOIN `state` st ON st.id = ts.stateFk JOIN agencyMode am ON t.agencyModeFk = am.id LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN `zone` z ON z.id = t.zoneFk + LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk + JOIN ticketCanAdvanceConfig tc WHERE t.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) AND t.warehouseFk = vWarehouseFk - AND st.order <= 5 + AND st.order <= tc.destinationOrder GROUP BY t.id ) dest ON dest.addressFk = origin.addressFk WHERE origin.hasStock; @@ -71736,7 +72753,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_canbePostponed`(vOriginDated DATE, vFutureDated DATE, vWarehouseFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_canbePostponed`(vOriginDated DATE, vFutureDated DATE, vWarehouseFk INT) BEGIN /** * Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro @@ -71758,6 +72775,7 @@ BEGIN t.clientFk, t.warehouseFk, ts.alertLevel, + sub2.alertLevel futureAlertLevel, t.shipped, t.totalWithVat, sub2.shipped futureShipped, @@ -71784,6 +72802,7 @@ BEGIN t.addressFk, t.id, t.shipped, + ts.alertLevel, st.name state, st.code, st.classColor, @@ -71813,16 +72832,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_canMerge` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_canMerge`(vDated DATE, vScopeDays INT, vLitersMax INT, vLinesMax INT, vWarehouseFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_canMerge`(vDated DATE, vScopeDays INT, vLitersMax INT, vLinesMax INT, vWarehouseFk INT) BEGIN /** * Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro @@ -71891,16 +72910,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_checkNoComponents` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_checkNoComponents`(vShippedFrom DATETIME, vShippedTo DATETIME) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_checkNoComponents`(vShippedFrom DATETIME, vShippedTo DATETIME) BEGIN /** @@ -71921,7 +72940,8 @@ BEGIN JOIN itemCategory ic ON ic.id = tp.categoryFk JOIN saleComponent sc ON sc.saleFk = s.id JOIN component c ON c.id = sc.componentFk - JOIN componentType ct ON ct.id = c.typeFk AND ct.id = 1 + JOIN componentType ct ON ct.id = c.typeFk + AND ct.code = 'cost' WHERE t.shipped BETWEEN vShippedFrom AND vShippedTo AND ic.merchandise; @@ -71949,16 +72969,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_Clone` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_Clone`(vOriginalTicket INT, OUT vNewTicket INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_Clone`(vOriginalTicket INT, OUT vNewTicket INT) BEGIN /** * Clona el contenido de un ticket en otro @@ -71968,6 +72988,11 @@ BEGIN */ DECLARE vStateFk INT; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + RESIGNAL; + END; + INSERT INTO ticket ( clientFk, shipped, @@ -72032,7 +73057,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_cloneAll`(vTicketFk INT, vNewShipped DATE, vWithWarehouse BOOLEAN, OUT vNewTicketFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_cloneAll`(vTicketFk INT, vNewShipped DATE, vWithWarehouse BOOLEAN, OUT vNewTicketFk INT) BEGIN DECLARE vDone BOOLEAN DEFAULT FALSE; @@ -72100,9 +73125,11 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_cloneWeekly`(vDateFrom DATE, vDateTo DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_cloneWeekly`( + vDateFrom DATE, + vDateTo DATE +) BEGIN - DECLARE vIsDone BOOL; DECLARE vLanding DATE; DECLARE vShipment DATE; DECLARE vWarehouseFk INT; @@ -72113,42 +73140,50 @@ BEGIN DECLARE vAgencyModeFk INT; DECLARE vNewTicket INT; DECLARE vYear INT; - DECLARE vSalesPersonFK INT; - DECLARE vItemPicker INT; + DECLARE vObservationSalesPersonFk INT + DEFAULT (SELECT id FROM observationType WHERE code = 'salesPerson'); + DECLARE vObservationItemPickerFk INT + DEFAULT (SELECT id FROM observationType WHERE code = 'itemPicker'); + DECLARE vEmail VARCHAR(255); + DECLARE vIsDuplicateMail BOOL; + DECLARE vSubject VARCHAR(100); + DECLARE vMessage TEXT; + DECLARE vDone BOOL; - DECLARE rsTicket CURSOR FOR - SELECT tt.ticketFk, - t.clientFk, - t.warehouseFk, - t.companyFk, - t.addressFk, - tt.agencyModeFk, - ti.dated - FROM ticketWeekly tt - JOIN ticket t ON tt.ticketFk = t.id - JOIN tmp.time ti - WHERE WEEKDAY(ti.dated) = tt.weekDay; + DECLARE vTickets CURSOR FOR + SELECT tt.ticketFk, + t.clientFk, + t.warehouseFk, + t.companyFk, + t.addressFk, + tt.agencyModeFk, + ti.dated + FROM ticketWeekly tt + JOIN ticket t ON tt.ticketFk = t.id + JOIN tmp.time ti + WHERE WEEKDAY(ti.dated) = tt.weekDay; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE; - - CALL `util`.`time_generate`(vDateFrom,vDateTo); - - OPEN rsTicket; - myLoop: LOOP - BEGIN - DECLARE vSalesPersonEmail VARCHAR(150); - DECLARE vIsDuplicateMail BOOL; - DECLARE vSubject VARCHAR(150); - DECLARE vMessage TEXT; - - SET vIsDone = FALSE; - FETCH rsTicket INTO vTicketFk,vClientFk, vWarehouseFk, vCompanyFk, vAddressFk, vAgencyModeFk,vShipment; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - IF vIsDone THEN - LEAVE myLoop; + CALL `util`.`time_generate`(vDateFrom, vDateTo); + + OPEN vTickets; + l: LOOP + SET vDone = FALSE; + FETCH vTickets INTO + vTicketFk, + vClientFk, + vWarehouseFk, + vCompanyFk, + vAddressFk, + vAgencyModeFk, + vShipment; + + IF vDone THEN + LEAVE l; END IF; - -- busca si el ticket ya ha sido clonado + -- Busca si el ticket ya ha sido clonado IF EXISTS (SELECT TRUE FROM ticket tOrig JOIN sale saleOrig ON tOrig.id = saleOrig.ticketFk JOIN saleCloned sc ON sc.saleOriginalFk = saleOrig.id @@ -72158,7 +73193,7 @@ BEGIN AND tClon.isDeleted = FALSE AND DATE(tClon.shipped) = vShipment) THEN - ITERATE myLoop; + ITERATE l; END IF; IF vAgencyModeFk IS NULL THEN @@ -72168,7 +73203,7 @@ BEGIN AND isDefaultAddress; END IF; - CALL zone_getLanded(vShipment, vAddressFk, vAgencyModeFk, vWarehouseFk,FALSE); + CALL zone_getLanded(vShipment, vAddressFk, vAgencyModeFk, vWarehouseFk, FALSE); SET vLanding = NULL; SELECT landed INTO vLanding FROM tmp.zoneGetLanded LIMIT 1; @@ -72189,18 +73224,24 @@ BEGIN SET clonedFrom = vTicketFk WHERE id = vNewTicket; - INSERT INTO sale (ticketFk, itemFk, concept, quantity, price, - discount, priceFixed, isPriceFixed) + INSERT INTO sale (ticketFk, + itemFk, + concept, + quantity, + price, + discount, + priceFixed, + isPriceFixed) SELECT vNewTicket, - saleOrig.itemFk, - saleOrig.concept, - saleOrig.quantity, - saleOrig.price, - saleOrig.discount, - saleOrig.priceFixed, - saleOrig.isPriceFixed - FROM sale saleOrig - WHERE saleOrig.ticketFk = vTicketFk; + itemFk, + concept, + quantity, + price, + discount, + priceFixed, + isPriceFixed + FROM sale + WHERE ticketFk = vTicketFk; INSERT IGNORE INTO saleCloned(saleOriginalFk, saleClonedFk) SELECT saleOriginal.id, saleClon.id @@ -72224,28 +73265,20 @@ BEGIN ,attenderFk, ticketFk) SELECT description, - ordered, - shipped, - quantity, - price, - itemFk, - clientFk, - response, - total, - buyed, - requesterFk, - attenderFk, - vNewTicket + ordered, + shipped, + quantity, + price, + itemFk, + clientFk, + response, + total, + buyed, + requesterFk, + attenderFk, + vNewTicket FROM ticketRequest - WHERE ticketFk =vTicketFk; - - SELECT id INTO vSalesPersonFK - FROM observationType - WHERE code = 'salesPerson'; - - SELECT id INTO vItemPicker - FROM observationType - WHERE code = 'itemPicker'; + WHERE ticketFk = vTicketFk; INSERT INTO ticketObservation( ticketFk, @@ -72253,7 +73286,7 @@ BEGIN description) VALUES( vNewTicket, - vSalesPersonFK, + vObservationSalesPersonFk, CONCAT('turno desde ticket: ',vTicketFk)) ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' '); @@ -72263,16 +73296,17 @@ BEGIN description) VALUES( vNewTicket, - vItemPicker, + vObservationItemPickerFk, 'ATENCION: Contiene lineas de TURNO') ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' '); - IF (vLanding IS NULL) THEN - - SELECT e.email INTO vSalesPersonEmail + IF vLanding IS NULL THEN + SELECT IFNULL(d.notificationEmail, e.email) INTO vEmail FROM client c JOIN account.emailUser e ON e.userFk = c.salesPersonFk + LEFT JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk + LEFT JOIN department d ON d.id = wd.departmentFk WHERE c.id = vClientFk; SET vSubject = CONCAT('Turnos - No se ha podido clonar correctamente el ticket ', @@ -72284,21 +73318,22 @@ BEGIN SELECT COUNT(*) INTO vIsDuplicateMail FROM mail - WHERE receiver = vSalesPersonEmail + WHERE receiver = vEmail AND subject = vSubject; IF NOT vIsDuplicateMail THEN - CALL mail_insert(vSalesPersonEmail, NULL, vSubject, vMessage); + CALL mail_insert(vEmail, NULL, vSubject, vMessage); END IF; - CALL ticketStateUpdate (vNewTicket, 'FIXING'); + CALL ticket_setState(vNewTicket, 'FIXING'); ELSE CALL ticketCalculateClon(vNewTicket, vTicketFk); END IF; - - END; END LOOP; - CLOSE rsTicket; - DROP TEMPORARY TABLE IF EXISTS tmp.time; + CLOSE vTickets; + + DROP TEMPORARY TABLE IF EXISTS + tmp.time, + tmp.zoneGetLanded; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -72315,10 +73350,10 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_close`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_close`() BEGIN /** - * Realiza el cierre de todos los + * Realiza el cierre de todos los * tickets de la tabla tmp.ticket_close. * * @table tmp.ticket_close(ticketFk) Identificadores de los tickets a cerrar @@ -72333,10 +73368,11 @@ BEGIN DECLARE vHasDailyInvoice BOOL; DECLARE vWithPackage BOOL; DECLARE vHasToInvoice BOOL; + DECLARE vSerial VARCHAR(2); DECLARE cur CURSOR FOR SELECT ticketFk FROM tmp.ticket_close; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN RESIGNAL; @@ -72346,7 +73382,7 @@ BEGIN proc: LOOP SET vDone = FALSE; - + FETCH cur INTO vCurTicketFk; IF vDone THEN @@ -72360,15 +73396,15 @@ BEGIN t.shipped, IFNULL(a.hasDailyInvoice, co.hasDailyInvoice), w.isManaged, - c.hasToInvoice + c.hasToInvoice INTO vClientFk, vIsTaxDataChecked, - vCompanyFk, + vCompanyFk, vShipped, vHasDailyInvoice, vWithPackage, - vHasToInvoice - FROM ticket t + vHasToInvoice + FROM ticket t JOIN `client` c ON c.id = t.clientFk JOIN province p ON p.id = c.provinceFk LEFT JOIN autonomy a ON a.id = p.autonomyFk @@ -72378,33 +73414,40 @@ BEGIN INSERT INTO ticketPackaging (ticketFk, packagingFk, quantity) (SELECT vCurTicketFk, p.id, COUNT(*) - FROM expedition e + FROM expedition e JOIN packaging p ON p.id = e.packagingFk + JOIN ticket t ON t.id = e.ticketFk + LEFT JOIN agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk WHERE e.ticketFk = vCurTicketFk AND p.isPackageReturnable AND vWithPackage + AND NOT dm.`code`= 'PICKUP' GROUP BY p.itemFk); -- No retornables o no catalogados - INSERT INTO sale (itemFk, ticketFk, concept, quantity, price, isPriceFixed) + INSERT INTO sale (itemFk, ticketFk, concept, quantity, price, isPriceFixed) (SELECT e.freightItemFk, vCurTicketFk, i.name, COUNT(*) AS amount, getSpecialPrice(e.freightItemFk, vClientFk), 1 - FROM expedition e + FROM expedition e JOIN item i ON i.id = e.freightItemFk LEFT JOIN packaging p ON p.itemFk = i.id WHERE e.ticketFk = vCurTicketFk AND IFNULL(p.isPackageReturnable, 0) = 0 AND getSpecialPrice(e.freightItemFk, vClientFk) > 0 GROUP BY e.freightItemFk); - - IF(vHasDailyInvoice) AND vHasToInvoice THEN - -- Facturacion rapida + IF(vHasDailyInvoice) AND vHasToInvoice THEN + SELECT invoiceSerial(vClientFk, vCompanyFk, 'quick') INTO vSerial; + IF vSerial IS NULL THEN + CALL util.throw('Cannot booking without a serial'); + END IF; + CALL ticket_setState(vCurTicketFk, 'DELIVERED'); - -- Facturar si está contabilizado + IF vIsTaxDataChecked THEN CALL invoiceOut_newFromClient( - vClientFk, - (SELECT invoiceSerial(vClientFk, vCompanyFk, 'M')), - vShipped, - vCompanyFk, + vClientFk, + vSerial, + vShipped, + vCompanyFk, NULL, NULL, vNewInvoiceId); @@ -72431,7 +73474,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_closeByTicket`(IN vTicketFk int) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_closeByTicket`(IN vTicketFk int) BEGIN /** * Inserta el ticket en la tabla temporal @@ -72463,16 +73506,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_componentMakeUpdate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_componentMakeUpdate`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_componentMakeUpdate`( vTicketFk INT, vClientFk INT, vNickname VARCHAR(50), @@ -72582,7 +73625,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_componentPreview`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_componentPreview`( vTicketFk INT, vLanded DATE, vAddressFk INT, @@ -72639,13 +73682,12 @@ BEGIN FROM zone WHERE id = vZoneFk; - CALL buyUltimate(vWarehouseFk, vShipped); + CALL buy_getUltimate(NULL, vWarehouseFk, vShipped); DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY ( - SELECT - vWarehouseFk AS warehouseFk, - NULL AS available, + SELECT vWarehouseFk warehouseFk, + NULL available, s.itemFk, bu.buyFk, vZoneFk zoneFk @@ -72696,24 +73738,25 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_DelayTruck`(vWarehouserFk INT, vHour INT, vMinute INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_DelayTruck`(vWarehouserFk INT, vHour INT, vMinute INT) BEGIN DECLARE done INT DEFAULT FALSE; DECLARE vTicketFk INT; - DECLARE cur1 CURSOR FOR SELECT ticketFk FROM tmp.ticket; + DECLARE cur1 CURSOR FOR SELECT ticketFk FROM tTicket; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; CALL vn.productionControl(vWarehouserFk,0) ; - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - CREATE TEMPORARY TABLE tmp.ticket + DROP TEMPORARY TABLE IF EXISTS tTicket; + CREATE TEMPORARY TABLE tTicket SELECT ticketFk FROM tmp.productionBuffer + JOIN alertLevel al ON al.code = 'FREE' WHERE shipped = util.VN_CURDATE() AND problem LIKE '%I:%' AND (HH <= vHour OR HH = vHour AND mm < vMinute) - AND alertLevel = 0; + AND alertLevel = al.id; OPEN cur1; @@ -72727,6 +73770,7 @@ BEGIN END LOOP; CLOSE cur1; + DROP TEMPORARY TABLE tTicket, tmp.productionBuffer; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -72743,7 +73787,9 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_DelayTruckSplit`(vTicketFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_DelayTruckSplit`( + vTicketFk INT +) BEGIN /** * Splita las lineas de ticket que no estan ubicadas @@ -72794,7 +73840,7 @@ BEGIN SET s.ticketFk = vNewTicketFk; END IF; - CALL ticketStateUpdate(vNewTicketFk, 'FIXING'); + CALL ticket_setState(vNewTicketFk, 'FIXING'); DROP TEMPORARY TABLE tmp.SalesToSplit; END ;; @@ -72813,7 +73859,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_doCmr`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_doCmr`(vSelf INT) BEGIN /** * Crea u actualiza la información del CMR asociado con @@ -72821,7 +73867,7 @@ BEGIN * * @param vSelf El id del ticket */ - DECLARE vCmrFk, vPreviousCmrFk, vCurrentCmrFk INT; + DECLARE vCmrFk INT; SELECT cmrFk INTO vCmrFk FROM ticket WHERE id = vSelf; @@ -72832,7 +73878,7 @@ BEGIN com.id companyFk, a.id addressFk, c2.defaultAddressFk, - su.id supplierFk, + IFNULL(sat.supplierFk, su.id) supplierFk, t.landed FROM ticket t JOIN ticketState ts ON ts.ticketFk = t.id @@ -72842,15 +73888,18 @@ BEGIN JOIN `address` a ON a.id = t.addressFk JOIN province p ON p.id = a.provinceFk JOIN country co ON co.id = p.countryFk - JOIN agencyMode am ON am.id = t.agencyModeFk JOIN warehouse w ON w.id = t.warehouseFk JOIN company com ON com.id = t.companyFk JOIN client c2 ON c2.id = com.clientFk - JOIN supplierAccount sa ON sa.id = com.supplierAccountFk + JOIN supplierAccount sa ON sa.id = com.supplierAccountFk JOIN supplier su ON su.id = sa.supplierFk LEFT JOIN route r ON r.id = t.routeFk LEFT JOIN worker wo ON wo.id = r.workerFk LEFT JOIN vehicle v ON v.id = r.vehicleFk + LEFT JOIN agencyMode am ON am.id = r.agencyModeFk + LEFT JOIN agency ag ON ag.id = am.agencyFk + LEFT JOIN supplierAgencyTerm sat ON sat.agencyFk = ag.id + AND wo.isFreelance WHERE al.code IN ('PACKED', 'DELIVERED') AND co.code <> 'ES' AND am.name <> 'ABONO' @@ -72858,8 +73907,6 @@ BEGIN AND t.id = vSelf GROUP BY t.id; - START TRANSACTION; - IF vCmrFk THEN UPDATE cmr c JOIN tTicket t @@ -72871,9 +73918,7 @@ BEGIN c.supplierFk = t.supplierFk, c.ead = t.landed WHERE id = vCmrFk; - ELSE - SELECT MAX(id) INTO vPreviousCmrFk FROM cmr; - + ELSE INSERT INTO cmr ( senderInstruccions, truckPlate, @@ -72884,17 +73929,14 @@ BEGIN ead ) SELECT * FROM tTicket; - - SELECT MAX(id) INTO vCurrentCmrFk FROM cmr; - IF vPreviousCmrFk <> vCurrentCmrFk THEN + IF (SELECT EXISTS(SELECT * FROM tTicket)) THEN UPDATE ticket - SET cmrFk = vCurrentCmrFk + SET cmrFk = LAST_INSERT_ID() WHERE id = vSelf; END IF; END IF; - COMMIT; DROP TEMPORARY TABLE tTicket; END ;; DELIMITER ; @@ -72912,7 +73954,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getFromFloramondo`(vDateFrom DATE, vDateTo DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_getFromFloramondo`(vDateFrom DATE, vDateTo DATE) BEGIN /** * Genera una tabla con la lista de tickets de Floramondo @@ -72979,7 +74021,7 @@ BEGIN JOIN vn.componentType ct ON ct.id = c.typeFk JOIN vn.sale s ON s.id = sc.saleFk JOIN tmp.ticket t ON t.ticketFk = s.ticketFk - WHERE ct.code = 'FREIGHT' + WHERE ct.code = 'freight' GROUP BY t.ticketFk) sb ON sb.ticketFk = tf.ticketFk SET tf.freight = sb.freight; @@ -73001,7 +74043,7 @@ BEGIN -- Margin UPDATE tmp.ticketFloramondo tf - JOIN (SELECT SUM(IF(ct.code = 'COST',sc.value, 0)) cost, + JOIN (SELECT SUM(IF(ct.code = 'cost',sc.value, 0)) cost, SUM(IF(ct.isMargin, sc.value, 0)) margin, t.ticketFk FROM vn.saleComponent sc @@ -73052,7 +74094,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getMovable`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_getMovable`( vTicketFk INT, vNewShipped DATETIME, vWarehouseFk INT @@ -73120,7 +74162,9 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getProblems`(IN vIsTodayRelative tinyint(1)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_getProblems`( + vIsTodayRelative tinyint(1) +) BEGIN /** * Calcula los problemas para un conjunto de tickets. @@ -73137,6 +74181,7 @@ BEGIN SELECT ticketFk, MAX(isFreezed) isFreezed, MAX(risk) risk, + MAX(hasRisk) hasRisk, MAX(hasHighRisk) hasHighRisk, MAX(hasTicketRequest) hasTicketRequest, MAX(itemShortage) itemShortage, @@ -73146,22 +74191,24 @@ BEGIN MAX(itemDelay) itemDelay, MAX(hasRounding) hasRounding, MAX(itemLost) itemLost, + MAX(isVip) isVip, 0 totalProblems FROM tmp.sale_problems GROUP BY ticketFk; - UPDATE tmp.ticket_problems tp - SET tp.totalProblems = ( - (tp.isFreezed) + - IF(tp.risk,TRUE, FALSE) + - (tp.hasTicketRequest) + - (tp.isTaxDataChecked = 0) + - (tp.hasComponentLack) + - (tp.itemDelay) + - (tp.isTooLittle) + - (tp.itemLost) + - (tp.hasRounding) + - (tp.itemShortage) + UPDATE tmp.ticket_problems + SET totalProblems = ( + (isFreezed) + + (hasHighRisk) + + (hasTicketRequest) + + (!isTaxDataChecked) + + (hasComponentLack) + + (itemDelay IS NOT NULL) + + (isTooLittle) + + (itemLost IS NOT NULL) + + (hasRounding IS NOT NULL) + + (itemShortage IS NOT NULL) + + (isVip) ); DROP TEMPORARY TABLE tmp.sale_problems; @@ -73181,7 +74228,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getSplitList`(vDated DATE, vHour TIME, vWarehouseFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_getSplitList`(vDated DATE, vHour TIME, vWarehouseFk INT) BEGIN /** * Devuelve un listado con los tickets posibles para splitar HOY. @@ -73354,7 +74401,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getTax`(IN vTaxArea VARCHAR(25)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_getTax`(IN vTaxArea VARCHAR(25)) BEGIN /** * Calcula la base imponible, el IVA y el recargo de equivalencia para @@ -73470,7 +74517,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getWarnings`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_getWarnings`() BEGIN /** * Calcula las adventencias para un conjunto de tickets. @@ -73525,7 +74572,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_getWithParameters`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_getWithParameters`( vClientFk INT, vWarehouseFk INT, vShipped DATE, @@ -73587,7 +74634,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_insertZone`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_insertZone`() BEGIN DECLARE vDone INT DEFAULT 0; DECLARE vFechedTicket INT; @@ -73622,6 +74669,62 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_mergeSales` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_mergeSales`( + vSelf INT +) +BEGIN + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + CREATE OR REPLACE TEMPORARY TABLE tSalesToPreserve + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT s.id, s.itemFk, SUM(s.quantity) newQuantity + FROM sale s + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + WHERE s.ticketFk = vSelf + AND it.isMergeable + GROUP BY s.itemFk, s.price, s.discount; + + START TRANSACTION; + + UPDATE sale s + JOIN tSalesToPreserve stp ON stp.id = s.id + SET s.quantity = newQuantity + WHERE s.ticketFk = vSelf; + + DELETE s.* + FROM sale s + LEFT JOIN tSalesToPreserve stp ON stp.id = s.id + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + WHERE s.ticketFk = vSelf + AND stp.id IS NULL + AND it.isMergeable; + + COMMIT; + + DROP TEMPORARY TABLE tSalesToPreserve; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_priceDifference` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -73630,7 +74733,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_priceDifference`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_priceDifference`( vTicketFk INT, vLanded DATE, vAddressFk INT, @@ -73687,7 +74790,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_printLabelPrevious`(vTicketFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_printLabelPrevious`(vTicketFk INT) BEGIN /** * Calls the report_print procedure and passes it @@ -73733,7 +74836,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_recalc`(vSelf INT, vTaxArea VARCHAR(25)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_recalc`(vSelf INT, vTaxArea VARCHAR(25)) proc:BEGIN /** * Calcula y guarda el total con/sin IVA en un ticket. @@ -73783,7 +74886,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_recalcByScope`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_recalcByScope`( vScope VARCHAR(255), vId INT ) @@ -73798,16 +74901,28 @@ BEGIN 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)); + SELECT DISTINCT t.id + FROM ticket t + LEFT JOIN tItems ti ON ti.id = t.id + WHERE t.refFk IS NULL + AND ((vScope = 'client' AND t.clientFk = vId) + OR (vScope = 'address' AND t.addressFk = vId) + OR (vScope = 'item' AND ti.id) + ); - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + CREATE OR REPLACE TEMPORARY TABLE tItems + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT DISTINCT t.id + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN itemTaxCountry itc ON itc.itemFk = s.itemFk + WHERE t.refFk IS NULL + AND (vScope = 'item' AND itc.itemFk = vId); OPEN cTickets; - myLoop: LOOP SET vDone = FALSE; FETCH cTickets INTO vTicketFk; @@ -73818,8 +74933,9 @@ BEGIN CALL ticket_recalc(vTicketFk, NULL); END LOOP; - CLOSE cTickets; + + DROP TEMPORARY TABLE tItems; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -73827,16 +74943,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_recalcComponents` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_recalcComponents`(vSelf INT, vOption VARCHAR(25)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_recalcComponents`(vSelf INT, vOption VARCHAR(25)) proc: BEGIN /** @@ -73861,25 +74977,32 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_setNextState` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setNextState`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_setNextState`( + vSelf INT +) BEGIN /** - * Cambia el estado del ticket al siguiente estado según la tabla state + * Cambia el estado del ticket al siguiente estado según la tabla state. * - * @param vSelf id dle ticket + * @param vSelf Id ticket */ DECLARE vStateFk INT; DECLARE vNewStateFk INT; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + RESIGNAL; + END; + SELECT stateFk INTO vStateFk FROM ticketState WHERE ticketFk = vSelf; @@ -73888,6 +75011,10 @@ BEGIN FROM state WHERE id = vStateFk; + IF vNewStateFk IS NULL THEN + CALL util.throw('The ticket not have next state'); + END IF; + INSERT INTO ticketTracking(stateFk, ticketFk, userFk) VALUES (vNewStateFk, vSelf, account.myUser_getId()); END ;; @@ -73906,13 +75033,16 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setParking`(IN `vTicketFk` VARCHAR(8), IN `vParkingFk` INT) -proc: BEGIN +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_setParking`( + vSelf INT, + vParkingFk INT +) +BEGIN /** - * Aparca un ticket en un parking + * Aparca un ticket en un parking. * - * @param vTicketFk id del ticket - * @param vParkingFk id del parking + * @param vSelf Id ticket + * @param vParkingFk Id parking */ DECLARE vDone INT DEFAULT FALSE; DECLARE vCollectionTicketFk INT; @@ -73921,7 +75051,7 @@ proc: BEGIN FROM ticket t LEFT JOIN ticketCollection tc1 ON tc1.ticketFk = t.id LEFT JOIN ticketCollection tc2 ON tc2.collectionFk = tc1.collectionFk - WHERE t.id = vTicketFk; + WHERE t.id = vSelf; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -73930,7 +75060,7 @@ proc: BEGIN FROM ticket t LEFT JOIN ticketCollection tc1 ON tc1.ticketFk = t.id LEFT JOIN ticketCollection tc2 ON tc2.collectionFk = tc1.collectionFk - WHERE t.id = vTicketFk + WHERE t.id = vSelf ON DUPLICATE KEY UPDATE parkingFk = vParkingFk; OPEN vCursor; @@ -73952,16 +75082,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_setPreviousState` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setPreviousState`(vTicketFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_setPreviousState`(vTicketFk INT) BEGIN DECLARE vControlFk INT; @@ -73998,6 +75128,475 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setProblem` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_setProblem`( + vProblemCode VARCHAR(25) +) +BEGIN +/** + * Update column ticket.problem with a problem code and SET NULL when + * the problem is not requiered + * + * @param vProblemCode Code to set or unset + * @table tmp.ticket(ticketFk, hasProblem, isProblemCalcNeeded) + */ + DECLARE vTicketFk INT; + DECLARE vHasProblem INT; + DECLARE vIsProblemCalcNeeded BOOL; + DECLARE vDone BOOL; + DECLARE vTicketList CURSOR FOR + SELECT ticketFk, hasProblem, isProblemCalcNeeded + FROM tmp.ticket; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vTicketList; + l: LOOP + SET vDone = FALSE; + FETCH vTicketList INTO vTicketFk, vHasProblem, vIsProblemCalcNeeded; + + IF vDone THEN + LEAVE l; + END IF; + + UPDATE ticket + SET problem = IF(vIsProblemCalcNeeded, + CONCAT(IF(vHasProblem, + CONCAT(problem, ',', vProblemCode), + REPLACE(problem, vProblemCode , ''))), + NULL) + WHERE id = vTicketFk; + END LOOP; + CLOSE vTicketList; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setProblemFreeze` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_setProblemFreeze`( + vClientFk INT +) +BEGIN +/** + * Update the problem of tickets whose client is frozen or unfrozen + * + * @param vClientFk Id Cliente, if NULL all clients + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + (INDEX(ticketFk, isProblemCalcNeeded)) + ENGINE = MEMORY + SELECT t.id ticketFk, + FALSE hasProblem, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded + FROM ticket t + WHERE t.shipped >= util.VN_CURDATE() + AND (vClientFk IS NULL OR t.clientFk = vClientFk); + + UPDATE tmp.ticket t + JOIN ticket ti ON ti.id = t.ticketFk + JOIN client c ON c.id = ti.clientFk + SET t.hasProblem = TRUE + WHERE c.isFreezed; + + CALL ticket_setProblem('isFreezed'); + + DROP TEMPORARY TABLE tmp.ticket; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setProblemRequest` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_setProblemRequest`( + vSelf INT +) +BEGIN +/** + * Update the problems of tickets that have a pending ticketRequest or no longer have it + * + * @param vSelf Id ticket, if NULL ALL tickets + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + (INDEX(ticketFk, isProblemCalcNeeded)) + ENGINE = MEMORY + SELECT t.id ticketFk, + FALSE hasProblem, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded + FROM ticket t + WHERE t.shipped >= util.VN_CURDATE() + AND (vSelf IS NULL OR t.id = vSelf); + + UPDATE tmp.ticket t + JOIN ticketRequest tr ON tr.ticketFk = t.ticketFk + SET t.hasProblem = TRUE + WHERE tr.isOK IS NULL; + + CALL ticket_setProblem('hasTicketRequest'); + + DROP TEMPORARY TABLE tmp.ticket; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setProblemRisk` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_setProblemRisk`( + vSelf INT +) +BEGIN +/** + * Update the risk problem for a specific ticket + * + * @param vSelf Id ticket + */ + DECLARE vHasRisk BOOL; + DECLARE vHasHighRisk BOOL; + DECLARE vIsProblemCalcNeeded BOOL; + + SELECT t.risk > (c.credit + 10), + (t.risk - cc.riskTolerance) > (c.credit + 10), + ticket_isProblemCalcNeeded(t.id) + INTO vHasRisk, vHasHighRisk, vIsProblemCalcNeeded + FROM client c + JOIN ticket t ON t.clientFk = c.id + JOIN clientConfig cc + WHERE t.id = vSelf; + + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + ENGINE = MEMORY + SELECT vSelf ticketFk, + vHasRisk hasProblem, + vIsProblemCalcNeeded isProblemCalcNeeded; + + CALL ticket_setProblem('hasRisk'); + + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + ENGINE = MEMORY + SELECT vSelf ticketFk, + vHasHighRisk hasProblem, + vIsProblemCalcNeeded isProblemCalcNeeded; + + CALL ticket_setProblem('hasHighRisk'); + + DROP TEMPORARY TABLE tmp.ticket; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setProblemRiskByClient` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_setProblemRiskByClient`( + vClientFk INT +) +BEGIN +/** + * Updates future ticket risk for a client. + * + * @param vClientFk Id client + */ + DECLARE vDone INT DEFAULT FALSE; + DECLARE vTicketFk INT; + DECLARE vTickets CURSOR FOR + SELECT id + FROM ticket + WHERE clientFk = vClientFk + AND shipped >= util.VN_CURDATE() + AND refFk IS NULL; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vTickets; + l: LOOP + SET vDone = FALSE; + FETCH vTickets INTO vTicketFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL vn.ticket_setProblemRisk(vTicketFk); + END LOOP; + CLOSE vTickets; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setProblemTaxDataChecked` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_setProblemTaxDataChecked`(vClientFk INT) +BEGIN +/** + * Update the problem of tickets, depending on whether + * the client taxDataCheched is verified or not + * + * @param vClientFk Id cliente, if NULL all clients + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + (INDEX(ticketFk, isProblemCalcNeeded)) + ENGINE = MEMORY + SELECT t.id ticketFk, + IF(c.isTaxDataChecked, FALSE, TRUE) hasProblem, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded + FROM ticket t + JOIN client c ON c.id = t.clientFk + WHERE t.shipped >= util.VN_CURDATE() + AND (c.id = vClientFk OR vClientFk IS NULL); + + CALL ticket_setProblem('isTaxDataChecked'); + + DROP TEMPORARY TABLE tmp.ticket; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setProblemTooLittle` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_setProblemTooLittle`( + vSelf INT +) +BEGIN +/** + * Update the problems when the ticket is too small or is no longer so + * + * @param vSelf Id del ticket + */ + DECLARE vTicketIsTooLittle BOOL; + + SELECT ticket_isTooLittle(vSelf) INTO vTicketIsTooLittle; + + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + (INDEX(ticketFk, isProblemCalcNeeded)) + ENGINE = MEMORY + WITH ticketData AS ( + SELECT addressFk, DATE(shipped) dated + FROM vn.ticket + WHERE id = vSelf + ) + SELECT t.id ticketFk, + vTicketIsTooLittle hasProblem, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded + FROM vn.ticket t + JOIN ticketData td ON td.addressFk = t.addressFk + WHERE t.shipped BETWEEN td.dated AND util.dayEnd(td.dated); + + CALL ticket_setProblem('isTooLittle'); + + DROP TEMPORARY TABLE tmp.ticket; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setProblemTooLittleItemCost` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_setProblemTooLittleItemCost`( + vItemFk INT +) +BEGIN +/** + * Update the problems when the ticket is too small or is no longer so, + * derived from changes in the itemCost table + * + * @param vItemFk Id del item, NULL ALL items + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + (INDEX(ticketFk, isProblemCalcNeeded)) + ENGINE = MEMORY + WITH tickets AS( + SELECT t.id ticketFk + FROM vn.ticket t + LEFT JOIN vn.sale s ON s.ticketFk = t.id + WHERE t.shipped >= util.VN_CURDATE() + AND (s.itemFk = vItemFk OR vItemFk IS NULL) + GROUP BY t.id + )SELECT ticketFk, + ticket_isTooLittle(ticketFk) hasProblem, + ticket_isProblemCalcNeeded(ticketFk) isProblemCalcNeeded + FROM tickets; + + CALL ticket_setProblem('isTooLittle'); + + DROP TEMPORARY TABLE tmp.ticket; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setRisk` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_setRisk`( + vClientFk INT +) +BEGIN +/** + * Update the risk for a client with pending tickets. + * + * @param vClientFk Id cliente + */ + IF (SELECT COUNT(*) FROM client WHERE id = vClientFk AND typeFk = 'normal') THEN + CREATE OR REPLACE TEMPORARY TABLE tTicketRisk + (PRIMARY KEY (ticketFk)) + ENGINE = MEMORY + WITH ticket AS ( + SELECT t.id ticketFk, + t.companyFk, + DATE(t.shipped) dated, + t.totalWithVat, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded + FROM vn.ticket t + JOIN vn.clientConfig cc + WHERE t.clientFk = vClientFk + AND t.refFk IS NULL + AND NOT t.isDeleted + AND IFNULL(t.totalWithVat, 0) <> 0 + AND t.shipped > (util.VN_CURDATE() - INTERVAL cc.riskScope MONTH) + ), uninvoiced AS ( + SELECT companyFk, dated, SUM(totalWithVat) amount + FROM ticket + GROUP BY companyFk, dated + ), companies AS ( + SELECT DISTINCT companyFk FROM uninvoiced + ), balance AS ( + SELECT SUM(IFNULL(amount, 0))amount, companyFk + FROM ( + SELECT cr.amount, c.companyFk + FROM companies c + LEFT JOIN vn.clientRisk cr ON cr.companyFk = c.companyFk + AND cr.clientFk = vClientFk + UNION ALL + SELECT -(SUM(t.amount) / 100) amount, c.companyFk + FROM companies c + LEFT JOIN hedera.tpvMerchant tm ON tm.companyFk = c.companyFk + LEFT JOIN hedera.tpvTransaction t ON t.merchantFk = tm.id + AND t.clientFk = vClientFk + AND t.receiptFk IS NULL + AND t.`status` = 'ok' + ) sub + WHERE companyFk + GROUP BY companyFk + ), receipt AS ( + SELECT r.companyFk, DATE(r.payed) dated, SUM(r.amountPaid) amount + FROM vn.receipt r + JOIN companies c ON c.companyFk = r.companyFk + WHERE r.clientFk = vClientFk + AND r.payed > util.VN_CURDATE() + GROUP BY r.companyFk, DATE(r.payed) + ), risk AS ( + SELECT b.companyFk, + ui.dated, + SUM(ui.amount) OVER (PARTITION BY b.companyFk ORDER BY ui.dated) + + b.amount + + SUM(IFNULL(r.amount, 0)) amount + FROM balance b + JOIN uninvoiced ui ON ui.companyFk = b.companyFk + LEFT JOIN receipt r ON r.dated > ui.dated + AND r.companyFk = ui.companyFk + GROUP BY b.companyFk, ui.dated + ) + SELECT ti.ticketFk, r.amount, ti.isProblemCalcNeeded + FROM ticket ti + JOIN risk r ON r.dated = ti.dated + AND r.companyFk = ti.companyFk; + + UPDATE ticket t + JOIN tTicketRisk tr ON tr.ticketFk = t.id + SET t.risk = IF(tr.isProblemCalcNeeded, tr.amount, NULL); + + DROP TEMPORARY TABLE tTicketRisk; + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_setState` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74006,7 +75605,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setState`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_setState`( vSelf INT, vStateCode VARCHAR(255) COLLATE utf8_general_ci ) @@ -74067,6 +75666,95 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setVolume` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_setVolume`( + vSelf INT +) +BEGIN +/** + * Update the volume ticket. + * + * @param vSelf Ticket id + */ + DECLARE vVolume DECIMAL(10,6); + + SELECT SUM(s.quantity * ic.cm3delivery / 1000000) INTO vVolume + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN itemCost ic ON ic.itemFk = s.itemFk + AND ic.warehouseFk = t.warehouseFk + WHERE t.id = vSelf; + + UPDATE ticket + SET volume = vVolume + WHERE id = vSelf; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setVolumeItemCost` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_setVolumeItemCost`( + vItemFk INT +) +BEGIN +/** + * Update the volume of tickets containing the item. + * + * @param vItemFk Item id + */ + DECLARE vTicket INT; + DECLARE vDone BOOL; + + DECLARE vTickets CURSOR FOR + SELECT DISTINCT t.id + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN itemCost ic ON ic.itemFk = s.itemFk + AND ic.warehouseFk = t.warehouseFk + WHERE s.itemFk = vItemFk + AND t.shipped >= util.VN_CURDATE() + AND t.refFk IS NULL; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vTickets; + l: LOOP + FETCH vTickets INTO vTicket; + + IF vDone THEN + LEAVE l; + END IF; + + CALL ticket_setVolume(vTicket); + + END LOOP l; + CLOSE vTickets; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_split` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74075,7 +75763,11 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_split`(vTicketFk INT, vTicketFutureFk INT, vDated DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_split`( + vTicketFk INT, + vTicketFutureFk INT, + vDated DATE +) proc:BEGIN /** * Mueve las lineas con problemas a otro ticket existente o a uno nuevo. @@ -74093,61 +75785,57 @@ proc:BEGIN FROM tmp.salesToSplit WHERE ticketFk = vTicketFk; - SELECT count(*) INTO vTotalLines - FROM vn.sale s + SELECT COUNT(*) INTO vTotalLines + FROM sale s WHERE s.ticketFk = vTicketFk; SET vHasFullProblem = (vTotalLines = vProblemLines); -- Ticket completo IF vHasFullProblem THEN - - UPDATE vn.ticket - SET landed = vDated + INTERVAL 1 DAY, + UPDATE ticket + SET landed = vDated + INTERVAL 1 DAY, shipped = vDated, - nickname = CONCAT('(',DAY(util.VN_CURDATE()),') ', nickname ) + nickname = CONCAT('(',DAY(util.VN_CURDATE()),') ', nickname) WHERE id = vTicketFk; - SELECT "moved" message, NULL ticketFuture; + SELECT 'moved' message, NULL ticketFuture; LEAVE proc; - END IF; -- Ticket a futuro existe IF vTicketFutureFk THEN - - UPDATE vn.sale s - JOIN tmp.salesToSplit ss ON s.id = ss.saleFk + UPDATE sale s + JOIN tmp.salesToSplit ss ON s.id = ss.saleFk SET s.ticketFk = vTicketFutureFk, s.concept = CONCAT('(s) ', s.concept) WHERE ss.ticketFk = vTicketFk; - SELECT "future" message, NULL ticketFuture; + SELECT 'future' message, NULL ticketFuture; LEAVE proc; - END IF; -- Ticket nuevo - CALL vn.ticket_Clone(vTicketFk, vTicketFutureFk); + CALL ticket_Clone(vTicketFk, vTicketFutureFk); - UPDATE vn.ticket t - JOIN vn.productionConfig pc + UPDATE ticket t + JOIN productionConfig pc SET t.routeFk = IF(t.shipped = vDated , t.routeFk, NULL), - t.landed = vDated + INTERVAL 1 DAY, + t.landed = vDated + INTERVAL 1 DAY, t.shipped = vDated, t.agencyModeFk = pc.defautlAgencyMode, t.zoneFk = pc.defaultZone WHERE t.id = vTicketFutureFk; - - UPDATE vn.sale s - JOIN tmp.salesToSplit sts ON sts.saleFk = s.id + + UPDATE sale s + JOIN tmp.salesToSplit sts ON sts.saleFk = s.id SET s.ticketFk = vTicketFutureFk, s.concept = CONCAT('(s) ', s.concept) WHERE sts.ticketFk = vTicketFk; - CALL vn.ticketStateUpdate(vTicketFutureFk, 'FIXING'); + CALL ticket_setState(vTicketFutureFk, 'FIXING'); - SELECT "new" message,vTicketFutureFk ticketFuture; + SELECT 'new' message, vTicketFutureFk ticketFuture; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -74164,13 +75852,16 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_splitItemPackingType`(vTicketFk INT, vOriginalItemPackingTypeFk VARCHAR(1)) -proc:BEGIN +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_splitItemPackingType`( + vSelf INT, + vOriginalItemPackingTypeFk VARCHAR(1) +) +BEGIN /** * Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado. * Respeta el id inicial para el tipo propuesto. * - * @param vTicketFk Identificador de vn.ticket + * @param vSelf Id ticket * @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) */ @@ -74179,94 +75870,111 @@ proc:BEGIN DECLARE vPackingTypesToSplit INT; DECLARE vDone INT DEFAULT FALSE; - DECLARE cur1 CURSOR FOR + DECLARE vSaleGroup CURSOR FOR SELECT itemPackingTypeFk - FROM tmp.saleGroup + FROM tSaleGroup WHERE itemPackingTypeFk IS NOT NULL ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DELETE FROM vn.sale - WHERE quantity = 0 - AND ticketFk = vTicketFk; + START TRANSACTION; - DROP TEMPORARY TABLE IF EXISTS tmp.sale; - CREATE TEMPORARY TABLE tmp.sale + SELECT id + FROM sale + WHERE ticketFk = vSelf + AND NOT quantity + FOR UPDATE; + + DELETE FROM sale + WHERE NOT quantity + AND ticketFk = vSelf; + + CREATE OR REPLACE TEMPORARY TABLE tSale (PRIMARY KEY (id)) - SELECT s.id, i.itemPackingTypeFk , IFNULL(sv.litros, 0) litros - FROM vn.sale s - JOIN vn.item i ON i.id = s.itemFk - LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id - WHERE s.ticketFk = vTicketFk; + ENGINE = MEMORY + SELECT s.id, i.itemPackingTypeFk, IFNULL(sv.litros, 0) litros + FROM sale s + JOIN item i ON i.id = s.itemFk + LEFT JOIN saleVolume sv ON sv.saleFk = s.id + WHERE s.ticketFk = vSelf; - DROP TEMPORARY TABLE IF EXISTS tmp.saleGroup; - CREATE TEMPORARY TABLE tmp.saleGroup - SELECT itemPackingTypeFk , sum(litros) AS totalLitros - FROM tmp.sale + CREATE OR REPLACE TEMPORARY TABLE tSaleGroup + ENGINE = MEMORY + SELECT itemPackingTypeFk, SUM(litros) totalLitros + FROM tSale GROUP BY itemPackingTypeFk; SELECT COUNT(*) INTO vPackingTypesToSplit - FROM tmp.saleGroup + FROM tSaleGroup WHERE itemPackingTypeFk IS NOT NULL; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketIPT; - CREATE TEMPORARY TABLE tmp.ticketIPT - (ticketFk INT, - itemPackingTypeFk VARCHAR(1)); + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT( + ticketFk INT, + itemPackingTypeFk VARCHAR(1) + ) ENGINE = MEMORY; CASE vPackingTypesToSplit WHEN 0 THEN INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vTicketFk, vItemPackingTypeFk); + VALUES(vSelf, vItemPackingTypeFk); WHEN 1 THEN INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - SELECT vTicketFk, itemPackingTypeFk - FROM tmp.saleGroup + SELECT vSelf, itemPackingTypeFk + FROM tSaleGroup WHERE itemPackingTypeFk IS NOT NULL; ELSE - OPEN cur1; - - FETCH cur1 INTO vItemPackingTypeFk; + OPEN vSaleGroup; + FETCH vSaleGroup INTO vItemPackingTypeFk; INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vTicketFk, vItemPackingTypeFk); + VALUES(vSelf, vItemPackingTypeFk); - read_loop: LOOP - FETCH cur1 INTO vItemPackingTypeFk; + l: LOOP + SET vDone = FALSE; + FETCH vSaleGroup INTO vItemPackingTypeFk; IF vDone THEN - LEAVE read_loop; + LEAVE l; END IF; - CALL vn.ticket_Clone(vTicketFk, vNewTicketFk); + CALL ticket_Clone(vSelf, vNewTicketFk); INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) VALUES(vNewTicketFk, vItemPackingTypeFk); END LOOP; - CLOSE cur1; + CLOSE vSaleGroup; - UPDATE vn.sale s - JOIN tmp.sale ts ON ts.id = s.id + SELECT s.id + FROM sale s + JOIN tSale ts ON ts.id = s.id + JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk + FOR UPDATE; + + UPDATE sale s + JOIN tSale ts ON ts.id = s.id JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk SET s.ticketFk = t.ticketFk; SELECT itemPackingTypeFk INTO vItemPackingTypeFk - FROM tmp.saleGroup sg - WHERE NOT ISNULL(sg.itemPackingTypeFk) + FROM tSaleGroup sg + WHERE sg.itemPackingTypeFk IS NOT NULL ORDER BY sg.itemPackingTypeFk LIMIT 1; - UPDATE vn.sale s - JOIN tmp.sale ts ON ts.id = s.id + UPDATE sale s + JOIN tSale ts ON ts.id = s.id JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk SET s.ticketFk = t.ticketFk WHERE ts.itemPackingTypeFk IS NULL; END CASE; - DROP TEMPORARY TABLE tmp.sale; - DROP TEMPORARY TABLE tmp.saleGroup; + COMMIT; + + DROP TEMPORARY TABLE + tSale, + tSaleGroup; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -74283,7 +75991,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_splitPackingComplete`(vTicketFk INT, vSectorFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_splitPackingComplete`(vTicketFk INT, vSectorFk INT) BEGIN DECLARE vNeedToSplit BOOLEAN; @@ -74338,7 +76046,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_WeightDeclaration`(vClientFk INT, vDated DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_WeightDeclaration`(vClientFk INT, vDated DATE) BEGIN DECLARE vTheorycalWeight DECIMAL(10,2); @@ -74385,6 +76093,92 @@ BEGIN GROUP BY ib.ediBotanic, o.code; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `till_new` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `till_new`( + vClient INT, + vBank INT, + vAmount DOUBLE, + vConcept VARCHAR(25), + vDated DATE, + vSerie CHAR(1), + vBatch TINYINT, + vNumber INT, + vCompany SMALLINT, + vWorker INT +) +BEGIN + DECLARE vAccount VARCHAR(12); + DECLARE vSubaccount VARCHAR(12); + DECLARE vAsiento INT DEFAULT NULL; + + -- Inserta el registro en cajas + INSERT INTO till + SET + workerFk = vWorker, + bankFk = vBank, + `in` = vAmount, + concept = vConcept, + dated = vDated, + serie = vSerie, + isAccountable = vBatch, + `number` = vNumber, + companyFk = vCompany; + + -- Inserta los asientos contables + SELECT account INTO vAccount + FROM accounting WHERE id = vBank; + + SELECT accountingAccount INTO vSubaccount + FROM `client` WHERE id = vClient; + + CALL xdiario_new( + vAsiento, + vDated, + vAccount, + vSubaccount, + vConcept, + vAmount, + 0, + 0, + NULL, -- Serie + NULL, -- Factura + NULL, -- IVA + NULL, -- Recargo + FALSE, -- Auxiliar + vCompany, + vAsiento); + + CALL xdiario_new( + vAsiento, + vDated, + vSubaccount, + vAccount, + vConcept, + 0, + vAmount, + 0, + NULL, -- Serie + NULL, -- Factura + NULL, -- IVA + NULL, -- Recargo + FALSE, -- Auxiliar + vCompany, + vAsiento); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -74401,7 +76195,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `timeBusiness_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** * Horas que debe trabajar un empleado según contrato y día. @@ -74499,7 +76293,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculateAll`(vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `timeBusiness_calculateAll`(vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** @@ -74531,7 +76325,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculateByDepartment`(vDepartmentFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `timeBusiness_calculateByDepartment`(vDepartmentFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** * @param vDepartmentFk @@ -74569,7 +76363,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculateByUser`(vUserFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `timeBusiness_calculateByUser`(vUserFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** @@ -74604,7 +76398,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `timeBusiness_calculateByWorker`(vWorkerFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `timeBusiness_calculateByWorker`(vWorkerFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** @@ -74638,7 +76432,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculate`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `timeControl_calculate`( vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN @@ -74845,7 +76639,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculateAll`(vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `timeControl_calculateAll`(vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** @@ -74877,7 +76671,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculateByDepartment`(vDepartmentFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `timeControl_calculateByDepartment`(vDepartmentFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** * @param vDepartmentFk @@ -74915,7 +76709,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculateByUser`(vUserFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `timeControl_calculateByUser`(vUserFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** @@ -74950,7 +76744,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_calculateByWorker`(vWorkerFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `timeControl_calculateByWorker`(vWorkerFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** @@ -74985,7 +76779,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `timeControl_getError`(vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `timeControl_getError`(vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /* * @param vDatedFrom @@ -75068,7 +76862,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `tpvTransaction_checkStatus`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `tpvTransaction_checkStatus`() BEGIN /** * @@ -75096,16 +76890,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `travelVolume` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `travelVolume`(vTravelFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `travelVolume`(vTravelFk INT) BEGIN SELECT w1.name AS ORI, @@ -75139,16 +76933,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `travelVolume_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `travelVolume_get`(vFromDated DATE, vToDated DATE, vWarehouseFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `travelVolume_get`(vFromDated DATE, vToDated DATE, vWarehouseFk INT) BEGIN SELECT tr.landed Fecha, a.name Agencia, @@ -75178,7 +76972,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_checkDates`(vShipped DATE, vLanded DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `travel_checkDates`(vShipped DATE, vLanded DATE) BEGIN /** * Checks the landing/shipment dates of travel, throws an error @@ -75208,7 +77002,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_checkPackaging`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `travel_checkPackaging`(vSelf INT) BEGIN DECLARE vDone BOOL; DECLARE vEntryFk INT; @@ -75251,7 +77045,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_checkWarehouseIsFeedStock`(vWarehouseFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `travel_checkWarehouseIsFeedStock`(vWarehouseFk INT) proc: BEGIN /* * Check that the warehouse is not Feed Stock @@ -75281,7 +77075,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_clone`(vSelf INT, vDays INT, OUT vNewTravelFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `travel_clone`(vSelf INT, vDays INT, OUT vNewTravelFk INT) BEGIN /** * Clona un travel el número de dias indicado y devuelve su id. @@ -75342,7 +77136,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_cloneWithEntries`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `travel_cloneWithEntries`( IN vTravelFk INT, IN vDateStart DATE, IN vDateEnd DATE, @@ -75367,8 +77161,8 @@ BEGIN DECLARE vEvaNotes VARCHAR(255); DECLARE vDone BOOL; DECLARE vAuxEntryFk INT; - DECLARE vTx BOOLEAN DEFAULT @@in_transaction; - DECLARE vRsEntry CURSOR FOR + DECLARE vIsRequiredTx BOOLEAN DEFAULT NOT @@in_transaction; + DECLARE vRsEntry CURSOR FOR SELECT e.id FROM entry e JOIN travel t ON t.id = e.travelFk @@ -75378,11 +77172,11 @@ BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN - CALL util.tx_rollback(vTx); + CALL util.tx_rollback(vIsRequiredTx); RESIGNAL; END; - CALL util.tx_start(vTx); + CALL util.tx_start(vIsRequiredTx); INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk, agencyModeFk, `ref`, isDelivered, isReceived, m3, cargoSupplierFk, kg,clonedFrom) SELECT vDateStart, vDateEnd, vWarehouseInFk, vWarehouseOutFk, vAgencyModeFk, vRef, isDelivered, isReceived, m3,cargoSupplierFk, kg,vTravelFk @@ -75419,7 +77213,7 @@ BEGIN SET @isModeInventory = FALSE; CLOSE vRsEntry; - CALL util.tx_commit(vTx); + CALL util.tx_commit(vIsRequiredTx); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -75436,7 +77230,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_getDetailFromContinent`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `travel_getDetailFromContinent`( vContinentFk INT ) BEGIN @@ -75549,16 +77343,16 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `travel_getEntriesMissingPackage` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_getEntriesMissingPackage`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `travel_getEntriesMissingPackage`(vSelf INT) BEGIN DECLARE vpackageOrPackingNull INT; DECLARE vTravelFk INT; @@ -75589,7 +77383,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_moveRaids`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `travel_moveRaids`() BEGIN /* @@ -75674,7 +77468,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_recalc`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `travel_recalc`(vSelf INT) proc: BEGIN /** * Updates the number of entries assigned to the travel. @@ -75696,6 +77490,33 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `travel_throwAwb` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `travel_throwAwb`(vSelf INT) +BEGIN +/** + * Throws an error if travel does not have a logical AWB + * or there are several AWBs associated with the same DUA + * + * @param vSelf The travel id + */ + IF NOT travel_hasUniqueAwb(vSelf) THEN + CALL util.throw('A different AWB is found in the entries'); + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `travel_upcomingArrivals` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -75704,7 +77525,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_upcomingArrivals`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `travel_upcomingArrivals`( vWarehouseFk INT, vDate DATETIME ) @@ -75798,7 +77619,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_updatePacking`(vItemFk INT, vPacking INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `travel_updatePacking`(vItemFk INT, vPacking INT) BEGIN /** * Actualiza packing para los movimientos de almacén de la subasta al almacén central @@ -75840,7 +77661,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_weeklyClone`(vSinceWeek INT, vToWeek INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `travel_weeklyClone`(vSinceWeek INT, vToWeek INT) BEGIN /** * Clona los traslados plantilla para las semanas pasadas por parámetros. @@ -75926,7 +77747,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `typeTagMake`(vTypeFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `typeTagMake`(vTypeFk INT) BEGIN /* * Plantilla para modificar reemplazar todos los tags @@ -75997,7 +77818,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `updatePedidosInternos`(vItemFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `updatePedidosInternos`(vItemFk INT) BEGIN UPDATE vn.item SET upToDown = 0 WHERE item.id = vItemFk; @@ -76019,7 +77840,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `vehicle_checkNumberPlate`(vNumberPlate VARCHAR(10), vCountryCodeFk VARCHAR(2)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `vehicle_checkNumberPlate`(vNumberPlate VARCHAR(10), vCountryCodeFk VARCHAR(2)) BEGIN /** * Comprueba si la matricula pasada tiene el formato correcto dependiendo del pais del vehiculo @@ -76049,7 +77870,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `vehicle_notifyEvents`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `vehicle_notifyEvents`() proc:BEGIN /** * Query the vehicleEvent table to see if there are any events that need to be notified. @@ -76113,7 +77934,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `visible_getMisfit`(vSectorFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `visible_getMisfit`(vSectorFk INT) BEGIN /* Devuelve una tabla temporal con los descuadres entre el visible teórico y lo ubicado en la práctica @@ -76172,7 +77993,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `warehouseFitting`(IN vWhOrigin INT , IN vWhDestiny INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `warehouseFitting`(IN vWhOrigin INT , IN vWhDestiny INT) BEGIN DECLARE vCacheVisibleOriginFk INT; DECLARE vCacheVisibleDestinyFk INT; @@ -76210,7 +78031,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `warehouseFitting_byTravel`(IN vTravelFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `warehouseFitting_byTravel`(IN vTravelFk INT) BEGIN DECLARE vWhOrigin INT; @@ -76238,7 +78059,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCalculateBoss`(vWorker INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerCalculateBoss`(vWorker INT) BEGIN /** * Actualiza la tabla workerBosses @@ -76279,7 +78100,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCalendar_calculateBusiness`(vYear INT, vBusinessFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerCalendar_calculateBusiness`(vYear INT, vBusinessFk INT) BEGIN /** * Calcula los días y horas de vacaciones en función de un contrato y año @@ -76353,7 +78174,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCalendar_calculateYear`(vYear INT, vWorkerFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerCalendar_calculateYear`(vYear INT, vWorkerFk INT) BEGIN /** @@ -76425,7 +78246,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerCreateExternal`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerCreateExternal`( vFirstName VARCHAR(50), vSurname1 VARCHAR(50), vSurname2 VARCHAR(50), @@ -76467,7 +78288,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerDepartmentByDate`(vDate DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerDepartmentByDate`(vDate DATE) BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.workerDepartmentByDate; @@ -76504,7 +78325,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerDisable`(vUserId int) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerDisable`(vUserId int) mainLabel:BEGIN IF (SELECT COUNT(*) FROM workerDisableExcluded WHERE workerFk = vUserId AND (dated > util.VN_CURDATE() OR dated IS NULL)) > 0 THEN @@ -76533,6 +78354,10 @@ mainLabel:BEGIN UPDATE `client` c SET c.salesPersonFk = null WHERE c.salesPersonFk = vUserId; + + UPDATE locker l + SET l.workerFk = NULL + WHERE l.workerFk = vUserId; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -76549,7 +78374,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerDisableAll`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerDisableAll`() BEGIN DECLARE done BOOL DEFAULT FALSE; DECLARE vUserFk INT; @@ -76598,7 +78423,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerForAllCalculateBoss`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerForAllCalculateBoss`() BEGIN /** * Actualiza la tabla workerBosses utilizando el procedimiento @@ -76644,7 +78469,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerJourney_replace`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerJourney_replace`( vDatedFrom DATE, vDatedTo DATE, vWorkerFk INT) @@ -76965,7 +78790,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerMistakeType_get`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerMistakeType_get`() BEGIN /** @@ -76992,7 +78817,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerMistake_add`(vWorkerFk INT, vWorkerMistakeTypeFk VARCHAR(10)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerMistake_add`(vWorkerFk INT, vWorkerMistakeTypeFk VARCHAR(10)) BEGIN /** * Añade error al trabajador @@ -77020,7 +78845,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControlSOWP`(IN vUserFk INT, IN vDated DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerTimeControlSOWP`(IN vUserFk INT, IN vDated DATE) BEGIN SET @order := 0; @@ -77046,7 +78871,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_calculateOddDays`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerTimeControl_calculateOddDays`() BEGIN /** * Calculo de las fichadas impares por empleado y dia. @@ -77093,7 +78918,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerTimeControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100)) proc: BEGIN /** * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a workerTimeControlAdd @@ -77274,7 +79099,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_checkBreak`(vStarted DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerTimeControl_checkBreak`(vStarted DATE) BEGIN /** * Retorna los trabajadores que no han respetado el descanso semanal de 36/72 horas @@ -77441,7 +79266,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_clockIn`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerTimeControl_clockIn`( vWorkerFk INT, vTimed DATETIME, vDirection VARCHAR(10), @@ -77749,7 +79574,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_direction`(vWorkerFk VARCHAR(10), vTimed DATETIME) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerTimeControl_direction`(vWorkerFk VARCHAR(10), vTimed DATETIME) BEGIN /** * Devuelve que direcciones de fichadas son lógicas a partir de la anterior fichada @@ -77759,6 +79584,8 @@ BEGIN */ DECLARE vLastIn DATETIME ; DECLARE vIsMiddleOdd BOOLEAN ; + DECLARE vMailTo VARCHAR(50) DEFAULT NULL; + DECLARE vUserName VARCHAR(50) DEFAULT NULL; IF (vTimed IS NULL) THEN SET vTimed = util.VN_NOW(); @@ -77807,6 +79634,19 @@ BEGIN VALUES('in', NULL); END IF; + IF (SELECT option1 IS NULL AND option2 IS NULL FROM tmp.workerTimeControlDirection) THEN + SELECT CONCAT(u.name, '@verdnatura.es'), CONCAT(w.firstName, ' ', w.lastName) + INTO vMailTo, vUserName + FROM account.user u + JOIN worker w ON w.bossFk = u.id + WHERE w.id = vWorkerFk; + + CALL mail_insert( + vMailTo, + vMailTo, + 'Error al fichar', + CONCAT(vUserName, ' tiene problemas para fichar')); + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -77823,7 +79663,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_getClockIn`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerTimeControl_getClockIn`( vUserFk INT, vDated DATE) BEGIN @@ -77914,7 +79754,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_login`(vWorkerFk VARCHAR(10)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerTimeControl_login`(vWorkerFk VARCHAR(10)) BEGIN /** * Consulta la información del usuario y los botones que tiene que activar en la tablet tras hacer login @@ -77953,7 +79793,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_remove`(IN vUserFk INT, IN vTimed DATETIME) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerTimeControl_remove`(IN vUserFk INT, IN vTimed DATETIME) BEGIN DECLARE vDirectionRemove VARCHAR(6); @@ -78015,7 +79855,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_sendMailByDepartment`(IN vDatedFrom DATETIME, IN vDatedTo DATETIME, IN vWorkerFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerTimeControl_sendMailByDepartment`(IN vDatedFrom DATETIME, IN vDatedTo DATETIME, IN vWorkerFk INT) BEGIN /** * Inserta el registro de horario semanalmente de PRODUCCION, CAMARA, REPARTO, TALLER NATURAL y TALLER ARTIFICIAL en vn.mail. @@ -78157,7 +79997,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_sendMailByDepartmentLauncher`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerTimeControl_sendMailByDepartmentLauncher`() BEGIN DECLARE vDatedFrom, vDatedTo DATETIME; @@ -78182,7 +80022,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerTimeControl_weekCheckBreak`(vStarted DATE, vEnded DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerTimeControl_weekCheckBreak`(vStarted DATE, vEnded DATE) BEGIN /** * Retorna los trabajadores que no han respetado el descanso semanal de 36/72 horas @@ -78231,7 +80071,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workerWeekControl`(vUserFk INT, vDated DATE, vTabletFk VARCHAR(100)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerWeekControl`(vUserFk INT, vDated DATE, vTabletFk VARCHAR(100)) BEGIN /* * Devuelve la cantidad de descansos de 12h y de 36 horas que ha disfrutado el trabajador @@ -78369,6 +80209,43 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `worker_checkMultipleDevice` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `worker_checkMultipleDevice`( + vSelf INT +) +BEGIN +/** + * Verify if a worker has multiple assigned devices, + * except for freelancers. + * + * @param vUserFk worker id. + */ + DECLARE vHasPda BOOLEAN; + DECLARE vIsFreelance BOOLEAN; + DECLARE vMaxDevicesPerUser INT; + + SELECT COUNT(*) INTO vHasPda FROM deviceProductionUser WHERE userFk = vSelf; + SELECT IFNULL(isFreelance, FALSE) INTO vIsFreelance FROM worker WHERE id = vSelf; + SELECT IFNULL(maxDevicesPerUser, FALSE) INTO vMaxDevicesPerUser FROM deviceProductionConfig LIMIT 1; + + IF NOT vIsFreelance AND vHasPda > vMaxDevicesPerUser THEN + CALL util.throw('You can only have one PDA'); + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `worker_getFromHasMistake` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -78377,7 +80254,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_getFromHasMistake`(vDepartmentFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `worker_getFromHasMistake`(vDepartmentFk INT) BEGIN /** @@ -78409,7 +80286,9 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_getHierarchy`(vUserFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `worker_getHierarchy`( + vUserFk INT +) BEGIN /** * Retorna una tabla temporal con los trabajadores que tiene @@ -78422,15 +80301,16 @@ BEGIN (PRIMARY KEY (workerFk)) ENGINE = MEMORY WITH RECURSIVE workerHierarchy AS ( - SELECT id workerFk, bossFk, 0 depth + SELECT id workerFk, bossFk, 0 `depth`, CAST(id AS CHAR(255)) `path` FROM vn.worker WHERE id = vUserFk UNION ALL - SELECT w.id, w.bossFk, wh.depth + 1 + SELECT w.id, w.bossFk, wh.`depth` + 1, CONCAT(wh.`path`, ',', w.id) FROM vn.worker w JOIN workerHierarchy wh ON w.bossFk = wh.workerFk + WHERE NOT FIND_IN_SET(w.id, wh.`path`) ) - SELECT * + SELECT * FROM workerHierarchy ORDER BY depth, workerFk; END ;; @@ -78449,7 +80329,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_getSector`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `worker_getSector`() BEGIN /** @@ -78477,7 +80357,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_updateBalance`(vSelfFk INT(11), vCredit DECIMAL(10,2), vDebit DECIMAL(10,2)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `worker_updateBalance`(vSelf INT(11), vCredit DECIMAL(10,2), vDebit DECIMAL(10,2)) BEGIN /** * Actualiza la columna balance de worker. @@ -78486,7 +80366,7 @@ BEGIN */ UPDATE worker SET balance = IFNULL(balance, 0) + IFNULL(vCredit, 0) - IFNULL(vDebit, 0) - WHERE id = vSelfFk; + WHERE id = vSelf; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -78503,7 +80383,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_updateBusiness`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `worker_updateBusiness`(vSelf INT) BEGIN /** * Activates an account and configures its email settings. @@ -78550,7 +80430,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_updateChangedBusiness`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `worker_updateChangedBusiness`() BEGIN /** * Actualiza el contrato actual de todos los trabajadores cuyo contracto ha @@ -78603,7 +80483,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workingHours`(username varchar(255), logon boolean) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workingHours`(username varchar(255), logon boolean) BEGIN DECLARE userid int(11); @@ -78632,7 +80512,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workingHoursTimeIn`(vUserId INT(11)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workingHoursTimeIn`(vUserId INT(11)) BEGIN INSERT INTO vn.workingHours (timeIn, userId) VALUES (util.VN_NOW(),vUserId); @@ -78652,7 +80532,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `workingHoursTimeOut`(vUserId INT(11)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `workingHoursTimeOut`(vUserId INT(11)) BEGIN UPDATE vn.workingHours SET timeOut = util.VN_NOW() @@ -78674,7 +80554,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `wrongEqualizatedClient`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `wrongEqualizatedClient`() BEGIN SELECT clientFk, c.name, c.isActive, c.isTaxDataChecked, count(ie) as num FROM vn.client c @@ -78714,26 +80594,13 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `XDiario_check`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `XDiario_check`() BEGIN /** * Realiza la revisión diaria de los asientos contables, * identificando y notificando los asientos descuadrados * y ajustando los saldos en caso necesario. */ - INSERT INTO mail (receiver, subject, body) - SELECT 'cau@verdnatura.es', - 'Asientos descuadrados', - GROUP_CONCAT(CONCAT(' Asiento: ', ASIEN, ' - Importe:', recon) SEPARATOR ' | \n') - FROM ( - SELECT ASIEN, - SUM(IFNULL(ROUND(Eurodebe, 2), 0)) - SUM(IFNULL(ROUND(EUROHABER, 2), 0)) recon - FROM XDiario - WHERE NOT enlazado - GROUP BY ASIEN - HAVING ABS(SUM(IFNULL(ROUND(Eurodebe, 2), 0)) - SUM(IFNULL(ROUND(EUROHABER, 2), 0))) > 0.01 - ) sub - HAVING COUNT(*); UPDATE XDiario xd JOIN ( @@ -78768,7 +80635,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `XDiario_checkDate`(vDate DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `XDiario_checkDate`(vDate DATE) proc: BEGIN /** * Comprueba si la fecha pasada esta en el rango @@ -78797,6 +80664,62 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `xdiario_new` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` PROCEDURE `xdiario_new`( + vBookNumber INT, + vDated DATE, + vSubaccount VARCHAR(12), + vAccount VARCHAR(12), + vConcept VARCHAR(25), + vDebit DOUBLE, + vCredit DOUBLE, + vEuro DOUBLE, + vSerie CHAR(1), + vInvoice VARCHAR(8), + vVat DOUBLE, + vRe DOUBLE, + vAux TINYINT, + vCompanyFk INT, + OUT vNewBookNumber INT +) +BEGIN + IF vBookNumber IS NULL THEN + CALL ledger_nextTx(YEAR(vDated), vBookNumber); + END IF; + + INSERT INTO XDiario + SET ASIEN = vBookNumber, + FECHA = vDated, + SUBCTA = vSubaccount, + CONTRA = vAccount, + CONCEPTO = vConcept, + EURODEBE = vDebit, + EUROHABER = vCredit, + BASEEURO = vEuro, + SERIE = vSerie, + FACTURA = vInvoice, + IVA = vVat, + RECEQUIV = vRe, + AUXILIAR = IF(vAux = FALSE, NULL, '*'), + MONEDAUSO = 2, + empresa_id = vCompanyFk; + + SET vNewBookNumber = vBookNumber; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zoneClosure_recalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -78805,7 +80728,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneClosure_recalc`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zoneClosure_recalc`() proc: BEGIN /** * Recalculates the delivery time (hour) for every zone in days + scope in future @@ -78865,7 +80788,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_calcTree`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zoneGeo_calcTree`() BEGIN /** * Calculates the #path, #lft, #rgt, #sons and #depth columns of @@ -78909,7 +80832,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_calcTreeRec`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zoneGeo_calcTreeRec`( vSelf INT, vPath VARCHAR(255), vDepth INT, @@ -78991,7 +80914,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_checkName`(vName VARCHAR(255)) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zoneGeo_checkName`(vName VARCHAR(255)) BEGIN IF vName = '' THEN SIGNAL SQLSTATE '45000' @@ -79013,7 +80936,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_delete`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zoneGeo_delete`(vSelf INT) BEGIN /** * Deletes a node from the #zoneGeo table. Also sets a mark @@ -79039,7 +80962,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_doCalc`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zoneGeo_doCalc`() proc: BEGIN /** * Recalculates the zones tree. @@ -79081,7 +81004,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_setParent`(vSelf INT, vParentFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zoneGeo_setParent`(vSelf INT, vParentFk INT) BEGIN /** * Updates the parent of a node. Also sets a mark @@ -79110,7 +81033,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zoneGeo_throwNotEditable`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zoneGeo_throwNotEditable`() BEGIN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Column `geoFk` cannot be modified'; @@ -79130,7 +81053,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_excludeFromGeo`(vZoneGeo INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_excludeFromGeo`(vZoneGeo INT) BEGIN /** * Excluye zonas a partir un geoFk. @@ -79163,57 +81086,59 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getAddresses`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getAddresses`( vSelf INT, - vLanded DATE + vShipped DATE, + vDepartmentFk INT ) BEGIN /** * Devuelve un listado de todos los clientes activos * con consignatarios a los que se les puede - * vender producto para esa zona y no tiene un ticket - * para ese día. + * vender producto para esa zona. * * @param vSelf Id de zona - * @param vDated Fecha de entrega + * @param vShipped Fecha de envio + * @param vDepartmentFk Id de departamento * @return Un select */ CALL zone_getPostalCode(vSelf); - WITH notHasTicket AS ( - SELECT id - FROM vn.client - WHERE id NOT IN ( - SELECT clientFk - FROM vn.ticket - WHERE landed BETWEEN vLanded AND util.dayEnd(vLanded) - ) + WITH clientWithTicket AS ( + SELECT clientFk + FROM vn.ticket + WHERE shipped BETWEEN vShipped AND util.dayEnd(vShipped) ) - SELECT c.id clientFk, - c.name, - c.phone, - bt.description, - c.salesPersonFk, - u.name username, - aai.invoiced, - cnb.lastShipped - FROM vn.client c - JOIN notHasTicket ON notHasTicket.id = c.id - LEFT JOIN account.`user` u ON u.id = c.salesPersonFk - JOIN vn.`address` a ON a.clientFk = c.id - JOIN vn.postCode pc ON pc.code = a.postalCode - JOIN vn.town t ON t.id = pc.townFk AND t.provinceFk = a.provinceFk - JOIN vn.zoneGeo zg ON zg.name = a.postalCode - JOIN tmp.zoneNodes zn ON zn.geoFk = pc.geoFk - LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = c.id - LEFT JOIN vn.annualAverageInvoiced aai ON aai.clientFk = c.id - JOIN vn.clientType ct ON ct.code = c.typeFk - JOIN vn.businessType bt ON bt.code = c.businessTypeFk - WHERE a.isActive - AND c.isActive - AND ct.code = 'normal' - AND bt.code <> 'worker' - GROUP BY c.id; + SELECT c.id, + c.name, + c.phone, + bt.description, + c.salesPersonFk, + u.name username, + aai.invoiced, + cnb.lastShipped, + cwt.clientFk + FROM vn.client c + JOIN vn.worker w ON w.id = c.salesPersonFk + JOIN vn.workerDepartment wd ON wd.workerFk = w.id + JOIN vn.department d ON d.id = wd.departmentFk + LEFT JOIN clientWithTicket cwt ON cwt.clientFk = c.id + LEFT JOIN account.`user` u ON u.id = c.salesPersonFk + JOIN vn.`address` a ON a.clientFk = c.id + JOIN vn.postCode pc ON pc.code = a.postalCode + JOIN vn.town t ON t.id = pc.townFk AND t.provinceFk = a.provinceFk + JOIN vn.zoneGeo zg ON zg.name = a.postalCode + JOIN tmp.zoneNodes zn ON zn.geoFk = pc.geoFk + LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = c.id + LEFT JOIN vn.annualAverageInvoiced aai ON aai.clientFk = c.id + JOIN vn.clientType ct ON ct.code = c.typeFk + JOIN vn.businessType bt ON bt.code = c.businessTypeFk + WHERE a.isActive + AND c.isActive + AND ct.code = 'normal' + AND bt.code <> 'worker' + AND (d.id = vDepartmentFk OR NOT vDepartmentFk) + GROUP BY c.id; DROP TEMPORARY TABLE tmp.zoneNodes; END ;; @@ -79232,7 +81157,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getAgency`(vAddress INT, vLanded DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getAgency`(vAddress INT, vLanded DATE) BEGIN /** * Devuelve el listado de agencias disponibles para la fecha @@ -79281,7 +81206,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getAvailable`(vAddress INT, vLanded DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getAvailable`(vAddress INT, vLanded DATE) BEGIN CALL zone_getFromGeo(address_getGeo(vAddress)); CALL zone_getOptionsForLanding(vLanded, FALSE); @@ -79307,7 +81232,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getClosed`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getClosed`() proc:BEGIN /** * Devuelve una tabla con las zonas cerradas para hoy @@ -79354,7 +81279,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getCollisions`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getCollisions`() BEGIN /** * Calcula si para un mismo codigo postal y dia @@ -79457,7 +81382,8 @@ BEGIN DROP TEMPORARY TABLE geoCollision, tmp.zone, - tmp.zoneNodes; + tmp.zoneNodes, + tmp.zoneOption; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -79474,7 +81400,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getEvents`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getEvents`( vGeoFk INT, vAgencyModeFk INT) BEGIN @@ -79551,7 +81477,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getFromGeo`(vGeoFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getFromGeo`(vGeoFk INT) BEGIN /** * Returns all zones which have the passed geo included. @@ -79620,7 +81546,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getLanded`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT, vShowExpiredZones BOOLEAN) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getLanded`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT, vShowExpiredZones BOOLEAN) BEGIN /** * Devuelve una tabla temporal con el dia de recepcion para vShipped. @@ -79680,7 +81606,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getLeaves`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getLeaves`( vSelf INT, vParentFk INT, vSearch VARCHAR(255), @@ -79816,7 +81742,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getOptionsForLanding`(vLanded DATE, vShowExpiredZones BOOLEAN) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getOptionsForLanding`(vLanded DATE, vShowExpiredZones BOOLEAN) BEGIN /** * Gets computed options for the passed zones and delivery date. @@ -79893,7 +81819,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getOptionsForShipment`(vShipped DATE, vShowExpiredZones BOOLEAN) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getOptionsForShipment`(vShipped DATE, vShowExpiredZones BOOLEAN) BEGIN /** * Gets computed options for the passed zones and shipping date. @@ -79981,7 +81907,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getPostalCode`(vSelf INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getPostalCode`(vSelf INT) BEGIN /** * Devuelve los códigos postales incluidos en una zona @@ -80040,7 +81966,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getShipped`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vShowExpiredZones BOOLEAN) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getShipped`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vShowExpiredZones BOOLEAN) BEGIN /** * Devuelve la mínima fecha de envío para cada warehouse @@ -80104,7 +82030,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getState`(vDated DATE) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getState`(vDated DATE) BEGIN /** * Devuelve las zonas y el estado para la fecha solicitada @@ -80159,7 +82085,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_getWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_getWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT) BEGIN /** * Devuelve el listado de agencias disponibles para la fecha, @@ -80209,7 +82135,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `zone_upcomingDeliveries`() +CREATE DEFINER=`vn`@`localhost` PROCEDURE `zone_upcomingDeliveries`() BEGIN DECLARE vForwardDays INT; @@ -80323,29 +82249,6 @@ SET character_set_client = utf8; 1 AS `isRiskFree` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Agencias_province__` --- - -DROP TABLE IF EXISTS `Agencias_province__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Agencias_province__` ( - `province_id` smallint(6) unsigned NOT NULL, - `agency_id` smallint(5) unsigned NOT NULL, - `zona` tinyint(4) NOT NULL, - `warehouse_id` smallint(6) unsigned NOT NULL, - `route` tinyint(4) NOT NULL COMMENT 'Etiqueta zeleris', - `isVolumetric` tinyint(1) NOT NULL DEFAULT 0, - PRIMARY KEY (`province_id`,`agency_id`,`warehouse_id`), - KEY `warehouse_id` (`warehouse_id`), - KEY `agency_id` (`agency_id`), - CONSTRAINT `Agencias_province___ibfk_1` FOREIGN KEY (`province_id`) REFERENCES `vn`.`province` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `Agencias_province___ibfk_2` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `Agencias_province___ibfk_3` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agency` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Articles` -- @@ -80395,7 +82298,6 @@ SET character_set_client = utf8; 1 AS `hasKgPrice`, 1 AS `Equivalente`, 1 AS `Imprimir`, - 1 AS `Familia__`, 1 AS `do_photo`, 1 AS `odbc_date`, 1 AS `isFloramondo`, @@ -80405,21 +82307,6 @@ SET character_set_client = utf8; 1 AS `packingOut` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Baldas__` --- - -DROP TABLE IF EXISTS `Baldas__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Baldas__` ( - `Id_Estanterias` int(11) NOT NULL, - `Id_Baldas` int(11) NOT NULL, - `h` int(11) NOT NULL, - PRIMARY KEY (`Id_Estanterias`,`Id_Baldas`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Bancos` -- @@ -80468,25 +82355,6 @@ SET character_set_client = utf8; 1 AS `insuranceExpired` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Brasa__` --- - -DROP TABLE IF EXISTS `Brasa__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Brasa__` ( - `Id_Cliente` int(10) unsigned NOT NULL DEFAULT 0, - `Cliente` varchar(50) NOT NULL, - `Vista` int(10) unsigned NOT NULL DEFAULT 0, - `Reg` bigint(21) unsigned NOT NULL DEFAULT 0, - `Consumo` double NOT NULL, - `Grupo` int(10) unsigned NOT NULL, - PRIMARY KEY (`Id_Cliente`), - KEY `Index_1` (`Id_Cliente`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Cajas` -- @@ -80518,20 +82386,6 @@ SET character_set_client = utf8; 1 AS `Proveedores_account_Id` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Clases__` --- - -DROP TABLE IF EXISTS `Clases__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Clases__` ( - `Id_Clase` int(11) NOT NULL DEFAULT 0, - `Clase` varchar(50) DEFAULT NULL, - PRIMARY KEY (`Id_Clase`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Clientes` -- @@ -80586,92 +82440,6 @@ SET character_set_client = utf8; 1 AS `typeFk` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Clientes_dits__` --- - -DROP TABLE IF EXISTS `Clientes_dits__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Clientes_dits__` ( - `idClientes_dits` int(11) NOT NULL AUTO_INCREMENT, - `idaccion_dits` int(11) NOT NULL, - `ODBC_DATE` timestamp NOT NULL DEFAULT current_timestamp(), - `Id_Ticket` int(11) NOT NULL, - `Id_Trabajador` int(11) NOT NULL, - `value_old` varchar(100) DEFAULT NULL, - `value_new` varchar(100) DEFAULT NULL, - PRIMARY KEY (`idClientes_dits`), - KEY `idaccion_dits` (`idaccion_dits`), - CONSTRAINT `Clientes_dits___ibfk_1` FOREIGN KEY (`idaccion_dits`) REFERENCES `accion_dits__` (`idaccion_dits`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Clientes_empresa__` --- - -DROP TABLE IF EXISTS `Clientes_empresa__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Clientes_empresa__` ( - `Id_Clientes_empresa` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `Id_Cliente` int(11) NOT NULL, - `empresa_id` int(10) unsigned NOT NULL, - `fecha_ini` date NOT NULL, - `fecha_fin` date NOT NULL, - PRIMARY KEY (`Id_Clientes_empresa`), - KEY `empresa_id_idx` (`empresa_id`), - CONSTRAINT `Clientes_empresaCompany_Fk` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON DELETE NO ACTION -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Clientes_event__` --- - -DROP TABLE IF EXISTS `Clientes_event__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Clientes_event__` ( - `Id_Cliente` int(11) NOT NULL, - `quantity` tinyint(3) unsigned NOT NULL, - `odbc_date` timestamp NOT NULL DEFAULT current_timestamp(), - PRIMARY KEY (`Id_Cliente`), - CONSTRAINT `Clientes_event___ibfk_1` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Clientes_potenciales__` --- - -DROP TABLE IF EXISTS `Clientes_potenciales__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Clientes_potenciales__` ( - `id` int(11) NOT NULL, - `PAIS` varchar(12) DEFAULT NULL, - `ACTIVIDAD` varchar(10) DEFAULT NULL, - `NOMBRE` varchar(45) NOT NULL DEFAULT '', - `PROVINCIA` varchar(25) DEFAULT NULL, - `POBLACION` varchar(45) NOT NULL DEFAULT '', - `CP` varchar(10) DEFAULT NULL, - `DIR_POSTAL` varchar(45) NOT NULL DEFAULT '', - `TELEFONO` varchar(12) NOT NULL DEFAULT '', - `TELEFONO2` varchar(12) NOT NULL DEFAULT '', - `FAX` varchar(12) NOT NULL DEFAULT '', - `E-MAIL` varchar(45) DEFAULT NULL, - `pagweb` varchar(45) DEFAULT NULL, - `SERVICIOS` varchar(45) DEFAULT NULL, - `state_id` smallint(6) DEFAULT 0 COMMENT '0 no se ha hecho nada\n1 ya existe el cliente\n2 cliente conseguido\n3 desestimado', - `Id_Trabajador` smallint(6) DEFAULT NULL, - `Notas` varchar(255) DEFAULT NULL, - `odbc_date` timestamp NULL DEFAULT current_timestamp(), - PRIMARY KEY (`NOMBRE`,`POBLACION`,`DIR_POSTAL`,`TELEFONO`,`TELEFONO2`,`FAX`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Comparativa` -- @@ -80725,7 +82493,6 @@ SET character_set_client = utf8; 1 AS `Id_Trabajador`, 1 AS `weight`, 1 AS `dispatched`, - 1 AS `container_id`, 1 AS `itemOriginalFk` */; SET character_set_client = @saved_cs_client; @@ -80744,30 +82511,6 @@ SET character_set_client = utf8; 1 AS `odbc_date` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Compres_ok__` --- - -DROP TABLE IF EXISTS `Compres_ok__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Compres_ok__` ( - `Id_Compra` int(11) NOT NULL, - `valor` tinyint(3) unsigned NOT NULL DEFAULT 0, - `odbc_date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `original_quantity` double DEFAULT NULL, - `Id_Trabajador` int(10) unsigned NOT NULL, - `Id_Accion` varchar(45) NOT NULL, - `Id_Compra_ok` int(11) NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`Id_Compra_ok`), - KEY `Id_Movimiento` (`Id_Compra`), - KEY `Id_Accion` (`Id_Accion`), - KEY `Compres_ok_Id_Trabajador_idx` (`Id_Trabajador`), - CONSTRAINT `Compres_ok_Id_Trabajador` FOREIGN KEY (`Id_Trabajador`) REFERENCES `vn`.`worker` (`id`), - CONSTRAINT `Compres_ok___ibfk_1` FOREIGN KEY (`Id_Compra`) REFERENCES `vn`.`buy` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Consignatarios` -- @@ -80794,39 +82537,6 @@ SET character_set_client = utf8; 1 AS `active` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Consignatarios_devices__` --- - -DROP TABLE IF EXISTS `Consignatarios_devices__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Consignatarios_devices__` ( - `Id_Consigna` int(11) NOT NULL, - `serialNumber` varchar(45) NOT NULL, - `notas` varchar(45) DEFAULT NULL, - PRIMARY KEY (`Id_Consigna`,`serialNumber`), - CONSTRAINT `Condigna_devices` FOREIGN KEY (`Id_Consigna`) REFERENCES `vn`.`address` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Conteo__` --- - -DROP TABLE IF EXISTS `Conteo__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Conteo__` ( - `Id_Conteo` int(11) NOT NULL AUTO_INCREMENT, - `Id_Article` int(11) NOT NULL, - `Fecha` timestamp NOT NULL DEFAULT current_timestamp(), - `dispositivo` varchar(15) DEFAULT NULL, - `warehouse_id` int(10) unsigned NOT NULL DEFAULT 1, - PRIMARY KEY (`Id_Conteo`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Cubos` -- @@ -80852,7 +82562,8 @@ SET character_set_client = utf8; 1 AS `Suben`, 1 AS `Base`, 1 AS `box`, - 1 AS `costeRetorno` */; + 1 AS `costeRetorno`, + 1 AS `isActive` */; SET character_set_client = @saved_cs_client; -- @@ -80918,24 +82629,6 @@ SET character_set_client = utf8; 1 AS `Id_Entrada` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Entradas_kop__` --- - -DROP TABLE IF EXISTS `Entradas_kop__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Entradas_kop__` ( - `Id_Entradas_kop` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `Id_Entrada` int(11) NOT NULL, - `kop` int(11) DEFAULT NULL, - `sub` mediumint(8) unsigned DEFAULT NULL, - PRIMARY KEY (`Id_Entradas_kop`), - KEY `entradas_entradas_kop_idx` (`Id_Entrada`), - CONSTRAINT `entradas_entradas_kop` FOREIGN KEY (`Id_Entrada`) REFERENCES `vn`.`entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Entradas_orden` -- @@ -80949,85 +82642,6 @@ SET character_set_client = utf8; 1 AS `orden` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Espionajes__` --- - -DROP TABLE IF EXISTS `Espionajes__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Espionajes__` ( - `idEspionaje` int(11) NOT NULL AUTO_INCREMENT, - `Id_Trabajador` varchar(45) DEFAULT NULL, - `Fecha` date DEFAULT NULL, - `HoraEntrada` time DEFAULT NULL, - `HoraSalida` time DEFAULT NULL, - `Id_Equipo` int(11) DEFAULT NULL, - PRIMARY KEY (`idEspionaje`), - KEY `index` (`Id_Trabajador`,`Fecha`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Estados__` --- - -DROP TABLE IF EXISTS `Estados__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Estados__` ( - `Id_Estado` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `Estado` varchar(50) DEFAULT NULL, - PRIMARY KEY (`Id_Estado`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Familias__` --- - -DROP TABLE IF EXISTS `Familias__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Familias__` ( - `Familia` varchar(3) NOT NULL, - `Subcuenta` varchar(10) DEFAULT NULL, - `Descripcion` varchar(50) DEFAULT NULL, - PRIMARY KEY (`Familia`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Forms__` --- - -DROP TABLE IF EXISTS `Forms__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Forms__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `titulo` varchar(50) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Grupos__` --- - -DROP TABLE IF EXISTS `Grupos__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Grupos__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(50) NOT NULL, - `Grupo` varchar(45) NOT NULL, - `observation_type_id` tinyint(3) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `name` (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Impresoras` -- @@ -81044,38 +82658,6 @@ SET character_set_client = utf8; 1 AS `isLabeler` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Informes__` --- - -DROP TABLE IF EXISTS `Informes__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Informes__` ( - `Id_Informe` tinyint(3) unsigned NOT NULL, - `Informe` varchar(50) DEFAULT NULL, - PRIMARY KEY (`Id_Informe`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Jefes__` --- - -DROP TABLE IF EXISTS `Jefes__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Jefes__` ( - `Id_Trabajador` int(10) unsigned NOT NULL, - `Id_Jefe` int(10) unsigned NOT NULL, - `Departamento` varchar(45) NOT NULL, - PRIMARY KEY (`Id_Trabajador`,`Id_Jefe`), - KEY `trabajador_jefe_idx` (`Id_Jefe`), - CONSTRAINT `trabajador_jefe` FOREIGN KEY (`Id_Jefe`) REFERENCES `vn`.`worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `trabajador_trabajador` FOREIGN KEY (`Id_Trabajador`) REFERENCES `vn`.`worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Deprecated 27-02-2023'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Monedas` -- @@ -81091,33 +82673,6 @@ SET character_set_client = utf8; 1 AS `Cambio` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Monitoring__` --- - -DROP TABLE IF EXISTS `Monitoring__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Monitoring__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `equipo_id` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `user_id` int(10) unsigned NOT NULL, - `form_id` int(11) NOT NULL, - `cliente_id` int(11) NOT NULL, - `ticket_id` int(11) NOT NULL, - `ODBC_TIME` timestamp NOT NULL DEFAULT current_timestamp(), - PRIMARY KEY (`id`), - KEY `equipo_id` (`equipo_id`,`user_id`,`form_id`,`cliente_id`,`ticket_id`), - KEY `user_id` (`user_id`), - KEY `form_id` (`form_id`), - KEY `cliente_id` (`cliente_id`), - KEY `ticket_id` (`ticket_id`), - CONSTRAINT `Monitoring_FK` FOREIGN KEY (`equipo_id`) REFERENCES `vn`.`host` (`code`) ON UPDATE CASCADE, - CONSTRAINT `Monitoring___ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `vn`.`worker` (`id`), - CONSTRAINT `Monitoring___ibfk_3` FOREIGN KEY (`form_id`) REFERENCES `Forms__` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Movimientos` -- @@ -81143,23 +82698,6 @@ SET character_set_client = utf8; 1 AS `isAdded` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Movimientos_avisar__` --- - -DROP TABLE IF EXISTS `Movimientos_avisar__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Movimientos_avisar__` ( - `Id_Movimiento` int(11) NOT NULL, - `Id_Remitente` int(11) DEFAULT NULL, - PRIMARY KEY (`Id_Movimiento`), - KEY `Movimiento` (`Id_Movimiento`), - KEY `Remitente` (`Id_Remitente`), - CONSTRAINT `Id_Movimientos_avisar_fk` FOREIGN KEY (`Id_Movimiento`) REFERENCES `vn`.`sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Movimientos_componentes` -- @@ -81194,40 +82732,6 @@ SET character_set_client = utf8; 1 AS `stateFk` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Movimientos_revisar__` --- - -DROP TABLE IF EXISTS `Movimientos_revisar__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Movimientos_revisar__` ( - `Id_Movimiento` int(11) NOT NULL, - `Comentario` varchar(255) DEFAULT NULL, - `Revisado` tinyint(1) NOT NULL DEFAULT 0, - `Id_Remitente` int(11) DEFAULT NULL, - `Id_Destinatario` int(11) DEFAULT NULL, - PRIMARY KEY (`Id_Movimiento`), - KEY `Remitente` (`Id_Remitente`), - KEY `Destinatario` (`Id_Destinatario`), - CONSTRAINT `Movimientos_revisar___ibfk_1` FOREIGN KEY (`Id_Movimiento`) REFERENCES `vn`.`sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Objetivos__` --- - -DROP TABLE IF EXISTS `Objetivos__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Objetivos__` ( - `Periodo` int(11) NOT NULL, - `Objetivo` double NOT NULL, - PRIMARY KEY (`Periodo`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Deprecated 27-02-2023'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Ordenes` -- @@ -81308,26 +82812,6 @@ SET character_set_client = utf8; 1 AS `hasDailyInvoice` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Permisos__` --- - -DROP TABLE IF EXISTS `Permisos__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Permisos__` ( - `Id_Grupo` int(10) unsigned NOT NULL, - `Id_Trabajador` int(10) unsigned NOT NULL, - `empresa_id` int(10) unsigned NOT NULL DEFAULT 442, - PRIMARY KEY (`Id_Grupo`,`Id_Trabajador`), - KEY `empresa_id` (`empresa_id`), - KEY `Permisos_ibfk_3_idx` (`Id_Trabajador`), - CONSTRAINT `PermisosCompany_Fk` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `Permisos___ibfk_2` FOREIGN KEY (`Id_Grupo`) REFERENCES `Grupos__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `Permisos___ibfk_3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `vn`.`worker` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `PreciosEspeciales` -- @@ -81357,7 +82841,6 @@ SET character_set_client = utf8; 1 AS `cuenta`, 1 AS `pais_id`, 1 AS `NIF`, - 1 AS `Agricola`, 1 AS `Telefono`, 1 AS `cuentaret`, 1 AS `ComisionProveedor`, @@ -81397,41 +82880,6 @@ SET character_set_client = utf8; 1 AS `Id_Proveedor` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Proveedores_comunicados__` --- - -DROP TABLE IF EXISTS `Proveedores_comunicados__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Proveedores_comunicados__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Id_Proveedor` int(10) unsigned NOT NULL, - `escrito_id` int(11) NOT NULL, - `fecha` timestamp NULL DEFAULT current_timestamp(), - PRIMARY KEY (`id`), - KEY `Proveedor` (`Id_Proveedor`), - KEY `Escrito` (`escrito_id`), - CONSTRAINT `Proveedores_comunicados___ibfk_4` FOREIGN KEY (`escrito_id`) REFERENCES `Proveedores_escritos__` (`id`) ON UPDATE CASCADE, - CONSTRAINT `Proveedores_comunicados_supplierFk` FOREIGN KEY (`Id_Proveedor`) REFERENCES `vn`.`supplier` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Proveedores_escritos__` --- - -DROP TABLE IF EXISTS `Proveedores_escritos__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Proveedores_escritos__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `escrito` varchar(45) NOT NULL, - `informe` varchar(45) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Proveedores_gestdoc` -- @@ -81466,21 +82914,6 @@ SET character_set_client = utf8; 1 AS `conciliado` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Recibos_recorded__` --- - -DROP TABLE IF EXISTS `Recibos_recorded__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Recibos_recorded__` ( - `Id_Recibos` int(11) NOT NULL, - `recorded` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Marcado si se ha contabilizado', - PRIMARY KEY (`Id_Recibos`), - CONSTRAINT `Recibos_recorded___ibfk_1` FOREIGN KEY (`Id_Recibos`) REFERENCES `vn`.`receipt` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Deprecated 27-02-2023'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Remesas` -- @@ -81496,34 +82929,6 @@ SET character_set_client = utf8; 1 AS `empresa_id` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Reservas__` --- - -DROP TABLE IF EXISTS `Reservas__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Reservas__` ( - `Id_Reserva` int(11) NOT NULL AUTO_INCREMENT, - `Id_Ticket` int(11) DEFAULT 0, - `Fecha` datetime DEFAULT NULL, - `Alias` varchar(50) DEFAULT NULL, - `article` varchar(50) DEFAULT NULL, - `medida` varchar(50) DEFAULT NULL, - `categoria` varchar(50) DEFAULT NULL, - `color` varchar(50) DEFAULT NULL, - `origen` varchar(50) DEFAULT NULL, - `cantidad` int(11) DEFAULT 0, - `Id_Article` double DEFAULT 0, - `buyFk` int(11) NOT NULL, - `grouping` int(11) DEFAULT NULL, - `packing` int(11) DEFAULT NULL, - PRIMARY KEY (`Id_Reserva`), - KEY `Id_1` (`Id_Ticket`), - KEY `Id_Article` (`Id_Article`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Deprecated 27-02-2023'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Rutas` -- @@ -81550,38 +82955,6 @@ SET character_set_client = utf8; 1 AS `description` */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `Saldos_Prevision` --- - -DROP TABLE IF EXISTS `Saldos_Prevision`; -/*!50001 DROP VIEW IF EXISTS `Saldos_Prevision`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `Saldos_Prevision` AS SELECT - 1 AS `Saldos_Prevision_id`, - 1 AS `Descripcion`, - 1 AS `Importe`, - 1 AS `Fecha`, - 1 AS `Id_Banco`, - 1 AS `empresa_id` */; -SET character_set_client = @saved_cs_client; - --- --- Table structure for table `Series__` --- - -DROP TABLE IF EXISTS `Series__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Series__` ( - `Id_Serie` varchar(2) NOT NULL, - `Serie` varchar(30) DEFAULT NULL, - `Cuenta` varchar(10) DEFAULT NULL, - PRIMARY KEY (`Id_Serie`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Split_lines` -- @@ -81642,7 +83015,6 @@ SET character_set_client = utf8; 1 AS `Id_Trabajador`, 1 AS `Observaciones`, 1 AS `Firmado`, - 1 AS `Etiquetasemitidas`, 1 AS `PedidoImpreso`, 1 AS `Hora`, 1 AS `blocked`, @@ -81653,22 +83025,6 @@ SET character_set_client = utf8; 1 AS `totalWithoutVat` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Tickets_stack__` --- - -DROP TABLE IF EXISTS `Tickets_stack__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Tickets_stack__` ( - `Id_Ticket` int(11) NOT NULL, - `orden` smallint(5) unsigned NOT NULL, - `label_number` smallint(6) DEFAULT 0, - `preparado` tinyint(4) DEFAULT 0, - PRIMARY KEY (`Id_Ticket`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Tickets_state` -- @@ -81731,32 +83087,13 @@ SET character_set_client = utf8; 1 AS `Id_Trabajador`, 1 AS `life`, 1 AS `isPackaging`, - 1 AS `density`, 1 AS `inventory`, 1 AS `odbc_date`, 1 AS `confeccion`, 1 AS `Temperatura`, - 1 AS `promo`, - 1 AS `maneuver`, - 1 AS `target`, - 1 AS `top_margin`, - 1 AS `profit` */; + 1 AS `promo` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Tipos_f11__` --- - -DROP TABLE IF EXISTS `Tipos_f11__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Tipos_f11__` ( - `f11_id` tinyint(4) NOT NULL AUTO_INCREMENT, - `description` varchar(15) NOT NULL, - PRIMARY KEY (`f11_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Trabajadores` -- @@ -81846,21 +83183,6 @@ SET character_set_client = utf8; 1 AS `gasoline` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `accion_dits__` --- - -DROP TABLE IF EXISTS `accion_dits__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `accion_dits__` ( - `idaccion_dits` int(11) NOT NULL AUTO_INCREMENT, - `accion` varchar(255) DEFAULT NULL, - PRIMARY KEY (`idaccion_dits`), - UNIQUE KEY `accion_UNIQUE` (`accion`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `account_conciliacion` -- @@ -81909,24 +83231,6 @@ SET character_set_client = utf8; 1 AS `description` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `agencia_descuadre__` --- - -DROP TABLE IF EXISTS `agencia_descuadre__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `agencia_descuadre__` ( - `agencia_descuadre_id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Id_Ticket` int(11) NOT NULL, - `date` date NOT NULL, - `price` double(7,2) NOT NULL, - `Consignatario` varchar(50) NOT NULL, - `Tipo` varchar(30) NOT NULL, - PRIMARY KEY (`agencia_descuadre_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `agency` -- @@ -81943,50 +83247,6 @@ SET character_set_client = utf8; 1 AS `workCenterFk` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `agency_hour__` --- - -DROP TABLE IF EXISTS `agency_hour__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `agency_hour__` ( - `agency_hour_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `week_day` tinyint(3) unsigned DEFAULT NULL COMMENT 'funcion de mysql Lunes = 0, Domingo = 6', - `agency_id` smallint(5) unsigned DEFAULT NULL, - `warehouse_id` smallint(5) unsigned DEFAULT NULL, - `province_id` smallint(5) unsigned DEFAULT NULL, - `subtract_day` tinyint(10) unsigned NOT NULL COMMENT 'dias a restar de la Fecha de entrega', - `max_hour` tinyint(3) unsigned NOT NULL COMMENT 'maxima hora hasta la cual se pueden hacer pedidos', - PRIMARY KEY (`agency_hour_id`), - UNIQUE KEY `week_day` (`week_day`,`agency_id`,`warehouse_id`,`province_id`,`max_hour`), - KEY `agency_id` (`agency_id`), - KEY `warehouse_id` (`warehouse_id`), - KEY `province_id` (`province_id`), - CONSTRAINT `agency_hour___ibfk_1` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agency` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `agency_hour___ibfk_2` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `agency_hour___ibfk_3` FOREIGN KEY (`province_id`) REFERENCES `vn`.`province` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `agency_warehouse__` --- - -DROP TABLE IF EXISTS `agency_warehouse__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `agency_warehouse__` ( - `agency_id` smallint(5) unsigned NOT NULL, - `warehouse_id` smallint(5) unsigned NOT NULL DEFAULT 1, - `Vista` tinyint(3) unsigned NOT NULL DEFAULT 0, - PRIMARY KEY (`agency_id`,`warehouse_id`), - KEY `warehouse_id` (`warehouse_id`), - CONSTRAINT `agency_warehouse___ibfk_1` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agency` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `agency_warehouse___ibfk_2` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `airline` -- @@ -82035,8 +83295,7 @@ SET character_set_client = utf8; 1 AS `Id_Trabajador`, 1 AS `Id_Responsable`, 1 AS `department_id`, - 1 AS `recibida_id`, - 1 AS `farmingFk` */; + 1 AS `recibida_id` */; SET character_set_client = @saved_cs_client; -- @@ -82311,8 +83570,7 @@ SET character_set_client = utf8; 1 AS `packingOut`, 1 AS `itemOriginalFk`, 1 AS `itemOriginalName`, - 1 AS `gramsMax`, - 1 AS `minQuantity` */; + 1 AS `gramsMax` */; SET character_set_client = @saved_cs_client; -- @@ -82325,7 +83583,6 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `buy_edi` AS SELECT 1 AS `id`, - 1 AS `barcode`, 1 AS `entry_year`, 1 AS `delivery_number`, 1 AS `fec`, @@ -82402,37 +83659,6 @@ SET character_set_client = utf8; 1 AS `description` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `call_information__` --- - -DROP TABLE IF EXISTS `call_information__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `call_information__` ( - `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `Descripcio` text NOT NULL, - `Conclusio` tinyint(3) unsigned NOT NULL, - `Id_Cliente` int(11) NOT NULL, - `fecha` date NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `call_option__` --- - -DROP TABLE IF EXISTS `call_option__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `call_option__` ( - `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `descripcion` varchar(20) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `cdr` -- @@ -82522,20 +83748,6 @@ SET character_set_client = utf8; 1 AS `consecuencia` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `cl_dep__` --- - -DROP TABLE IF EXISTS `cl_dep__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cl_dep__` ( - `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `departamento` varchar(20) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `cl_det` -- @@ -82585,34 +83797,6 @@ SET character_set_client = utf8; 1 AS `motivo` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `cl_pet__` --- - -DROP TABLE IF EXISTS `cl_pet__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cl_pet__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `peticion` varchar(15) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `cl_que__` --- - -DROP TABLE IF EXISTS `cl_que__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cl_que__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `queja` varchar(25) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `cl_res` -- @@ -82641,39 +83825,6 @@ SET character_set_client = utf8; 1 AS `addressFk` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `commission__` --- - -DROP TABLE IF EXISTS `commission__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `commission__` ( - `commisision_id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `percentage` tinyint(3) unsigned NOT NULL, - `value` float unsigned NOT NULL, - PRIMARY KEY (`commisision_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `config__` --- - -DROP TABLE IF EXISTS `config__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `config__` ( - `id` int(11) NOT NULL, - `generic_item` int(11) NOT NULL COMMENT 'Id del artículo genérico', - `edi_entry` int(11) NOT NULL COMMENT 'Entrada usada para los EKTs', - `lastMana` int(11) NOT NULL DEFAULT 0, - `lastNicho` varchar(10) DEFAULT NULL, - `lastReserve` varchar(10) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `config_host` -- @@ -82692,26 +83843,6 @@ SET character_set_client = utf8; 1 AS `route_days_after` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `config_host_forms__` --- - -DROP TABLE IF EXISTS `config_host_forms__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `config_host_forms__` ( - `config_host_id` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `formname` varchar(56) NOT NULL, - `x` int(8) NOT NULL, - `y` int(8) NOT NULL, - `h` int(8) NOT NULL, - `l` int(8) NOT NULL, - `odbc_date` timestamp NULL DEFAULT current_timestamp(), - PRIMARY KEY (`config_host_id`,`formname`), - CONSTRAINT `config_host_forms_FK` FOREIGN KEY (`config_host_id`) REFERENCES `vn`.`host` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `consignatarios_observation` -- @@ -82727,51 +83858,6 @@ SET character_set_client = utf8; 1 AS `text` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `container__` --- - -DROP TABLE IF EXISTS `container__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `container__` ( - `container_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, - `Continente` varchar(10) DEFAULT NULL, - PRIMARY KEY (`container_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `cooler_path__` --- - -DROP TABLE IF EXISTS `cooler_path__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cooler_path__` ( - `cooler_path_id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(45) DEFAULT NULL, - PRIMARY KEY (`cooler_path_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `cp__` --- - -DROP TABLE IF EXISTS `cp__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cp__` ( - `cp_id` int(11) NOT NULL AUTO_INCREMENT, - `cpd` int(11) NOT NULL, - `cph` int(11) NOT NULL, - `zone_id` smallint(6) DEFAULT NULL, - `town` varchar(45) NOT NULL, - PRIMARY KEY (`cp_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `credit` -- @@ -82788,62 +83874,6 @@ SET character_set_client = utf8; 1 AS `odbc_date` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `credit_card__` --- - -DROP TABLE IF EXISTS `credit_card__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `credit_card__` ( - `credit_card_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `Id_Cliente` int(10) NOT NULL, - `number` varchar(20) NOT NULL, - `expiration_month` tinyint(2) unsigned zerofill NOT NULL, - `expiration_year` tinyint(2) unsigned zerofill NOT NULL, - `priority` tinyint(3) unsigned NOT NULL DEFAULT 1, - `obs` varchar(45) DEFAULT NULL, - PRIMARY KEY (`credit_card_id`), - KEY `Id_Cliente` (`Id_Cliente`), - CONSTRAINT `credit_card___ibfk_1` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `cyc__` --- - -DROP TABLE IF EXISTS `cyc__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cyc__` ( - `Id_Cliente` int(11) NOT NULL, - `Riesgo` double DEFAULT NULL, - `Fecha` timestamp NOT NULL DEFAULT current_timestamp(), - `cyc_id` int(11) NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`cyc_id`), - KEY `Cliente` (`Id_Cliente`), - CONSTRAINT `Cliente` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `cyc_declaration__` --- - -DROP TABLE IF EXISTS `cyc_declaration__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cyc_declaration__` ( - `factura_id` int(10) unsigned NOT NULL, - `Riesgo` double DEFAULT NULL, - `Fecha` date NOT NULL, - `Vencimiento` int(10) NOT NULL DEFAULT 0, - PRIMARY KEY (`factura_id`), - CONSTRAINT `Factura` FOREIGN KEY (`factura_id`) REFERENCES `vn`.`invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `definitivo` -- @@ -82860,37 +83890,6 @@ SET character_set_client = utf8; 1 AS `fecha` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `dock__` --- - -DROP TABLE IF EXISTS `dock__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `dock__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `code` varchar(5) NOT NULL, - `xPos` int(11) DEFAULT NULL, - `yPos` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `code_UNIQUE` (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-03-05'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `duaDismissed__` --- - -DROP TABLE IF EXISTS `duaDismissed__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `duaDismissed__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `ticketFk` varchar(45) NOT NULL, - PRIMARY KEY (`id`,`ticketFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `edi_article` -- @@ -82976,36 +83975,6 @@ SET character_set_client = utf8; 1 AS `company_name` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `edi_testigos__` --- - -DROP TABLE IF EXISTS `edi_testigos__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `edi_testigos__` ( - `id` smallint(6) NOT NULL AUTO_INCREMENT, - `table` varchar(25) NOT NULL, - `field` varchar(32) NOT NULL, - `testigo` varchar(5) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `emp_day_pay__` --- - -DROP TABLE IF EXISTS `emp_day_pay__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `emp_day_pay__` ( - `id` smallint(5) unsigned NOT NULL, - `emp_day_pay` tinyint(3) unsigned NOT NULL, - PRIMARY KEY (`id`,`emp_day_pay`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `empresa` -- @@ -83090,65 +84059,6 @@ SET character_set_client = utf8; 1 AS `observationWorkerCode` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `expeditions_deleted__` --- - -DROP TABLE IF EXISTS `expeditions_deleted__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `expeditions_deleted__` ( - `expeditions_id` int(11) NOT NULL AUTO_INCREMENT, - `agency_id` int(11) NOT NULL, - `ticket_id` int(10) NOT NULL, - `EsBulto` int(11) DEFAULT 1, - `odbc_date` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `reembolso` bit(1) DEFAULT b'0', - `recogida` bit(1) DEFAULT b'0', - `Id_Article` int(11) DEFAULT NULL, - `counter` smallint(5) unsigned NOT NULL, - `checked` tinyint(4) NOT NULL DEFAULT 0, - `completed` tinyint(4) DEFAULT 0, - `expedicion` varchar(45) DEFAULT NULL, - `Id_Trabajador` int(11) DEFAULT NULL, - PRIMARY KEY (`expeditions_id`), - KEY `index1` (`agency_id`), - KEY `index2` (`EsBulto`), - KEY `index3` (`odbc_date`), - KEY `index4` (`ticket_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `expeditions_pictures__` --- - -DROP TABLE IF EXISTS `expeditions_pictures__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `expeditions_pictures__` ( - `Id_Article` int(11) NOT NULL, - `NoImprimirEtiqueta` bit(1) DEFAULT b'0', - PRIMARY KEY (`Id_Article`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `filtros__` --- - -DROP TABLE IF EXISTS `filtros__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `filtros__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(45) NOT NULL, - `sql` varchar(255) NOT NULL, - `Estanteria` tinyint(1) DEFAULT 0, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-21;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `financialProductType` -- @@ -83181,23 +84091,6 @@ SET character_set_client = utf8; 1 AS `airport_in` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `form_query__` --- - -DROP TABLE IF EXISTS `form_query__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `form_query__` ( - `form_query_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, - `query` varchar(50) NOT NULL, - `response1` varchar(10) NOT NULL, - `response2` varchar(10) NOT NULL, - `type_id` enum('gest_doc') NOT NULL, - PRIMARY KEY (`form_query_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-21;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `gastos_resumen` -- @@ -83215,38 +84108,6 @@ SET character_set_client = utf8; 1 AS `empresa_id` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `guillen__` --- - -DROP TABLE IF EXISTS `guillen__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `guillen__` ( - `bulto` tinyint(3) unsigned NOT NULL, - `1` float unsigned NOT NULL, - `2` float unsigned NOT NULL, - `re_exp` float unsigned NOT NULL, - PRIMARY KEY (`bulto`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `guillen_carry__` --- - -DROP TABLE IF EXISTS `guillen_carry__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `guillen_carry__` ( - `carry` tinyint(3) unsigned NOT NULL, - `1` float unsigned NOT NULL, - `2` float unsigned NOT NULL, - `re_exp` float unsigned NOT NULL, - PRIMARY KEY (`carry`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `integra2` -- @@ -83261,23 +84122,6 @@ SET character_set_client = utf8; 1 AS `warehouse_id` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `integra2_escala__` --- - -DROP TABLE IF EXISTS `integra2_escala__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `integra2_escala__` ( - `province_id` smallint(6) unsigned NOT NULL, - `warehouse_id` smallint(6) unsigned NOT NULL, - PRIMARY KEY (`province_id`,`warehouse_id`), - KEY `warehouse_escala_idx` (`warehouse_id`), - CONSTRAINT `province_escala` FOREIGN KEY (`province_id`) REFERENCES `vn`.`province` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `warehouse_escala` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `integra2_province` -- @@ -83291,72 +84135,6 @@ SET character_set_client = utf8; 1 AS `franquicia` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `invoice_observation__` --- - -DROP TABLE IF EXISTS `invoice_observation__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `invoice_observation__` ( - `invoice_observation_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `desde` date NOT NULL, - `hasta` date NOT NULL, - `serie` varchar(1) NOT NULL DEFAULT '0', - `empresa_id` smallint(5) unsigned NOT NULL DEFAULT 0, - `text` text NOT NULL, - PRIMARY KEY (`invoice_observation_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `jerarquia__` --- - -DROP TABLE IF EXISTS `jerarquia__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `jerarquia__` ( - `worker_id` int(10) unsigned NOT NULL, - `boss_id` int(10) unsigned NOT NULL, - `vinculado` tinyint(3) unsigned NOT NULL DEFAULT 0, - PRIMARY KEY (`worker_id`,`boss_id`), - KEY `worker_trabajador` (`worker_id`), - KEY `jerarquiaBossFk_idx` (`boss_id`), - CONSTRAINT `jerarquiaBossFk` FOREIGN KEY (`boss_id`) REFERENCES `account`.`account` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `jerarquiaWorkerFk` FOREIGN KEY (`worker_id`) REFERENCES `account`.`account` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #7258 @deprecated 2023-12-13'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `language__` --- - -DROP TABLE IF EXISTS `language__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `language__` ( - `code` varchar(10) NOT NULL, - `name` varchar(20) NOT NULL, - `active` tinyint(1) NOT NULL DEFAULT 0, - PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `link__` --- - -DROP TABLE IF EXISTS `link__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `link__` ( - `Id_Cliente` int(11) NOT NULL, - `Id_Proveedor` int(11) NOT NULL, - PRIMARY KEY (`Id_Cliente`,`Id_Proveedor`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `mail` -- @@ -83411,19 +84189,6 @@ SET character_set_client = utf8; 1 AS `Nombre` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `nichos__` --- - -DROP TABLE IF EXISTS `nichos__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `nichos__` ( - `id` varchar(5) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `pago` -- @@ -83515,45 +84280,6 @@ SET character_set_client = utf8; 1 AS `isNotified` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `payroll_basess__` --- - -DROP TABLE IF EXISTS `payroll_basess__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `payroll_basess__` ( - `id_payroll_Basess` int(11) NOT NULL AUTO_INCREMENT, - `empresa_id` int(10) NOT NULL, - `id_tipobasess` int(11) NOT NULL, - `valor` double NOT NULL, - `fechadesde` date NOT NULL, - `fechahasta` date DEFAULT NULL, - `contratotemporal` tinyint(1) DEFAULT 0, - PRIMARY KEY (`id_payroll_Basess`), - KEY `payroll_basess_1_idx` (`id_tipobasess`), - KEY `payroll_basess_2_idx` (`empresa_id`), - CONSTRAINT `payroll_basess_1` FOREIGN KEY (`id_tipobasess`) REFERENCES `payroll_tipobasess__` (`id_payroll_tipobasess`) ON DELETE NO ACTION ON UPDATE CASCADE, - CONSTRAINT `payroll_basess_2` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`payrollWorkCenter` (`empresa_id__`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `payroll_bonificaciones__` --- - -DROP TABLE IF EXISTS `payroll_bonificaciones__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `payroll_bonificaciones__` ( - `codtrabajador` int(11) NOT NULL, - `codempresa` int(11) NOT NULL, - `Fecha` date NOT NULL, - `bonificacionSS` double NOT NULL, - PRIMARY KEY (`codtrabajador`,`codempresa`,`Fecha`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `payroll_categorias` -- @@ -83597,49 +84323,6 @@ SET character_set_client = utf8; 1 AS `isException` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `payroll_datos__` --- - -DROP TABLE IF EXISTS `payroll_datos__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `payroll_datos__` ( - `codtrabajador` int(11) NOT NULL, - `codempresa` int(10) NOT NULL, - `Fecha` date NOT NULL, - `conceptoid` int(11) NOT NULL, - `orden` tinyint(4) DEFAULT NULL, - `dias` smallint(6) DEFAULT NULL, - `Importe` decimal(8,2) NOT NULL, - `DH` tinyint(4) DEFAULT NULL, - `T_Paga` tinyint(4) NOT NULL, - `TributaIRPF` tinyint(4) NOT NULL, - PRIMARY KEY (`codtrabajador`,`codempresa`,`conceptoid`,`Fecha`), - KEY `fgkey_payrolldatos_1_idx` (`conceptoid`), - CONSTRAINT `fgkey_payrolldatos_1` FOREIGN KEY (`conceptoid`) REFERENCES `vn`.`payrollComponent` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `payroll_embargos__` --- - -DROP TABLE IF EXISTS `payroll_embargos__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `payroll_embargos__` ( - `codtrabajador` int(11) NOT NULL, - `codempresa` int(10) NOT NULL, - `conceptoid` int(11) NOT NULL, - `Fecha` date NOT NULL, - `pagado` double NOT NULL, - `pendiente` double DEFAULT NULL, - `total` double NOT NULL, - PRIMARY KEY (`codtrabajador`,`codempresa`,`Fecha`,`conceptoid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `payroll_employee` -- @@ -83654,41 +84337,6 @@ SET character_set_client = utf8; 1 AS `workerFk` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `payroll_tipobasess__` --- - -DROP TABLE IF EXISTS `payroll_tipobasess__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `payroll_tipobasess__` ( - `id_payroll_tipobasess` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id_payroll_tipobasess`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `payrroll_apEmpresarial__` --- - -DROP TABLE IF EXISTS `payrroll_apEmpresarial__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `payrroll_apEmpresarial__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `codTrabajador` int(11) NOT NULL, - `Fecha` date NOT NULL, - `CosteEmpresaAT` decimal(8,2) NOT NULL, - `costeEmpresaCC` decimal(8,2) NOT NULL, - `costeEmpresaDesempleo` decimal(8,2) NOT NULL, - `costeEmpresaFP` decimal(8,2) NOT NULL, - `costeEmpresaFogasa` decimal(8,2) NOT NULL, - `costeEmpresaExtra` decimal(8,2) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `plantpassport` -- @@ -83718,22 +84366,6 @@ SET character_set_client = utf8; 1 AS `Paises_Id` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `preparation_exception__` --- - -DROP TABLE IF EXISTS `preparation_exception__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `preparation_exception__` ( - `exception_day` date NOT NULL COMMENT 'preparation day', - `warehouse_id` smallint(6) unsigned DEFAULT NULL, - `percentage` tinyint(2) NOT NULL DEFAULT 0, - UNIQUE KEY `exception_day_UNIQUE` (`exception_day`), - UNIQUE KEY `warehouse_id_UNIQUE` (`warehouse_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `price_fixed` -- @@ -83805,22 +84437,6 @@ SET character_set_client = utf8; 1 AS `geoFk` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `rec_translator__` --- - -DROP TABLE IF EXISTS `rec_translator__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `rec_translator__` ( - `Id_Article` int(11) NOT NULL, - `denominacion` varchar(85) NOT NULL, - PRIMARY KEY (`Id_Article`,`denominacion`), - KEY `id_article_rec_idx` (`Id_Article`), - CONSTRAINT `id_article_rec` FOREIGN KEY (`Id_Article`) REFERENCES `vn`.`item` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `recibida` -- @@ -83854,21 +84470,6 @@ SET character_set_client = utf8; 1 AS `expenseFkDeductible` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `recibida_agricola__` --- - -DROP TABLE IF EXISTS `recibida_agricola__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `recibida_agricola__` ( - `recibida_id` mediumint(8) unsigned NOT NULL, - `num` smallint(5) unsigned NOT NULL, - PRIMARY KEY (`recibida_id`), - CONSTRAINT `recibida_agricola___ibfk_1` FOREIGN KEY (`recibida_id`) REFERENCES `vn`.`invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `recibida_intrastat` -- @@ -83971,150 +84572,6 @@ SET character_set_client = utf8; 1 AS `efimero` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `rounding__` --- - -DROP TABLE IF EXISTS `rounding__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `rounding__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `amount` double NOT NULL DEFAULT 0, - `price` double DEFAULT 0, - `discount` double NOT NULL DEFAULT 0, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `route__` --- - -DROP TABLE IF EXISTS `route__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `route__` ( - `agency_id` smallint(5) unsigned NOT NULL, - `week_day` tinyint(3) unsigned NOT NULL COMMENT 'weekday de access el domingo = 1, sabado = 7. Intentar cambiar al de Mysql Lunes = 0', - PRIMARY KEY (`agency_id`,`week_day`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `scanTree__` --- - -DROP TABLE IF EXISTS `scanTree__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `scanTree__` ( - `id` int(11) NOT NULL DEFAULT 0, - `name` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `lft` int(11) NOT NULL, - `rgt` int(11) NOT NULL, - `depth` bigint(22) NOT NULL DEFAULT 0, - `sons` int(11) DEFAULT 0, - `lastScanned` datetime DEFAULT NULL, - `routeCount` int(11) DEFAULT NULL, - `minRoute` int(11) DEFAULT NULL, - `maxRoute` int(11) DEFAULT NULL, - `scanned` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `lft_rgt_depth` (`lft`,`rgt`,`depth`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `scan__` --- - -DROP TABLE IF EXISTS `scan__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `scan__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `lft` int(11) NOT NULL, - `rgt` int(11) NOT NULL, - `name` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `odbc_date` timestamp NOT NULL DEFAULT current_timestamp(), - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `scan_line__` --- - -DROP TABLE IF EXISTS `scan_line__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `scan_line__` ( - `scan_line_id` int(11) NOT NULL AUTO_INCREMENT, - `scan_id` int(11) NOT NULL, - `code` varchar(45) NOT NULL, - `odbc_date` timestamp NOT NULL DEFAULT current_timestamp(), - PRIMARY KEY (`scan_line_id`), - KEY `id_scan_id_idx` (`scan_id`), - CONSTRAINT `id_scan_id` FOREIGN KEY (`scan_id`) REFERENCES `scan__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `sort_merge_results_ernesto__` --- - -DROP TABLE IF EXISTS `sort_merge_results_ernesto__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sort_merge_results_ernesto__` ( - `hora` datetime NOT NULL, - `uptime` int(11) DEFAULT NULL, - `log_output` varchar(5) DEFAULT NULL, - `uptime_since_flush` int(11) DEFAULT NULL, - `smp_old` int(11) DEFAULT NULL, - `smp_new` int(11) DEFAULT NULL, - `smp` int(11) DEFAULT NULL, - `smp_hour` int(11) DEFAULT NULL, - `connections` int(11) DEFAULT NULL, - `Threads_created` int(11) DEFAULT NULL, - `Threads_cached` int(11) DEFAULT NULL, - `Thread_cache_size` int(11) DEFAULT NULL, - `comment` varchar(255) DEFAULT NULL, - `TABLE_OPEN_CACHE_OVERFLOWS` int(11) DEFAULT NULL, - `TABLE_OPEN_CACHE_MISSES` int(11) DEFAULT NULL, - `TABLE_OPEN_CACHE_HITS` int(11) DEFAULT NULL, - `table_open_cache` int(11) DEFAULT NULL, - `table_open_cache_instances` int(11) DEFAULT NULL, - `open_tables` int(11) DEFAULT NULL, - `opened_tables` int(11) DEFAULT NULL, - `Innodb_os_log_written` double DEFAULT NULL, - `table_definition_cache` int(11) DEFAULT NULL, - `Open_table_definitions` int(11) DEFAULT NULL, - `sort_buffer_size` int(11) DEFAULT NULL, - `join_buffer_size` int(11) DEFAULT NULL, - `read_rnd_buffer_size` int(11) DEFAULT NULL, - `tmp_table_size` int(11) DEFAULT NULL, - `max_heap_table_size` int(11) DEFAULT NULL, - `created_tmp_disk_tables` int(11) DEFAULT NULL, - `created_tmp_tables` int(11) DEFAULT NULL, - `Created_tmp_files` int(11) DEFAULT NULL, - `OpenTablesxUptimeDivOpened` float DEFAULT NULL, - `innodb_open_files` int(11) DEFAULT NULL, - `Innodb_num_open_files` int(11) DEFAULT NULL, - `open_files_limit` int(11) DEFAULT NULL, - `query_cache_size` int(11) DEFAULT NULL, - `query_cache_type` varchar(3) DEFAULT NULL, - `trx_rseg_history_len` int(11) DEFAULT NULL, - `Qcache_hits` int(11) DEFAULT NULL, - `Qcache_inserts` int(11) DEFAULT NULL, - `Qcache_not_cached` int(11) DEFAULT NULL, - PRIMARY KEY (`hora`), - UNIQUE KEY `hora_UNIQUE` (`hora`), - KEY `uptime` (`uptime`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `state` -- @@ -84129,7 +84586,6 @@ SET character_set_client = utf8; 1 AS `order`, 1 AS `alert_level`, 1 AS `code`, - 1 AS `sectorProdPriority`, 1 AS `nextStateFk`, 1 AS `isPreviousPreparable`, 1 AS `isPicked` */; @@ -84229,78 +84685,6 @@ SET character_set_client = utf8; 1 AS `ASIEN` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `tblIVA__` --- - -DROP TABLE IF EXISTS `tblIVA__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tblIVA__` ( - `tipoiva` varchar(50) NOT NULL, - `iva` smallint(6) NOT NULL DEFAULT 0, - `cuenta` double DEFAULT 0, - `cuentaRE` double DEFAULT 0, - `cuentaivaRE` double DEFAULT 0, - `REQ` double DEFAULT 0, - PRIMARY KEY (`tipoiva`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `template_bionic_component__` --- - -DROP TABLE IF EXISTS `template_bionic_component__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `template_bionic_component__` ( - `warehouse_id` smallint(5) unsigned NOT NULL, - `item_id` int(11) NOT NULL, - `component_id` int(10) unsigned NOT NULL, - `cost` decimal(10,4) NOT NULL, - UNIQUE KEY `item_warehouse_component` (`item_id`,`warehouse_id`,`component_id`) USING HASH, - KEY `item_warehouse` (`item_id`,`warehouse_id`) USING BTREE -) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `template_bionic_lot__` --- - -DROP TABLE IF EXISTS `template_bionic_lot__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `template_bionic_lot__` ( - `warehouse_id` smallint(5) unsigned NOT NULL, - `item_id` int(11) NOT NULL, - `available` double DEFAULT NULL, - `buy_id` int(11) DEFAULT NULL, - `fix` tinyint(3) unsigned DEFAULT 0, - UNIQUE KEY `warehouse_id` (`warehouse_id`,`item_id`), - KEY `item_id` (`item_id`) -) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `template_bionic_price__` --- - -DROP TABLE IF EXISTS `template_bionic_price__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `template_bionic_price__` ( - `warehouse_id` smallint(5) unsigned NOT NULL, - `item_id` int(11) NOT NULL, - `rate` tinyint(3) unsigned NOT NULL, - `items` int(11) DEFAULT NULL, - `grouping` int(11) DEFAULT NULL, - `price` decimal(10,2) DEFAULT NULL, - UNIQUE KEY `warehouse_id` (`warehouse_id`,`item_id`,`rate`), - KEY `item_id` (`item_id`) USING BTREE -) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `thermograph` -- @@ -84360,52 +84744,6 @@ SET character_set_client = utf8; 1 AS `yearMonth` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `tipsa__` --- - -DROP TABLE IF EXISTS `tipsa__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tipsa__` ( - `kilos` tinyint(3) unsigned NOT NULL, - `importe` double unsigned NOT NULL, - `zona` tinyint(3) unsigned NOT NULL, - PRIMARY KEY (`kilos`,`zona`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `tmpNEWTARIFAS__` --- - -DROP TABLE IF EXISTS `tmpNEWTARIFAS__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tmpNEWTARIFAS__` ( - `Id_Cliente` int(11) NOT NULL, - `Cliente` varchar(50) NOT NULL, - `Consumo_medio_mensual` double(17,0) DEFAULT NULL, - `Tarifa_Actual` int(11) DEFAULT 0, - `Nueva_Tarifa` int(11) DEFAULT NULL, - `Id_Trabajador` int(11) DEFAULT 20, - PRIMARY KEY (`Id_Cliente`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `transport__` --- - -DROP TABLE IF EXISTS `transport__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `transport__` ( - `wday` tinyint(4) NOT NULL, - PRIMARY KEY (`wday`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `travel` -- @@ -84434,196 +84772,6 @@ SET character_set_client = utf8; 1 AS `awbFk` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `travel_pattern__` --- - -DROP TABLE IF EXISTS `travel_pattern__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `travel_pattern__` ( - `travel_pattern_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, - `week_start` tinyint(3) unsigned NOT NULL, - `week_end` tinyint(3) unsigned NOT NULL, - `warehouse_out` smallint(5) unsigned NOT NULL, - `warehouse_in` smallint(5) unsigned NOT NULL, - `agency_id` int(11) NOT NULL, - `day_out` tinyint(3) unsigned NOT NULL, - `duration` tinyint(3) unsigned NOT NULL, - `ref` varchar(20) NOT NULL, - `cargoSupplierFk` int(10) unsigned DEFAULT NULL, - `kg` decimal(10,0) unsigned DEFAULT NULL, - `travelFk` int(10) unsigned DEFAULT NULL COMMENT 'travel origen para clonar ademas sus entradas', - PRIMARY KEY (`travel_pattern_id`), - KEY `warehouse_out` (`warehouse_out`), - KEY `warehouse_in` (`warehouse_in`), - KEY `agency_id` (`agency_id`), - KEY `travel_pattern_ibfk_6_idx` (`cargoSupplierFk`), - KEY `travel_pattern_FK` (`travelFk`), - CONSTRAINT `travel_pattern_FK` FOREIGN KEY (`travelFk`) REFERENCES `vn`.`travel` (`id`) ON UPDATE CASCADE, - CONSTRAINT `travel_pattern___ibfk_3` FOREIGN KEY (`warehouse_out`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE, - CONSTRAINT `travel_pattern___ibfk_4` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agencyMode` (`id`) ON UPDATE CASCADE, - CONSTRAINT `travel_pattern___ibfk_5` FOREIGN KEY (`warehouse_in`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE, - CONSTRAINT `travel_pattern_supplierFk` FOREIGN KEY (`cargoSupplierFk`) REFERENCES `vn`.`supplier` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `travel_reserve__` --- - -DROP TABLE IF EXISTS `travel_reserve__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `travel_reserve__` ( - `travel_reserve_id` int(11) NOT NULL AUTO_INCREMENT, - `travel_id` int(11) unsigned NOT NULL, - `Id_Trabajador` int(11) NOT NULL, - `reserved` decimal(4,1) DEFAULT NULL, - `buyed` decimal(4,1) DEFAULT NULL, - `askingfor` decimal(4,1) DEFAULT NULL, - `odbc_date` timestamp NULL DEFAULT current_timestamp(), - `labeled` decimal(4,1) unsigned NOT NULL DEFAULT 0.0, - PRIMARY KEY (`Id_Trabajador`,`travel_id`), - UNIQUE KEY `travel_reserve_id_UNIQUE` (`travel_reserve_id`), - KEY `travel_travel_reserve_idx` (`travel_id`), - KEY `traveL_buyer_id_idx` (`Id_Trabajador`), - CONSTRAINT `travel_reserve___ibfk_1` FOREIGN KEY (`travel_id`) REFERENCES `vn`.`travel` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `trolley__` --- - -DROP TABLE IF EXISTS `trolley__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `trolley__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `fecha` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `ref` varchar(4) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `unaryScanFilter__` --- - -DROP TABLE IF EXISTS `unaryScanFilter__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `unaryScanFilter__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(50) NOT NULL, - `filter` text NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `unary__` --- - -DROP TABLE IF EXISTS `unary__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `unary__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `parent` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `idunary_UNIQUE` (`id`), - KEY `unary_parent_idx` (`parent`), - CONSTRAINT `unary_parent` FOREIGN KEY (`parent`) REFERENCES `unary__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #7258 @deprecated 2023-12-13'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `unary_scan__` --- - -DROP TABLE IF EXISTS `unary_scan__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `unary_scan__` ( - `unary_id` int(11) NOT NULL, - `name` varchar(45) DEFAULT NULL, - `odbc_date` timestamp NOT NULL DEFAULT current_timestamp(), - `type` set('BUYS','EXPEDITIONS') NOT NULL, - PRIMARY KEY (`unary_id`), - KEY `scan_unary_idx` (`unary_id`), - CONSTRAINT `unary_scan` FOREIGN KEY (`unary_id`) REFERENCES `unary__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `unary_scan_line__` --- - -DROP TABLE IF EXISTS `unary_scan_line__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `unary_scan_line__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `code` varchar(45) NOT NULL, - `odbc_date` timestamp NOT NULL DEFAULT current_timestamp(), - `unary_id` int(11) NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `id_UNIQUE` (`id`), - KEY `unary_line_idx` (`unary_id`), - CONSTRAINT `unary_line` FOREIGN KEY (`unary_id`) REFERENCES `unary_scan__` (`unary_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `unary_scan_line_buy__` --- - -DROP TABLE IF EXISTS `unary_scan_line_buy__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `unary_scan_line_buy__` ( - `scan_line_id` int(11) NOT NULL, - `Id_Article` int(11) NOT NULL, - PRIMARY KEY (`scan_line_id`), - UNIQUE KEY `scan_line_id_UNIQUE` (`scan_line_id`), - KEY `Id_Article_buy_idx` (`Id_Article`), - CONSTRAINT `Id_Article_buy` FOREIGN KEY (`Id_Article`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `scan_line_id_patriarcal` FOREIGN KEY (`scan_line_id`) REFERENCES `unary_scan_line__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `unary_scan_line_expedition__` --- - -DROP TABLE IF EXISTS `unary_scan_line_expedition__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `unary_scan_line_expedition__` ( - `scan_line_id` int(11) NOT NULL, - `expedition_id` int(11) NOT NULL, - PRIMARY KEY (`scan_line_id`), - UNIQUE KEY `scan_line_id_UNIQUE` (`scan_line_id`), - KEY `expedition_id_scan_idx` (`expedition_id`), - CONSTRAINT `expedition_id_scan` FOREIGN KEY (`expedition_id`) REFERENCES `vn`.`expedition` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `unary_source__` --- - -DROP TABLE IF EXISTS `unary_source__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `unary_source__` ( - `name` varchar(100) NOT NULL, - PRIMARY KEY (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `v_Articles_botanical` -- @@ -84743,90 +84891,6 @@ SET character_set_client = utf8; 1 AS `critical` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `viaxpress__` --- - -DROP TABLE IF EXISTS `viaxpress__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `viaxpress__` ( - `codigo_postal` varchar(5) NOT NULL, - `zona` tinyint(4) NOT NULL DEFAULT 2, - `m_t` tinyint(4) NOT NULL DEFAULT 0, - `POBLACION` varchar(25) NOT NULL, - `PROVINCIA` varchar(20) NOT NULL, - PRIMARY KEY (`codigo_postal`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `warehouse_filtro__` --- - -DROP TABLE IF EXISTS `warehouse_filtro__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `warehouse_filtro__` ( - `warehouse_id` smallint(6) unsigned NOT NULL, - `Id_Trabajador` int(11) NOT NULL, - `ok` tinyint(3) unsigned DEFAULT 1, - PRIMARY KEY (`Id_Trabajador`,`warehouse_id`), - KEY `wh_worker_idx` (`Id_Trabajador`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `warehouse_group__` --- - -DROP TABLE IF EXISTS `warehouse_group__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `warehouse_group__` ( - `warehouse_alias_id` smallint(5) unsigned NOT NULL DEFAULT 22, - `warehouse_id` smallint(5) unsigned NOT NULL, - PRIMARY KEY (`warehouse_alias_id`,`warehouse_id`), - KEY `warehosue_group_ware_idx` (`warehouse_id`), - CONSTRAINT `warehosue_group_ware` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `warehouse_group_alias` FOREIGN KEY (`warehouse_alias_id`) REFERENCES `vn`.`warehouseAlias__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `warehouse_joined__` --- - -DROP TABLE IF EXISTS `warehouse_joined__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `warehouse_joined__` ( - `warehouse_id` smallint(5) unsigned NOT NULL, - `warehouse_alias_id` smallint(5) unsigned NOT NULL, - PRIMARY KEY (`warehouse_id`,`warehouse_alias_id`), - CONSTRAINT `warehouse_joined___ibfk_3` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `warehouse_lc__` --- - -DROP TABLE IF EXISTS `warehouse_lc__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `warehouse_lc__` ( - `whin` smallint(6) unsigned NOT NULL, - `whout` smallint(6) unsigned NOT NULL, - `m3` double NOT NULL DEFAULT 15, - `days` int(11) NOT NULL DEFAULT 1, - PRIMARY KEY (`whin`,`whout`), - KEY `whout_wh_idx` (`whout`), - CONSTRAINT `whin_wh` FOREIGN KEY (`whin`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE, - CONSTRAINT `whout_wh` FOREIGN KEY (`whout`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `warehouse_pickup` -- @@ -84840,71 +84904,6 @@ SET character_set_client = utf8; 1 AS `agency_id` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `wh_selection__` --- - -DROP TABLE IF EXISTS `wh_selection__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `wh_selection__` ( - `Id_Trabajador` int(10) unsigned NOT NULL, - `warehouse_id` smallint(6) unsigned NOT NULL, - PRIMARY KEY (`Id_Trabajador`,`warehouse_id`), - KEY `Trabajadores` (`Id_Trabajador`), - KEY `Warehouse` (`warehouse_id`), - CONSTRAINT `Trabajadores` FOREIGN KEY (`Id_Trabajador`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE, - CONSTRAINT `Warehouse` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `widget__` --- - -DROP TABLE IF EXISTS `widget__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `widget__` ( - `widget_id` int(11) NOT NULL, - `chr` int(11) NOT NULL, - PRIMARY KEY (`widget_id`), - UNIQUE KEY `chr_UNIQUE` (`chr`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `wks__` --- - -DROP TABLE IF EXISTS `wks__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `wks__` ( - `wk` int(10) unsigned NOT NULL, - `yr` int(10) unsigned NOT NULL, - `vwk` int(10) unsigned NOT NULL, - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `comments` text DEFAULT NULL, - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `zones__` --- - -DROP TABLE IF EXISTS `zones__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `zones__` ( - `zone_id` tinyint(4) NOT NULL, - `name` varchar(45) NOT NULL, - `printingOrder` int(11) NOT NULL DEFAULT 0, - PRIMARY KEY (`zone_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Dumping events for database 'vn2008' -- @@ -85155,7 +85154,7 @@ USE `bi`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `tarifa_componentes_series` AS select `ct`.`id` AS `tarifa_componentes_series_id`,`ct`.`type` AS `Serie`,`ct`.`isBase` AS `base`,`ct`.`isMargin` AS `margen` from `vn`.`componentType` `ct` */; +/*!50001 VIEW `tarifa_componentes_series` AS select `ct`.`id` AS `tarifa_componentes_series_id`,`ct`.`name` AS `Serie`,`ct`.`isBase` AS `base`,`ct`.`isMargin` AS `margen` from `vn`.`componentType` `ct` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -85287,7 +85286,7 @@ USE `edi`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ektRecent` AS select `e`.`id` AS `id`,`e`.`barcode` AS `barcode`,`e`.`entryYear` AS `entryYear`,`e`.`batchNumber` AS `batchNumber`,`e`.`deliveryNumber` AS `deliveryNumber`,`e`.`vendorOrderNumber` AS `vendorOrderNumber`,`e`.`fec` AS `fec`,`e`.`hor` AS `hor`,`e`.`now` AS `now`,`e`.`ptj` AS `ptj`,`e`.`ref` AS `ref`,`e`.`item` AS `item`,`e`.`pac` AS `pac`,`e`.`qty` AS `qty`,`e`.`ori` AS `ori`,`e`.`cat` AS `cat`,`e`.`agj` AS `agj`,`e`.`kop` AS `kop`,`e`.`ptd` AS `ptd`,`e`.`sub` AS `sub`,`e`.`pro` AS `pro`,`e`.`pri` AS `pri`,`e`.`package` AS `package`,`e`.`auction` AS `auction`,`e`.`klo` AS `klo`,`e`.`k1` AS `k1`,`e`.`k2` AS `k2`,`e`.`k3` AS `k3`,`e`.`k4` AS `k4`,`e`.`s1` AS `s1`,`e`.`s2` AS `s2`,`e`.`s3` AS `s3`,`e`.`s4` AS `s4`,`e`.`s5` AS `s5`,`e`.`s6` AS `s6`,`e`.`ok` AS `ok`,`e`.`trolleyFk` AS `trolleyFk`,`e`.`putOrderFk` AS `putOrderFk`,`e`.`scanned` AS `scanned`,`e`.`cps` AS `cps`,`e`.`dp` AS `dp`,`e`.`sender` AS `sender`,`ec`.`usefulAuctionLeftSegmentLength` AS `usefulAuctionLeftSegmentLength`,`ec`.`standardBarcodeLength` AS `standardBarcodeLength`,`ec`.`floridayBarcodeLength` AS `floridayBarcodeLength`,`ec`.`floramondoBarcodeLength` AS `floramondoBarcodeLength`,`ec`.`defaultKlo` AS `defaultKlo`,`ec`.`ektRecentScopeDays` AS `ektRecentScopeDays` from (`ekt` `e` join `ektConfig` `ec`) where `e`.`entryYear` = year(`util`.`VN_CURDATE`()) and `e`.`fec` >= `util`.`VN_CURDATE`() + interval -`ec`.`ektRecentScopeDays` day */; +/*!50001 VIEW `ektRecent` AS select `e`.`id` AS `id`,`e`.`entryYear` AS `entryYear`,`e`.`batchNumber` AS `batchNumber`,`e`.`deliveryNumber` AS `deliveryNumber`,`e`.`vendorOrderNumber` AS `vendorOrderNumber`,`e`.`fec` AS `fec`,`e`.`hor` AS `hor`,`e`.`now` AS `now`,`e`.`ptj` AS `ptj`,`e`.`ref` AS `ref`,`e`.`item` AS `item`,`e`.`pac` AS `pac`,`e`.`qty` AS `qty`,`e`.`ori` AS `ori`,`e`.`cat` AS `cat`,`e`.`agj` AS `agj`,`e`.`kop` AS `kop`,`e`.`ptd` AS `ptd`,`e`.`sub` AS `sub`,`e`.`pro` AS `pro`,`e`.`pri` AS `pri`,`e`.`package` AS `package`,`e`.`auction` AS `auction`,`e`.`klo` AS `klo`,`e`.`k1` AS `k1`,`e`.`k2` AS `k2`,`e`.`k3` AS `k3`,`e`.`k4` AS `k4`,`e`.`s1` AS `s1`,`e`.`s2` AS `s2`,`e`.`s3` AS `s3`,`e`.`s4` AS `s4`,`e`.`s5` AS `s5`,`e`.`s6` AS `s6`,`e`.`ok` AS `ok`,`e`.`trolleyFk` AS `trolleyFk`,`e`.`putOrderFk` AS `putOrderFk`,`e`.`scanned` AS `scanned`,`e`.`cps` AS `cps`,`e`.`dp` AS `dp`,`e`.`sender` AS `sender`,`ec`.`usefulAuctionLeftSegmentLength` AS `usefulAuctionLeftSegmentLength`,`ec`.`standardBarcodeLength` AS `standardBarcodeLength`,`ec`.`floridayBarcodeLength` AS `floridayBarcodeLength`,`ec`.`floramondoBarcodeLength` AS `floramondoBarcodeLength`,`ec`.`defaultKlo` AS `defaultKlo`,`ec`.`ektRecentScopeDays` AS `ektRecentScopeDays` from (`ekt` `e` join `ektConfig` `ec`) where `e`.`entryYear` = year(`util`.`VN_CURDATE`()) and `e`.`fec` >= `util`.`VN_CURDATE`() + interval -`ec`.`ektRecentScopeDays` day */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -85743,7 +85742,7 @@ USE `pbx`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `queueConf` AS select `q`.`name` AS `name`,`c`.`strategy` AS `strategy`,`c`.`timeout` AS `timeout`,`c`.`retry` AS `retry`,`c`.`weight` AS `weight`,`c`.`maxLen` AS `maxlen`,`c`.`ringInUse` AS `ringinuse` from (`queue` `q` join `queueConfig` `c` on(`q`.`config` = `c`.`id`)) */; +/*!50001 VIEW `queueConf` AS select `q`.`name` AS `name`,`c`.`strategy` AS `strategy`,`c`.`timeout` AS `timeout`,`c`.`retry` AS `retry`,`c`.`weight` AS `weight`,`c`.`maxLen` AS `maxlen`,`c`.`ringInUse` AS `ringinuse` from (`queue` `q` join `queueMultiConfig` `c` on(`q`.`config` = `c`.`id`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -85779,7 +85778,7 @@ USE `pbx`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `sipConf` AS select `s`.`user_id` AS `id`,`s`.`extension` AS `name`,`s`.`extension` AS `regexten`,NULL AS `callbackextension`,`s`.`md5Secret` AS `md5secret`,`u`.`nickname` AS `callerid`,`c`.`host` AS `host`,`c`.`deny` AS `deny`,`c`.`permit` AS `permit`,`c`.`type` AS `type`,`c`.`context` AS `context`,`c`.`incomingLimit` AS `incominglimit`,`c`.`pickupGroup` AS `pickupgroup`,`c`.`directMedia` AS `directmedia`,`c`.`insecure` AS `insecure`,`c`.`transport` AS `transport`,`c`.`nat` AS `nat`,`c`.`disallow` AS `disallow`,`c`.`allow` AS `allow`,`r`.`ipAddr` AS `ipaddr`,`r`.`regSeconds` AS `regseconds`,`r`.`port` AS `port`,`r`.`defaultUser` AS `defaultuser`,`r`.`userAgent` AS `useragent`,`r`.`lastMs` AS `lastms`,`r`.`fullContact` AS `fullcontact`,`r`.`regServer` AS `regserver` from (((`pbx`.`sip` `s` join `account`.`user` `u` on(`u`.`id` = `s`.`user_id`)) left join `pbx`.`sipReg` `r` on(`s`.`user_id` = `r`.`userId`)) join `pbx`.`sipConfig` `c`) */; +/*!50001 VIEW `sipConf` AS select `s`.`user_id` AS `id`,`s`.`extension` AS `name`,`s`.`extension` AS `regexten`,NULL AS `callbackextension`,`s`.`md5Secret` AS `md5secret`,`u`.`nickname` AS `callerid`,`c`.`host` AS `host`,`c`.`deny` AS `deny`,`c`.`permit` AS `permit`,`c`.`type` AS `type`,`c`.`context` AS `context`,`c`.`call-limit` AS `call-limit`,`c`.`pickupGroup` AS `pickupgroup`,`c`.`directMedia` AS `directmedia`,`c`.`insecure` AS `insecure`,`c`.`transport` AS `transport`,`c`.`nat` AS `nat`,`c`.`disallow` AS `disallow`,`c`.`allow` AS `allow`,`r`.`ipAddr` AS `ipaddr`,`r`.`regSeconds` AS `regseconds`,`r`.`port` AS `port`,`r`.`defaultUser` AS `defaultuser`,`r`.`userAgent` AS `useragent`,`r`.`lastMs` AS `lastms`,`r`.`fullContact` AS `fullcontact`,`r`.`regServer` AS `regserver` from (((`pbx`.`sip` `s` join `account`.`user` `u` on(`u`.`id` = `s`.`user_id`)) left join `pbx`.`sipReg` `r` on(`s`.`user_id` = `r`.`userId`)) join `pbx`.`sipConfig` `c`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -85965,7 +85964,7 @@ USE `srt`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `bufferDayMinute` AS select `b`.`id` AS `bufferFk`,`e`.`id` AS `expeditionFk`,`srt`.`dayMinute`(ifnull(`et`.`eta`,`z`.`hour`)) AS `dayMinute`,`e`.`position` AS `position`,ifnull(`et`.`eta`,`util`.`VN_CURDATE`() + interval `srt`.`dayMinute`(`z`.`hour`) minute) AS `ETD`,`e2`.`ticketFk` AS `ticketFk`,ifnull(`t`.`routeFk`,`t`.`agencyModeFk`) AS `routeFk`,`z`.`name` AS `zonaTicket`,`es`.`description` AS `expeditionState` from ((((((((`srt`.`buffer` `b` left join `srt`.`expedition` `e` on(`b`.`id` = `e`.`bufferFk`)) left join `srt`.`expeditionState` `es` on(`es`.`id` = `e`.`stateFk`)) join `srt`.`bufferType` `bt` on(`bt`.`id` = `b`.`typeFk`)) left join `vn`.`expedition` `e2` on(`e2`.`id` = `e`.`id`)) left join `vn`.`ticket` `t` on(`e2`.`ticketFk` = `t`.`id`)) left join `vn`.`routesMonitor` `rm` on(`t`.`routeFk` = `rm`.`routeFk`)) left join `vn`.`expeditionTruck` `et` on(`rm`.`expeditionTruckFk` = `et`.`id`)) left join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) where `b`.`isActive` <> 0 */; +/*!50001 VIEW `bufferDayMinute` AS select `b`.`id` AS `bufferFk`,`e`.`id` AS `expeditionFk`,`srt`.`dayMinute`(ifnull(`rs`.`eta`,`z`.`hour`)) AS `dayMinute`,`e`.`position` AS `position`,ifnull(`rs`.`eta`,`util`.`VN_CURDATE`() + interval `srt`.`dayMinute`(`z`.`hour`) minute) AS `ETD`,`e2`.`ticketFk` AS `ticketFk`,ifnull(`t`.`routeFk`,`t`.`agencyModeFk`) AS `routeFk`,`z`.`name` AS `zonaTicket`,`es`.`description` AS `expeditionState` from ((((((((`srt`.`buffer` `b` left join `srt`.`expedition` `e` on(`b`.`id` = `e`.`bufferFk`)) left join `srt`.`expeditionState` `es` on(`es`.`id` = `e`.`stateFk`)) join `srt`.`bufferType` `bt` on(`bt`.`id` = `b`.`typeFk`)) left join `vn`.`expedition` `e2` on(`e2`.`id` = `e`.`id`)) left join `vn`.`ticket` `t` on(`e2`.`ticketFk` = `t`.`id`)) left join `vn`.`routesMonitor` `rm` on(`t`.`routeFk` = `rm`.`routeFk`)) left join `vn`.`roadmapStop` `rs` on(`rm`.`roadmapStopFk` = `rs`.`id`)) left join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) where `b`.`isActive` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86001,7 +86000,7 @@ USE `srt`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `bufferStock` AS select `e`.`id` AS `expeditionFk`,`e`.`bufferFk` AS `bufferFk`,`e`.`position` AS `position`,`srt`.`dayMinute`(ifnull(`et`.`eta`,`z`.`hour`)) AS `dayMinute`,ifnull(`et`.`eta`,`util`.`VN_CURDATE`() + interval `srt`.`dayMinute`(`z`.`hour`) + 120 minute) AS `eta`,`ve`.`ticketFk` AS `ticketFk`,ifnull(`t`.`routeFk`,`t`.`agencyModeFk`) AS `routeFk`,`z`.`name` AS `zonaTicket`,`et`.`description` AS `truck`,`es`.`description` AS `expeditionState`,`b`.`hasWorkerWaiting` AS `hasWorkerWaiting`,`b`.`isActive` AS `isActive`,if(`et`.`id` is null,`c`.`bufferDefault`,`et`.`bufferFk`) AS `bufferTruck`,`bt`.`typeName` AS `typeName`,`rm`.`bufferFk` AS `routeBuffer` from (((((((((`srt`.`expedition` `e` left join `vn`.`expedition` `ve` on(`ve`.`id` = `e`.`id`)) join `srt`.`expeditionState` `es` on(`es`.`id` = `e`.`stateFk`)) join `srt`.`buffer` `b` on(`b`.`id` = `e`.`bufferFk`)) left join `vn`.`ticket` `t` on(`t`.`id` = `ve`.`ticketFk`)) left join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `vn`.`routesMonitor` `rm` on(`t`.`routeFk` = `rm`.`routeFk`)) left join `vn`.`expeditionTruck` `et` on(`rm`.`expeditionTruckFk` = `et`.`id`)) join `srt`.`config` `c`) join `srt`.`bufferType` `bt` on(`bt`.`id` = `b`.`typeFk`)) where `bt`.`typeName` <> 'DISABLED' */; +/*!50001 VIEW `bufferStock` AS select `e`.`id` AS `expeditionFk`,`e`.`bufferFk` AS `bufferFk`,`e`.`position` AS `position`,`srt`.`dayMinute`(ifnull(`rs`.`eta`,`z`.`hour`)) AS `dayMinute`,ifnull(`rs`.`eta`,`util`.`VN_CURDATE`() + interval `srt`.`dayMinute`(`z`.`hour`) + 120 minute) AS `eta`,`ve`.`ticketFk` AS `ticketFk`,ifnull(`t`.`routeFk`,`t`.`agencyModeFk`) AS `routeFk`,`z`.`name` AS `zonaTicket`,`rs`.`description` AS `truck`,`es`.`description` AS `expeditionState`,`b`.`hasWorkerWaiting` AS `hasWorkerWaiting`,`b`.`isActive` AS `isActive`,if(`rs`.`id` is null,`c`.`bufferDefault`,`rs`.`bufferFk`) AS `bufferTruck`,`bt`.`typeName` AS `typeName`,`rm`.`bufferFk` AS `routeBuffer` from (((((((((`srt`.`expedition` `e` left join `vn`.`expedition` `ve` on(`ve`.`id` = `e`.`id`)) join `srt`.`expeditionState` `es` on(`es`.`id` = `e`.`stateFk`)) join `srt`.`buffer` `b` on(`b`.`id` = `e`.`bufferFk`)) left join `vn`.`ticket` `t` on(`t`.`id` = `ve`.`ticketFk`)) left join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `vn`.`routesMonitor` `rm` on(`t`.`routeFk` = `rm`.`routeFk`)) left join `vn`.`roadmapStop` `rs` on(`rm`.`roadmapStopFk` = `rs`.`id`)) join `srt`.`config` `c`) join `srt`.`bufferType` `bt` on(`bt`.`id` = `b`.`typeFk`)) where `bt`.`typeName` <> 'DISABLED' */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86091,7 +86090,7 @@ USE `srt`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `upperStickers` AS select `e`.`id` AS `expeditionFk`,`e`.`id` MOD 10000 AS `expedition`,ifnull(`et`.`eta`,`util`.`VN_CURDATE`() + interval `srt`.`dayMinute`(`z`.`hour`) + 120 minute) AS `ETD`,`ve`.`ticketFk` AS `ticketFk`,right(ifnull(`t`.`routeFk`,`t`.`agencyModeFk`),3) AS `routeFk`,`z`.`name` AS `zonaTicket`,`et`.`description` AS `truck`,`epo`.`workerCode` AS `worker`,`p`.`name` AS `labeler`,`ve`.`counter` AS `expeditionCounter`,`vn`.`ticketTotalVolume`(`t`.`id`) AS `m3`,`t`.`clientFk` AS `clientFk` from (((((((`srt`.`expedition` `e` left join `vn`.`expedition` `ve` on(`ve`.`id` = `e`.`id`)) left join `vn`.`ticket` `t` on(`t`.`id` = `ve`.`ticketFk`)) left join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `vn`.`routesMonitor` `rm` on(`t`.`routeFk` = `rm`.`routeFk`)) left join `vn`.`expeditionTruck` `et` on(`rm`.`expeditionTruckFk` = `et`.`id`)) join `dipole`.`expedition_PrintOut` `epo` on(`epo`.`expeditionFk` = `e`.`id`)) join `vn`.`printer` `p` on(`p`.`id` = `epo`.`printerFk`)) */; +/*!50001 VIEW `upperStickers` AS select `e`.`id` AS `expeditionFk`,`e`.`id` MOD 10000 AS `expedition`,ifnull(`rs`.`eta`,`util`.`VN_CURDATE`() + interval `srt`.`dayMinute`(`z`.`hour`) + 120 minute) AS `ETD`,`ve`.`ticketFk` AS `ticketFk`,right(ifnull(`t`.`routeFk`,`t`.`agencyModeFk`),3) AS `routeFk`,`z`.`name` AS `zonaTicket`,`rs`.`description` AS `truck`,`epo`.`workerCode` AS `worker`,`p`.`name` AS `labeler`,`ve`.`counter` AS `expeditionCounter`,`vn`.`ticketTotalVolume`(`t`.`id`) AS `m3`,`t`.`clientFk` AS `clientFk` from (((((((`srt`.`expedition` `e` left join `vn`.`expedition` `ve` on(`ve`.`id` = `e`.`id`)) left join `vn`.`ticket` `t` on(`t`.`id` = `ve`.`ticketFk`)) left join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `vn`.`routesMonitor` `rm` on(`t`.`routeFk` = `rm`.`routeFk`)) left join `vn`.`roadmapStop` `rs` on(`rm`.`roadmapStopFk` = `rs`.`id`)) join `dipole`.`expedition_PrintOut` `epo` on(`epo`.`expeditionFk` = `e`.`id`)) join `vn`.`printer` `p` on(`p`.`id` = `epo`.`printerFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86150,7 +86149,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `NewView` AS select `c`.`id` AS `clientFk`,max(`t`.`shipped`) AS `lastShipped`,`pc`.`notBuyingMonths` AS `notBuyingMonths` from ((`client` `c` join `productionConfig` `pc`) left join `ticket` `t` on(`c`.`id` = `t`.`clientFk` and `t`.`shipped` < `util`.`VN_CURDATE`() + interval -`pc`.`rookieDays` day)) group by `c`.`id` having `lastShipped` is null or `lastShipped` < `util`.`VN_CURDATE`() + interval -`notBuyingMonths` month */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86164,11 +86163,11 @@ USE `vn`; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb3 */; -/*!50001 SET character_set_results = utf8mb3 */; -/*!50001 SET collation_connection = utf8mb3_general_ci */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `agencyTerm` AS select `sat`.`agencyFk` AS `agencyFk`,`sat`.`minimumPackages` AS `minimumPackages`,`sat`.`kmPrice` AS `kmPrice`,`sat`.`packagePrice` AS `packagePrice`,`sat`.`routePrice` AS `routePrice`,`sat`.`minimumKm` AS `minimumKm`,`sat`.`minimumM3` AS `minimumM3`,`sat`.`m3Price` AS `m3Price` from `supplierAgencyTerm` `sat` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86186,7 +86185,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `annualAverageInvoiced` AS select `cec`.`clientFk` AS `clientFk`,`cec`.`invoiced` AS `invoiced` from `bs`.`clientAnnualConsumption` `cec` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86204,7 +86203,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `awbVolume` AS select `t`.`awbFk` AS `awbFk`,`b`.`stickers` * `i`.`density` * if(`p`.`volume` > 0,`p`.`volume`,`p`.`width` * `p`.`depth` * if(`p`.`height` = 0,`i`.`size` + 10,`p`.`height`)) / (`vc`.`aerealVolumetricDensity` * 1000) AS `volume`,`b`.`id` AS `buyFk` from ((((((`buy` `b` join `item` `i` on(`b`.`itemFk` = `i`.`id`)) join `itemType` `it` on(`i`.`typeFk` = `it`.`id`)) join `packaging` `p` on(`p`.`id` = `b`.`packagingFk`)) join `entry` `e` on(`b`.`entryFk` = `e`.`id`)) join `travel` `t` on(`t`.`id` = `e`.`travelFk`)) join `volumeConfig` `vc`) where `t`.`shipped` > makedate(year(`util`.`VN_CURDATE`()) - 1,1) and `t`.`awbFk` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86222,7 +86221,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `businessCalendar` AS select `c`.`id` AS `id`,`c`.`businessFk` AS `businessFk`,`c`.`dayOffTypeFk` AS `absenceTypeFk`,`c`.`dated` AS `dated` from `calendar` `c` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86240,7 +86239,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `buyer` AS select distinct `u`.`id` AS `userFk`,`u`.`nickname` AS `nickname` from (`account`.`user` `u` join `vn`.`itemType` `it` on(`it`.`workerFk` = `u`.`id`)) where `u`.`active` <> 0 order by `u`.`nickname` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86258,7 +86257,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `buyerSales` AS select `v`.`importe` AS `importe`,`w`.`code` AS `comprador`,`t`.`year` AS `año`,`t`.`week` AS `semana` from (((`bs`.`ventas` `v` join `vn`.`time` `t` on(`t`.`dated` = `v`.`fecha`)) join `vn`.`itemType` `it` on(`it`.`id` = `v`.`tipo_id`)) join `vn`.`worker` `w` on(`w`.`id` = `it`.`workerFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86276,7 +86275,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `clientLost` AS select `c`.`id` AS `clientFk`,max(`t`.`shipped`) AS `lastShipped`,`pc`.`notBuyingMonths` AS `notBuyingMonths` from ((`client` `c` join `productionConfig` `pc`) left join `ticket` `t` on(`c`.`id` = `t`.`clientFk` and `t`.`shipped` < `util`.`VN_CURDATE`() + interval -`pc`.`rookieDays` day)) group by `c`.`id` having `lastShipped` is null or `lastShipped` < `util`.`VN_CURDATE`() + interval -`notBuyingMonths` month */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86294,7 +86293,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `clientPhoneBook` AS select `c`.`id` AS `clientFk`,trim(`c`.`phone`) AS `phone` from `client` `c` where `c`.`phone` <> 0 and `c`.`isActive` <> 0 union select `c`.`id` AS `clientFk`,trim(`c`.`mobile`) AS `phone` from `client` `c` where `c`.`mobile` <> 0 and `c`.`isActive` <> 0 union select `a`.`clientFk` AS `clientFk`,trim(`a`.`phone`) AS `phone` from (`address` `a` join `client` `c` on(`c`.`id` = `a`.`clientFk`)) where `a`.`phone` <> 0 and `c`.`isActive` <> 0 union select `a`.`clientFk` AS `clientFk`,trim(`a`.`mobile`) AS `phone` from (`address` `a` join `client` `c` on(`c`.`id` = `a`.`clientFk`)) where `a`.`mobile` <> 0 and `c`.`isActive` <> 0 union select `cc`.`clientFk` AS `clientFk`,trim(`cc`.`phone`) AS `phone` from (`clientContact` `cc` left join `client` `c` on(`c`.`id` = `cc`.`clientFk`)) where `c`.`phone` <> 0 and `c`.`isActive` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86312,7 +86311,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `companyL10n` AS select `c`.`id` AS `id`,ifnull(`ci`.`footnotes`,`c`.`footnotes`) AS `footnotes` from (`company` `c` left join `companyI18n` `ci` on(`ci`.`companyFk` = `c`.`id` and `ci`.`lang` = `util`.`LANG`())) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86330,7 +86329,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `defaulter` AS select `d`.`clientFk` AS `clientFk`,`d`.`created` AS `created`,`d`.`amount` AS `amount`,`d`.`defaulterSinced` AS `defaulterSinced`,`d`.`hasChanged` AS `hasChanged`,`c`.`countryFk` AS `country`,`c`.`payMethodFk` AS `payMethod` from (((`bs`.`defaulter` `d` join `vn`.`client` `c` on(`c`.`id` = `d`.`clientFk`)) join `vn`.`country` `co` on(`co`.`id` = `c`.`countryFk`)) join `vn`.`payMethod` `pm` on(`pm`.`id` = `c`.`payMethodFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86348,7 +86347,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `departmentTree` AS select `node`.`id` AS `id`,concat(convert(repeat(repeat(' ',5),count(`parent`.`id`) - 1) using utf8mb3),`node`.`name`) AS `dep` from (`department` `node` join `department` `parent`) where `node`.`lft` between `parent`.`lft` and `parent`.`rgt` group by `node`.`id` order by `node`.`lft` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86366,7 +86365,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `ediGenus` AS select `g`.`genus_id` AS `id`,`g`.`latin_genus_name` AS `latinGenusName`,`g`.`entry_date` AS `entried`,`g`.`expiry_date` AS `dued`,`g`.`change_date_time` AS `modified` from `edi`.`genus` `g` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86384,7 +86383,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `ediSpecie` AS select `s`.`specie_id` AS `id`,`s`.`genus_id` AS `genusFk`,`s`.`latin_species_name` AS `latinSpeciesName`,`s`.`entry_date` AS `entried`,`s`.`expiry_date` AS `dued`,`s`.`change_date_time` AS `modified` from `edi`.`specie` `s` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86402,7 +86401,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `ektSubAddress` AS select `eea`.`sub` AS `sub`,`a`.`clientFk` AS `clientFk`,`a`.`nickname` AS `nickname`,`eea`.`addressFk` AS `addressFk` from (`ektEntryAssign` `eea` join `address` `a` on(`a`.`id` = `eea`.`addressFk`)) group by `eea`.`sub` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86420,7 +86419,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `especialPrice` AS select `sp`.`id` AS `id`,`sp`.`clientFk` AS `clientFk`,`sp`.`itemFk` AS `itemFk`,`sp`.`value` AS `value` from `specialPrice` `sp` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86438,7 +86437,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `exchangeInsuranceEntry` AS select max(`tr`.`landed`) AS `dated`,cast(sum((`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`) as decimal(10,2)) AS `Dolares`,cast(sum((`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`) / sum((100 + `e`.`commission`) / 100 * (`b`.`buyingValue` + `b`.`freightValue`) * `b`.`quantity`) as decimal(10,4)) AS `rate` from ((`entry` `e` join `buy` `b` on(`e`.`id` = `b`.`entryFk`)) join `travel` `tr` on(`tr`.`id` = `e`.`travelFk`)) where `tr`.`landed` between '2016-01-31' and `util`.`VN_CURDATE`() and `e`.`commission` < 0 and `e`.`currencyFk` = 2 group by month(`tr`.`landed`),year(`tr`.`landed`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86456,7 +86455,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `exchangeInsuranceIn` AS select `exchangeInsuranceInPrevious`.`dated` AS `dated`,sum(`exchangeInsuranceInPrevious`.`amount`) AS `amount`,cast(sum(`exchangeInsuranceInPrevious`.`amount` * `exchangeInsuranceInPrevious`.`rate`) / sum(`exchangeInsuranceInPrevious`.`amount`) as decimal(10,4)) AS `rate` from `exchangeInsuranceInPrevious` group by `exchangeInsuranceInPrevious`.`dated` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86474,7 +86473,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `exchangeInsuranceInPrevious` AS select `ei`.`dueDated` AS `dated`,`ei`.`amount` AS `amount`,`ei`.`rate` AS `rate` from `exchangeInsurance` `ei` where `ei`.`amount` <> 0 and `ei`.`financialProductTypefk` = 'SC' */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86492,48 +86491,12 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `exchangeInsuranceOut` AS select `p`.`received` AS `received`,sum(`p`.`divisa`) AS `divisa`,sum(`p`.`divisa`) / sum(`p`.`amount`) AS `rate` from ((`payment` `p` join `accounting` `a` on(`a`.`id` = `p`.`bankFk`)) join `accountingType` `at2` on(`at2`.`id` = `a`.`accountingTypeFk`)) where `p`.`currencyFk` = 2 and `at2`.`code` = 'wireTransfer' and `p`.`supplierFk` <> 2213 group by `p`.`received` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `exchangeReportSource` --- - -/*!50001 DROP VIEW IF EXISTS `exchangeReportSource`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb4 */; -/*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `exchangeReportSource` AS select `e`.`dated` AS `dated`,cast(sum(`e`.`amountIn`) as decimal(10,2)) AS `amountIn`,cast(sum(`e`.`rateIn`) as decimal(10,4)) AS `rateIn`,cast(sum(`e`.`amountOut`) as decimal(10,2)) AS `amountOut`,cast(sum(`e`.`rateOut`) as decimal(10,4)) AS `rateOut`,cast(sum(`e`.`amountEntry`) as decimal(10,2)) AS `amountEntry`,cast(sum(`e`.`rateEntry`) as decimal(10,4)) AS `rateEntry`,cast(ifnull(`rr`.`value`,`rrc`.`simulatedValue`) as decimal(10,4)) AS `rateECB` from ((`exchangeReportSourcePrevious` `e` left join `referenceRate` `rr` on(`rr`.`dated` = `e`.`dated`)) join `referenceRateConfig` `rrc` on(1)) group by `e`.`dated` order by `e`.`dated` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `exchangeReportSourcePrevious` --- - -/*!50001 DROP VIEW IF EXISTS `exchangeReportSourcePrevious`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb4 */; -/*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `exchangeReportSourcePrevious` AS select `exchangeInsuranceIn`.`dated` AS `dated`,`exchangeInsuranceIn`.`amount` AS `amountIn`,`exchangeInsuranceIn`.`rate` AS `rateIn`,0.00 AS `amountOut`,0.00 AS `rateOut`,0.00 AS `amountEntry`,0.00 AS `rateEntry` from `exchangeInsuranceIn` union all select `exchangeInsuranceOut`.`received` AS `received`,0.00 AS `amountIn`,0.00 AS `ratedIn`,`exchangeInsuranceOut`.`divisa` AS `amountOut`,`exchangeInsuranceOut`.`rate` AS `ratedOut`,0.00 AS `amountEntry`,0.00 AS `rateEntry` from `exchangeInsuranceOut` union all select `exchangeInsuranceEntry`.`dated` AS `dated`,0.00 AS `amountIn`,0.00 AS `ratedIn`,0.00 AS `amountOut`,0.00 AS `ratedOut`,`exchangeInsuranceEntry`.`Dolares` AS `amountEntry`,`exchangeInsuranceEntry`.`rate` AS `rateEntry` from `exchangeInsuranceEntry` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - -- -- Final view structure for view `expeditionCommon` -- @@ -86546,8 +86509,8 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionCommon` AS select `et`.`id` AS `truckFk`,`et`.`eta` AS `eta`,ifnull(ucase(`et`.`description`),'SIN ESCANEAR') AS `description`,`es`.`palletFk` AS `palletFk`,`t`.`routeFk` AS `routeFk`,`es`.`id` AS `scanFk`,`e`.`id` AS `expeditionFk`,`r`.`expeditionTruckFk` AS `expeditionTruckFk`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `lastPacked`,`t`.`id` AS `ticketFk` from (((((`expeditionTruck` `et` left join `routesMonitor` `r` on(`et`.`id` = `r`.`expeditionTruckFk`)) left join `ticket` `t` on(`r`.`routeFk` = `t`.`routeFk`)) left join `expedition` `e` on(`t`.`id` = `e`.`ticketFk`)) left join `expeditionScan` `es` on(`e`.`id` = `es`.`expeditionFk`)) left join `expeditionPallet` `ep` on(`es`.`palletFk` = `ep`.`id`)) where `et`.`eta` >= `util`.`VN_CURDATE`() */; +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `expeditionCommon` AS select `rs`.`id` AS `truckFk`,`rs`.`eta` AS `eta`,ifnull(ucase(`rs`.`description`),'SIN ESCANEAR') AS `description`,`es`.`palletFk` AS `palletFk`,`t`.`routeFk` AS `routeFk`,`es`.`id` AS `scanFk`,`e`.`id` AS `expeditionFk`,`r`.`roadmapStopFk` AS `roadmapStopFk`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `lastPacked`,`t`.`id` AS `ticketFk` from (((((`roadmapStop` `rs` left join `routesMonitor` `r` on(`rs`.`id` = `r`.`roadmapStopFk`)) left join `ticket` `t` on(`r`.`routeFk` = `t`.`routeFk`)) left join `expedition` `e` on(`t`.`id` = `e`.`ticketFk`)) left join `expeditionScan` `es` on(`e`.`id` = `es`.`expeditionFk`)) left join `expeditionPallet` `ep` on(`es`.`palletFk` = `ep`.`id`)) where `rs`.`eta` >= `util`.`VN_CURDATE`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86564,8 +86527,8 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionPallet_Print` AS select `et2`.`description` AS `truck`,`t`.`routeFk` AS `routeFk`,`r`.`description` AS `zone`,count(`es`.`id`) AS `eti`,`ep`.`id` AS `palletFk`,`et`.`id` <=> `rm`.`expeditionTruckFk` AS `isMatch`,`t`.`warehouseFk` AS `warehouseFk`,if(`r`.`created` > `util`.`VN_CURDATE`() + interval 1 day,ucase(dayname(`r`.`created`)),NULL) AS `nombreDia` from (((((((`expeditionTruck` `et` join `expeditionPallet` `ep` on(`ep`.`truckFk` = `et`.`id`)) join `expeditionScan` `es` on(`es`.`palletFk` = `ep`.`id`)) join `expedition` `e` on(`e`.`id` = `es`.`expeditionFk`)) join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `route` `r` on(`r`.`id` = `t`.`routeFk`)) left join `routesMonitor` `rm` on(`rm`.`routeFk` = `r`.`id`)) left join `expeditionTruck` `et2` on(`et2`.`id` = `rm`.`expeditionTruckFk`)) group by `ep`.`id`,`t`.`routeFk` */; +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `expeditionPallet_Print` AS select `rs2`.`description` AS `truck`,`t`.`routeFk` AS `routeFk`,`r`.`description` AS `zone`,count(`es`.`id`) AS `eti`,`ep`.`id` AS `palletFk`,`rs`.`id` <=> `rm`.`roadmapStopFk` AS `isMatch`,`t`.`warehouseFk` AS `warehouseFk`,if(`r`.`created` > `util`.`VN_CURDATE`() + interval 1 day,ucase(dayname(`r`.`created`)),NULL) AS `nombreDia` from (((((((`roadmapStop` `rs` join `expeditionPallet` `ep` on(`ep`.`truckFk` = `rs`.`id`)) join `expeditionScan` `es` on(`es`.`palletFk` = `ep`.`id`)) join `expedition` `e` on(`e`.`id` = `es`.`expeditionFk`)) join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `route` `r` on(`r`.`id` = `t`.`routeFk`)) left join `routesMonitor` `rm` on(`rm`.`routeFk` = `r`.`id`)) left join `roadmapStop` `rs2` on(`rs2`.`id` = `rm`.`roadmapStopFk`)) group by `ep`.`id`,`t`.`routeFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86582,8 +86545,8 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionRoute_Monitor` AS select `r`.`id` AS `routeFk`,count(distinct if(`e`.`id` is null,`t`.`id`,NULL)) AS `tickets`,count(distinct `e`.`id`) AS `expeditions`,count(distinct `es`.`id`) AS `scanned`,max(`e`.`created`) AS `lastPacked`,`r`.`created` AS `created` from (((((`route` `r` left join `routesMonitor` `rm` on(`r`.`id` = `rm`.`routeFk`)) left join `expeditionTruck` `et` on(`et`.`id` = `rm`.`expeditionTruckFk`)) join `ticket` `t` on(`t`.`routeFk` = `r`.`id`)) left join `expedition` `e` on(`e`.`ticketFk` = `t`.`id`)) left join `expeditionScan` `es` on(`es`.`expeditionFk` = `e`.`id`)) where `r`.`created` >= `util`.`yesterday`() group by `r`.`id` */; +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `expeditionRoute_Monitor` AS select `r`.`id` AS `routeFk`,count(distinct if(`e`.`id` is null,`t`.`id`,NULL)) AS `tickets`,count(distinct `e`.`id`) AS `expeditions`,count(distinct `es`.`id`) AS `scanned`,max(`e`.`created`) AS `lastPacked`,`r`.`created` AS `created` from (((((`route` `r` left join `routesMonitor` `rm` on(`r`.`id` = `rm`.`routeFk`)) left join `roadmapStop` `rs` on(`rs`.`id` = `rm`.`roadmapStopFk`)) join `ticket` `t` on(`t`.`routeFk` = `r`.`id`)) left join `expedition` `e` on(`e`.`ticketFk` = `t`.`id`)) left join `expeditionScan` `es` on(`es`.`expeditionFk` = `e`.`id`)) where `r`.`created` >= `util`.`yesterday`() group by `r`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86600,7 +86563,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `expeditionRoute_freeTickets` AS select `t`.`routeFk` AS `routeFk`,`tss`.`ticketFk` AS `ticket`,`s`.`name` AS `code`,`w`.`name` AS `almacen`,`tss`.`updated` AS `updated`,`p`.`code` AS `parkingCode` from (((((`ticketState` `tss` join `ticket` `t` on(`t`.`id` = `tss`.`ticketFk`)) join `warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) join `state` `s` on(`s`.`id` = `tss`.`state`)) left join `ticketParking` `tp` on(`tp`.`ticketFk` = `t`.`id`)) left join `parking` `p` on(`p`.`id` = `tp`.`parkingFk`)) where ifnull(`t`.`packages`,0) = 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86618,8 +86581,8 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionScan_Monitor` AS select `et`.`id` AS `truckFk`,`et`.`eta` AS `ETD`,`et`.`description` AS `description`,`ep`.`id` AS `palletFk`,`ep`.`position` AS `position`,`ep`.`built` AS `built`,`es`.`id` AS `scanFk`,`es`.`expeditionFk` AS `expeditionFk`,`es`.`scanned` AS `scanned` from ((`expeditionTruck` `et` left join `expeditionPallet` `ep` on(`ep`.`truckFk` = `et`.`id`)) left join `expeditionScan` `es` on(`es`.`palletFk` = `ep`.`id`)) */; +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `expeditionScan_Monitor` AS select `rs`.`id` AS `truckFk`,`rs`.`eta` AS `ETD`,`rs`.`description` AS `description`,`ep`.`id` AS `palletFk`,`ep`.`position` AS `position`,`ep`.`built` AS `built`,`es`.`id` AS `scanFk`,`es`.`expeditionFk` AS `expeditionFk`,`es`.`scanned` AS `scanned` from ((`roadmapStop` `rs` left join `expeditionPallet` `ep` on(`ep`.`truckFk` = `rs`.`id`)) left join `expeditionScan` `es` on(`es`.`palletFk` = `ep`.`id`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86636,8 +86599,8 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionSticker` AS select `e`.`id` AS `expeditionFk`,`e`.`ticketFk` AS `ticketFk`,`t`.`addressFk` AS `addressFk`,`t`.`clientFk` AS `clientFk`,`a`.`street` AS `street`,`a`.`postalCode` AS `postalCode`,`a`.`city` AS `city`,`a`.`nickname` AS `nickname`,concat('R(',right(`t`.`routeFk`,3),')') AS `routeFk`,`rm`.`beachFk` AS `beachFk`,if(`t`.`routeFk`,ifnull(`et`.`description`,replace(`am`.`name`,'ZONA ','Z')),`z`.`name`) AS `zona`,`p`.`name` AS `province`,ifnull(`c`.`mobile`,ifnull(`a`.`mobile`,ifnull(`c`.`phone`,`a`.`phone`))) AS `phone`,`w`.`code` AS `workerCode` from (((((((((((`expedition` `e` join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `address` `a` on(`a`.`id` = `t`.`addressFk`)) join `province` `p` on(`p`.`id` = `a`.`provinceFk`)) left join `routesMonitor` `rm` on(`rm`.`routeFk` = `t`.`routeFk`)) left join `expeditionTruck` `et` on(`et`.`id` = `rm`.`expeditionTruckFk`)) left join `beach` `b` on(`b`.`code` = `rm`.`beachFk`)) left join `zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `route` `r` on(`r`.`id` = `t`.`routeFk`)) left join `agencyMode` `am` on(`am`.`id` = `r`.`agencyModeFk`)) join `client` `c` on(`c`.`id` = `a`.`clientFk`)) join `worker` `w` on(`w`.`id` = `e`.`workerFk`)) */; +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `expeditionSticker` AS select `e`.`id` AS `expeditionFk`,`e`.`ticketFk` AS `ticketFk`,`t`.`addressFk` AS `addressFk`,`t`.`clientFk` AS `clientFk`,`a`.`street` AS `street`,`a`.`postalCode` AS `postalCode`,`a`.`city` AS `city`,`a`.`nickname` AS `nickname`,concat('R(',right(`t`.`routeFk`,3),')') AS `routeFk`,`rm`.`beachFk` AS `beachFk`,if(`t`.`routeFk`,ifnull(`rs`.`description`,replace(`am`.`name`,'ZONA ','Z')),`z`.`name`) AS `zona`,`p`.`name` AS `province`,ifnull(`c`.`mobile`,ifnull(`a`.`mobile`,ifnull(`c`.`phone`,`a`.`phone`))) AS `phone`,`w`.`code` AS `workerCode` from (((((((((((`expedition` `e` join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `address` `a` on(`a`.`id` = `t`.`addressFk`)) join `province` `p` on(`p`.`id` = `a`.`provinceFk`)) left join `routesMonitor` `rm` on(`rm`.`routeFk` = `t`.`routeFk`)) left join `roadmapStop` `rs` on(`rs`.`id` = `rm`.`roadmapStopFk`)) left join `beach` `b` on(`b`.`code` = `rm`.`beachFk`)) left join `zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `route` `r` on(`r`.`id` = `t`.`routeFk`)) left join `agencyMode` `am` on(`am`.`id` = `r`.`agencyModeFk`)) join `client` `c` on(`c`.`id` = `a`.`clientFk`)) join `worker` `w` on(`w`.`id` = `e`.`workerFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86654,8 +86617,8 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionTicket_NoBoxes` AS select `t`.`id` AS `ticketFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`routeFk` AS `routeFk`,`et`.`description` AS `description` from (((`ticket` `t` left join `expedition` `e` on(`e`.`ticketFk` = `t`.`id`)) join `routesMonitor` `rm` on(`rm`.`routeFk` = `t`.`routeFk`)) join `expeditionTruck` `et` on(`et`.`id` = `rm`.`expeditionTruckFk`)) where `e`.`id` is null and `et`.`eta` > `util`.`VN_CURDATE`() */; +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `expeditionTicket_NoBoxes` AS select `t`.`id` AS `ticketFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`routeFk` AS `routeFk`,`rs`.`description` AS `description` from (((`ticket` `t` left join `expedition` `e` on(`e`.`ticketFk` = `t`.`id`)) join `routesMonitor` `rm` on(`rm`.`routeFk` = `t`.`routeFk`)) join `roadmapStop` `rs` on(`rs`.`id` = `rm`.`roadmapStopFk`)) where `e`.`id` is null and `rs`.`eta` > `util`.`VN_CURDATE`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86672,17 +86635,17 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `expeditionTimeExpended` AS select `e`.`ticketFk` AS `ticketFk`,min(`e`.`created`) AS `started`,max(`e`.`created`) AS `finished`,max(`e`.`counter`) AS `cajas`,`w`.`code` AS `code`,`t`.`warehouseFk` AS `warehouseFk` from ((`expedition` `e` join `worker` `w` on(`w`.`id` = `e`.`workerFk`)) join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) where `e`.`created` > `util`.`VN_CURDATE`() group by `e`.`ticketFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `expeditionTruck_Control` +-- Final view structure for view `expeditionTruck` -- -/*!50001 DROP VIEW IF EXISTS `expeditionTruck_Control`*/; +/*!50001 DROP VIEW IF EXISTS `expeditionTruck`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -86690,44 +86653,8 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionTruck_Control` AS select `e`.`truckFk` AS `id`,`e`.`eta` AS `ETD`,`e`.`description` AS `description`,count(distinct if(`e`.`expeditionFk` is null,`e`.`ticketFk`,NULL)) AS `ticketsSinBultos`,count(distinct `e`.`palletFk`) AS `pallets`,count(distinct `e`.`routeFk`) AS `routes`,count(distinct `e`.`scanFk`) AS `scans`,count(distinct `e`.`expeditionFk`) AS `expeditions`,sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,max(`e`.`lastPacked`) AS `lastPacked` from `expeditionCommon` `e` group by `e`.`truckFk` order by sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) desc,`e`.`eta` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `expeditionTruck_Control_Detail` --- - -/*!50001 DROP VIEW IF EXISTS `expeditionTruck_Control_Detail`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb4 */; -/*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionTruck_Control_Detail` AS select `e`.`truckFk` AS `id`,`e`.`eta` AS `eta`,`e`.`description` AS `destino`,`e`.`palletFk` AS `pallet`,count(distinct `e`.`routeFk`) AS `routes`,count(distinct `e`.`scanFk`) AS `scans`,count(distinct `e`.`expeditionTruckFk`) AS `destinos`,sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,max(`e`.`lastPacked`) AS `lastPacked` from `expeditionCommon` `e` group by `e`.`truckFk`,`e`.`palletFk` order by sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) desc,`e`.`eta`,`e`.`truckFk` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `expeditionTruck_Control_Detail_Pallet` --- - -/*!50001 DROP VIEW IF EXISTS `expeditionTruck_Control_Detail_Pallet`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb4 */; -/*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionTruck_Control_Detail_Pallet` AS select `e`.`truckFk` AS `id`,`e`.`eta` AS `eta`,`e`.`description` AS `destino`,`e`.`palletFk` AS `pallet`,`e`.`routeFk` AS `route`,count(distinct `e`.`scanFk`) AS `scans`,`et`.`description` AS `destinos`,sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,`e`.`expeditionTruckFk` AS `expeditionTruckFk`,max(`e`.`lastPacked`) AS `lastPacked` from (`expeditionCommon` `e` left join `expeditionTruck` `et` on(`et`.`id` = `e`.`expeditionTruckFk`)) group by `e`.`truckFk`,`e`.`palletFk`,`e`.`routeFk` order by sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) desc,`e`.`palletFk` */; +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `expeditionTruck` AS select `rs`.`id` AS `id`,`rs`.`roadmapFk` AS `roadmapFk`,`rs`.`eta` AS `eta`,`rs`.`description` AS `description`,`rs`.`bufferFk` AS `bufferFk`,`rs`.`created` AS `created`,`rs`.`userFk` AS `userFk` from `roadmapStop` `rs` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86744,7 +86671,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `firstTicketShipped` AS select min(`ticket`.`shipped`) AS `shipped`,`ticket`.`clientFk` AS `clientFk` from `ticket` where `ticket`.`shipped` > '2001-01-01' group by `ticket`.`clientFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86762,7 +86689,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `floraHollandBuyedItems` AS select `b`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`b`.`quantity` AS `quantity`,`b`.`buyingValue` AS `buyingValue`,`tr`.`landed` AS `landed`,`e`.`companyFk` AS `companyFk` from (((((`buy` `b` join `item` `i` on(`b`.`itemFk` = `i`.`id`)) join `itemType` `it` on(`it`.`id` = `i`.`typeFk`)) join `itemCategory` `ic` on(`ic`.`id` = `it`.`categoryFk`)) join `entry` `e` on(`e`.`id` = `b`.`entryFk`)) join `travel` `tr` on(`tr`.`id` = `e`.`travelFk` and `ic`.`id` not in (8,6) and `b`.`buyingValue` <> 0 and `b`.`quantity` <> 0 and `e`.`supplierFk` in (1664,1665,1666,1465,1433))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86780,7 +86707,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `inkL10n` AS select `k`.`id` AS `id`,ifnull(`i`.`name`,`k`.`name`) AS `name` from (`ink` `k` left join `inkI18n` `i` on(`i`.`inkFk` = `k`.`id` and `i`.`lang` = `util`.`lang`())) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86798,7 +86725,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `invoiceCorrectionDataSource` AS select `s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`s`.`price` AS `price`,`s`.`discount` AS `discount`,`t`.`refFk` AS `refFk`,`s`.`id` AS `saleFk`,`t`.`shipped` AS `shipped` from (`sale` `s` join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) where `t`.`shipped` > `util`.`VN_CURDATE`() + interval -3 year */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86816,7 +86743,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemBotanicalWithGenus` AS select `ib`.`itemFk` AS `itemFk`,concat(`g`.`name`,' ',ifnull(`s`.`name`,'')) AS `ediBotanic` from ((`itemBotanical` `ib` left join `specie` `s` on(`s`.`id` = `ib`.`specieFk`)) left join `genus` `g` on(`g`.`id` = `ib`.`genusFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86834,7 +86761,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemCategoryL10n` AS select `c`.`id` AS `id`,ifnull(`i`.`name`,`c`.`name`) AS `name` from (`itemCategory` `c` left join `itemCategoryI18n` `i` on(`i`.`categoryFk` = `c`.`id` and `i`.`lang` = `util`.`lang`())) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86852,7 +86779,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemColor` AS select `it`.`itemFk` AS `itemFk`,`it`.`value` AS `color` from (`itemTag` `it` join `tag` `t` on(`t`.`id` = `it`.`tagFk`)) where `t`.`code` = 'COLOR' */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86870,7 +86797,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemEntryIn` AS select `t`.`warehouseInFk` AS `warehouseInFk`,`t`.`landed` AS `landed`,`b`.`itemFk` AS `itemFk`,`b`.`quantity` AS `quantity`,`t`.`isReceived` AS `isReceived`,`e`.`isRaid` AS `isVirtualStock`,`e`.`id` AS `entryFk` from ((`buy` `b` join `entry` `e` on(`b`.`entryFk` = `e`.`id`)) join `travel` `t` on(`e`.`travelFk` = `t`.`id`)) where `e`.`isExcludedFromAvailable` = 0 and `b`.`quantity` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86888,7 +86815,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemEntryOut` AS select `t`.`warehouseOutFk` AS `warehouseOutFk`,`t`.`shipped` AS `shipped`,`b`.`itemFk` AS `itemFk`,-`b`.`quantity` AS `quantity`,`t`.`isDelivered` AS `isDelivered`,`e`.`id` AS `entryFk` from ((`buy` `b` join `entry` `e` on(`b`.`entryFk` = `e`.`id`)) join `travel` `t` on(`e`.`travelFk` = `t`.`id`)) where `e`.`isExcludedFromAvailable` = 0 and `e`.`isRaid` = 0 and `b`.`quantity` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86906,7 +86833,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemInk` AS select `i`.`longName` AS `longName`,`i`.`inkFk` AS `inkFk`,`ink`.`name` AS `color` from (`item` `i` join `ink` on(`ink`.`id` = `i`.`inkFk`)) where `ink`.`isRealColor` <> 0 group by `i`.`longName` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86924,7 +86851,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,ifnull(`isps`.`created`,`ips`.`created`) AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0)) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,`ips`.`sectorFk` AS `sectorFk` from ((((`itemPlacementSupply` `ips` join `item` `i` on(`i`.`id` = `ips`.`itemFk`)) left join `worker` `w` on(`w`.`id` = `ips`.`userFk`)) left join `worker` `rw` on(`rw`.`id` = `ips`.`repoUserFk`)) left join `itemShelvingPlacementSupply` `isps` on(`isps`.`itemPlacementSupplyFk` = `ips`.`id`)) where `ips`.`created` >= `util`.`VN_CURDATE`() group by `ips`.`priority`,`ips`.`id`,`ips`.`sectorFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86942,7 +86869,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemProductor` AS select `it`.`itemFk` AS `itemFk`,`it`.`value` AS `productor` from (`itemTag` `it` join `tag` `t` on(`t`.`id` = `it`.`tagFk`)) where `t`.`code` = 'PRODUCER' */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86960,7 +86887,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemSearch` AS select `s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`t`.`nickname` AS `nickname`,`t`.`shipped` AS `shipped` from ((`sale` `s` join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) where `t`.`shipped` between `util`.`yesterday`() and `util`.`tomorrow`() and `w`.`name` in ('VNH','Floramondo') */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -86978,8 +86905,8 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,0 AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume`,`t`.`warehouseFk` AS `warehouseFk` from (((((((((`sale` `s` join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `agencyMode` `am` on(`am`.`id` = `t`.`agencyModeFk`)) join `ticketStateToday` `tst` on(`tst`.`ticketFk` = `t`.`id`)) join `state` `st` on(`st`.`id` = `tst`.`state`)) join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `itemShelvingStock` `stock` on(`stock`.`itemFk` = `i`.`id`)) left join `saleTracking` `stk` on(`stk`.`saleFk` = `s`.`id`)) left join `zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `saleVolume` `sv` on(`sv`.`saleFk` = `s`.`id`)) where `t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(`util`.`VN_CURDATE`()) and `stk`.`id` is null and `stock`.`visible` > 0 and `stk`.`saleFk` is null and `st`.`isPreviousPreparable` <> 0 */; +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,0 AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume`,`t`.`warehouseFk` AS `warehouseFk` from (((((((((`sale` `s` join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `agencyMode` `am` on(`am`.`id` = `t`.`agencyModeFk`)) join `ticketStateToday` `tst` on(`tst`.`ticketFk` = `t`.`id`)) join `state` `st` on(`st`.`id` = `tst`.`state`)) join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `itemShelvingStock` `stock` on(`stock`.`itemFk` = `i`.`id`)) left join `saleTracking` `stk` on(`stk`.`saleFk` = `s`.`id`)) left join `zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `saleVolume` `sv` on(`sv`.`saleFk` = `s`.`id`)) where `t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(`util`.`VN_CURDATE`()) and `stk`.`id` is null and `stock`.`visible` > 0 and `stk`.`saleFk` is null and `st`.`isPreviousPreparable` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86996,7 +86923,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemShelvingList` AS select `ish`.`shelvingFk` AS `shelvingFk`,`ish`.`visible` AS `visible`,`ish`.`created` AS `created`,`pk`.`code` AS `parking`,`ish`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`parked` AS `parked`,`pk`.`sectorFk` AS `sectorFk` from (((`itemShelving` `ish` join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) join `item` `i` on(`i`.`id` = `ish`.`itemFk`)) left join `parking` `pk` on(`pk`.`id` = `sh`.`parkingFk`)) order by `ish`.`created` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87014,7 +86941,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemShelvingPlacementSupplyStock` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,`ish`.`packing` AS `packing`,`ish`.`visible` AS `stock`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`code` AS `shelving`,`p`.`code` AS `parking`,`ish`.`created` AS `created`,ifnull(`sh`.`priority`,1) AS `priority`,`p`.`id` AS `parkingFk`,`p`.`sectorFk` AS `sectorFk` from (((`itemShelving` `ish` join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) left join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) join `item` `i` on(`i`.`id` = `ish`.`itemFk`)) group by `ish`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87032,7 +86959,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemShelvingSaleSum` AS select `iss`.`id` AS `id`,`iss`.`itemShelvingFk` AS `itemShelvingFk`,`iss`.`saleFk` AS `saleFk`,sum(`iss`.`quantity`) AS `quantity`,`iss`.`created` AS `created`,`p`.`sectorFk` AS `sectorFk` from (((`itemShelvingSale` `iss` join `itemShelving` `ish` on(`ish`.`id` = `iss`.`itemShelvingFk`)) join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) group by `iss`.`saleFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87050,7 +86977,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemShelvingStock` AS select `ish`.`itemFk` AS `itemFk`,sum(`ish`.`visible`) AS `visible`,min(`ish`.`packing`) AS `packing`,min(`ish`.`grouping`) AS `grouping`,`s`.`description` AS `sector`,sum(`ish`.`visible`) AS `visibleOriginal`,0 AS `removed`,`p`.`sectorFk` AS `sectorFk`,`s`.`warehouseFk` AS `warehouseFk`,`ish`.`shelvingFk` AS `shelvingFk`,`p`.`code` AS `parkingCode`,`sh`.`parkingFk` AS `parkingFk`,`ish`.`id` AS `itemShelvingFk`,`ish`.`created` AS `created`,`st`.`code` = 'previousPrepared' AS `isPreviousPrepared` from ((((`itemShelving` `ish` left join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) left join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) left join `sector` `s` on(`s`.`id` = `p`.`sectorFk`)) left join `sectorType` `st` on(`st`.`id` = `s`.`typeFk`)) where `ish`.`visible` <> 0 and `p`.`sectorFk` <> 0 group by `ish`.`itemFk`,`p`.`sectorFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87068,7 +86995,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemShelvingStockFull` AS select `ish`.`itemFk` AS `itemFk`,`ish`.`visible` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`grouping` AS `grouping`,`s`.`description` AS `sector`,`issr`.`removed` AS `removed`,`p`.`sectorFk` AS `sectorFk`,`s`.`warehouseFk` AS `warehouseFk`,`ish`.`shelvingFk` AS `shelvingFk`,`p`.`code` AS `parkingCode`,`sh`.`parkingFk` AS `parkingFk`,`ish`.`id` AS `itemShelvingFk`,`ish`.`created` AS `created` from ((((`itemShelving` `ish` join `shelving` `sh` on(`sh`.`code` = `ish`.`shelvingFk`)) join `parking` `p` on(`p`.`id` = `sh`.`parkingFk`)) join `sector` `s` on(`s`.`id` = `p`.`sectorFk`)) left join `itemShelvingStockRemoved` `issr` on(`issr`.`itemShelvingFk` = `ish`.`id`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87086,7 +87013,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemShelvingStockRemoved` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,0 AS `removed` from ((`itemShelving` `ish` left join `itemShelvingSale` `iss` on(`iss`.`itemShelvingFk` = `ish`.`id`)) left join `itemShelvingPlacementSupply` `isps` on(`isps`.`itemShelvingFk` = `ish`.`id`)) group by `ish`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87104,7 +87031,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemTagged` AS select distinct `itemTag`.`itemFk` AS `itemFk` from `itemTag` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87122,7 +87049,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemTaxCountrySpain` AS select `i`.`id` AS `id`,`i`.`name` AS `name`,`i`.`typeFk` AS `typeFk`,`i`.`stems` AS `stems`,`i`.`description` AS `description`,`i`.`intrastatFk` AS `intrastatFk`,`i`.`expenseFk` AS `expenseFk`,`i`.`comment` AS `comment`,`i`.`relevancy` AS `relevancy`,`i`.`image` AS `image`,`i`.`generic` AS `generic`,`itc`.`taxClassFk` AS `taxClassFk` from (`item` `i` join `itemTaxCountry` `itc` on(`itc`.`itemFk` = `i`.`id`)) where `itc`.`countryFk` = 1 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87140,7 +87067,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemTicketOut` AS select `t`.`warehouseFk` AS `warehouseFk`,`t`.`shipped` AS `shipped`,`s`.`itemFk` AS `itemFk`,-`s`.`quantity` AS `quantity`,`s`.`isPicked` AS `isPicked`,`s`.`reserved` AS `reserved`,`t`.`refFk` AS `refFk`,`s`.`id` AS `saleFk`,`s`.`ticketFk` AS `ticketFk` from (`sale` `s` join `ticket` `t` on(`s`.`ticketFk` = `t`.`id`)) where `s`.`quantity` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87158,7 +87085,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `itemTypeL10n` AS select `t`.`id` AS `id`,ifnull(`i`.`name`,`t`.`name`) AS `name` from (`itemType` `t` left join `itemTypeI18n` `i` on(`i`.`typeFk` = `t`.`id` and `i`.`lang` = `util`.`LANG`())) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87176,7 +87103,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `item_Free_Id` AS select `i1`.`id` + 1 AS `newId` from (`item` `i1` left join `item` `i2` on(`i1`.`id` + 1 = `i2`.`id`)) where `i2`.`id` is null and `i1`.`isFloramondo` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87194,7 +87121,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `labelInfo` AS select `i`.`id` AS `itemId`,`i`.`name` AS `itemName`,`b`.`stickers` AS `stickers`,`b`.`printedStickers` AS `life`,`i`.`inkFk` AS `colorCode`,`i`.`stems` AS `stems`,`i`.`category` AS `category`,`i`.`subName` AS `productor`,`b`.`packing` AS `packing`,`clb`.`warehouse_id` AS `warehouse_id`,`i`.`size` AS `size`,`b`.`isPickedOff` AS `isPickedOff`,`e`.`evaNotes` AS `notes`,`w`.`name` AS `wh_in`,`e`.`id` AS `entryId`,`b`.`id` AS `buyId` from (((((`vn`.`buy` `b` join `vn`.`item` `i` on(`i`.`id` = `b`.`itemFk`)) join `cache`.`last_buy` `clb` on(`clb`.`item_id` = `i`.`id`)) join `vn`.`entry` `e` on(`e`.`id` = `b`.`entryFk`)) left join `vn`.`travel` `tr` on(`tr`.`id` = `e`.`travelFk`)) join `vn`.`warehouse` `w` on(`w`.`id` = `tr`.`warehouseInFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87212,7 +87139,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `lastHourProduction` AS select `t`.`warehouseFk` AS `warehouseFk`,cast(sum(ifnull(`p`.`volume`,`p`.`width` * `p`.`height` * `p`.`depth`) / 1000000) as decimal(5,1)) AS `m3` from (((`warehouse` `w` join `ticket` `t` on(`t`.`warehouseFk` = `w`.`id`)) left join `expedition` `e` on(`t`.`id` = `e`.`ticketFk`)) left join `packaging` `p` on(`p`.`id` = `e`.`packagingFk`)) where `e`.`created` between `util`.`VN_NOW`() - interval 1 hour and `util`.`VN_NOW`() group by `t`.`warehouseFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87230,7 +87157,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `lastPurchases` AS select `tr`.`landed` AS `landed`,`w`.`id` AS `warehouseFk`,`w`.`name` AS `warehouse`,`i`.`longName` AS `longName`,`i`.`subName` AS `subName`,`e`.`id` AS `entryFk`,`b`.`stickers` AS `stickers`,`b`.`packing` AS `packing`,`e`.`invoiceNumber` AS `ref`,`b`.`itemFk` AS `itemFk`,`ek`.`pro` AS `pro`,`ek`.`ref` AS `ektRef`,`ek`.`agj` AS `agj` from (((((`vn`.`buy` `b` join `vn`.`entry` `e` on(`e`.`id` = `b`.`entryFk`)) join `vn`.`item` `i` on(`i`.`id` = `b`.`itemFk`)) join `vn`.`travel` `tr` on(`tr`.`id` = `e`.`travelFk`)) join `vn`.`warehouse` `w` on(`w`.`id` = `tr`.`warehouseInFk`)) left join `edi`.`ekt` `ek` on(`ek`.`id` = `b`.`ektFk`)) where `tr`.`landed` between `util`.`yesterday`() and `util`.`tomorrow`() and `e`.`isRaid` = 0 and `b`.`stickers` > 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87248,7 +87175,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `lastTopClaims` AS select `s`.`itemFk` AS `itemFk`,`i`.`longName` AS `itemName`,`it`.`name` AS `itemTypeName`,count(0) AS `claimsNumber`,round(sum(`cb`.`quantity` * `s`.`price` * (1 - (`c`.`responsibility` - 1) / 4) * (100 - `s`.`discount`) / 100),2) AS `claimedAmount`,round(sum(`cb`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100),2) AS `totalAmount` from ((((`claim` `c` join `claimBeginning` `cb` on(`cb`.`claimFk` = `c`.`id`)) join `sale` `s` on(`s`.`id` = `cb`.`saleFk`)) join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `itemType` `it` on(`it`.`id` = `i`.`typeFk`)) where `c`.`created` >= `util`.`VN_CURDATE`() + interval -1 week group by `s`.`itemFk` having `claimedAmount` > 100 and `claimsNumber` > 2 or `claimsNumber` > 4 order by count(0) desc */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87266,7 +87193,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `mistake` AS select `wr`.`code` AS `revisador`,`s`.`concept` AS `concept`,`w`.`code` AS `sacador`,`w`.`firstName` AS `firstName`,`w`.`lastName` AS `lastName`,`mt`.`description` AS `description`,cast(`iss`.`created` as date) AS `created`,`w`.`id` AS `workerFk` from (((((`saleMistake` `sm` join `mistakeType` `mt` on(`mt`.`id` = `sm`.`typeFk`)) join `worker` `wr` on(`wr`.`id` = `sm`.`userFk`)) join `sale` `s` on(`s`.`id` = `sm`.`saleFk`)) join `itemShelvingSale` `iss` on(`iss`.`saleFk` = `sm`.`saleFk`)) join `worker` `w` on(`w`.`id` = `iss`.`userFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87284,7 +87211,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `mistakeRatio` AS select `wr`.`code` AS `revisador`,`w`.`code` AS `sacador`,`w`.`firstName` AS `firstName`,`w`.`lastName` AS `lastName`,`mt`.`description` AS `description`,cast(`iss`.`created` as date) AS `created`,`w`.`id` AS `workerFk`,`sm`.`saleFk` AS `saleFk` from ((((`itemShelvingSale` `iss` join `worker` `w` on(`w`.`id` = `iss`.`userFk`)) left join `saleMistake` `sm` on(`iss`.`saleFk` = `sm`.`saleFk`)) left join `mistakeType` `mt` on(`mt`.`id` = `sm`.`typeFk`)) left join `worker` `wr` on(`wr`.`id` = `sm`.`userFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87302,7 +87229,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `newBornSales` AS select `v`.`importe` AS `amount`,`v`.`Id_Cliente` AS `clientFk`,`c`.`salesPersonFk` AS `userFk`,`v`.`fecha` AS `dated`,`cn`.`firstShipped` AS `firstShipped` from ((((`bs`.`clientNewBorn` `cn` join `bs`.`ventas` `v` on(`cn`.`firstShipped` + interval 1 year > `v`.`fecha` and `v`.`Id_Cliente` = `cn`.`clientFk`)) join `vn`.`client` `c` on(`c`.`id` = `v`.`Id_Cliente`)) join `account`.`user` `u` on(`u`.`id` = `c`.`salesPersonFk`)) join `account`.`role` `r` on(`r`.`id` = `u`.`role`)) where `r`.`name` = 'salesPerson' and `u`.`name` not in ('ismaelalcolea','ruben') */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87316,11 +87243,11 @@ USE `vn`; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb3 */; -/*!50001 SET character_set_results = utf8mb3 */; -/*!50001 SET collation_connection = utf8mb3_general_ci */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `operatorWorkerCode` AS select `o`.`workerFk` AS `workerFk`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `fullName`,`w`.`code` AS `code`,`o`.`numberOfWagons` AS `numberOfWagons` from ((`worker` `w` join `operator` `o` on(`o`.`workerFk` = `w`.`id`)) join `sector` `s` on(`o`.`sectorFk` = `s`.`id`)) where `o`.`sectorFk` is not null and `s`.`code` in ('H2','H2','PEQUES_H','ALTILLO COMP','ALTILLO ARTI') */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87338,7 +87265,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `originL10n` AS select `o`.`id` AS `id`,ifnull(`i`.`name`,`o`.`name`) AS `name` from (`origin` `o` left join `originI18n` `i` on(`i`.`originFk` = `o`.`id` and `i`.`lang` = `util`.`lang`())) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87356,7 +87283,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `packageEquivalentItem` AS select `p`.`itemFk` AS `itemFk`,`p2`.`itemFk` AS `equivalentFk` from ((`packageEquivalent` `pe` join `packaging` `p` on(`p`.`id` = `pe`.`packagingFk`)) join `packaging` `p2` on(`p2`.`id` = `pe`.`equivalentFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87374,7 +87301,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `paymentExchangeInsurance` AS select `ei`.`id` AS `pago_sdc_id`,`ei`.`amount` AS `importe`,`ei`.`dated` AS `fecha`,`ei`.`dueDated` AS `vencimiento`,`ei`.`entityFk` AS `entity_id`,`ei`.`ref` AS `ref`,`ei`.`rate` AS `rate`,`ei`.`companyFk` AS `empresa_id`,`ei`.`financialProductTypefk` AS `financialProductTypefk`,`ei`.`upperBarrier` AS `upperBarrier`,`ei`.`lowerBarrier` AS `lowerBarrier`,`ei`.`strike` AS `strike` from `exchangeInsurance` `ei` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87392,7 +87319,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `payrollCenter` AS select `b`.`workCenterFkA3` AS `codCenter`,`b`.`companyFkA3` AS `companyCode` from `payrollWorkCenter` `b` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87410,7 +87337,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `personMedia` AS select `c`.`id` AS `workerFk`,ifnull(`c`.`mobile`,`c`.`phone`) AS `mediaValue` from (`client` `c` join `worker` `w` on(`w`.`id` = `c`.`id`)) having `mediaValue` is not null */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87428,7 +87355,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `phoneBook` AS select 'C' AS `Tipo`,`client`.`id` AS `Id`,`client`.`name` AS `Cliente`,`client`.`phone` AS `Telefono` from `client` where `client`.`phone` is not null union select 'C' AS `Tipo`,`client`.`id` AS `Id`,`client`.`name` AS `Cliente`,`client`.`mobile` AS `Movil` from `client` where `client`.`mobile` is not null union select 'C' AS `Tipo`,`clientContact`.`clientFk` AS `clientFk`,`clientContact`.`name` AS `name`,`clientContact`.`phone` AS `phone` from `clientContact` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87446,7 +87373,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `productionVolume` AS select hour(`e`.`created`) AS `hora`,minute(`e`.`created`) AS `minuto`,ifnull(`p`.`volume`,ifnull(`p`.`width` * `p`.`height` * `p`.`depth`,94500)) AS `cm3`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `created` from (((`expedition` `e` left join `packaging` `p` on(`p`.`id` = `e`.`packagingFk`)) join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `client` `c` on(`c`.`id` = `t`.`clientFk`)) where `e`.`created` between `util`.`VN_CURDATE`() and `util`.`dayend`(`util`.`VN_CURDATE`()) and `c`.`isRelevant` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87464,7 +87391,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `productionVolume_LastHour` AS select cast(sum(`productionVolume`.`cm3` / 1000000) as decimal(10,0)) AS `m3`,`productionVolume`.`warehouseFk` AS `warehouseFk` from `productionVolume` where `productionVolume`.`created` > `util`.`VN_NOW`() + interval -1 hour and `productionVolume`.`warehouseFk` in (1,44,60) group by `productionVolume`.`warehouseFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87482,7 +87409,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `role` AS select `account`.`role`.`id` AS `id`,`account`.`role`.`name` AS `name`,`account`.`role`.`description` AS `description`,`account`.`role`.`hasLogin` AS `hasLogin` from `account`.`role` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87500,8 +87427,8 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `routesControl` AS select `t`.`routeFk` AS `routeFk`,count(`e`.`id`) AS `expeditions`,count(`es`.`id`) AS `scanned`,count(distinct `es`.`palletFk`) AS `pallets`,max(`es`.`scanned`) AS `lastScanned`,max(`et`.`description`) AS `description`,max(`et`.`eta`) AS `eta` from ((((`ticket` `t` join `expedition` `e` on(`t`.`id` = `e`.`ticketFk`)) left join `expeditionScan` `es` on(`es`.`expeditionFk` = `e`.`id`)) left join `expeditionPallet` `ep` on(`ep`.`id` = `es`.`palletFk`)) left join `expeditionTruck` `et` on(`et`.`id` = `ep`.`truckFk`)) where `t`.`shipped` >= `util`.`VN_CURDATE`() and `t`.`routeFk` <> 0 group by `t`.`routeFk` order by max(`et`.`eta`) */; +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `routesControl` AS select `t`.`routeFk` AS `routeFk`,count(`e`.`id`) AS `expeditions`,count(`es`.`id`) AS `scanned`,count(distinct `es`.`palletFk`) AS `pallets`,max(`es`.`scanned`) AS `lastScanned`,max(`rs`.`description`) AS `description`,max(`rs`.`eta`) AS `eta` from ((((`ticket` `t` join `expedition` `e` on(`t`.`id` = `e`.`ticketFk`)) left join `expeditionScan` `es` on(`es`.`expeditionFk` = `e`.`id`)) left join `expeditionPallet` `ep` on(`ep`.`id` = `es`.`palletFk`)) left join `roadmapStop` `rs` on(`rs`.`id` = `ep`.`truckFk`)) where `t`.`shipped` >= `util`.`VN_CURDATE`() and `t`.`routeFk` <> 0 group by `t`.`routeFk` order by max(`rs`.`eta`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87518,8 +87445,8 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleCost` AS select `s`.`itemFk` AS `itemFk`,`s`.`ticketFk` AS `ticketFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`s`.`discount` AS `discount`,`s`.`price` AS `price`,`c`.`name` AS `component`,`sc`.`value` AS `coste` from (((`sale` `s` join `saleComponent` `sc` on(`sc`.`saleFk` = `s`.`id`)) join `component` `c` on(`c`.`id` = `sc`.`componentFk`)) join `componentType` `ct` on(`ct`.`id` = `c`.`typeFk`)) where `ct`.`type` = 'coste' */; +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `saleCost` AS select `s`.`itemFk` AS `itemFk`,`s`.`ticketFk` AS `ticketFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`s`.`discount` AS `discount`,`s`.`price` AS `price`,`c`.`name` AS `component`,`sc`.`value` AS `coste` from (((`sale` `s` join `saleComponent` `sc` on(`sc`.`saleFk` = `s`.`id`)) join `component` `c` on(`c`.`id` = `sc`.`componentFk`)) join `componentType` `ct` on(`ct`.`id` = `c`.`typeFk`)) where `ct`.`code` = 'cost' */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87536,7 +87463,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `saleMistakeList` AS select `st`.`saleFk` AS `saleFk`,`st`.`workerFk` AS `workerFk`,concat(`w2`.`firstName`,' ',`w2`.`lastName`) AS `sacador`,`st`.`created` AS `created`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `revisador`,`mt`.`description` AS `description`,`sm`.`created` AS `controlled` from (((((`saleTracking` `st` join `worker` `w2` on(`w2`.`id` = `st`.`workerFk`)) join `state` `s` on(`s`.`id` = `st`.`stateFk` and `s`.`code` in ('PREVIOUS_PREPARATION','PREPARED','OK'))) left join `saleMistake` `sm` on(`st`.`saleFk` = `sm`.`saleFk`)) left join `mistakeType` `mt` on(`mt`.`id` = `sm`.`typeFk`)) left join `worker` `w` on(`w`.`id` = `sm`.`userFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87554,7 +87481,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `saleMistake_list__2` AS select `st`.`saleFk` AS `saleFk`,`st`.`workerFk` AS `workerFk`,concat(`w2`.`firstName`,' ',`w2`.`lastName`) AS `sacador`,`st`.`created` AS `created`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `revisador`,`mt`.`description` AS `description`,`sm`.`created` AS `controlled` from (((((`saleTracking` `st` join `worker` `w2` on(`w2`.`id` = `st`.`workerFk`)) join `state` `s` on(`s`.`id` = `st`.`stateFk` and `s`.`code` in ('PREVIOUS_PREPARATION','PREPARED','OK'))) left join `saleMistake` `sm` on(`st`.`saleFk` = `sm`.`saleFk`)) left join `mistakeType` `mt` on(`mt`.`id` = `sm`.`typeFk`)) left join `worker` `w` on(`w`.`id` = `sm`.`userFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87572,7 +87499,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `saleSaleTracking` AS select distinct `st`.`saleFk` AS `saleFk` from `saleTracking` `st` where `st`.`created` >= `util`.`VN_CURDATE`() + interval -1 day */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87590,7 +87517,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `saleValue` AS select `wh`.`name` AS `warehouse`,`c`.`name` AS `client`,`c`.`typeFk` AS `typeFk`,`u`.`name` AS `buyer`,`it`.`id` AS `itemTypeFk`,`it`.`name` AS `family`,`s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`b`.`buyingValue` + `b`.`freightValue` + `b`.`comissionValue` + `b`.`packageValue` AS `cost`,(`b`.`buyingValue` + `b`.`freightValue` + `b`.`comissionValue` + `b`.`packageValue`) * `s`.`quantity` AS `value`,`tm`.`year` AS `year`,`tm`.`week` AS `week` from (((((((((`vn`.`sale` `s` join `vn`.`item` `i` on(`i`.`id` = `s`.`itemFk`)) join `vn`.`itemType` `it` on(`it`.`id` = `i`.`typeFk`)) join `account`.`user` `u` on(`u`.`id` = `it`.`workerFk`)) join `vn`.`ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `vn`.`client` `c` on(`c`.`id` = `t`.`clientFk`)) join `vn`.`warehouse` `wh` on(`wh`.`id` = `t`.`warehouseFk`)) join `vn`.`time` `tm` on(`tm`.`dated` = cast(`t`.`shipped` as date))) join `cache`.`last_buy` `lb` on(`lb`.`item_id` = `i`.`id` and `lb`.`warehouse_id` = `wh`.`id`)) join `vn`.`buy` `b` on(`b`.`id` = `lb`.`buy_id`)) where `wh`.`isManaged` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87608,8 +87535,8 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,round(`ic`.`cm3delivery` * `s`.`quantity` / 1000,0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `volume`,`s`.`quantity` * `ic`.`grams` / 1000 AS `physicalWeight`,`s`.`quantity` * `ic`.`cm3delivery` * greatest(`ic`.`grams` / `ic`.`cm3delivery`,`vc`.`aerealVolumetricDensity`) / 1000000 AS `weight`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `physicalVolume`,`s`.`quantity` * `ic`.`cm3delivery` * ifnull(`t`.`zonePrice` - ifnull(`t`.`zoneBonus`,0),`z`.`price` - `z`.`bonus`) / (`vc`.`standardFlowerBox` * 1000) * `z`.`inflation` AS `freight`,`t`.`zoneFk` AS `zoneFk`,`t`.`clientFk` AS `clientFk`,`s`.`isPicked` AS `isPicked`,`s`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100 AS `eurosValue`,`i`.`itemPackingTypeFk` AS `itemPackingTypeFk` from (((((`sale` `s` join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `zone` `z` on(`z`.`id` = `t`.`zoneFk`)) join `volumeConfig` `vc`) join `itemCost` `ic` on(`ic`.`itemFk` = `s`.`itemFk` and `ic`.`warehouseFk` = `t`.`warehouseFk`)) where `s`.`quantity` > 0 */; +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,round(`ic`.`cm3delivery` * `s`.`quantity` / 1000,0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `volume`,`s`.`quantity` * `ic`.`grams` / 1000 AS `physicalWeight`,`s`.`quantity` * `ic`.`cm3delivery` * greatest(`ic`.`grams` / `ic`.`cm3delivery`,`vc`.`aerealVolumetricDensity`) / 1000000 AS `weight`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `physicalVolume`,`s`.`quantity` * `ic`.`cm3delivery` * ifnull(`t`.`zonePrice` - ifnull(`t`.`zoneBonus`,0),`z`.`price` - `z`.`bonus`) / (`vc`.`standardFlowerBox` * 1000) * `z`.`inflation` AS `freight`,`t`.`zoneFk` AS `zoneFk`,`t`.`clientFk` AS `clientFk`,`s`.`isPicked` AS `isPicked`,`s`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100 AS `eurosValue`,`i`.`itemPackingTypeFk` AS `itemPackingTypeFk` from (((((`sale` `s` join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `zone` `z` on(`z`.`id` = `t`.`zoneFk`)) join `volumeConfig` `vc`) join `itemCost` `ic` FORCE INDEX (PRIMARY) on(`ic`.`itemFk` = `s`.`itemFk` and `ic`.`warehouseFk` = `t`.`warehouseFk`)) where `s`.`quantity` > 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87626,8 +87553,8 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleVolume_Today_VNH` AS select `t`.`nickname` AS `Cliente`,`p`.`name` AS `Provincia`,`c`.`country` AS `Pais`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `volume` from (((((`saleVolume` `sv` join `ticket` `t` on(`t`.`id` = `sv`.`ticketFk`)) join `address` `a` on(`a`.`id` = `t`.`addressFk`)) join `province` `p` on(`p`.`id` = `a`.`provinceFk`)) join `country` `c` on(`c`.`id` = `p`.`countryFk`)) join `warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) where `w`.`name` = 'VNH' and `t`.`shipped` between `util`.`VN_CURDATE`() and `util`.`dayend`(`util`.`VN_CURDATE`()) group by `t`.`nickname`,`p`.`name` */; +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `saleVolume_Today_VNH` AS select `t`.`nickname` AS `Cliente`,`p`.`name` AS `Provincia`,`c`.`name` AS `Pais`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `volume` from (((((`saleVolume` `sv` join `ticket` `t` on(`t`.`id` = `sv`.`ticketFk`)) join `address` `a` on(`a`.`id` = `t`.`addressFk`)) join `province` `p` on(`p`.`id` = `a`.`provinceFk`)) join `country` `c` on(`c`.`id` = `p`.`countryFk`)) join `warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) where `w`.`name` = 'VNH' and `t`.`shipped` between `util`.`VN_CURDATE`() and `util`.`dayend`(`util`.`VN_CURDATE`()) group by `t`.`nickname`,`p`.`name` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87644,8 +87571,8 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `sale_freightComponent` AS select `t`.`id` AS `ticketFk`,`sc`.`value` * `s`.`quantity` AS `amount`,`t`.`shipped` AS `shipped` from ((((`ticket` `t` straight_join `sale` `s` on(`t`.`id` = `s`.`ticketFk`)) join `saleComponent` `sc` on(`sc`.`saleFk` = `s`.`id`)) join `component` `c` on(`c`.`id` = `sc`.`componentFk`)) join `componentType` `ct` on(`ct`.`id` = `c`.`typeFk` and `ct`.`type` = 'agencia')) */; +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `sale_freightComponent` AS select `t`.`id` AS `ticketFk`,`sc`.`value` * `s`.`quantity` AS `amount`,`t`.`shipped` AS `shipped` from ((((`ticket` `t` straight_join `sale` `s` on(`t`.`id` = `s`.`ticketFk`)) join `saleComponent` `sc` on(`sc`.`saleFk` = `s`.`id`)) join `component` `c` on(`c`.`id` = `sc`.`componentFk`)) join `componentType` `ct` on(`ct`.`id` = `c`.`typeFk` and `ct`.`code` = 'freight')) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87662,7 +87589,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `salesPersonSince` AS select `b`.`workerFk` AS `workerFk`,min(`b`.`started`) AS `started` from ((`business` `b` join `worker` `w` on(`w`.`id` = `b`.`workerFk`)) left join `professionalCategory` `pc` on(`pc`.`id` = `b`.`workerBusinessProfessionalCategoryFk`)) where `pc`.`description` = 'Aux ventas' group by `b`.`workerFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87680,7 +87607,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `salesPreparedLastHour` AS select `t`.`warehouseFk` AS `warehouseFk`,`st`.`saleFk` AS `saleFk`,`st`.`isChecked` AS `isChecked`,`st`.`originalQuantity` AS `originalQuantity`,`st`.`created` AS `created`,`e`.`code` AS `code`,`w`.`firstName` AS `firstname`,`w`.`lastName` AS `lastName`,`w`.`code` AS `workerCode`,`ic`.`cm3delivery` * `s`.`quantity` / 1000 AS `litros`,`s`.`concept` AS `concept`,`d`.`name` AS `departmentName` from ((((((((`saleTracking` `st` left join `salesPreviousPreparated` `prevPrepSales` on(`prevPrepSales`.`saleFk` = `st`.`saleFk`)) join `sale` `s` on(`s`.`id` = `st`.`saleFk`)) join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `itemCost` `ic` on(`ic`.`warehouseFk` = `t`.`warehouseFk` and `ic`.`itemFk` = `s`.`itemFk`)) join `worker` `w` on(`w`.`id` = `st`.`workerFk`)) join `state` `e` on(`e`.`id` = `st`.`stateFk`)) join `workerDepartment` `wd` on(`wd`.`workerFk` = `st`.`workerFk`)) join `department` `d` on(`d`.`id` = `wd`.`departmentFk`)) where `st`.`created` > `util`.`VN_NOW`() + interval -1 hour and `prevPrepSales`.`saleFk` is null and `d`.`name` not like 'EQUIPO%' */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87698,7 +87625,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `salesPreviousPreparated` AS select `st`.`saleFk` AS `saleFk` from (`saleTracking` `st` join `state` `e` on(`e`.`id` = `st`.`stateFk`)) where `st`.`created` > `util`.`VN_CURDATE`() and `e`.`code` like 'PREVIOUS_PREPARATION' */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87716,7 +87643,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `supplierPackaging` AS select `e`.`supplierFk` AS `supplierFk`,`b`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`s`.`name` AS `supplier`,`b`.`entryFk` AS `entryFk`,`tr`.`landed` AS `landed`,-least(`b`.`quantity`,0) AS `out`,greatest(`b`.`quantity`,0) AS `in`,`w`.`name` AS `warehouse`,`b`.`buyingValue` AS `buyingValue` from ((((((`buy` `b` join `item` `i` on(`i`.`id` = `b`.`itemFk`)) join `packaging` `p` on(`p`.`itemFk` = `i`.`id`)) join `entry` `e` on(`e`.`id` = `b`.`entryFk`)) join `supplier` `s` on(`s`.`id` = `e`.`supplierFk`)) join `travel` `tr` on(`tr`.`id` = `e`.`travelFk`)) join `warehouse` `w` on(`w`.`id` = `tr`.`warehouseInFk`)) where `p`.`isPackageReturnable` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87734,7 +87661,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `tagL10n` AS select `t`.`id` AS `id`,ifnull(`i`.`name`,`t`.`name`) AS `name` from (`tag` `t` left join `tagI18n` `i` on(`i`.`tagFk` = `t`.`id` and `i`.`lang` = `util`.`LANG`())) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87752,7 +87679,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `ticketDownBuffer` AS select `td`.`ticketFk` AS `ticketFk`,`td`.`created` AS `created`,`td`.`selected` AS `selected`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `sacador`,`pk`.`code` AS `parking` from ((((`ticketDown` `td` join `ticketParking` `tp` on(`tp`.`ticketFk` = `td`.`ticketFk`)) join `parking` `pk` on(`pk`.`id` = `tp`.`parkingFk`)) join `ticketStateToday` `tst` on(`tst`.`ticketFk` = `td`.`ticketFk`)) join `worker` `w` on(`w`.`id` = `tst`.`userFk`)) where `td`.`selected` = 2 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87770,7 +87697,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `ticketLastUpdated` AS select `ticketLastUpdatedList`.`ticketFk` AS `ticketFk`,max(`ticketLastUpdatedList`.`created`) AS `lastUpdated` from `ticketLastUpdatedList` group by `ticketLastUpdatedList`.`ticketFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87788,7 +87715,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `ticketLastUpdatedList` AS select `s`.`ticketFk` AS `ticketFk`,`st`.`created` AS `created` from (`saleTracking` `st` join `sale` `s` on(`s`.`id` = `st`.`saleFk`)) where `st`.`created` > `util`.`VN_CURDATE`() union all select `tt`.`ticketFk` AS `Id_Ticket`,`tt`.`created` AS `odbc_date` from `ticketTracking` `tt` where `tt`.`created` > `util`.`VN_CURDATE`() union all select `s`.`ticketFk` AS `ticketFk`,`iss`.`created` AS `created` from (`itemShelvingSale` `iss` join `sale` `s` on(`s`.`id` = `iss`.`saleFk`)) where `iss`.`created` > `util`.`VN_CURDATE`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87806,7 +87733,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `ticketNotInvoiced` AS select `t`.`companyFk` AS `companyFk`,`cm`.`code` AS `companyCode`,`t`.`clientFk` AS `clientFk`,`c`.`name` AS `clientName`,`t`.`shipped` AS `shipped`,cast(sum(`s`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100) as decimal(10,2)) AS `value` from (((`ticket` `t` join `sale` `s` on(`s`.`ticketFk` = `t`.`id`)) join `client` `c` on(`c`.`id` = `t`.`clientFk`)) join `company` `cm` on(`cm`.`id` = `t`.`companyFk`)) where `t`.`refFk` is null and `t`.`shipped` > '2017-01-01' group by `t`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87824,7 +87751,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `ticketPackingList` AS select `t`.`nickname` AS `nickname`,`t`.`id` AS `ticketFk`,`am`.`name` AS `agencyMode`,`am`.`flag` AS `flag`,`p`.`name` AS `province`,`s`.`itemFk` AS `itemFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`sv`.`litros` AS `litros`,`to`.`description` AS `observaciones` from (((((((`ticket` `t` join `address` `a` on(`a`.`id` = `t`.`addressFk`)) join `province` `p` on(`p`.`id` = `a`.`provinceFk`)) join `agencyMode` `am` on(`am`.`id` = `t`.`agencyModeFk`)) left join `sale` `s` on(`s`.`ticketFk` = `t`.`id`)) left join `saleVolume` `sv` on(`sv`.`saleFk` = `s`.`id`)) join `observationType` `ot` on(`ot`.`code` = 'packager')) left join `ticketObservation` `to` on(`to`.`ticketFk` = `t`.`id` and `ot`.`id` = `to`.`observationTypeFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87842,8 +87769,8 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketPreviousPreparingList` AS select `s`.`ticketFk` AS `ticketFk`,`w`.`code` AS `code`,count(`s`.`id`) AS `saleLines`,sum(`s`.`isPicked` <> 0) AS `alreadyMadeSaleLines`,sum(`s`.`isPicked` <> 0) / count(`s`.`id`) AS `madeRate`,`sg`.`created` AS `created`,`p`.`code` AS `parking`,`iss`.`sectorFk` AS `sectorFk`,`al`.`code` AS `alertCode` from (((((((`saleGroup` `sg` join `saleGroupDetail` `sgd` on(`sgd`.`saleGroupFk` = `sg`.`id`)) join `sale` `s` on(`s`.`id` = `sgd`.`saleFk`)) join `ticketState` `tls` on(`tls`.`ticketFk` = `s`.`ticketFk`)) join `alertLevel` `al` on(`al`.`id` = `tls`.`alertLevel`)) join `worker` `w` on(`w`.`id` = `sg`.`userFk`)) left join `parking` `p` on(`p`.`id` = `sg`.`parkingFk`)) join `itemShelvingStock` `iss` on(`iss`.`itemFk` = `s`.`itemFk`)) where `sg`.`created` >= `util`.`VN_CURDATE`() + interval 0.1 day group by `sg`.`id` */; +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `ticketPreviousPreparingList` AS select `s`.`ticketFk` AS `ticketFk`,`w`.`code` AS `code`,count(`s`.`id`) AS `saleLines`,sum(`s`.`isPicked` <> 0) AS `alreadyMadeSaleLines`,sum(`s`.`isPicked` <> 0) / count(`s`.`id`) AS `madeRate`,`sg`.`created` AS `created`,`p`.`code` AS `parking`,`iss`.`sectorFk` AS `sectorFk`,`al`.`code` AS `alertCode` from (((((((`saleGroup` `sg` join `saleGroupDetail` `sgd` on(`sgd`.`saleGroupFk` = `sg`.`id`)) join `sale` `s` FORCE INDEX (PRIMARY) on(`s`.`id` = `sgd`.`saleFk`)) join `ticketState` `tls` on(`tls`.`ticketFk` = `s`.`ticketFk`)) join `alertLevel` `al` on(`al`.`id` = `tls`.`alertLevel`)) join `worker` `w` on(`w`.`id` = `sg`.`userFk`)) left join `parking` `p` on(`p`.`id` = `sg`.`parkingFk`)) join `itemShelvingStock` `iss` on(`iss`.`itemFk` = `s`.`itemFk`)) where `sg`.`created` >= `util`.`VN_CURDATE`() + interval 0.1 day group by `sg`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87860,7 +87787,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `ticketState` AS select `tt`.`created` AS `updated`,`tt`.`stateFk` AS `stateFk`,`tt`.`userFk` AS `userFk`,`tls`.`ticketFk` AS `ticketFk`,`s`.`id` AS `state`,`s`.`order` AS `productionOrder`,`s`.`alertLevel` AS `alertLevel`,`s`.`code` AS `code`,`s`.`isPreviousPreparable` AS `isPreviousPreparable`,`s`.`isPicked` AS `isPicked` from ((`ticketLastState` `tls` join `ticketTracking` `tt` on(`tt`.`id` = `tls`.`ticketTrackingFk`)) join `state` `s` on(`s`.`id` = `tt`.`stateFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87878,8 +87805,8 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketStateToday` AS select `ts`.`ticketFk` AS `ticketFk`,`ts`.`state` AS `state`,`ts`.`productionOrder` AS `productionOrder`,`ts`.`alertLevel` AS `alertLevel`,`ts`.`userFk` AS `userFk`,`ts`.`code` AS `code`,`ts`.`updated` AS `updated`,`ts`.`isPicked` AS `isPicked` from (`ticketState` `ts` join `ticket` `t` on(`t`.`id` = `ts`.`ticketFk`)) where `t`.`shipped` between `util`.`VN_CURDATE`() and `MIDNIGHT`(`util`.`VN_CURDATE`()) */; +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `ticketStateToday` AS select `ts`.`ticketFk` AS `ticketFk`,`ts`.`state` AS `state`,`ts`.`productionOrder` AS `productionOrder`,`ts`.`alertLevel` AS `alertLevel`,`ts`.`userFk` AS `userFk`,`ts`.`code` AS `code`,`ts`.`updated` AS `updated`,`ts`.`isPicked` AS `isPicked` from (`ticketState` `ts` join `ticket` `t` on(`t`.`id` = `ts`.`ticketFk`)) where `t`.`shipped` between `util`.`VN_CURDATE`() and `util`.`midnight`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87896,7 +87823,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `tr2` AS select `travel`.`id` AS `id`,`travel`.`shipped` AS `shipped`,`travel`.`shipmentHour` AS `shipmentHour`,`travel`.`landed` AS `landed`,`travel`.`landingHour` AS `landingHour`,`travel`.`warehouseInFk` AS `warehouseInFk`,`travel`.`warehouseOutFk` AS `warehouseOutFk`,`travel`.`agencyModeFk` AS `agencyFk`,`travel`.`ref` AS `ref`,`travel`.`isDelivered` AS `isDelivered`,`travel`.`isReceived` AS `isReceived`,`travel`.`m3` AS `m3`,`travel`.`kg` AS `kg`,`travel`.`cargoSupplierFk` AS `cargoSupplierFk`,`travel`.`totalEntries` AS `totalEntries` from `travel` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87914,7 +87841,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `traceabilityBuy` AS select `b`.`id` AS `buyFk`,`b`.`quantity` AS `quantity`,`tr`.`landed` AS `landed`,`w`.`name` AS `warehouseName`,`b`.`entryFk` AS `entryFk`,`s`.`name` AS `supplierName`,ifnull(`b`.`itemOriginalFk`,`b`.`itemFk`) AS `itemFk` from ((((`buy` `b` join `entry` `e` on(`e`.`id` = `b`.`entryFk`)) join `travel` `tr` on(`tr`.`id` = `e`.`travelFk`)) join `supplier` `s` on(`s`.`id` = `e`.`supplierFk`)) join `warehouse` `w` on(`w`.`id` = `tr`.`warehouseInFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87932,7 +87859,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `traceabilitySale` AS select `s`.`ticketFk` AS `ticketFk`,`sb`.`buyFk` AS `buyFk`,`t`.`shipped` AS `shipped`,`t`.`nickname` AS `nickname`,`s`.`quantity` AS `quantity`,concat(`w`.`firstName`,' ',`w`.`lastName`) AS `worker` from (((`saleBuy` `sb` join `sale` `s` on(`s`.`id` = `sb`.`saleFk`)) join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `worker` `w` on(`w`.`id` = `sb`.`workerFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87950,7 +87877,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `workerBusinessDated` AS select `t`.`dated` AS `dated`,`b`.`id` AS `businessFk`,`b`.`workerFk` AS `workerFk` from (`time` `t` left join `business` `b` on(`t`.`dated` between `b`.`started` and ifnull(`b`.`ended`,`util`.`VN_CURDATE`()))) where `t`.`dated` > `util`.`VN_CURDATE`() + interval -2 year */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87968,7 +87895,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `workerDepartment` AS select `b`.`workerFk` AS `workerFk`,`b`.`departmentFk` AS `departmentFk` from (`business` `b` join `worker` `w` on(`w`.`businessFk` = `b`.`id`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -87986,7 +87913,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `workerLabour` AS select `b`.`id` AS `businessFk`,`b`.`workerFk` AS `workerFk`,`b`.`workcenterFk` AS `workCenterFk`,`b`.`started` AS `started`,`b`.`ended` AS `ended`,`b`.`departmentFk` AS `departmentFk`,`b`.`payedHolidays` AS `payedHolidays` from `business` `b` order by `b`.`started` desc */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -88004,7 +87931,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `workerMedia` AS select `w`.`id` AS `workerFk`,`w`.`phone` AS `mediaValue` from `worker` `w` where `w`.`phone` is not null */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -88022,7 +87949,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `workerSpeedExpedition` AS select `sv`.`ticketFk` AS `ticketFk`,sum(`sv`.`litros`) AS `litros`,sum(if(`sub`.`started` > `util`.`VN_NOW`() + interval -1 hour,`sv`.`litros`,0)) AS `literLastHour`,cast(60 * sum(`sv`.`litros`) / time_to_sec(timediff(max(`sub`.`finished`),min(`sub`.`started`))) as decimal(10,1)) AS `litersByMinute`,`sub`.`code` AS `workerCode`,`sub`.`cajas` AS `cajas`,`sub`.`warehouseFk` AS `warehouseFk` from (`saleVolume` `sv` join `expeditionTimeExpended` `sub` on(`sub`.`ticketFk` = `sv`.`ticketFk`)) group by `sub`.`code` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -88040,7 +87967,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `workerSpeedSaleTracking` AS select `salesPreparedLastHour`.`warehouseFk` AS `warehouseFk`,`salesPreparedLastHour`.`code` AS `state`,`salesPreparedLastHour`.`workerCode` AS `workerCode`,sum(`salesPreparedLastHour`.`litros`) AS `sumaLitros`,min(`salesPreparedLastHour`.`created`) AS `started`,max(`salesPreparedLastHour`.`created`) AS `finished`,sum(if(`salesPreparedLastHour`.`created` >= `util`.`VN_NOW`() + interval -1 hour,`salesPreparedLastHour`.`litros`,0)) AS `sumaLitrosLastHour`,cast(60 * sum(`salesPreparedLastHour`.`litros`) / time_to_sec(timediff(max(`salesPreparedLastHour`.`created`),min(`salesPreparedLastHour`.`created`))) as decimal(10,1)) AS `litersByMinute`,`salesPreparedLastHour`.`departmentName` AS `departmentName` from `salesPreparedLastHour` group by `salesPreparedLastHour`.`warehouseFk`,`salesPreparedLastHour`.`code`,`salesPreparedLastHour`.`workerCode` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -88058,7 +87985,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `workerTeamCollegues` AS select distinct `w`.`workerFk` AS `workerFk`,`t`.`workerFk` AS `collegueFk` from (`workerTeam` `w` join `workerTeam` `t` on(`w`.`team` = `t`.`team`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -88076,7 +88003,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `workerTimeControlUserInfo` AS select `u`.`id` AS `userFk`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`u`.`name` AS `user`,`u`.`password` AS `password`,`wd`.`departmentFk` AS `departmentFk`,left(`c`.`fi`,8) AS `dni` from (((`account`.`user` `u` join `vn`.`worker` `w` on(`w`.`id` = `u`.`id`)) join `vn`.`client` `c` on(`c`.`id` = `u`.`id`)) left join `vn`.`workerDepartment` `wd` on(`wd`.`workerFk` = `w`.`id`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -88094,7 +88021,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `workerTimeJourneyNG` AS select `wtc`.`userFk` AS `userFk`,cast(`wtc`.`timed` as date) AS `dated`,if(`wtc`.`order` MOD 2,-1,1) * (hour(`wtc`.`timed`) + minute(`wtc`.`timed`) / 60) AS `Journey`,dayname(`wtc`.`timed`) AS `dayName`,`w`.`lastName` AS `name`,`w`.`firstName` AS `firstname` from (`workerTimeControl` `wtc` join `worker` `w` on(`w`.`id` = `wtc`.`userFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -88112,7 +88039,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `workerWithoutTractor` AS select `c`.`workerFk` AS `workerFk`,`cl`.`name` AS `Trabajador`,count(distinct `c`.`id`) AS `Colecciones`,max(`c`.`created`) AS `created` from ((`collection` `c` join `client` `cl` on(`cl`.`id` = `c`.`workerFk`)) left join `machineWorker` `mw` on(`mw`.`workerFk` = `c`.`workerFk` and `mw`.`inTimed` > `util`.`VN_CURDATE`())) where `c`.`created` > `util`.`VN_CURDATE`() and `mw`.`workerFk` is null group by `c`.`workerFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -88130,7 +88057,7 @@ USE `vn`; /*!50001 SET character_set_results = utf8mb4 */; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `zoneEstimatedDelivery` AS select `t`.`zoneFk` AS `zoneFk`,`zc`.`hour` AS `zoneClosureHour`,`z`.`hour` AS `zoneHour`,`sv`.`volume` AS `volume`,`al`.`hasToRecalcPrice` AS `hasToRecalcPrice`,`lhp`.`m3` AS `m3`,`dl`.`minSpeed` AS `minSpeed` from (((((((((`vn`.`ticket` `t` join `vn`.`ticketStateToday` `tst` on(`tst`.`ticketFk` = `t`.`id`)) join `vn`.`state` `s` on(`s`.`id` = `tst`.`state`)) join `vn`.`saleVolume` `sv` on(`sv`.`ticketFk` = `t`.`id`)) left join `vn`.`lastHourProduction` `lhp` on(`lhp`.`warehouseFk` = `t`.`warehouseFk`)) join `vn`.`warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) straight_join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `vn`.`zoneClosure` `zc` on(`zc`.`zoneFk` = `t`.`zoneFk` and `zc`.`dated` = `util`.`VN_CURDATE`())) left join `cache`.`departure_limit` `dl` on(`dl`.`warehouse_id` = `t`.`warehouseFk` and `dl`.`fecha` = `util`.`VN_CURDATE`())) join `vn`.`alertLevel` `al` on(`al`.`id` = `s`.`alertLevel`)) where `w`.`hasProduction` <> 0 and cast(`t`.`shipped` as date) = `util`.`VN_CURDATE`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -88173,7 +88100,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `Articles` AS select `i`.`id` AS `Id_Article`,`i`.`name` AS `Article`,`i`.`typeFk` AS `tipo_id`,`i`.`size` AS `Medida`,`i`.`inkFk` AS `Color`,`i`.`category` AS `Categoria`,`i`.`stems` AS `Tallos`,`i`.`originFk` AS `id_origen`,`i`.`description` AS `description`,`i`.`producerFk` AS `producer_id`,`i`.`intrastatFk` AS `Codintrastat`,`i`.`box` AS `caja`,`i`.`expenseFk` AS `expenseFk`,`i`.`comment` AS `comments`,`i`.`relevancy` AS `relevancy`,`i`.`image` AS `Foto`,`i`.`generic` AS `generic`,`i`.`density` AS `density`,`i`.`minPrice` AS `PVP`,`i`.`hasMinPrice` AS `Min`,`i`.`isActive` AS `isActive`,`i`.`longName` AS `longName`,`i`.`subName` AS `subName`,`i`.`tag5` AS `tag5`,`i`.`value5` AS `value5`,`i`.`tag6` AS `tag6`,`i`.`value6` AS `value6`,`i`.`tag7` AS `tag7`,`i`.`value7` AS `value7`,`i`.`tag8` AS `tag8`,`i`.`value8` AS `value8`,`i`.`tag9` AS `tag9`,`i`.`value9` AS `value9`,`i`.`tag10` AS `tag10`,`i`.`value10` AS `value10`,`i`.`minimum` AS `minimum`,`i`.`upToDown` AS `upToDown`,`i`.`hasKgPrice` AS `hasKgPrice`,`i`.`equivalent` AS `Equivalente`,`i`.`isToPrint` AS `Imprimir`,`i`.`family` AS `Familia__`,`i`.`doPhoto` AS `do_photo`,`i`.`created` AS `odbc_date`,`i`.`isFloramondo` AS `isFloramondo`,`i`.`supplyResponseFk` AS `supplyResponseFk`,`i`.`stemMultiplier` AS `stemMultiplier`,`i`.`itemPackingTypeFk` AS `itemPackingTypeFk`,`i`.`packingOut` AS `packingOut` from `vn`.`item` `i` */; +/*!50001 VIEW `Articles` AS select `i`.`id` AS `Id_Article`,`i`.`name` AS `Article`,`i`.`typeFk` AS `tipo_id`,`i`.`size` AS `Medida`,`i`.`inkFk` AS `Color`,`i`.`category` AS `Categoria`,`i`.`stems` AS `Tallos`,`i`.`originFk` AS `id_origen`,`i`.`description` AS `description`,`i`.`producerFk` AS `producer_id`,`i`.`intrastatFk` AS `Codintrastat`,`i`.`box` AS `caja`,`i`.`expenseFk` AS `expenseFk`,`i`.`comment` AS `comments`,`i`.`relevancy` AS `relevancy`,`i`.`image` AS `Foto`,`i`.`generic` AS `generic`,`i`.`density` AS `density`,`i`.`minPrice` AS `PVP`,`i`.`hasMinPrice` AS `Min`,`i`.`isActive` AS `isActive`,`i`.`longName` AS `longName`,`i`.`subName` AS `subName`,`i`.`tag5` AS `tag5`,`i`.`value5` AS `value5`,`i`.`tag6` AS `tag6`,`i`.`value6` AS `value6`,`i`.`tag7` AS `tag7`,`i`.`value7` AS `value7`,`i`.`tag8` AS `tag8`,`i`.`value8` AS `value8`,`i`.`tag9` AS `tag9`,`i`.`value9` AS `value9`,`i`.`tag10` AS `tag10`,`i`.`value10` AS `value10`,`i`.`minimum` AS `minimum`,`i`.`upToDown` AS `upToDown`,`i`.`hasKgPrice` AS `hasKgPrice`,`i`.`equivalent` AS `Equivalente`,`i`.`isToPrint` AS `Imprimir`,`i`.`doPhoto` AS `do_photo`,`i`.`created` AS `odbc_date`,`i`.`isFloramondo` AS `isFloramondo`,`i`.`supplyResponseFk` AS `supplyResponseFk`,`i`.`stemMultiplier` AS `stemMultiplier`,`i`.`itemPackingTypeFk` AS `itemPackingTypeFk`,`i`.`packingOut` AS `packingOut` from `vn`.`item` `i` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88276,12 +88203,12 @@ USE `vn2008`; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb3 */; -/*!50001 SET character_set_results = utf8mb3 */; -/*!50001 SET collation_connection = utf8mb3_general_ci */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `Compres` AS select `c`.`id` AS `Id_Compra`,`c`.`entryFk` AS `Id_Entrada`,`c`.`itemFk` AS `Id_Article`,`c`.`buyingValue` AS `Costefijo`,`c`.`quantity` AS `Cantidad`,`c`.`packagingFk` AS `Id_Cubo`,`c`.`stickers` AS `Etiquetas`,`c`.`freightValue` AS `Portefijo`,`c`.`packageValue` AS `Embalajefijo`,`c`.`comissionValue` AS `Comisionfija`,`c`.`packing` AS `Packing`,`c`.`grouping` AS `grouping`,`c`.`groupingMode` AS `caja`,`c`.`location` AS `Nicho`,`c`.`price1` AS `Tarifa1`,`c`.`price2` AS `Tarifa2`,`c`.`price3` AS `Tarifa3`,`c`.`minPrice` AS `PVP`,`c`.`printedStickers` AS `Vida`,`c`.`isChecked` AS `punteo`,`c`.`ektFk` AS `buy_edi_id`,`c`.`created` AS `odbc_date`,`c`.`isIgnored` AS `Novincular`,`c`.`isPickedOff` AS `isPickedOff`,`c`.`workerFk` AS `Id_Trabajador`,`c`.`weight` AS `weight`,`c`.`dispatched` AS `dispatched`,`c`.`containerFk` AS `container_id`,`c`.`itemOriginalFk` AS `itemOriginalFk` from `vn`.`buy` `c` */; +/*!50001 VIEW `Compres` AS select `c`.`id` AS `Id_Compra`,`c`.`entryFk` AS `Id_Entrada`,`c`.`itemFk` AS `Id_Article`,`c`.`buyingValue` AS `Costefijo`,`c`.`quantity` AS `Cantidad`,`c`.`packagingFk` AS `Id_Cubo`,`c`.`stickers` AS `Etiquetas`,`c`.`freightValue` AS `Portefijo`,`c`.`packageValue` AS `Embalajefijo`,`c`.`comissionValue` AS `Comisionfija`,`c`.`packing` AS `Packing`,`c`.`grouping` AS `grouping`,`c`.`groupingMode` AS `caja`,`c`.`location` AS `Nicho`,`c`.`price1` AS `Tarifa1`,`c`.`price2` AS `Tarifa2`,`c`.`price3` AS `Tarifa3`,`c`.`minPrice` AS `PVP`,`c`.`printedStickers` AS `Vida`,`c`.`isChecked` AS `punteo`,`c`.`ektFk` AS `buy_edi_id`,`c`.`created` AS `odbc_date`,`c`.`isIgnored` AS `Novincular`,`c`.`isPickedOff` AS `isPickedOff`,`c`.`workerFk` AS `Id_Trabajador`,`c`.`weight` AS `weight`,`c`.`dispatched` AS `dispatched`,`c`.`itemOriginalFk` AS `itemOriginalFk` from `vn`.`buy` `c` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88335,7 +88262,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `Cubos` AS select `p`.`id` AS `Id_Cubo`,`p`.`volume` AS `Volumen`,`p`.`width` AS `X`,`p`.`depth` AS `Y`,`p`.`height` AS `Z`,`p`.`isPackageReturnable` AS `Retornable`,`p`.`created` AS `odbc_date`,`p`.`itemFk` AS `item_id`,`p`.`price` AS `pvp`,`p`.`cubicPackage` AS `bultoCubico`,`p`.`value` AS `Valor`,`p`.`packagingReturnFk` AS `idCubos_Retorno`,`p`.`lower` AS `Bajan`,`p`.`upload` AS `Suben`,`p`.`base` AS `Base`,`p`.`isBox` AS `box`,`p`.`returnCost` AS `costeRetorno` from `vn`.`packaging` `p` */; +/*!50001 VIEW `Cubos` AS select `p`.`id` AS `Id_Cubo`,`p`.`volume` AS `Volumen`,`p`.`width` AS `X`,`p`.`depth` AS `Y`,`p`.`height` AS `Z`,`p`.`isPackageReturnable` AS `Retornable`,`p`.`created` AS `odbc_date`,`p`.`itemFk` AS `item_id`,`p`.`price` AS `pvp`,`p`.`cubicPackage` AS `bultoCubico`,`p`.`value` AS `Valor`,`p`.`packagingReturnFk` AS `idCubos_Retorno`,`p`.`lower` AS `Bajan`,`p`.`upload` AS `Suben`,`p`.`base` AS `Base`,`p`.`isBox` AS `box`,`p`.`returnCost` AS `costeRetorno`,`p`.`isActive` AS `isActive` from `vn`.`packaging` `p` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88569,7 +88496,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `Paises` AS select `c`.`id` AS `Id`,`c`.`country` AS `Pais`,`c`.`CEE` AS `CEE`,`c`.`isUeeMember` AS `isUeeMember`,`c`.`code` AS `Codigo`,`c`.`currencyFk` AS `Id_Moneda`,`c`.`geoFk` AS `geoFk`,`c`.`ibanLength` AS `ibanLength`,`c`.`hasDailyInvoice` AS `hasDailyInvoice` from `vn`.`country` `c` */; +/*!50001 VIEW `Paises` AS select `c`.`id` AS `Id`,`c`.`name` AS `Pais`,`c`.`CEE` AS `CEE`,`c`.`isUeeMember` AS `isUeeMember`,`c`.`code` AS `Codigo`,`c`.`currencyFk` AS `Id_Moneda`,`c`.`geoFk` AS `geoFk`,`c`.`ibanLength` AS `ibanLength`,`c`.`hasDailyInvoice` AS `hasDailyInvoice` from `vn`.`country` `c` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88605,7 +88532,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `Proveedores` AS select `s`.`id` AS `Id_Proveedor`,`s`.`name` AS `Proveedor`,`s`.`account` AS `cuenta`,`s`.`countryFk` AS `pais_id`,`s`.`nif` AS `NIF`,`s`.`isFarmer` AS `Agricola`,`s`.`phone` AS `Telefono`,`s`.`retAccount` AS `cuentaret`,`s`.`commission` AS `ComisionProveedor`,`s`.`created` AS `odbc_time`,`s`.`postcodeFk` AS `postcode_id`,`s`.`isActive` AS `active`,`s`.`street` AS `Domicilio`,`s`.`city` AS `Localidad`,`s`.`provinceFk` AS `province_id`,`s`.`postCode` AS `codpos`,`s`.`payMethodFk` AS `pay_met_id`,`s`.`payDemFk` AS `pay_dem_id`,`s`.`nickname` AS `Alias`,`s`.`isOfficial` AS `oficial`,`s`.`workerFk` AS `workerFk`,`s`.`payDay` AS `pay_day`,`s`.`isReal` AS `serious`,`s`.`note` AS `notas`,`s`.`taxTypeSageFk` AS `taxTypeSageFk`,`s`.`withholdingSageFk` AS `withholdingSageFk`,`s`.`isTrucker` AS `isTrucker`,`s`.`transactionTypeSageFk` AS `transactionTypeSageFk`,`s`.`supplierActivityFk` AS `supplierActivityFk`,`s`.`healthRegister` AS `healthRegister`,`s`.`isPayMethodChecked` AS `isPayMethodChecked` from `vn`.`supplier` `s` */; +/*!50001 VIEW `Proveedores` AS select `s`.`id` AS `Id_Proveedor`,`s`.`name` AS `Proveedor`,`s`.`account` AS `cuenta`,`s`.`countryFk` AS `pais_id`,`s`.`nif` AS `NIF`,`s`.`phone` AS `Telefono`,`s`.`retAccount` AS `cuentaret`,`s`.`commission` AS `ComisionProveedor`,`s`.`created` AS `odbc_time`,`s`.`postcodeFk` AS `postcode_id`,`s`.`isActive` AS `active`,`s`.`street` AS `Domicilio`,`s`.`city` AS `Localidad`,`s`.`provinceFk` AS `province_id`,`s`.`postCode` AS `codpos`,`s`.`payMethodFk` AS `pay_met_id`,`s`.`payDemFk` AS `pay_dem_id`,`s`.`nickname` AS `Alias`,`s`.`isOfficial` AS `oficial`,`s`.`workerFk` AS `workerFk`,`s`.`payDay` AS `pay_day`,`s`.`isReal` AS `serious`,`s`.`note` AS `notas`,`s`.`taxTypeSageFk` AS `taxTypeSageFk`,`s`.`withholdingSageFk` AS `withholdingSageFk`,`s`.`isTrucker` AS `isTrucker`,`s`.`transactionTypeSageFk` AS `transactionTypeSageFk`,`s`.`supplierActivityFk` AS `supplierActivityFk`,`s`.`healthRegister` AS `healthRegister`,`s`.`isPayMethodChecked` AS `isPayMethodChecked` from `vn`.`supplier` `s` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88700,24 +88627,6 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `Saldos_Prevision` --- - -/*!50001 DROP VIEW IF EXISTS `Saldos_Prevision`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb4 */; -/*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `Saldos_Prevision` AS select `fb`.`id` AS `Saldos_Prevision_id`,`fb`.`description` AS `Descripcion`,`fb`.`amount` AS `Importe`,`fb`.`dated` AS `Fecha`,`fb`.`accountingFk` AS `Id_Banco`,`fb`.`companyFk` AS `empresa_id` from `vn`.`forecastedBalance` `fb` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - -- -- Final view structure for view `Split_lines` -- @@ -88767,7 +88676,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `Tickets` AS select `t`.`id` AS `Id_Ticket`,`t`.`clientFk` AS `Id_Cliente`,`t`.`warehouseFk` AS `warehouse_id`,`t`.`shipped` AS `Fecha`,`t`.`landed` AS `landing`,`t`.`nickname` AS `Alias`,`t`.`refFk` AS `Factura`,`t`.`addressFk` AS `Id_Consigna`,`t`.`location` AS `Localizacion`,`t`.`solution` AS `Solucion`,`t`.`routeFk` AS `Id_Ruta`,`t`.`companyFk` AS `empresa_id`,`t`.`agencyModeFk` AS `Id_Agencia`,`t`.`priority` AS `Prioridad`,`t`.`packages` AS `Bultos`,`t`.`isDeleted` AS `isDeleted`,`t`.`created` AS `odbc_date`,`t`.`workerFk` AS `Id_Trabajador`,`t`.`observations` AS `Observaciones`,`t`.`isSigned` AS `Firmado`,`t`.`isLabeled` AS `Etiquetasemitidas`,`t`.`isPrinted` AS `PedidoImpreso`,`t`.`hour` AS `Hora`,`t`.`isBlocked` AS `blocked`,`t`.`hasPriority` AS `priority`,`t`.`isBoxed` AS `boxed`,`t`.`zoneFk` AS `zoneFk`,`t`.`totalWithVat` AS `totalWithVat`,`t`.`totalWithoutVat` AS `totalWithoutVat` from `vn`.`ticket` `t` */; +/*!50001 VIEW `Tickets` AS select `t`.`id` AS `Id_Ticket`,`t`.`clientFk` AS `Id_Cliente`,`t`.`warehouseFk` AS `warehouse_id`,`t`.`shipped` AS `Fecha`,`t`.`landed` AS `landing`,`t`.`nickname` AS `Alias`,`t`.`refFk` AS `Factura`,`t`.`addressFk` AS `Id_Consigna`,`t`.`location` AS `Localizacion`,`t`.`solution` AS `Solucion`,`t`.`routeFk` AS `Id_Ruta`,`t`.`companyFk` AS `empresa_id`,`t`.`agencyModeFk` AS `Id_Agencia`,`t`.`priority` AS `Prioridad`,`t`.`packages` AS `Bultos`,`t`.`isDeleted` AS `isDeleted`,`t`.`created` AS `odbc_date`,`t`.`workerFk` AS `Id_Trabajador`,`t`.`observations` AS `Observaciones`,`t`.`isSigned` AS `Firmado`,`t`.`isPrinted` AS `PedidoImpreso`,`t`.`hour` AS `Hora`,`t`.`isBlocked` AS `blocked`,`t`.`hasPriority` AS `priority`,`t`.`isBoxed` AS `boxed`,`t`.`zoneFk` AS `zoneFk`,`t`.`totalWithVat` AS `totalWithVat`,`t`.`totalWithoutVat` AS `totalWithoutVat` from `vn`.`ticket` `t` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88839,7 +88748,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `Tipos` AS select `it`.`id` AS `tipo_id`,`it`.`code` AS `Id_Tipo`,`it`.`name` AS `Tipo`,`it`.`order` AS `Orden`,`it`.`categoryFk` AS `reino_id`,`it`.`workerFk` AS `Id_Trabajador`,`it`.`life` AS `life`,`it`.`isPackaging` AS `isPackaging`,`it`.`density` AS `density`,`it`.`isInventory` AS `inventory`,`it`.`created` AS `odbc_date`,`it`.`making` AS `confeccion`,`it`.`temperatureFk` AS `Temperatura`,`it`.`promo` AS `promo`,`it`.`maneuver` AS `maneuver`,`it`.`target` AS `target`,`it`.`topMargin` AS `top_margin`,`it`.`profit` AS `profit` from `vn`.`itemType` `it` */; +/*!50001 VIEW `Tipos` AS select `it`.`id` AS `tipo_id`,`it`.`code` AS `Id_Tipo`,`it`.`name` AS `Tipo`,`it`.`order` AS `Orden`,`it`.`categoryFk` AS `reino_id`,`it`.`workerFk` AS `Id_Trabajador`,`it`.`life` AS `life`,`it`.`isPackaging` AS `isPackaging`,`it`.`isInventory` AS `inventory`,`it`.`created` AS `odbc_date`,`it`.`making` AS `confeccion`,`it`.`temperatureFk` AS `Temperatura`,`it`.`promo` AS `promo` from `vn`.`itemType` `it` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89037,7 +88946,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `albaran` AS select `dn`.`id` AS `albaran_id`,`dn`.`ref` AS `ref`,`dn`.`note` AS `note`,`dn`.`shipped` AS `fecha`,`dn`.`landed` AS `fecha_entrega`,`dn`.`amount` AS `valor`,`dn`.`supplierFk` AS `Id_Proveedor`,`dn`.`companyFk` AS `empresa_id`,`dn`.`warehouseFk` AS `warehouse_id`,`dn`.`stateFk` AS `albaran_state_id`,`dn`.`workerFk` AS `Id_Trabajador`,`dn`.`supervisorFk` AS `Id_Responsable`,`dn`.`departmentFk` AS `department_id`,`dn`.`invoiceInFk` AS `recibida_id`,`dn`.`farmingFk` AS `farmingFk` from `vn`.`deliveryNote` `dn` */; +/*!50001 VIEW `albaran` AS select `dn`.`id` AS `albaran_id`,`dn`.`ref` AS `ref`,`dn`.`note` AS `note`,`dn`.`shipped` AS `fecha`,`dn`.`landed` AS `fecha_entrega`,`dn`.`amount` AS `valor`,`dn`.`supplierFk` AS `Id_Proveedor`,`dn`.`companyFk` AS `empresa_id`,`dn`.`warehouseFk` AS `warehouse_id`,`dn`.`stateFk` AS `albaran_state_id`,`dn`.`workerFk` AS `Id_Trabajador`,`dn`.`supervisorFk` AS `Id_Responsable`,`dn`.`departmentFk` AS `department_id`,`dn`.`invoiceInFk` AS `recibida_id` from `vn`.`deliveryNote` `dn` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89271,7 +89180,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `buySource` AS select `b`.`entryFk` AS `Id_Entrada`,`b`.`isPickedOff` AS `isPickedOff`,NULL AS `tarifa0`,`e`.`kop` AS `kop`,`b`.`id` AS `Id_Compra`,`i`.`typeFk` AS `tipo_id`,`b`.`itemFk` AS `Id_Article`,`i`.`size` AS `Medida`,`i`.`stems` AS `Tallos`,`b`.`stickers` AS `Etiquetas`,`b`.`packagingFk` AS `Id_Cubo`,`b`.`buyingValue` AS `Costefijo`,`b`.`packing` AS `Packing`,`b`.`grouping` AS `Grouping`,`b`.`quantity` AS `Cantidad`,`b`.`price2` AS `Tarifa2`,`b`.`price3` AS `Tarifa3`,`b`.`isChecked` AS `Punteo`,`b`.`groupingMode` AS `Caja`,`i`.`isToPrint` AS `Imprimir`,`i`.`name` AS `Article`,`vn`.`ink`.`picture` AS `Tinta`,`i`.`originFk` AS `id_origen`,`i`.`minPrice` AS `PVP`,NULL AS `Id_Accion`,`s`.`company_name` AS `pro`,`i`.`hasMinPrice` AS `Min`,`b`.`isIgnored` AS `Novincular`,`b`.`freightValue` AS `Portefijo`,round(`b`.`buyingValue` * `b`.`quantity`,2) AS `Importe`,`b`.`printedStickers` AS `Vida`,`i`.`comment` AS `reference`,`b`.`workerFk` AS `Id_Trabajador`,`e`.`s1` AS `S1`,`e`.`s2` AS `S2`,`e`.`s3` AS `S3`,`e`.`s4` AS `S4`,`e`.`s5` AS `S5`,`e`.`s6` AS `S6`,0 AS `price_fixed`,`i`.`producerFk` AS `producer_id`,`i`.`subName` AS `tag1`,`i`.`value5` AS `tag2`,`i`.`value6` AS `tag3`,`i`.`value7` AS `tag4`,`i`.`value8` AS `tag5`,`i`.`value9` AS `tag6`,`i`.`value10` AS `tag7`,`s`.`company_name` AS `company_name`,`b`.`weight` AS `weightPacking`,`i`.`packingOut` AS `packingOut`,`b`.`itemOriginalFk` AS `itemOriginalFk`,`io`.`longName` AS `itemOriginalName`,`it`.`gramsMax` AS `gramsMax`,`i`.`minQuantity` AS `minQuantity` from ((((((`vn`.`item` `i` join `vn`.`itemType` `it` on(`it`.`id` = `i`.`typeFk`)) left join `vn`.`ink` on(`vn`.`ink`.`id` = `i`.`inkFk`)) left join `vn`.`buy` `b` on(`b`.`itemFk` = `i`.`id`)) left join `vn`.`item` `io` on(`io`.`id` = `b`.`itemOriginalFk`)) left join `edi`.`ekt` `e` on(`e`.`id` = `b`.`ektFk`)) left join `edi`.`supplier` `s` on(`e`.`pro` = `s`.`supplier_id`)) */; +/*!50001 VIEW `buySource` AS select `b`.`entryFk` AS `Id_Entrada`,`b`.`isPickedOff` AS `isPickedOff`,NULL AS `tarifa0`,`e`.`kop` AS `kop`,`b`.`id` AS `Id_Compra`,`i`.`typeFk` AS `tipo_id`,`b`.`itemFk` AS `Id_Article`,`i`.`size` AS `Medida`,`i`.`stems` AS `Tallos`,`b`.`stickers` AS `Etiquetas`,`b`.`packagingFk` AS `Id_Cubo`,`b`.`buyingValue` AS `Costefijo`,`b`.`packing` AS `Packing`,`b`.`grouping` AS `Grouping`,`b`.`quantity` AS `Cantidad`,`b`.`price2` AS `Tarifa2`,`b`.`price3` AS `Tarifa3`,`b`.`isChecked` AS `Punteo`,`b`.`groupingMode` AS `Caja`,`i`.`isToPrint` AS `Imprimir`,`i`.`name` AS `Article`,`vn`.`ink`.`picture` AS `Tinta`,`i`.`originFk` AS `id_origen`,`i`.`minPrice` AS `PVP`,NULL AS `Id_Accion`,`s`.`company_name` AS `pro`,`i`.`hasMinPrice` AS `Min`,`b`.`isIgnored` AS `Novincular`,`b`.`freightValue` AS `Portefijo`,round(`b`.`buyingValue` * `b`.`quantity`,2) AS `Importe`,`b`.`printedStickers` AS `Vida`,`i`.`comment` AS `reference`,`b`.`workerFk` AS `Id_Trabajador`,`e`.`s1` AS `S1`,`e`.`s2` AS `S2`,`e`.`s3` AS `S3`,`e`.`s4` AS `S4`,`e`.`s5` AS `S5`,`e`.`s6` AS `S6`,0 AS `price_fixed`,`i`.`producerFk` AS `producer_id`,`i`.`subName` AS `tag1`,`i`.`value5` AS `tag2`,`i`.`value6` AS `tag3`,`i`.`value7` AS `tag4`,`i`.`value8` AS `tag5`,`i`.`value9` AS `tag6`,`i`.`value10` AS `tag7`,`s`.`company_name` AS `company_name`,`b`.`weight` AS `weightPacking`,`i`.`packingOut` AS `packingOut`,`b`.`itemOriginalFk` AS `itemOriginalFk`,`io`.`longName` AS `itemOriginalName`,`it`.`gramsMax` AS `gramsMax` from ((((((`vn`.`item` `i` join `vn`.`itemType` `it` on(`it`.`id` = `i`.`typeFk`)) left join `vn`.`ink` on(`vn`.`ink`.`id` = `i`.`inkFk`)) left join `vn`.`buy` `b` on(`b`.`itemFk` = `i`.`id`)) left join `vn`.`item` `io` on(`io`.`id` = `b`.`itemOriginalFk`)) left join `edi`.`ekt` `e` on(`e`.`id` = `b`.`ektFk`)) left join `edi`.`supplier` `s` on(`e`.`pro` = `s`.`supplier_id`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89289,7 +89198,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `buy_edi` AS select `t`.`id` AS `id`,`t`.`barcode` AS `barcode`,`t`.`entryYear` AS `entry_year`,`t`.`deliveryNumber` AS `delivery_number`,`t`.`fec` AS `fec`,`t`.`hor` AS `hor`,`t`.`now` AS `now`,`t`.`ptj` AS `ptj`,`t`.`ref` AS `ref`,`t`.`item` AS `item`,`t`.`pac` AS `pac`,`t`.`qty` AS `qty`,`t`.`ori` AS `ori`,`t`.`cat` AS `cat`,`t`.`agj` AS `agj`,`t`.`kop` AS `kop`,`t`.`ptd` AS `ptd`,`t`.`sub` AS `sub`,`t`.`pro` AS `pro`,`t`.`pri` AS `pri`,`t`.`package` AS `package`,`t`.`auction` AS `auction`,`t`.`klo` AS `klo`,`t`.`k1` AS `k01`,`t`.`k2` AS `k02`,`t`.`k3` AS `k03`,`t`.`k4` AS `k04`,`t`.`s1` AS `s1`,`t`.`s2` AS `s2`,`t`.`s3` AS `s3`,`t`.`s4` AS `s4`,`t`.`s5` AS `s5`,`t`.`s6` AS `s6`,`t`.`ok` AS `ok`,`t`.`trolleyFk` AS `trolley_id`,`t`.`putOrderFk` AS `putOrderFk`,`t`.`scanned` AS `scanned` from `edi`.`ekt` `t` */; +/*!50001 VIEW `buy_edi` AS select `t`.`id` AS `id`,`t`.`entryYear` AS `entry_year`,`t`.`deliveryNumber` AS `delivery_number`,`t`.`fec` AS `fec`,`t`.`hor` AS `hor`,`t`.`now` AS `now`,`t`.`ptj` AS `ptj`,`t`.`ref` AS `ref`,`t`.`item` AS `item`,`t`.`pac` AS `pac`,`t`.`qty` AS `qty`,`t`.`ori` AS `ori`,`t`.`cat` AS `cat`,`t`.`agj` AS `agj`,`t`.`kop` AS `kop`,`t`.`ptd` AS `ptd`,`t`.`sub` AS `sub`,`t`.`pro` AS `pro`,`t`.`pri` AS `pri`,`t`.`package` AS `package`,`t`.`auction` AS `auction`,`t`.`klo` AS `klo`,`t`.`k1` AS `k01`,`t`.`k2` AS `k02`,`t`.`k3` AS `k03`,`t`.`k4` AS `k04`,`t`.`s1` AS `s1`,`t`.`s2` AS `s2`,`t`.`s3` AS `s3`,`t`.`s4` AS `s4`,`t`.`s5` AS `s5`,`t`.`s6` AS `s6`,`t`.`ok` AS `ok`,`t`.`trolleyFk` AS `trolley_id`,`t`.`putOrderFk` AS `putOrderFk`,`t`.`scanned` AS `scanned` from `edi`.`ekt` `t` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89883,7 +89792,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `mandato_tipo` AS select `m`.`id` AS `idmandato_tipo`,`m`.`name` AS `Nombre` from `vn`.`mandateType` `m` */; +/*!50001 VIEW `mandato_tipo` AS select `m`.`id` AS `idmandato_tipo`,`m`.`code` AS `Nombre` from `vn`.`mandateType` `m` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90297,7 +90206,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `state` AS select `s`.`id` AS `id`,`s`.`name` AS `name`,`s`.`order` AS `order`,`s`.`alertLevel` AS `alert_level`,`s`.`code` AS `code`,`s`.`sectorProdPriority` AS `sectorProdPriority`,`s`.`nextStateFk` AS `nextStateFk`,`s`.`isPreviousPreparable` AS `isPreviousPreparable`,`s`.`isPicked` AS `isPicked` from `vn`.`state` `s` */; +/*!50001 VIEW `state` AS select `s`.`id` AS `id`,`s`.`name` AS `name`,`s`.`order` AS `order`,`s`.`alertLevel` AS `alert_level`,`s`.`code` AS `code`,`s`.`nextStateFk` AS `nextStateFk`,`s`.`isPreviousPreparable` AS `isPreviousPreparable`,`s`.`isPicked` AS `isPicked` from `vn`.`state` `s` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90563,4 +90472,4 @@ USE `vn2008`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-05-14 6:26:25 +-- Dump completed on 2024-10-03 7:42:53 diff --git a/db/dump/.dump/triggers.sql b/db/dump/.dump/triggers.sql index 251e46260..74190df36 100644 --- a/db/dump/.dump/triggers.sql +++ b/db/dump/.dump/triggers.sql @@ -1,4 +1,5 @@ --- MariaDB dump 10.19 Distrib 10.5.23-MariaDB, for debian-linux-gnu (x86_64) +/*M!999999\- enable the sandbox mode */ +-- MariaDB dump 10.19 Distrib 10.5.26-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: account -- ------------------------------------------------------ @@ -175,6 +176,70 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailAliasAccount_beforeInsert` + BEFORE INSERT ON `mailAliasAccount` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailAliasAccount_beforeUpdate` + BEFORE UPDATE ON `mailAliasAccount` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailAliasAccount_afterDelete` + AFTER DELETE ON `mailAliasAccount` + FOR EACH ROW +BEGIN + INSERT INTO userLog + SET `action` = 'delete', + `changedModel` = 'MailAliasAccount', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailForward_beforeInsert` BEFORE INSERT ON `mailForward` FOR EACH ROW @@ -1359,6 +1424,70 @@ DELIMITER ; -- USE `salix`; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `salix`.`ACL_beforeInsert` + BEFORE INSERT ON `ACL` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `salix`.`ACL_beforeUpdate` + BEFORE UPDATE ON `ACL` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `salix`.`ACL_afterDelete` + AFTER DELETE ON `ACL` + FOR EACH ROW +BEGIN + INSERT INTO ACLLog + SET `action` = 'delete', + `changedModel` = 'Acl', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; -- -- Current Database: `srt` @@ -1374,6 +1503,134 @@ USE `srt`; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `srt`.`buffer_beforeInsert` + BEFORE INSERT ON `buffer` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `srt`.`buffer_beforeUpdate` + BEFORE UPDATE ON `buffer` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `srt`.`buffer_afterDelete` + AFTER DELETE ON `buffer` + FOR EACH ROW +BEGIN + INSERT INTO buffer + SET `action` = 'delete', + `changedModel` = 'Buffer', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `srt`.`config_beforeInsert` + BEFORE INSERT ON `config` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `srt`.`config_beforeUpdate` + BEFORE UPDATE ON `config` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `srt`.`config_afterDelete` + AFTER DELETE ON `config` + FOR EACH ROW +BEGIN + INSERT INTO config + SET `action` = 'delete', + `changedModel` = 'Config', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `srt`.`expedition_beforeUpdate` BEFORE UPDATE ON `expedition` FOR EACH ROW @@ -1571,13 +1828,13 @@ USE `vn`; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`XDiario_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`XDiario_beforeInsert` BEFORE INSERT ON `XDiario` FOR EACH ROW BEGIN @@ -1607,13 +1864,13 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`XDiario_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`XDiario_beforeUpdate` BEFORE UPDATE ON `XDiario` FOR EACH ROW BEGIN @@ -1663,7 +1920,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`accountReconciliation_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`accountReconciliation_beforeInsert` BEFORE INSERT ON `accountReconciliation` FOR EACH ROW @@ -1690,7 +1947,31 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`address_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`address_afterInsert` + BEFORE INSERT ON `address` + FOR EACH ROW +BEGIN + IF (SELECT client_hasDifferentCountries(NEW.clientFk)) THEN + UPDATE client + SET hasToInvoiceByAddress = TRUE + WHERE id = NEW.clientFk; + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`address_beforeInsert` BEFORE INSERT ON `address` FOR EACH ROW BEGIN @@ -1729,31 +2010,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`address_afterInsert` - BEFORE INSERT ON `address` - FOR EACH ROW -BEGIN - IF (SELECT client_hasDifferentCountries(NEW.clientFk)) THEN - UPDATE client - SET hasToInvoiceByAddress = TRUE - WHERE id = NEW.clientFk; - END IF; -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`address_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`address_beforeUpdate` BEFORE UPDATE ON `address` FOR EACH ROW BEGIN @@ -1783,7 +2040,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`address_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`address_afterUpdate` AFTER UPDATE ON `address` FOR EACH ROW BEGIN @@ -1831,7 +2088,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`address_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`address_afterDelete` AFTER DELETE ON `address` FOR EACH ROW BEGIN @@ -1855,7 +2112,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`agency_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`agency_beforeInsert` BEFORE INSERT ON `agency` FOR EACH ROW BEGIN @@ -1875,7 +2132,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`agency_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`agency_afterInsert` AFTER INSERT ON `agency` FOR EACH ROW BEGIN @@ -1895,7 +2152,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`autonomy_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`autonomy_beforeInsert` BEFORE INSERT ON `autonomy` FOR EACH ROW BEGIN @@ -1917,7 +2174,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`autonomy_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`autonomy_beforeUpdate` BEFORE UPDATE ON `autonomy` FOR EACH ROW BEGIN @@ -1945,7 +2202,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`autonomy_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`autonomy_afterDelete` AFTER DELETE ON `autonomy` FOR EACH ROW BEGIN @@ -1965,7 +2222,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`awb_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`awb_beforeInsert` BEFORE INSERT ON `awb` FOR EACH ROW BEGIN @@ -1988,7 +2245,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`awbInvoiceIn_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`awbInvoiceIn_afterDelete` AFTER DELETE ON `awbInvoiceIn` FOR EACH ROW BEGIN @@ -2015,7 +2272,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`bankEntity_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`bankEntity_beforeInsert` BEFORE INSERT ON `bankEntity` FOR EACH ROW BEGIN @@ -2035,7 +2292,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`bankEntity_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`bankEntity_beforeUpdate` BEFORE UPDATE ON `bankEntity` FOR EACH ROW BEGIN @@ -2057,7 +2314,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`budgetNotes_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`budgetNotes_beforeInsert` BEFORE INSERT ON `budgetNotes` FOR EACH ROW BEGIN @@ -2083,7 +2340,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_beforeInsert` BEFORE INSERT ON `business` FOR EACH ROW BEGIN @@ -2107,7 +2364,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_afterInsert` AFTER INSERT ON `business` FOR EACH ROW BEGIN @@ -2127,7 +2384,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_beforeUpdate` BEFORE UPDATE ON `business` FOR EACH ROW BEGIN @@ -2140,24 +2397,22 @@ BEGIN END IF; IF !(OLD.started <=> NEW.started AND OLD.ended <=> NEW.ended) THEN - - SELECT COUNT(*) > 0 INTO isOverlapping - FROM business b - WHERE (util.hasDateOverlapped( - NEW.started, - IFNULL(NEW.ended, b.started), - b.started, - IFNULL(b.ended, NEW.started)) - OR (NEW.ended <=> NULL AND b.ended <=> NULL)) - AND b.id <> OLD.id - AND workerFk = OLD.workerFk; + SELECT util.hasDateOverlapped( + started, + ended, + NEW.started, + IFNULL(NEW.ended, b.started) + ) isOverlapped INTO isOverlapping + FROM vn.business b + WHERE workerFk = NEW.workerFK + AND b.id <> NEW.id + ORDER BY isOverlapped DESC + LIMIT 1; IF isOverlapping THEN CALL util.throw ('IS_OVERLAPPING'); END IF; - END IF; - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -2173,7 +2428,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_afterUpdate` AFTER UPDATE ON `business` FOR EACH ROW BEGIN @@ -2197,7 +2452,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`business_afterDelete` AFTER DELETE ON `business` FOR EACH ROW BEGIN @@ -2223,7 +2478,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_beforeInsert` BEFORE INSERT ON `buy` FOR EACH ROW trig: BEGIN @@ -2239,7 +2494,7 @@ trig: BEGIN LEAVE trig; END IF; - CALL entry_checkBooked(NEW.entryFk); + CALL entry_isEditable(NEW.entryFk); IF NEW.printedStickers <> 0 THEN CALL util.throw('it is not possible to create buy lines with printedstickers other than 0'); END IF; @@ -2328,7 +2583,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_afterInsert` AFTER INSERT ON `buy` FOR EACH ROW trig: BEGIN @@ -2352,7 +2607,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_beforeUpdate` BEFORE UPDATE ON `buy` FOR EACH ROW trig:BEGIN @@ -2366,7 +2621,15 @@ trig:BEGIN LEAVE trig; END IF; - CALL entry_checkBooked(OLD.entryFk); + IF NOT (NEW.entryFk <=> OLD.entryFk) OR + NOT (NEW.quantity <=> OLD.quantity) OR + NOT (NEW.buyingValue <=> OLD.buyingValue) OR + NOT (NEW.packing <=> OLD.packing) + THEN + + CALL entry_isEditable(OLD.entryFk); + END IF; + SET NEW.editorFk = account.myUser_getId(); SELECT defaultEntry INTO vDefaultEntry @@ -2414,6 +2677,10 @@ trig:BEGIN IF NOT NEW.printedStickers <=> OLD.printedStickers THEN CALL util.throw("Stickers cannot be modified if they are inventory"); END IF; + + IF OLD.entryFk <> NEW.entryFk THEN + CALL util.throw("Cannot transfer lines to inventory entry"); + END IF; END IF; IF NEW.quantity < 0 THEN @@ -2450,7 +2717,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_afterUpdate` AFTER UPDATE ON `buy` FOR EACH ROW trig: BEGIN @@ -2511,11 +2778,11 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_beforeDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_beforeDelete` BEFORE DELETE ON `buy` FOR EACH ROW BEGIN - CALL entry_checkBooked(OLD.entryFk); + CALL entry_isEditable(OLD.entryFk); IF OLD.printedStickers <> 0 THEN CALL util.throw("it is not possible to delete buys with printed labels "); END IF; @@ -2534,7 +2801,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`buy_afterDelete` AFTER DELETE ON `buy` FOR EACH ROW trig: BEGIN @@ -2562,7 +2829,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`calendar_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`calendar_beforeInsert` BEFORE INSERT ON `calendar` FOR EACH ROW BEGIN @@ -2582,11 +2849,11 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`calendar_beforeUpdate` - BEFORE UPDATE ON `calendar` - FOR EACH ROW -BEGIN - SET NEW.editorFk = account.myUser_getId(); +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`calendar_beforeUpdate` + BEFORE UPDATE ON `calendar` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -2602,15 +2869,15 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`calendar_afterDelete` - AFTER DELETE ON `calendar` - FOR EACH ROW -BEGIN - INSERT INTO workerLog - SET `action` = 'delete', - `changedModel` = 'Calendar', - `changedModelId` = OLD.id, - `userFk` = account.myUser_getId(); +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`calendar_afterDelete` + AFTER DELETE ON `calendar` + FOR EACH ROW +BEGIN + INSERT INTO workerLog + SET `action` = 'delete', + `changedModel` = 'Calendar', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -2626,7 +2893,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claim_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claim_beforeInsert` BEFORE INSERT ON `claim` FOR EACH ROW BEGIN @@ -2646,7 +2913,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claim_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claim_beforeUpdate` BEFORE UPDATE ON `claim` FOR EACH ROW BEGIN @@ -2666,7 +2933,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claim_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claim_afterDelete` AFTER DELETE ON `claim` FOR EACH ROW BEGIN @@ -2690,7 +2957,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimBeginning_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimBeginning_beforeInsert` BEFORE INSERT ON `claimBeginning` FOR EACH ROW BEGIN @@ -2710,7 +2977,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimBeginning_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimBeginning_beforeUpdate` BEFORE UPDATE ON `claimBeginning` FOR EACH ROW BEGIN @@ -2730,7 +2997,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimBeginning_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimBeginning_afterDelete` AFTER DELETE ON `claimBeginning` FOR EACH ROW BEGIN @@ -2754,7 +3021,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDevelopment_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDevelopment_beforeInsert` BEFORE INSERT ON `claimDevelopment` FOR EACH ROW BEGIN @@ -2774,7 +3041,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDevelopment_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDevelopment_beforeUpdate` BEFORE UPDATE ON `claimDevelopment` FOR EACH ROW BEGIN @@ -2794,7 +3061,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDevelopment_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDevelopment_afterDelete` AFTER DELETE ON `claimDevelopment` FOR EACH ROW BEGIN @@ -2818,7 +3085,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDms_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDms_beforeInsert` BEFORE INSERT ON `claimDms` FOR EACH ROW BEGIN @@ -2838,7 +3105,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDms_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDms_beforeUpdate` BEFORE UPDATE ON `claimDms` FOR EACH ROW BEGIN @@ -2858,7 +3125,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDms_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimDms_afterDelete` AFTER DELETE ON `claimDms` FOR EACH ROW BEGIN @@ -2882,7 +3149,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimEnd_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimEnd_beforeInsert` BEFORE INSERT ON `claimEnd` FOR EACH ROW BEGIN @@ -2902,7 +3169,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimEnd_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimEnd_beforeUpdate` BEFORE UPDATE ON `claimEnd` FOR EACH ROW BEGIN @@ -2922,7 +3189,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimEnd_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimEnd_afterDelete` AFTER DELETE ON `claimEnd` FOR EACH ROW BEGIN @@ -2946,7 +3213,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimObservation_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimObservation_beforeInsert` BEFORE INSERT ON `claimObservation` FOR EACH ROW BEGIN @@ -2966,7 +3233,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimObservation_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimObservation_beforeUpdate` BEFORE UPDATE ON `claimObservation` FOR EACH ROW BEGIN @@ -2986,7 +3253,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimObservation_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimObservation_afterDelete` AFTER DELETE ON `claimObservation` FOR EACH ROW BEGIN @@ -3010,7 +3277,53 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimState_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimRatio_afterInsert` + AFTER INSERT ON `claimRatio` + FOR EACH ROW +BEGIN + INSERT INTO clientRate(clientFk, `value`) + VALUES(NEW.clientFk, NEW.priceIncreasing) + ON DUPLICATE KEY UPDATE + `value` = VALUES(`value`); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimRatio_afterUpdate` + AFTER UPDATE ON `claimRatio` + FOR EACH ROW +BEGIN + INSERT INTO clientRate(clientFk, `value`) + VALUES(NEW.clientFk, NEW.priceIncreasing) + ON DUPLICATE KEY UPDATE + `value` = VALUES(`value`); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimState_beforeInsert` BEFORE INSERT ON `claimState` FOR EACH ROW BEGIN @@ -3030,7 +3343,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimState_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimState_beforeUpdate` BEFORE UPDATE ON `claimState` FOR EACH ROW BEGIN @@ -3050,7 +3363,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimState_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`claimState_afterDelete` AFTER DELETE ON `claimState` FOR EACH ROW BEGIN @@ -3074,7 +3387,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`client_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`client_beforeInsert` BEFORE INSERT ON `client` FOR EACH ROW BEGIN @@ -3107,7 +3420,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`client_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`client_afterInsert` AFTER INSERT ON `client` FOR EACH ROW BEGIN @@ -3132,7 +3445,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`client_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`client_beforeUpdate` BEFORE UPDATE ON `client` FOR EACH ROW BEGIN @@ -3198,11 +3511,11 @@ BEGIN END IF; END IF; - IF !(NEW.salesPersonFk <=> OLD.salesPersonFk) THEN + IF NOT (NEW.salesPersonFk <=> OLD.salesPersonFk) THEN SET NEW.lastSalesPersonFk = IFNULL(NEW.salesPersonFk, OLD.salesPersonFk); END IF; - IF !(NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN + IF NOT (NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN SET NEW.isTaxDataChecked = 0; END IF; END */;; @@ -3220,17 +3533,40 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`client_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`client_afterUpdate` AFTER UPDATE ON `client` FOR EACH ROW BEGIN - IF !(NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN + IF NOT (NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN UPDATE `address` SET isDefaultAddress = FALSE WHERE clientFk = NEW.id; UPDATE `address` SET isDefaultAddress = TRUE WHERE id = NEW.defaultAddressFk; END IF; + + IF NEW.id <> OLD.id + OR NOT (NEW.provinceFk <=> OLD.provinceFk) + OR NOT (NEW.socialName <=> OLD.socialName) + OR NOT (NEW.street <=> OLD.street) + OR NOT (NEW.accountingAccount <=> OLD.accountingAccount) + OR NOT (NEW.isVies <=> OLD.isVies) + OR NOT (NEW.fi <=> OLD.fi) + OR NOT (NEW.postcode <=> OLD.postcode) + OR NOT (NEW.city <=> OLD.city) + OR NOT (NEW.countryFk <=> OLD.countryFk) + OR NOT (NEW.taxTypeSageFk <=> OLD.taxTypeSageFk) + OR NOT (NEW.transactionTypeSageFk <=> OLD.transactionTypeSageFk) + OR NOT (NEW.email <=> OLD.email) + OR NOT (NEW.iban <=> OLD.iban) + OR NOT (NEW.phone <=> OLD.phone) + OR NOT (NEW.mobile <=> OLD.mobile) THEN + + UPDATE sage.clientSupplier + SET isSync = FALSE + WHERE idClientSupplier IN (NEW.id, OLD.id) + AND `type` = 'C'; + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -3246,7 +3582,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`client_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`client_afterDelete` AFTER DELETE ON `client` FOR EACH ROW BEGIN @@ -3270,7 +3606,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientContact_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientContact_beforeInsert` BEFORE INSERT ON `clientContact` FOR EACH ROW BEGIN @@ -3290,7 +3626,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientContact_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientContact_afterDelete` AFTER DELETE ON `clientContact` FOR EACH ROW BEGIN @@ -3314,7 +3650,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientCredit_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientCredit_afterInsert` AFTER INSERT ON `clientCredit` FOR EACH ROW BEGIN @@ -3349,7 +3685,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientDms_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientDms_beforeInsert` BEFORE INSERT ON `clientDms` FOR EACH ROW BEGIN @@ -3369,7 +3705,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientDms_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientDms_beforeUpdate` BEFORE UPDATE ON `clientDms` FOR EACH ROW BEGIN @@ -3389,7 +3725,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientDms_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientDms_afterDelete` AFTER DELETE ON `clientDms` FOR EACH ROW BEGIN @@ -3413,7 +3749,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientObservation_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientObservation_beforeInsert` BEFORE INSERT ON `clientObservation` FOR EACH ROW BEGIN @@ -3433,7 +3769,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientObservation_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientObservation_beforeUpdate` BEFORE UPDATE ON `clientObservation` FOR EACH ROW BEGIN @@ -3453,7 +3789,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientObservation_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientObservation_afterDelete` AFTER DELETE ON `clientObservation` FOR EACH ROW BEGIN @@ -3477,7 +3813,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientSample_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientSample_beforeInsert` BEFORE INSERT ON `clientSample` FOR EACH ROW BEGIN @@ -3497,7 +3833,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientSample_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientSample_beforeUpdate` BEFORE UPDATE ON `clientSample` FOR EACH ROW BEGIN @@ -3517,7 +3853,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientSample_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientSample_afterDelete` AFTER DELETE ON `clientSample` FOR EACH ROW BEGIN @@ -3541,7 +3877,47 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`cmr_beforeDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientUnpaid_beforeInsert` + BEFORE INSERT ON `clientUnpaid` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`clientUnpaid_beforeUpdate` + BEFORE UPDATE ON `clientUnpaid` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`cmr_beforeDelete` BEFORE DELETE ON `cmr` FOR EACH ROW BEGIN @@ -3563,7 +3939,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`collection_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`collection_beforeUpdate` BEFORE UPDATE ON `collection` FOR EACH ROW BEGIN @@ -3611,9 +3987,9 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER vn.collectionColors_beforeInsert -BEFORE INSERT -ON collectionColors FOR EACH ROW +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`collectionColors_beforeInsert` + BEFORE INSERT ON `collectionColors` + FOR EACH ROW BEGIN CALL util.checkHex(NEW.rgb); END */;; @@ -3631,7 +4007,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`collectionColors_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`collectionColors_beforeUpdate` BEFORE UPDATE ON `collectionColors` FOR EACH ROW BEGIN @@ -3651,7 +4027,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`collectionVolumetry_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`collectionVolumetry_afterInsert` AFTER INSERT ON `collectionVolumetry` FOR EACH ROW BEGIN @@ -3689,7 +4065,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`collectionVolumetry_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`collectionVolumetry_afterUpdate` AFTER UPDATE ON `collectionVolumetry` FOR EACH ROW BEGIN @@ -3747,7 +4123,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`collectionVolumetry_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`collectionVolumetry_afterDelete` AFTER DELETE ON `collectionVolumetry` FOR EACH ROW BEGIN @@ -3785,11 +4161,11 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`country_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`country_beforeInsert` BEFORE INSERT ON `country` FOR EACH ROW BEGIN - SET NEW.geoFk = zoneGeo_new('country', NEW.country, NULL); + SET NEW.geoFk = zoneGeo_new('country', NEW.name, NULL); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -3805,20 +4181,23 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`country_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`country_afterInsert` AFTER INSERT ON `country` FOR EACH ROW BEGIN UPDATE sage.Naciones SET countryFk = NEW.id - WHERE Nacion = NEW.country; + WHERE Nacion = NEW.name; IF ROW_COUNT() = 0 THEN CALL mail_insert( 'cau@verdnatura.es', NULL, 'Actualizar tabla sage.Naciones', - CONCAT('Se ha insertado un nuevo país en la tabla vn.conuntry. Para el correcto funcionamiento del sistema \n\t\t\t\tde contabilidad es necesario actualizar la columna sage.Naciones.countryFk con el valor del nuevo país. \n\t\t\t Hay que buscar el nuevo país: ', NEW.country, ' en la tabla sage.Naciones y actualizar el campo sage.Naciones.countryFk con el valor ', NEW.id) + CONCAT('Se ha insertado un nuevo país en la tabla vn.conuntry. + Para el correcto funcionamiento del sistema \n\t\t\t\tde contabilidad es necesario actualizar la columna + sage.Naciones.countryFk con el valor del nuevo país. \n\t\t\t Hay que buscar el nuevo país: ', NEW.name, + ' en la tabla sage.Naciones y actualizar el campo sage.Naciones.countryFk con el valor ', NEW.id) ); END IF; END */;; @@ -3836,7 +4215,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`country_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`country_beforeUpdate` BEFORE UPDATE ON `country` FOR EACH ROW BEGIN @@ -3858,12 +4237,12 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`country_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`country_afterUpdate` AFTER UPDATE ON `country` FOR EACH ROW BEGIN - IF !(OLD.country <=> NEW.country) THEN - UPDATE zoneGeo SET `name` = NEW.country + IF !(OLD.name <=> NEW.name) THEN + UPDATE zoneGeo SET `name` = NEW.name WHERE id = NEW.geoFk; END IF; END */;; @@ -3881,7 +4260,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`country_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`country_afterDelete` AFTER DELETE ON `country` FOR EACH ROW BEGIN @@ -3901,7 +4280,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`creditClassification_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`creditClassification_beforeUpdate` BEFORE UPDATE ON `creditClassification` FOR EACH ROW BEGIN @@ -3921,41 +4300,19 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`creditInsurance_beforeInsert` - BEFORE INSERT ON `creditInsurance` - FOR EACH ROW -BEGIN - IF NEW.creditClassificationFk THEN - SET NEW.creditClassification = NEW.creditClassificationFk; - END IF; -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`creditInsurance_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`creditInsurance_afterInsert` AFTER INSERT ON `creditInsurance` FOR EACH ROW BEGIN UPDATE `client` c JOIN vn.creditClassification cc ON cc.client = c.id - SET creditInsurance = NEW.credit WHERE cc.id = NEW.creditClassification; + SET creditInsurance = NEW.credit WHERE cc.id = NEW.creditClassificationFk; END */;; DELIMITER ; @@ -3966,61 +4323,22 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`delivery_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`delivery_beforeInsert` BEFORE INSERT ON `delivery` FOR EACH ROW BEGIN - - IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) + IF (NEW.longitude IS NOT NULL + AND NEW.latitude IS NOT NULL + AND NEW.ticketFK IS NOT NULL) THEN - UPDATE address - SET longitude = NEW.longitude, - latitude = NEW.latitude - WHERE id IN ( - SELECT addressFK - FROM ticket - WHERE id = NEW.ticketFk - ); + CALL address_updateCoordinates(NEW.ticketFk, NEW.longitude, NEW.latitude); END IF; - -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`delivery_beforeUpdate` - BEFORE UPDATE ON `delivery` - FOR EACH ROW -BEGIN - -IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) - THEN - UPDATE address - SET longitude = NEW.longitude, - latitude = NEW.latitude - WHERE id IN ( - SELECT addressFK - FROM ticket - WHERE id = NEW.ticketFk - ); - END IF; - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -4036,7 +4354,32 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`department_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`delivery_beforeUpdate` + BEFORE UPDATE ON `delivery` + FOR EACH ROW +BEGIN + IF (NEW.longitude IS NOT NULL + AND NEW.latitude IS NOT NULL + AND NEW.ticketFK IS NOT NULL) + THEN + CALL address_updateCoordinates(NEW.ticketFk, NEW.longitude, NEW.latitude); + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`department_beforeInsert` BEFORE INSERT ON `department` FOR EACH ROW BEGIN @@ -4056,7 +4399,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`department_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`department_afterUpdate` AFTER UPDATE ON `department` FOR EACH ROW BEGIN @@ -4085,7 +4428,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`department_beforeDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`department_beforeDelete` BEFORE DELETE ON `department` FOR EACH ROW BEGIN @@ -4110,7 +4453,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`department_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`department_afterDelete` AFTER DELETE ON `department` FOR EACH ROW BEGIN @@ -4136,7 +4479,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProduction_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProduction_beforeInsert` BEFORE INSERT ON `deviceProduction` FOR EACH ROW BEGIN @@ -4156,7 +4499,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProduction_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProduction_beforeUpdate` BEFORE UPDATE ON `deviceProduction` FOR EACH ROW BEGIN @@ -4176,7 +4519,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProduction_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProduction_afterDelete` AFTER DELETE ON `deviceProduction` FOR EACH ROW BEGIN @@ -4200,32 +4543,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionConfig_afterUpdate` - AFTER UPDATE ON `deviceProductionConfig` - FOR EACH ROW -BEGIN - IF NEW.isAllUsersAllowed = 1 OR NEW.isAllUsersAllowed = -1 THEN - SET @username := (SELECT account.myUser_getName()); - INSERT INTO vn.mail (receiver, subject, body) - VALUES ('cau@verdnatura.es', 'Se ha activado la autenticación sin restricciones en la app', - CONCAT('El usuario ', @username,' ha habilitado la opción para que todos los usuarios puedan acceder a la app sin restricciones')); - END IF; -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionModels_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionModels_beforeInsert` BEFORE INSERT ON `deviceProductionModels` FOR EACH ROW BEGIN @@ -4245,7 +4563,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionModels_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionModels_beforeUpdate` BEFORE UPDATE ON `deviceProductionModels` FOR EACH ROW BEGIN @@ -4265,7 +4583,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionState_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionState_beforeInsert` BEFORE INSERT ON `deviceProductionState` FOR EACH ROW BEGIN @@ -4285,7 +4603,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionState_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionState_beforeUpdate` BEFORE UPDATE ON `deviceProductionState` FOR EACH ROW BEGIN @@ -4305,7 +4623,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionUser_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionUser_beforeInsert` BEFORE INSERT ON `deviceProductionUser` FOR EACH ROW BEGIN @@ -4325,10 +4643,32 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionUser_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionUser_afterInsert` + AFTER INSERT ON `deviceProductionUser` + FOR EACH ROW +BEGIN + CALL worker_checkMultipleDevice(NEW.userFk); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionUser_beforeUpdate` BEFORE UPDATE ON `deviceProductionUser` FOR EACH ROW BEGIN + + CALL worker_checkMultipleDevice(NEW.userFk); SET NEW.editorFk = account.myUser_getId(); END */;; DELIMITER ; @@ -4345,7 +4685,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionUser_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionUser_afterDelete` AFTER DELETE ON `deviceProductionUser` FOR EACH ROW BEGIN @@ -4369,7 +4709,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`dms_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`dms_beforeInsert` BEFORE INSERT ON `dms` FOR EACH ROW BEGIN @@ -4402,13 +4742,13 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`dms_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`dms_beforeUpdate` BEFORE UPDATE ON `dms` FOR EACH ROW BEGIN @@ -4448,7 +4788,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`dms_beforeDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`dms_beforeDelete` BEFORE DELETE ON `dms` FOR EACH ROW BEGIN @@ -4476,7 +4816,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`duaTax_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`duaTax_beforeInsert` BEFORE INSERT ON `duaTax` FOR EACH ROW BEGIN @@ -4497,7 +4837,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`duaTax_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`duaTax_beforeUpdate` BEFORE UPDATE ON `duaTax` FOR EACH ROW BEGIN @@ -4518,10 +4858,10 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER ektEntryAssign_afterInsert -AFTER INSERT -ON ektEntryAssign FOR EACH ROW - UPDATE entry SET reference = NEW.`ref` WHERE id = NEW.entryFk */;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ektEntryAssign_afterInsert` + AFTER INSERT ON `ektEntryAssign` + FOR EACH ROW +UPDATE entry SET reference = NEW.`ref` WHERE id = NEW.entryFk */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; @@ -4536,8 +4876,8 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER vn.ektEntryAssign_afterUpdate - AFTER UPDATE ON ektEntryAssign +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ektEntryAssign_afterUpdate` + AFTER UPDATE ON `ektEntryAssign` FOR EACH ROW BEGIN IF NOT(NEW.`ref` <=> OLD.`ref`) OR NOT(NEW.`entryFk` <=> OLD.`entryFk`) THEN @@ -4558,7 +4898,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entry_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`entry_beforeInsert` BEFORE INSERT ON `entry` FOR EACH ROW BEGIN @@ -4566,8 +4906,8 @@ BEGIN CALL supplier_checkIsActive(NEW.supplierFk); SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk); SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk); - IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN - CALL util.throw('The travel is incorrect, there is a different AWB in the associated entries'); + IF NEW.travelFk IS NOT NULL THEN + CALL travel_throwAwb(NEW.travelFk); END IF; END */;; DELIMITER ; @@ -4584,7 +4924,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entry_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`entry_beforeUpdate` BEFORE UPDATE ON `entry` FOR EACH ROW BEGIN @@ -4592,10 +4932,19 @@ BEGIN DECLARE vPrintedCount INT; DECLARE vHasDistinctWarehouses BOOL; DECLARE vTotalBuy INT; - - IF NEW.isBooked = OLD.isBooked THEN - CALL entry_checkBooked(OLD.id); + + IF NEW.isBooked = OLD.isBooked AND ( + NOT (NEW.supplierFk <=> OLD.supplierFk) OR + NOT (NEW.dated <=> OLD.dated) OR + NOT (NEW.travelFk <=> OLD.travelFk) OR + NOT (NEW.companyFk <=> OLD.companyFk) OR + NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) OR + NOT (NEW.typeFk <=> OLD.typeFk) + ) THEN + + CALL entry_isEditable(OLD.id); ELSE + IF NEW.isBooked THEN SELECT COUNT(*) INTO vTotalBuy FROM buy @@ -4610,8 +4959,8 @@ BEGIN IF NOT (NEW.travelFk <=> OLD.travelFk) THEN - IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN - CALL util.throw('The travel is incorrect, there is a different AWB in the associated entries'); + IF NEW.travelFk IS NOT NULL THEN + CALL travel_throwAwb(NEW.travelFk); END IF; SELECT COUNT(*) > 0 INTO vIsVirtual @@ -4647,7 +4996,10 @@ BEGIN SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk); END IF; - IF NOT (NEW.travelFk <=> OLD.travelFk) OR NOT (NEW.currencyFk <=> OLD.currencyFk) THEN + IF NOT (NEW.travelFk <=> OLD.travelFk) + OR NOT (NEW.currencyFk <=> OLD.currencyFk) + OR NOT (NEW.supplierFk <=> OLD.supplierFk) THEN + SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk, NEW.supplierFk); END IF; END */;; @@ -4665,7 +5017,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entry_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`entry_afterUpdate` AFTER UPDATE ON `entry` FOR EACH ROW BEGIN @@ -4692,11 +5044,11 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entry_beforeDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`entry_beforeDelete` BEFORE DELETE ON `entry` FOR EACH ROW BEGIN - CALL entry_checkBooked(OLD.id); + CALL entry_isEditable(OLD.id); DELETE FROM buy WHERE entryFk = OLD.id; END */;; DELIMITER ; @@ -4713,7 +5065,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entry_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`entry_afterDelete` AFTER DELETE ON `entry` FOR EACH ROW BEGIN @@ -4737,7 +5089,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryDms_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryDms_beforeInsert` BEFORE INSERT ON `entryDms` FOR EACH ROW BEGIN @@ -4757,7 +5109,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryDms_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryDms_beforeUpdate` BEFORE UPDATE ON `entryDms` FOR EACH ROW BEGIN @@ -4777,7 +5129,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryDms_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryDms_afterDelete` AFTER DELETE ON `entryDms` FOR EACH ROW BEGIN @@ -4801,7 +5153,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryObservation_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryObservation_beforeInsert` BEFORE INSERT ON `entryObservation` FOR EACH ROW BEGIN @@ -4821,7 +5173,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryObservation_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryObservation_beforeUpdate` BEFORE UPDATE ON `entryObservation` FOR EACH ROW BEGIN @@ -4841,7 +5193,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryObservation_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`entryObservation_afterDelete` AFTER DELETE ON `entryObservation` FOR EACH ROW BEGIN @@ -4865,29 +5217,29 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expedition_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`expedition_beforeInsert` BEFORE INSERT ON `expedition` FOR EACH ROW BEGIN - DECLARE intcounter INT; - DECLARE vShipFk INT; + DECLARE vMaxCounter INT; SET NEW.editorFk = account.myUser_getId(); - IF NEW.freightItemFk IS NOT NULL THEN + IF NEW.freightItemFk IS NOT NULL THEN UPDATE ticket SET packages = IFNULL(packages, 0) + 1 WHERE id = NEW.ticketFk; - SELECT IFNULL(MAX(counter),0) +1 INTO intcounter - FROM expedition e - INNER JOIN ticket t1 ON e.ticketFk = t1.id + SELECT IFNULL(MAX(counter),0) + 1 INTO vMaxCounter + FROM expedition e + JOIN alertLevel al ON al.code = 'DELIVERED' + JOIN ticket t1 ON e.ticketFk = t1.id LEFT JOIN ticketState ts ON ts.ticketFk = t1.id - INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped) + JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped) AND t1.warehouseFk = t2.warehouseFk - WHERE t2.id = NEW.ticketFk AND ts.alertLevel < 3 AND t1.companyFk = t2.companyFk + WHERE t2.id = NEW.ticketFk AND ts.alertLevel < al.id AND t1.companyFk = t2.companyFk AND t1.agencyModeFk = t2.agencyModeFk; - SET NEW.`counter` = intcounter; + SET NEW.`counter` = vMaxCounter; END IF; END */;; DELIMITER ; @@ -4904,7 +5256,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expedition_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`expedition_beforeUpdate` BEFORE UPDATE ON `expedition` FOR EACH ROW BEGIN @@ -4933,7 +5285,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expedition_beforeDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`expedition_beforeDelete` BEFORE DELETE ON `expedition` FOR EACH ROW BEGIN @@ -4957,7 +5309,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expedition_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`expedition_afterDelete` AFTER DELETE ON `expedition` FOR EACH ROW BEGIN @@ -4981,7 +5333,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionPallet_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionPallet_beforeInsert` BEFORE INSERT ON `expeditionPallet` FOR EACH ROW BEGIN @@ -5009,7 +5361,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionScan_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionScan_beforeInsert` BEFORE INSERT ON `expeditionScan` FOR EACH ROW BEGIN @@ -5031,7 +5383,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionState_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionState_beforeInsert` BEFORE INSERT ON `expeditionState` FOR EACH ROW BEGIN @@ -5051,7 +5403,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionState_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionState_afterInsert` AFTER INSERT ON `expeditionState` FOR EACH ROW BEGIN @@ -5075,51 +5427,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionTruck_beforeInsert` - BEFORE INSERT ON `expeditionTruck` - FOR EACH ROW -BEGIN - - SET NEW.description = UCASE(NEW.description); - -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionTruck_beforeUpdate` - BEFORE UPDATE ON `expeditionTruck` - FOR EACH ROW -BEGIN - - SET NEW.description = UCASE(NEW.description); - -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`floramondoConfig_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`floramondoConfig_afterInsert` AFTER INSERT ON `floramondoConfig` FOR EACH ROW BEGIN @@ -5139,8 +5447,8 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`gregue_beforeInsert` - BEFORE INSERT ON greuge +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`gregue_beforeInsert` + BEFORE INSERT ON `greuge` FOR EACH ROW BEGIN IF NEW.userFk IS NULL THEN @@ -5161,7 +5469,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`greuge_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`greuge_beforeInsert` BEFORE INSERT ON `greuge` FOR EACH ROW BEGIN @@ -5181,7 +5489,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`greuge_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`greuge_beforeUpdate` BEFORE UPDATE ON `greuge` FOR EACH ROW BEGIN @@ -5201,7 +5509,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`greuge_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`greuge_afterDelete` AFTER DELETE ON `greuge` FOR EACH ROW BEGIN @@ -5225,11 +5533,11 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`host_beforeUpdate` - BEFORE UPDATE ON `host` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`host_beforeInsert` + BEFORE INSERT ON `host` FOR EACH ROW BEGIN - SET new.updated = util.VN_NOW(); + SET NEW.editorFk = account.myUser_getId(); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -5245,7 +5553,28 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceIn_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`host_beforeUpdate` + BEFORE UPDATE ON `host` + FOR EACH ROW +BEGIN + SET new.updated = util.VN_NOW(); + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceIn_beforeInsert` BEFORE INSERT ON `invoiceIn` FOR EACH ROW BEGIN @@ -5313,7 +5642,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceIn_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceIn_beforeUpdate` BEFORE UPDATE ON `invoiceIn` FOR EACH ROW BEGIN @@ -5357,7 +5686,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceIn_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceIn_afterUpdate` AFTER UPDATE ON `invoiceIn` FOR EACH ROW BEGIN @@ -5395,7 +5724,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceIn_beforeDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceIn_beforeDelete` BEFORE DELETE ON `invoiceIn` FOR EACH ROW BEGIN @@ -5415,7 +5744,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceIn_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceIn_afterDelete` AFTER DELETE ON `invoiceIn` FOR EACH ROW BEGIN @@ -5439,7 +5768,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInDueDay_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInDueDay_beforeInsert` BEFORE INSERT ON `invoiceInDueDay` FOR EACH ROW BEGIN @@ -5481,7 +5810,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInDueDay_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInDueDay_beforeUpdate` BEFORE UPDATE ON `invoiceInDueDay` FOR EACH ROW BEGIN @@ -5523,7 +5852,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInDueDay_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInDueDay_afterDelete` AFTER DELETE ON `invoiceInDueDay` FOR EACH ROW BEGIN @@ -5547,7 +5876,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInTax_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInTax_beforeInsert` BEFORE INSERT ON `invoiceInTax` FOR EACH ROW BEGIN @@ -5568,7 +5897,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInTax_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInTax_beforeUpdate` BEFORE UPDATE ON `invoiceInTax` FOR EACH ROW BEGIN @@ -5592,7 +5921,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInTax_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceInTax_afterDelete` AFTER DELETE ON `invoiceInTax` FOR EACH ROW BEGIN @@ -5610,13 +5939,13 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceOut_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceOut_beforeInsert` BEFORE INSERT ON `invoiceOut` FOR EACH ROW BEGIN @@ -5681,13 +6010,13 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceOut_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceOut_afterInsert` AFTER INSERT ON `invoiceOut` FOR EACH ROW BEGIN @@ -5707,7 +6036,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceOut_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceOut_beforeUpdate` BEFORE UPDATE ON `invoiceOut` FOR EACH ROW BEGIN @@ -5728,7 +6057,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceOut_beforeDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`invoiceOut_beforeDelete` BEFORE DELETE ON `invoiceOut` FOR EACH ROW BEGIN @@ -5748,7 +6077,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`item_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`item_beforeInsert` BEFORE INSERT ON `item` FOR EACH ROW BEGIN @@ -5778,7 +6107,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`item_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`item_afterInsert` AFTER INSERT ON `item` FOR EACH ROW BEGIN @@ -5806,7 +6135,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`item_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`item_beforeUpdate` BEFORE UPDATE ON `item` FOR EACH ROW BEGIN @@ -5832,7 +6161,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`item_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`item_afterUpdate` AFTER UPDATE ON `item` FOR EACH ROW BEGIN @@ -5855,7 +6184,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`item_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`item_afterDelete` AFTER DELETE ON `item` FOR EACH ROW BEGIN @@ -5880,7 +6209,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBarcode_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBarcode_beforeInsert` BEFORE INSERT ON `itemBarcode` FOR EACH ROW BEGIN @@ -5900,7 +6229,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBarcode_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBarcode_beforeUpdate` BEFORE UPDATE ON `itemBarcode` FOR EACH ROW BEGIN @@ -5920,7 +6249,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBarcode_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBarcode_afterDelete` AFTER DELETE ON `itemBarcode` FOR EACH ROW BEGIN @@ -5944,7 +6273,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBotanical_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBotanical_beforeInsert` BEFORE INSERT ON `itemBotanical` FOR EACH ROW BEGIN @@ -5964,7 +6293,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBotanical_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBotanical_beforeUpdate` BEFORE UPDATE ON `itemBotanical` FOR EACH ROW BEGIN @@ -5984,7 +6313,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBotanical_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemBotanical_afterDelete` AFTER DELETE ON `itemBotanical` FOR EACH ROW BEGIN @@ -6008,7 +6337,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemCategory_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemCategory_afterInsert` AFTER INSERT ON `itemCategory` FOR EACH ROW BEGIN @@ -6031,7 +6360,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemCost_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemCost_beforeInsert` BEFORE INSERT ON `itemCost` FOR EACH ROW BEGIN @@ -6054,7 +6383,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemCost_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemCost_beforeUpdate` BEFORE UPDATE ON `itemCost` FOR EACH ROW BEGIN @@ -6096,12 +6425,79 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemMinimumQuantity_beforeInsert` + BEFORE INSERT ON `itemMinimumQuantity` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); + CALL itemMinimumQuantity_check(NEW.id, NEW.itemFk, NEW.started, NEW.ended, NEW.warehouseFk); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemMinimumQuantity_beforeUpdate` + BEFORE UPDATE ON `itemMinimumQuantity` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); + CALL itemMinimumQuantity_check(NEW.id, NEW.itemFk, NEW.started, NEW.ended, NEW.warehouseFk); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemMinimumQuantity_afterDelete` + AFTER DELETE ON `itemMinimumQuantity` + FOR EACH ROW +BEGIN + INSERT INTO itemLog + SET `action` = 'delete', + `changedModel` = 'ItemMinimumQuantity', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_beforeInsert` BEFORE INSERT ON `itemShelving` FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); SET NEW.userFk = account.myUser_getId(); + SET NEW.available = NEW.visible; END */;; DELIMITER ; @@ -6118,48 +6514,21 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_afterInsert` AFTER INSERT ON `itemShelving` FOR EACH ROW -INSERT INTO vn.itemShelvingLog( itemShelvingFk, - workerFk, - accion, - itemFk, - shelvingFk, - visible, - `grouping`, - packing) - VALUES( NEW.id, - NEW.userFk, - 'CREA REGISTRO', - NEW.itemFk, - NEW.shelvingFk, - NEW.visible, - NEW.`grouping`, - NEW.packing - ) */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_beforeUpdate` - BEFORE UPDATE ON `itemShelving` - FOR EACH ROW -BEGIN - SET NEW.editorFk = account.myUser_getId(); - IF NEW.userFk IS NULL THEN - SET NEW.userFk = account.myUser_getId(); - END IF; +BEGIN + INSERT INTO itemShelvingLog + SET itemShelvingFk = NEW.id, + workerFk = account.myUser_getId(), + accion = 'CREA REGISTRO', + itemFk = NEW.itemFk, + shelvingFk = NEW.shelvingFk, + visible = NEW.visible, + `grouping` = NEW.`grouping`, + packing = NEW.packing, + available = NEW.available; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6175,18 +6544,17 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_afterUpdate` - AFTER UPDATE ON `itemShelving` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_beforeUpdate` + BEFORE UPDATE ON `itemShelving` FOR EACH ROW -INSERT INTO itemShelvingLog - SET itemShelvingFk = NEW.id, - workerFk = account.myUser_getId(), - accion = 'CAMBIO', - itemFk = NEW.itemFk, - shelvingFk = NEW.shelvingFk, - visible = NEW.visible, - `grouping` = NEW.`grouping`, - packing = NEW.packing */;; +BEGIN + + SET NEW.editorFk = account.myUser_getId(); + IF NEW.userFk IS NULL THEN + SET NEW.userFk = account.myUser_getId(); + END IF; + +END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; @@ -6201,7 +6569,37 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_beforeDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_afterUpdate` + AFTER UPDATE ON `itemShelving` + FOR EACH ROW +BEGIN + INSERT INTO itemShelvingLog + SET itemShelvingFk = NEW.id, + workerFk = account.myUser_getId(), + accion = 'CAMBIO', + itemFk = NEW.itemFk, + shelvingFk = NEW.shelvingFk, + visible = NEW.visible, + `grouping` = NEW.`grouping`, + packing = NEW.packing, + available = NEW.available; + +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_beforeDelete` BEFORE DELETE ON `itemShelving` FOR EACH ROW INSERT INTO vn.itemShelvingLog(itemShelvingFk, @@ -6228,13 +6626,13 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving _afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_afterDelete` AFTER DELETE ON `itemShelving` FOR EACH ROW BEGIN INSERT INTO shelvingLog SET `action` = 'delete', - `changedModel` = 'itemShelving', + `changedModel` = 'ItemShelving', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); END */;; @@ -6252,15 +6650,15 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelvingSale_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelvingSale_afterInsert` AFTER INSERT ON `itemShelvingSale` FOR EACH ROW -BEGIN - - UPDATE vn.sale - SET isPicked = TRUE - WHERE id = NEW.saleFk; - +BEGIN + + UPDATE sale s + JOIN operator o ON o.workerFk = account.myUser_getId() + SET s.isPicked = IF(o.isOnReservationMode, s.isPicked, TRUE) + WHERE id = NEW.saleFk; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6276,7 +6674,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTag_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTag_beforeInsert` BEFORE INSERT ON `itemTag` FOR EACH ROW BEGIN @@ -6297,7 +6695,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTag_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTag_afterInsert` AFTER INSERT ON `itemTag` FOR EACH ROW trig: BEGIN @@ -6321,7 +6719,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTag_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTag_beforeUpdate` BEFORE UPDATE ON `itemTag` FOR EACH ROW BEGIN @@ -6346,7 +6744,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTag_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTag_afterUpdate` AFTER UPDATE ON `itemTag` FOR EACH ROW trig: BEGIN @@ -6382,7 +6780,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTag_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTag_afterDelete` AFTER DELETE ON `itemTag` FOR EACH ROW trig: BEGIN @@ -6412,7 +6810,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTaxCountry_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTaxCountry_beforeInsert` BEFORE INSERT ON `itemTaxCountry` FOR EACH ROW BEGIN @@ -6432,7 +6830,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTaxCountry_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTaxCountry_beforeUpdate` BEFORE UPDATE ON `itemTaxCountry` FOR EACH ROW BEGIN @@ -6452,7 +6850,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTaxCountry_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemTaxCountry_afterDelete` AFTER DELETE ON `itemTaxCountry` FOR EACH ROW BEGIN @@ -6476,7 +6874,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemType_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemType_beforeUpdate` BEFORE UPDATE ON `itemType` FOR EACH ROW BEGIN @@ -6506,7 +6904,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`machine_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`machine_beforeInsert` BEFORE INSERT ON `machine` FOR EACH ROW BEGIN @@ -6528,7 +6926,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`mail_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`mail_beforeInsert` BEFORE INSERT ON `mail` FOR EACH ROW BEGIN @@ -6554,7 +6952,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`mandate_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`mandate_beforeInsert` BEFORE INSERT ON `mandate` FOR EACH ROW BEGIN @@ -6572,13 +6970,13 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`operator_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`operator_beforeInsert` BEFORE INSERT ON `operator` FOR EACH ROW BEGIN @@ -6598,7 +6996,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`operator_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`operator_beforeUpdate` BEFORE UPDATE ON `operator` FOR EACH ROW BEGIN @@ -6620,7 +7018,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`packaging_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`packaging_beforeInsert` BEFORE INSERT ON `packaging` FOR EACH ROW BEGIN @@ -6640,7 +7038,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`packaging_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`packaging_beforeUpdate` BEFORE UPDATE ON `packaging` FOR EACH ROW BEGIN @@ -6660,7 +7058,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`packingSite_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`packingSite_beforeInsert` BEFORE INSERT ON `packingSite` FOR EACH ROW BEGIN @@ -6680,7 +7078,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`packingSite_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`packingSite_beforeUpdate` BEFORE UPDATE ON `packingSite` FOR EACH ROW BEGIN @@ -6700,7 +7098,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`packingSite_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`packingSite_afterDelete` AFTER DELETE ON `packingSite` FOR EACH ROW BEGIN @@ -6724,7 +7122,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`parking_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`parking_beforeInsert` BEFORE INSERT ON `parking` FOR EACH ROW BEGIN @@ -6746,7 +7144,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`parking_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`parking_beforeUpdate` BEFORE UPDATE ON `parking` FOR EACH ROW BEGIN @@ -6768,7 +7166,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`parking_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`parking_afterDelete` AFTER DELETE ON `parking` FOR EACH ROW BEGIN @@ -6792,98 +7190,98 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`payment_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`payment_beforeInsert` BEFORE INSERT ON `payment` FOR EACH ROW BEGIN - DECLARE cuenta_banco,cuenta_proveedor DOUBLE; - DECLARE vNewBookEntry INT; - DECLARE bolCASH BOOLEAN; - DECLARE isSupplierActive BOOLEAN; + DECLARE vBankAccount DOUBLE; + DECLARE vSupplierAccount DOUBLE; + DECLARE vNewBookEntry INT; + DECLARE vIsCash BOOLEAN; + DECLARE vIsSupplierActive BOOLEAN; - -- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH - SELECT (at2.code = 'cash') INTO bolCASH - FROM accounting a - JOIN accountingType at2 ON at2.id = a.accountingTypeFk - WHERE a.id = NEW.bankFk; + SELECT (at2.code = 'cash') INTO vIsCash + FROM accounting a + JOIN accountingType at2 ON at2.id = a.accountingTypeFk + WHERE a.id = NEW.bankFk; - IF bolCASH THEN - - SELECT account INTO cuenta_banco - FROM accounting - WHERE id = NEW.bankFk; - - SELECT account INTO cuenta_proveedor - FROM supplier - WHERE id = NEW.supplierFk; + IF vIsCash THEN + SELECT account INTO vBankAccount + FROM accounting + WHERE id = NEW.bankFk; - CALL ledger_next(vNewBookEntry); - - INSERT INTO XDiario ( ASIEN, - FECHA, - SUBCTA, - CONTRA, - CONCEPTO, - EURODEBE, - EUROHABER, - empresa_id) - SELECT vNewBookEntry, - NEW.received, - SUBCTA, - CONTRA, - NEW.concept, - EURODEBE, - EUROHABER, - NEW.companyFk - FROM ( SELECT cuenta_banco SUBCTA, - cuenta_proveedor CONTRA, - 0 EURODEBE, - NEW.amount + NEW.bankingFees EUROHABER - UNION ALL - SELECT cuenta_proveedor SUBCTA, - cuenta_banco CONTRA, - NEW.amount EURODEBE, - 0 EUROHABER) gf; - - IF NEW.bankingFees <> 0 THEN - INSERT INTO XDiario ( ASIEN, - FECHA, - SUBCTA, - CONTRA, - CONCEPTO, - EURODEBE, - EUROHABER, - empresa_id) - SELECT vNewBookEntry, - NEW.received, - IF(c.id = 1,6260000002, - IF(CEE = 1,6260000003,6260000004)), - cuenta_banco, - NEW.concept, - NEW.bankingFees, - 0, - NEW.companyFk - FROM supplier s - JOIN country c ON s.countryFk = c.id - WHERE s.id = NEW.supplierFk; - END IF; - END IF; - - SET NEW.dueDated = IFNULL(NEW.dueDated, NEW.received); - - SELECT isActive INTO isSupplierActive + SELECT account INTO vSupplierAccount FROM supplier WHERE id = NEW.supplierFk; - - IF isSupplierActive = FALSE THEN - CALL util.throw('SUPPLIER_INACTIVE'); - END IF; - - IF ISNULL(NEW.workerFk) THEN - SET NEW.workerFk = account.myUser_getId(); - END IF; - - END */;; + + CALL ledger_next(YEAR(NEW.received), vNewBookEntry); + + INSERT INTO XDiario ( + ASIEN, + FECHA, + SUBCTA, + CONTRA, + CONCEPTO, + EURODEBE, + EUROHABER, + empresa_id) + SELECT vNewBookEntry, + NEW.received, + SUBCTA, + CONTRA, + NEW.concept, + EURODEBE, + EUROHABER, + NEW.companyFk + FROM (SELECT vBankAccount SUBCTA, + vSupplierAccount CONTRA, + 0 EURODEBE, + NEW.amount + NEW.bankingFees EUROHABER + UNION ALL + SELECT vSupplierAccount SUBCTA, + vBankAccount CONTRA, + NEW.amount EURODEBE, + 0 EUROHABER) gf; + + IF NEW.bankingFees <> 0 THEN + INSERT INTO XDiario ( + ASIEN, + FECHA, + SUBCTA, + CONTRA, + CONCEPTO, + EURODEBE, + EUROHABER, + empresa_id) + SELECT vNewBookEntry, + NEW.received, + IF(c.id = 1,6260000002, + IF(CEE = 1,6260000003,6260000004)), + vBankAccount, + NEW.concept, + NEW.bankingFees, + 0, + NEW.companyFk + FROM supplier s + JOIN country c ON s.countryFk = c.id + WHERE s.id = NEW.supplierFk; + END IF; + END IF; + + SET NEW.dueDated = IFNULL(NEW.dueDated, NEW.received); + + SELECT isActive INTO vIsSupplierActive + FROM supplier + WHERE id = NEW.supplierFk; + + IF vIsSupplierActive = FALSE THEN + CALL util.throw('SUPPLIER_INACTIVE'); + END IF; + + IF ISNULL(NEW.workerFk) THEN + SET NEW.workerFk = account.myUser_getId(); + END IF; +END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; @@ -6898,7 +7296,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`payment_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`payment_afterInsert` AFTER INSERT ON `payment` FOR EACH ROW BEGIN @@ -6940,11 +7338,13 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER payment_beforeUpdate BEFORE UPDATE ON payment FOR EACH ROW +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`payment_beforeUpdate` + BEFORE UPDATE ON `payment` + FOR EACH ROW BEGIN IF ISNULL(NEW.workerFk) THEN SET NEW.workerFk = account.myUser_getId(); @@ -6964,7 +7364,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`postCode_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`postCode_beforeInsert` BEFORE INSERT ON `postCode` FOR EACH ROW BEGIN @@ -6985,7 +7385,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`postCode_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`postCode_beforeUpdate` BEFORE UPDATE ON `postCode` FOR EACH ROW BEGIN @@ -7007,7 +7407,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`postCode_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`postCode_afterUpdate` AFTER UPDATE ON `postCode` FOR EACH ROW BEGIN @@ -7035,7 +7435,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`postCode_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`postCode_afterDelete` AFTER DELETE ON `postCode` FOR EACH ROW BEGIN @@ -7055,7 +7455,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`priceFixed_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`priceFixed_beforeInsert` BEFORE INSERT ON `priceFixed` FOR EACH ROW BEGIN @@ -7080,7 +7480,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`priceFixed_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`priceFixed_beforeUpdate` BEFORE UPDATE ON `priceFixed` FOR EACH ROW BEGIN @@ -7105,7 +7505,71 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`projectNotes_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`productionConfig_beforeInsert` + BEFORE INSERT ON `productionConfig` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`productionConfig_beforeUpdate` + BEFORE UPDATE ON `productionConfig` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`productionConfig_afterDelete` + AFTER DELETE ON `productionConfig` + FOR EACH ROW +BEGIN + INSERT INTO productionConfig + SET `action` = 'delete', + `changedModel` = 'ProductionConfig', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`projectNotes_beforeInsert` BEFORE INSERT ON `projectNotes` FOR EACH ROW BEGIN @@ -7131,7 +7595,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`province_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`province_beforeInsert` BEFORE INSERT ON `province` FOR EACH ROW BEGIN @@ -7156,7 +7620,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`province_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`province_beforeUpdate` BEFORE UPDATE ON `province` FOR EACH ROW BEGIN @@ -7182,7 +7646,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`province_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`province_afterUpdate` AFTER UPDATE ON `province` FOR EACH ROW BEGIN @@ -7210,7 +7674,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`province_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`province_afterDelete` AFTER DELETE ON `province` FOR EACH ROW BEGIN @@ -7230,7 +7694,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`rate_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`rate_beforeInsert` BEFORE INSERT ON `rate` FOR EACH ROW BEGIN @@ -7250,7 +7714,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`rate_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`rate_beforeUpdate` BEFORE UPDATE ON `rate` FOR EACH ROW BEGIN @@ -7270,7 +7734,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`rate_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`rate_afterDelete` AFTER DELETE ON `rate` FOR EACH ROW BEGIN @@ -7294,7 +7758,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`receipt_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`receipt_beforeInsert` BEFORE INSERT ON `receipt` FOR EACH ROW BEGIN @@ -7323,7 +7787,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`receipt_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`receipt_afterInsert` AFTER INSERT ON `receipt` FOR EACH ROW CALL clientRisk_update(NEW.clientFk, NEW.companyFk, -NEW.amountPaid) */;; @@ -7341,7 +7805,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`receipt_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`receipt_beforeUpdate` BEFORE UPDATE ON `receipt` FOR EACH ROW BEGIN @@ -7363,7 +7827,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`receipt_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`receipt_afterUpdate` AFTER UPDATE ON `receipt` FOR EACH ROW BEGIN @@ -7390,7 +7854,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`receipt_beforeDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`receipt_beforeDelete` BEFORE DELETE ON `receipt` FOR EACH ROW CALL clientRisk_update(OLD.clientFk, OLD.companyFk, OLD.amountPaid) */;; @@ -7408,7 +7872,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`recovery_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`recovery_beforeInsert` BEFORE INSERT ON `recovery` FOR EACH ROW BEGIN @@ -7428,7 +7892,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`recovery_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`recovery_beforeUpdate` BEFORE UPDATE ON `recovery` FOR EACH ROW BEGIN @@ -7448,7 +7912,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`recovery_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`recovery_afterDelete` AFTER DELETE ON `recovery` FOR EACH ROW BEGIN @@ -7472,7 +7936,99 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`roadmap_beforeInsert` + BEFORE INSERT ON `roadmap` + FOR EACH ROW +BEGIN + IF NEW.driver1Fk IS NOT NULL THEN + SET NEW.driverName = (SELECT firstName FROM worker WHERE id = NEW.driver1Fk); + ELSE + SET NEW.driverName = NULL; + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`roadmap_beforeUpdate` + BEFORE UPDATE ON `roadmap` + FOR EACH ROW +BEGIN + IF NEW.driver1Fk IS NOT NULL THEN + SET NEW.driverName = (SELECT firstName FROM worker WHERE id = NEW.driver1Fk); + ELSE + SET NEW.driverName = NULL; + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`roadmapStop_beforeInsert` + BEFORE INSERT ON `roadmapStop` + FOR EACH ROW +BEGIN + + SET NEW.description = UCASE(NEW.description); + +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`roadmapStop_beforeUpdate` + BEFORE UPDATE ON `roadmapStop` + FOR EACH ROW +BEGIN + + SET NEW.description = UCASE(NEW.description); + +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_beforeInsert` BEFORE INSERT ON `route` FOR EACH ROW BEGIN @@ -7513,7 +8069,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_afterInsert` AFTER INSERT ON `route` FOR EACH ROW BEGIN @@ -7533,7 +8089,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_beforeUpdate` BEFORE UPDATE ON `route` FOR EACH ROW BEGIN @@ -7574,7 +8130,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_afterUpdate` AFTER UPDATE ON `route` FOR EACH ROW BEGIN @@ -7615,7 +8171,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_afterDelete` AFTER DELETE ON `route` FOR EACH ROW BEGIN @@ -7639,7 +8195,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`routesMonitor_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`routesMonitor_beforeInsert` BEFORE INSERT ON `routesMonitor` FOR EACH ROW BEGIN @@ -7659,7 +8215,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`routesMonitor_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`routesMonitor_beforeUpdate` BEFORE UPDATE ON `routesMonitor` FOR EACH ROW BEGIN @@ -7679,7 +8235,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`routesMonitor_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`routesMonitor_afterDelete` AFTER DELETE ON `routesMonitor` FOR EACH ROW BEGIN @@ -7703,7 +8259,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_beforeInsert` BEFORE INSERT ON `sale` FOR EACH ROW BEGIN @@ -7724,7 +8280,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_afterInsert` AFTER INSERT ON `sale` FOR EACH ROW BEGIN @@ -7766,7 +8322,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_beforeUpdate` BEFORE UPDATE ON `sale` FOR EACH ROW BEGIN @@ -7801,7 +8357,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_afterUpdate` AFTER UPDATE ON `sale` FOR EACH ROW BEGIN @@ -7886,7 +8442,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_beforeDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_beforeDelete` BEFORE DELETE ON `sale` FOR EACH ROW BEGIN @@ -7916,7 +8472,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`sale_afterDelete` AFTER DELETE ON `sale` FOR EACH ROW BEGIN @@ -7973,7 +8529,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleBuy_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleBuy_beforeInsert` BEFORE INSERT ON `saleBuy` FOR EACH ROW BEGIN @@ -7995,7 +8551,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleGroup_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleGroup_beforeInsert` BEFORE INSERT ON `saleGroup` FOR EACH ROW BEGIN @@ -8015,7 +8571,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleGroup_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleGroup_beforeUpdate` BEFORE UPDATE ON `saleGroup` FOR EACH ROW BEGIN @@ -8035,11 +8591,11 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleGroup_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleGroup_afterDelete` AFTER DELETE ON `saleGroup` FOR EACH ROW BEGIN - INSERT INTO ticketLog + INSERT INTO saleGroupLog SET `action` = 'delete', `changedModel` = 'SaleGroup', `changedModelId` = OLD.id, @@ -8059,7 +8615,71 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleLabel_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleGroupDetail_beforeInsert` + BEFORE INSERT ON `saleGroupDetail` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleGroupDetail_beforeUpdate` + BEFORE UPDATE ON `saleGroupDetail` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleGroupDetail_afterDelete` + AFTER DELETE ON `saleGroupDetail` + FOR EACH ROW +BEGIN + INSERT INTO saleGroupLog + SET `action` = 'delete', + `changedModel` = 'SaleGroupDetail', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleLabel_afterUpdate` AFTER UPDATE ON `vn`.`saleLabel` FOR EACH ROW IF NEW.stem >= (SELECT s.quantity FROM sale s WHERE s.id = NEW.saleFk) THEN @@ -8079,7 +8699,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleTracking_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleTracking_afterInsert` AFTER INSERT ON `saleTracking` FOR EACH ROW BEGIN @@ -8108,7 +8728,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sharingCart_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`sharingCart_beforeInsert` BEFORE INSERT ON `sharingCart` FOR EACH ROW BEGIN @@ -8135,7 +8755,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sharingCart_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`sharingCart_beforeUpdate` BEFORE UPDATE ON `sharingCart` FOR EACH ROW BEGIN @@ -8168,7 +8788,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sharingCart_beforeDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`sharingCart_beforeDelete` BEFORE DELETE ON `sharingCart` FOR EACH ROW BEGIN @@ -8191,7 +8811,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sharingClient_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`sharingClient_beforeInsert` BEFORE INSERT ON `sharingClient` FOR EACH ROW BEGIN @@ -8212,7 +8832,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`sharingClient_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`sharingClient_beforeUpdate` BEFORE UPDATE ON `sharingClient` FOR EACH ROW BEGIN @@ -8233,7 +8853,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`shelving_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`shelving_beforeInsert` BEFORE INSERT ON `shelving` FOR EACH ROW BEGIN @@ -8258,7 +8878,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`shelving_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`shelving_beforeUpdate` BEFORE UPDATE ON `shelving` FOR EACH ROW BEGIN @@ -8286,7 +8906,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`shelving_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`shelving_afterDelete` AFTER DELETE ON `shelving` FOR EACH ROW BEGIN @@ -8310,13 +8930,13 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`solunionCAP_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`solunionCAP_afterInsert` AFTER INSERT ON `solunionCAP` FOR EACH ROW BEGIN UPDATE client c JOIN creditClassification cc ON cc.client = c.id - JOIN creditInsurance ci ON ci.creditClassification = cc.id + JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id SET creditInsurance = ci.credit * 2 WHERE ci.id = NEW.creditInsurance; END */;; DELIMITER ; @@ -8333,19 +8953,19 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`solunionCAP_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`solunionCAP_afterUpdate` AFTER UPDATE ON `solunionCAP` FOR EACH ROW BEGIN IF NEW.dateLeaving IS NOT NULL THEN UPDATE client c JOIN creditClassification cc ON cc.client = c.id - JOIN creditInsurance ci ON ci.creditClassification = cc.id + JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance; ELSE UPDATE client c JOIN creditClassification cc ON cc.client = c.id - JOIN creditInsurance ci ON ci.creditClassification = cc.id + JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id SET creditInsurance = ci.credit * 2 WHERE ci.id = OLD.creditInsurance; END IF; END */;; @@ -8363,13 +8983,13 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`solunionCAP_beforeDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`solunionCAP_beforeDelete` BEFORE DELETE ON `solunionCAP` FOR EACH ROW BEGIN UPDATE client c JOIN creditClassification cc ON cc.client = c.id - JOIN creditInsurance ci ON ci.creditClassification = cc.id + JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance; END */;; DELIMITER ; @@ -8386,7 +9006,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`specie_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`specie_beforeInsert` BEFORE INSERT ON `specie` FOR EACH ROW BEGIN @@ -8406,7 +9026,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`specie_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`specie_beforeUpdate` BEFORE UPDATE ON `specie` FOR EACH ROW BEGIN @@ -8426,7 +9046,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplier_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplier_beforeInsert` BEFORE INSERT ON `supplier` FOR EACH ROW BEGIN @@ -8446,7 +9066,45 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplier_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplier_afterUpdate` + BEFORE UPDATE ON `supplier` + FOR EACH ROW +BEGIN + IF NEW.id <> OLD.id + OR NOT (NEW.name <=> OLD.name) + OR NOT (NEW.street <=> OLD.street) + OR NOT (NEW.account <=> OLD.account) + OR NOT (NEW.nif <=> OLD.nif) + OR NOT (NEW.isVies <=> OLD.isVies) + OR NOT (NEW.provinceFk <=> OLD.provinceFk) + OR NOT (NEW.countryFk <=> OLD.countryFk) + OR NOT (NEW.postCode <=> OLD.postCode) + OR NOT (NEW.city <=> OLD.city) + OR NOT (NEW.taxTypeSageFk <=> OLD.taxTypeSageFk) + OR NOT (NEW.transactionTypeSageFk <=> OLD.transactionTypeSageFk) + OR NOT (NEW.withholdingSageFk <=> OLD.withholdingSageFk) THEN + + UPDATE sage.clientSupplier + SET isSync = FALSE + WHERE idClientSupplier IN (NEW.id, OLD.id) + AND `type` = 'P'; + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplier_beforeUpdate` BEFORE UPDATE ON `supplier` FOR EACH ROW BEGIN @@ -8502,7 +9160,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplier_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplier_afterDelete` AFTER DELETE ON `supplier` FOR EACH ROW BEGIN @@ -8526,7 +9184,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAccount_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAccount_beforeInsert` BEFORE INSERT ON `supplierAccount` FOR EACH ROW BEGIN @@ -8546,7 +9204,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAccount_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAccount_beforeUpdate` BEFORE UPDATE ON `supplierAccount` FOR EACH ROW BEGIN @@ -8566,7 +9224,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAccount_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAccount_afterDelete` AFTER DELETE ON `supplierAccount` FOR EACH ROW BEGIN @@ -8590,7 +9248,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAddress_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAddress_beforeInsert` BEFORE INSERT ON `supplierAddress` FOR EACH ROW BEGIN @@ -8610,7 +9268,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAddress_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAddress_beforeUpdate` BEFORE UPDATE ON `supplierAddress` FOR EACH ROW BEGIN @@ -8630,7 +9288,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAddress_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierAddress_afterDelete` AFTER DELETE ON `supplierAddress` FOR EACH ROW BEGIN @@ -8654,7 +9312,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierContact_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierContact_beforeInsert` BEFORE INSERT ON `supplierContact` FOR EACH ROW BEGIN @@ -8674,7 +9332,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierContact_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierContact_beforeUpdate` BEFORE UPDATE ON `supplierContact` FOR EACH ROW BEGIN @@ -8694,7 +9352,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierContact_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierContact_afterDelete` AFTER DELETE ON `supplierContact` FOR EACH ROW BEGIN @@ -8718,7 +9376,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierDms_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierDms_beforeInsert` BEFORE INSERT ON `supplierDms` FOR EACH ROW BEGIN @@ -8738,7 +9396,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierDms_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierDms_beforeUpdate` BEFORE UPDATE ON `supplierDms` FOR EACH ROW BEGIN @@ -8758,7 +9416,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierDms_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`supplierDms_afterDelete` AFTER DELETE ON `supplierDms` FOR EACH ROW BEGIN @@ -8782,7 +9440,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`tag_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`tag_beforeInsert` BEFORE INSERT ON `tag` FOR EACH ROW BEGIN @@ -8804,7 +9462,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_beforeInsert` BEFORE INSERT ON `ticket` FOR EACH ROW BEGIN @@ -8824,7 +9482,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_afterInsert` AFTER INSERT ON `ticket` FOR EACH ROW BEGIN @@ -8874,7 +9532,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_beforeUpdate` BEFORE UPDATE ON `ticket` FOR EACH ROW BEGIN @@ -8883,13 +9541,22 @@ BEGIN SET NEW.editorFk = account.myUser_getId(); IF NOT (NEW.routeFk <=> OLD.routeFk) THEN - INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`) - SELECT r.id - FROM vn.route r - WHERE r.isOk = FALSE - AND r.id IN (OLD.routeFk,NEW.routeFk) - AND r.created >= util.VN_CURDATE() - GROUP BY r.id; + IF NEW.isSigned AND NOT ( + SELECT (COUNT(s.id) = COUNT(cb.saleFk) + AND SUM(s.quantity) = SUM(cb.quantity)) + FROM sale s + LEFT JOIN claimBeginning cb ON cb.saleFk = s.id + WHERE s.ticketFk = NEW.id + ) THEN + CALL util.throw('A signed ticket cannot be rerouted'); + END IF; + INSERT IGNORE INTO routeRecalc(routeFk) + SELECT id + FROM `route` + WHERE NOT isOk + AND id IN (OLD.routeFk, NEW.routeFk) + AND created >= util.VN_CURDATE() + GROUP BY id; END IF; IF NOT (DATE(NEW.shipped) <=> DATE(OLD.shipped)) THEN @@ -8953,7 +9620,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_afterUpdate` AFTER UPDATE ON `ticket` FOR EACH ROW BEGIN @@ -8961,6 +9628,10 @@ BEGIN UPDATE expedition SET hasNewRoute = TRUE WHERE ticketFk = NEW.id; + + IF NEW.cmrFk THEN + CALL ticket_doCmr(NEW.id); + END IF; END IF; END */;; DELIMITER ; @@ -8977,7 +9648,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_beforeDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_beforeDelete` BEFORE DELETE ON `ticket` FOR EACH ROW BEGIN @@ -9007,7 +9678,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticket_afterDelete` AFTER DELETE ON `ticket` FOR EACH ROW BEGIN @@ -9025,15 +9696,15 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER ticketCollection_afterDelete -AFTER DELETE -ON ticketCollection FOR EACH ROW +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketCollection_afterDelete` + AFTER DELETE ON `ticketCollection` + FOR EACH ROW BEGIN DECLARE vSalesRemaining INT; @@ -9071,7 +9742,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketDms_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketDms_beforeInsert` BEFORE INSERT ON `ticketDms` FOR EACH ROW BEGIN @@ -9091,7 +9762,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketDms_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketDms_beforeUpdate` BEFORE UPDATE ON `ticketDms` FOR EACH ROW BEGIN @@ -9111,7 +9782,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketDms_beforeDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketDms_beforeDelete` BEFORE DELETE ON `ticketDms` FOR EACH ROW BEGIN @@ -9139,7 +9810,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketDms_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketDms_afterDelete` AFTER DELETE ON `ticketDms` FOR EACH ROW BEGIN @@ -9163,7 +9834,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketObservation_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketObservation_beforeInsert` BEFORE INSERT ON `ticketObservation` FOR EACH ROW BEGIN @@ -9183,7 +9854,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketObservation_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketObservation_beforeUpdate` BEFORE UPDATE ON `ticketObservation` FOR EACH ROW BEGIN @@ -9203,7 +9874,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketObservation_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketObservation_afterDelete` AFTER DELETE ON `ticketObservation` FOR EACH ROW BEGIN @@ -9227,7 +9898,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketPackaging_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketPackaging_beforeInsert` BEFORE INSERT ON `ticketPackaging` FOR EACH ROW BEGIN @@ -9247,7 +9918,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketPackaging_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketPackaging_beforeUpdate` BEFORE UPDATE ON `ticketPackaging` FOR EACH ROW BEGIN @@ -9267,7 +9938,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketPackaging_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketPackaging_afterDelete` AFTER DELETE ON `ticketPackaging` FOR EACH ROW BEGIN @@ -9291,7 +9962,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketParking_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketParking_beforeInsert` BEFORE INSERT ON `ticketParking` FOR EACH ROW BEGIN @@ -9313,12 +9984,11 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRefund_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRefund_beforeInsert` BEFORE INSERT ON `ticketRefund` FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); - CALL ticketRefund_beforeUpsert(NEW.refundTicketFk, NEW.originalTicketFk); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -9334,12 +10004,11 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRefund_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRefund_beforeUpdate` BEFORE UPDATE ON `ticketRefund` FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); - CALL ticketRefund_beforeUpsert(NEW.refundTicketFk, NEW.originalTicketFk); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -9355,7 +10024,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRefund_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRefund_afterDelete` AFTER DELETE ON `ticketRefund` FOR EACH ROW BEGIN @@ -9379,7 +10048,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRequest_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRequest_beforeInsert` BEFORE INSERT ON `ticketRequest` FOR EACH ROW BEGIN @@ -9411,7 +10080,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRequest_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRequest_beforeUpdate` BEFORE UPDATE ON `ticketRequest` FOR EACH ROW BEGIN @@ -9439,7 +10108,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRequest_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketRequest_afterDelete` AFTER DELETE ON `ticketRequest` FOR EACH ROW BEGIN @@ -9463,7 +10132,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketService_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketService_beforeInsert` BEFORE INSERT ON `ticketService` FOR EACH ROW BEGIN @@ -9483,7 +10152,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketService_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketService_beforeUpdate` BEFORE UPDATE ON `ticketService` FOR EACH ROW BEGIN @@ -9503,7 +10172,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketService_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketService_afterDelete` AFTER DELETE ON `ticketService` FOR EACH ROW BEGIN @@ -9527,7 +10196,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketTracking_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketTracking_beforeInsert` BEFORE INSERT ON `ticketTracking` FOR EACH ROW BEGIN @@ -9547,7 +10216,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketTracking_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketTracking_afterInsert` AFTER INSERT ON `ticketTracking` FOR EACH ROW BEGIN @@ -9570,9 +10239,9 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketTracking_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketTracking_beforeUpdate` BEFORE UPDATE ON `ticketTracking` FOR EACH ROW BEGIN @@ -9592,7 +10261,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketTracking_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketTracking_afterUpdate` AFTER UPDATE ON `ticketTracking` FOR EACH ROW BEGIN @@ -9636,7 +10305,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketTracking_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketTracking_afterDelete` AFTER DELETE ON `ticketTracking` FOR EACH ROW BEGIN @@ -9655,11 +10324,6 @@ BEGIN `changedModel` = 'TicketTracking', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); - - CALL util.debugAdd('deletedState', - CONCAT('interFk: ', OLD.id, - ' ticketFk: ', OLD.ticketFk, - ' stateFk: ', OLD.stateFk)); SELECT i.ticketFk, i.id, s.`name` INTO vTicketFk, vTicketTrackingFk, vStateName @@ -9688,7 +10352,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketWeekly_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketWeekly_beforeInsert` BEFORE INSERT ON `ticketWeekly` FOR EACH ROW BEGIN @@ -9708,7 +10372,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketWeekly_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketWeekly_beforeUpdate` BEFORE UPDATE ON `ticketWeekly` FOR EACH ROW BEGIN @@ -9728,7 +10392,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketWeekly_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`ticketWeekly_afterDelete` AFTER DELETE ON `ticketWeekly` FOR EACH ROW BEGIN @@ -9752,7 +10416,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`time_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`time_afterUpdate` AFTER UPDATE ON `time` FOR EACH ROW BEGIN @@ -9777,7 +10441,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`town_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`town_beforeInsert` BEFORE INSERT ON `town` FOR EACH ROW BEGIN @@ -9798,7 +10462,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`town_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`town_beforeUpdate` BEFORE UPDATE ON `town` FOR EACH ROW BEGIN @@ -9820,7 +10484,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`town_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`town_afterUpdate` AFTER UPDATE ON `town` FOR EACH ROW BEGIN @@ -9848,7 +10512,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`town_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`town_afterDelete` AFTER DELETE ON `town` FOR EACH ROW BEGIN @@ -9868,7 +10532,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travel_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`travel_beforeInsert` BEFORE INSERT ON `travel` FOR EACH ROW BEGIN @@ -9878,8 +10542,8 @@ BEGIN CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk); - IF NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN - CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries'); + IF NEW.awbFk IS NOT NULL THEN + CALL travel_throwAwb(NEW.id); END IF; END */;; DELIMITER ; @@ -9896,7 +10560,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travel_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`travel_beforeUpdate` BEFORE UPDATE ON `travel` FOR EACH ROW BEGIN @@ -9930,8 +10594,8 @@ BEGIN END IF; END IF; - IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN - CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries'); + IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL THEN + CALL travel_throwAwb(NEW.id); END IF; END */;; DELIMITER ; @@ -9948,7 +10612,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travel_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`travel_afterUpdate` AFTER UPDATE ON `travel` FOR EACH ROW BEGIN @@ -9985,7 +10649,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travel_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`travel_afterDelete` AFTER DELETE ON `travel` FOR EACH ROW BEGIN @@ -10009,7 +10673,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travelThermograph_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`travelThermograph_beforeInsert` BEFORE INSERT ON `travelThermograph` FOR EACH ROW BEGIN @@ -10029,7 +10693,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travelThermograph_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`travelThermograph_beforeUpdate` BEFORE UPDATE ON `travelThermograph` FOR EACH ROW BEGIN @@ -10049,7 +10713,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`travelThermograph_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`travelThermograph_afterDelete` AFTER DELETE ON `travelThermograph` FOR EACH ROW BEGIN @@ -10073,7 +10737,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`vehicle_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`vehicle_beforeInsert` BEFORE INSERT ON `vehicle` FOR EACH ROW BEGIN @@ -10093,7 +10757,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`vehicle_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`vehicle_beforeUpdate` BEFORE UPDATE ON `vehicle` FOR EACH ROW BEGIN @@ -10113,7 +10777,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`warehouse_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`warehouse_afterInsert` BEFORE UPDATE ON `warehouse` FOR EACH ROW BEGIN @@ -10135,7 +10799,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`worker_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`worker_beforeInsert` BEFORE INSERT ON `worker` FOR EACH ROW BEGIN @@ -10155,7 +10819,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`worker_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`worker_beforeUpdate` BEFORE UPDATE ON `worker` FOR EACH ROW BEGIN @@ -10175,7 +10839,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`worker_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`worker_afterDelete` AFTER DELETE ON `worker` FOR EACH ROW BEGIN @@ -10199,8 +10863,8 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerDocument_beforeInsert` - BEFORE INSERT ON `workerDocument` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerDms_beforeInsert` + BEFORE INSERT ON `workerDms` FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); @@ -10219,8 +10883,8 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerDocument_beforeUpdate` - BEFORE UPDATE ON `workerDocument` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerDms_beforeUpdate` + BEFORE UPDATE ON `workerDms` FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); @@ -10239,13 +10903,13 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerDocument_afterDelete` - AFTER DELETE ON `workerDocument` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerDms_afterDelete` + AFTER DELETE ON `workerDms` FOR EACH ROW BEGIN INSERT INTO workerLog SET `action` = 'delete', - `changedModel` = 'WorkerDocument', + `changedModel` = 'WorkerDms', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); END */;; @@ -10263,7 +10927,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerIncome_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerIncome_afterInsert` AFTER INSERT ON `workerIncome` FOR EACH ROW BEGIN @@ -10283,7 +10947,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerIncome_afterUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerIncome_afterUpdate` AFTER UPDATE ON `workerIncome` FOR EACH ROW BEGIN @@ -10305,7 +10969,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerIncome_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerIncome_afterDelete` AFTER DELETE ON `workerIncome` FOR EACH ROW BEGIN @@ -10325,11 +10989,11 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerTimeControl_beforeInsert` - BEFORE INSERT ON `workerTimeControl` - FOR EACH ROW -BEGIN - SET NEW.editorFk = account.myUser_getId(); +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerTimeControl_beforeInsert` + BEFORE INSERT ON `workerTimeControl` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -10345,7 +11009,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerTimeControl_afterInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerTimeControl_afterInsert` AFTER INSERT ON `workerTimeControl` FOR EACH ROW BEGIN @@ -10367,11 +11031,11 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerTimeControl_beforeUpdate` - BEFORE UPDATE ON `workerTimeControl` - FOR EACH ROW -BEGIN - SET NEW.editorFk = account.myUser_getId(); +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerTimeControl_beforeUpdate` + BEFORE UPDATE ON `workerTimeControl` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -10387,15 +11051,15 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerTimeControl_afterDelete` - AFTER DELETE ON `workerTimeControl` - FOR EACH ROW -BEGIN - INSERT INTO workerLog - SET `action` = 'delete', - `changedModel` = 'WorkerTimeControl', - `changedModelId` = OLD.id, - `userFk` = account.myUser_getId(); +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`workerTimeControl_afterDelete` + AFTER DELETE ON `workerTimeControl` + FOR EACH ROW +BEGIN + INSERT INTO workerLog + SET `action` = 'delete', + `changedModel` = 'WorkerTimeControl', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -10411,7 +11075,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`workingHours_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`workingHours_beforeInsert` BEFORE INSERT ON `workingHours` FOR EACH ROW BEGIN @@ -10433,7 +11097,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zone_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`zone_beforeInsert` BEFORE INSERT ON `zone` FOR EACH ROW BEGIN @@ -10453,7 +11117,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zone_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`zone_beforeUpdate` BEFORE UPDATE ON `zone` FOR EACH ROW BEGIN @@ -10473,7 +11137,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zone_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`zone_afterDelete` AFTER DELETE ON `zone` FOR EACH ROW BEGIN @@ -10497,7 +11161,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneEvent_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneEvent_beforeInsert` BEFORE INSERT ON `zoneEvent` FOR EACH ROW BEGIN @@ -10517,7 +11181,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneEvent_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneEvent_beforeUpdate` BEFORE UPDATE ON `zoneEvent` FOR EACH ROW BEGIN @@ -10537,7 +11201,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneEvent_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneEvent_afterDelete` AFTER DELETE ON `zoneEvent` FOR EACH ROW BEGIN @@ -10561,7 +11225,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneExclusion_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneExclusion_beforeInsert` BEFORE INSERT ON `zoneExclusion` FOR EACH ROW BEGIN @@ -10583,7 +11247,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneExclusion_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneExclusion_beforeUpdate` BEFORE UPDATE ON `zoneExclusion` FOR EACH ROW BEGIN @@ -10605,7 +11269,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneExclusion_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneExclusion_afterDelete` AFTER DELETE ON `zoneExclusion` FOR EACH ROW BEGIN @@ -10629,7 +11293,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneGeo_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneGeo_beforeInsert` BEFORE INSERT ON `zoneGeo` FOR EACH ROW BEGIN @@ -10649,7 +11313,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneGeo_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneGeo_beforeUpdate` BEFORE UPDATE ON `zoneGeo` FOR EACH ROW BEGIN @@ -10671,7 +11335,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneIncluded_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneIncluded_beforeInsert` BEFORE INSERT ON `zoneIncluded` FOR EACH ROW BEGIN @@ -10692,7 +11356,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneIncluded_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneIncluded_beforeUpdate` BEFORE UPDATE ON `zoneIncluded` FOR EACH ROW BEGIN @@ -10713,7 +11377,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneIncluded_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneIncluded_afterDelete` AFTER DELETE ON `zoneIncluded` FOR EACH ROW BEGIN @@ -10738,7 +11402,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneWarehouse_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneWarehouse_beforeInsert` BEFORE INSERT ON `zoneWarehouse` FOR EACH ROW BEGIN @@ -10758,7 +11422,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneWarehouse_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneWarehouse_beforeUpdate` BEFORE UPDATE ON `zoneWarehouse` FOR EACH ROW BEGIN @@ -10778,7 +11442,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneWarehouse_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`zoneWarehouse_afterDelete` AFTER DELETE ON `zoneWarehouse` FOR EACH ROW BEGIN @@ -10805,4 +11469,4 @@ USE `vn2008`; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-05-14 6:26:46 +-- Dump completed on 2024-10-03 7:43:14 diff --git a/db/dump/dump.before.sql b/db/dump/dump.before.sql index 24168fe60..20a365c83 100644 --- a/db/dump/dump.before.sql +++ b/db/dump/dump.before.sql @@ -1 +1,14 @@ -- Executed before dump + +CREATE USER 'vn'@'localhost'; + +GRANT SELECT, + INSERT, + UPDATE, + DELETE, + DROP, + CREATE TEMPORARY TABLES, + EXECUTE, + EVENT, + TRIGGER + ON *.* TO 'vn'@'localhost'; diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index fd940d8a6..59730d592 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -10,9 +10,6 @@ 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); @@ -129,7 +126,7 @@ INSERT INTO vn.itemShelving (id,itemFk,visible,shelvingFk,`grouping`,packing,pac INSERT INTO vn.beach (code,warehouseFk) VALUES ('TEST',1); -INSERT INTO vn.routesMonitor (routeFk,name,beachFk,m3,expeditionTruckFk) VALUES +INSERT INTO vn.routesMonitor (routeFk,name,beachFk,m3,roadmapStopFk) VALUES (1,'TEST','TEST',1.0,1); /* #5483 INSERT INTO vn.ticket (clientFk, warehouseFk, shipped, nickname, refFk, addressFk, workerFk, observations, isSigned, isLabeled, isPrinted, packages, location, `hour`, created, isBlocked, solution, routeFk, priority, hasPriority, companyFk, agencyModeFk, landed, isBoxed, isDeleted, zoneFk, zonePrice, zoneBonus, totalWithVat, totalWithoutVat, weight) @@ -314,5 +311,4 @@ INSERT INTO mysql.roles_mapping (`User`, `Host`, `Role`, `Admin_option`) SELECT SUBSTR(`User`, @prefixLen + 1), `Host`, `Role`, `Admin_option` FROM mysql.roles_mapping WHERE `User` LIKE @prefixedLike AND `Host` = @genRoleHost; - FLUSH PRIVILEGES; diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 3e6edf07d..7f7e50dd3 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -108,6 +108,7 @@ INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `bossFk`) UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20; UPDATE `vn`.`worker` SET bossFk = 20 WHERE id = 1 OR id = 9; UPDATE `vn`.`worker` SET bossFk = 19 WHERE id = 18; +UPDATE `vn`.`worker` SET bossFk = 50 WHERE id = 49; DELETE FROM `vn`.`worker` WHERE firstName ='customer'; @@ -115,10 +116,13 @@ INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType` VALUES (1, 978, 1, 0, 2000, 9, 0); +INSERT INTO hedera.orderConfig (`id`, `employeeFk`, `defaultAgencyFk`, `guestMethod`, `guestAgencyFk`, `reserveTime`, `defaultCompanyFk`) + VALUES (1, 1, 2, 'PICKUP', 1, '00:20:00', 442); + INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`, `image`) VALUES (1101, 'brucewayne', 'Bruce Wayne', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'BruceWayne@mydomain.com', 'es','1101'), - (1102, 'petterparker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'PetterParker@mydomain.com', 'en','1102'), + (1102, 'petterparker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 131, 1, 'PetterParker@mydomain.com', 'en','1102'), (1103, 'clarkkent', 'Clark Kent', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'ClarkKent@mydomain.com', 'fr','1103'), (1104, 'tonystark', 'Tony Stark', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'TonyStark@mydomain.com', 'es','1104'), (1105, 'maxeisenhardt', 'Max Eisenhardt', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt','1105'), @@ -181,6 +185,7 @@ INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0), (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1), (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0), + (6, 'Warehouse six', 'vnh', 1, 1, 1, 1, 0, 0, 1, 1, 0, 0), (13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 1, 0, 0, 0), (60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0); @@ -301,6 +306,17 @@ UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 8; UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 4 WHERE `id` = 23; UPDATE `vn`.`agencyMode` SET `deliveryMethodFk` = 1 WHERE `id` = 10; +UPDATE `vn`.`agencyMode` SET `description` = 'inhouse pickup' WHERE `id` = 1; +UPDATE `vn`.`agencyMode` SET `description` = 'Super-Man delivery' WHERE `id` = 2; +UPDATE `vn`.`agencyMode` SET `description` = 'Teleportation device' WHERE `id` = 3; +UPDATE `vn`.`agencyMode` SET `description` = 'Entanglement' WHERE `id` = 4; +UPDATE `vn`.`agencyMode` SET `description` = 'Quantum break device' WHERE `id` = 5; +UPDATE `vn`.`agencyMode` SET `description` = 'Walking' WHERE `id` = 6; +UPDATE `vn`.`agencyMode` SET `description` = 'Gotham247' WHERE `id` = 7; +UPDATE `vn`.`agencyMode` SET `description` = 'Gotham247Expensive' WHERE `id` = 8; +UPDATE `vn`.`agencyMode` SET `description` = 'Other agency' WHERE `id` = 10; +UPDATE `vn`.`agencyMode` SET `description` = 'Refund' WHERE `id` = 23; + UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com'; UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23; @@ -320,21 +336,21 @@ INSERT INTO `vn`.`payDem`(`id`, `payDem`) (2, 20), (7, 0); -INSERT INTO `vn`.`autonomy`(`id`, `name`, `countryFk`) +INSERT INTO `vn`.`autonomy`(`id`, `name`, `countryFk`, `hasDailyInvoice`) VALUES - (1, 'Autonomy one', 1), - (2, 'Autonomy two', 1), - (3, 'Autonomy three', 2), - (4, 'Autonomy four', 13); + (1, 'Autonomy one', 1, 1), + (2, 'Autonomy two', 1, 0), + (3, 'Autonomy three', 2, 0), + (4, 'Autonomy four', 13, 0); INSERT INTO `vn`.`province`(`id`, `name`, `countryFk`, `autonomyFk`, `warehouseFk`) VALUES - (1, 'Province one', 1, 1, NULL), - (2, 'Province two', 1, 1, NULL), - (3, 'Province three', 30, 2, NULL), - (4, 'Province four', 2, 3, NULL), - (5, 'Province five', 13, 4, NULL); + (1, 'Province one', 1, 1, NULL), + (2, 'Province two', 1, 1, NULL), + (3, 'Province three', 30, 2, NULL), + (4, 'Province four', 2, 3, NULL), + (5, 'Province five', 13, 4, NULL); INSERT INTO `vn`.`town`(`id`, `name`, `provinceFk`) VALUES @@ -350,6 +366,7 @@ INSERT INTO `vn`.`postCode`(`code`, `townFk`, `geoFk`) ('46460', 2, 6), ('46680', 3, 6), ('46600', 4, 7), + ('46600',1, 6), ('EC170150', 5, 8); INSERT INTO `vn`.`clientType`(`code`, `type`) @@ -382,7 +399,7 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city (1107, 'Hank Pym', '09854837G', 'ANT MAN', 'Hawk', 'ANTHILL, SAN FRANCISCO, CALIFORNIA', 'Gotham', 46460, 1111111111, 222222222, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 19, 0, 'florist','normal'), (1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 19, 0, 'florist','normal'), (1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, 9, 0, 'florist','normal'), - (1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 0, 0, NULL, 0, 0, NULL, 0, 'florist','normal'), + (1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, NULL, 1, 'florist','normal'), (1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'), (1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'); @@ -398,7 +415,7 @@ INSERT INTO `vn`.`clientManaCache`(`clientFk`, `mana`, `dated`) (1103, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), (1104, -30, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)); -INSERT INTO `vn`.`mandateType`(`id`, `name`) +INSERT INTO `vn`.`mandateType`(`id`, `code`) VALUES (1, 'B2B'), (2, 'CORE'), @@ -528,7 +545,9 @@ INSERT INTO `vn`.`observationType`(`id`,`description`, `code`) (5, 'Administrative', 'administrative'), (6, 'Weight', 'weight'), (7, 'InvoiceOut', 'invoiceOut'), - (8, 'DropOff', 'dropOff'); + (8, 'DropOff', 'dropOff'), + (9, 'Sustitución', 'substitution'), + (10, 'Finance', 'finance'); INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`description`) VALUES @@ -567,6 +586,7 @@ INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif` VALUES (1, 'PLANTS SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_CURDATE(), 1, 'supplier address 1', 'GOTHAM', 1, 46000, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), (2, 'FARMER KING', 'The farmer', 4000020002, 1, '87945234L', 0, util.VN_CURDATE(), 1, 'supplier address 2', 'GOTHAM', 2, 46000, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), + (4, 'INVENTARIO', 'INVENTARIO', 4000000004, NULL, NULL, 0, util.VN_CURDATE(), 1, NULL, NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL, NULL), (69, 'PACKAGING', 'Packaging nick', 4100000069, 1, '94935005K', 0, util.VN_CURDATE(), 1, 'supplier address 5', 'ASGARD', 3, 46600, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), (442, 'VERDNATURA LEVANTE SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE(), 1, 'supplier address 3', 'GOTHAM', 1, 46000, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'), (567, 'HOLLAND', 'Holland nick', 4000020567, 1, '14364089Z', 0, util.VN_CURDATE(), 1, 'supplier address 6', 'ASGARD', 3, 46600, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), @@ -617,7 +637,7 @@ INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaF ('A', 'Global nacional', 1, 'NATIONAL', 0, 'global'), ('T', 'Española rapida', 1, 'NATIONAL', 0, 'quick'), ('V', 'Intracomunitaria global', 0, 'CEE', 1, 'global'), - ('M', 'Múltiple nacional', 1, 'NATIONAL', 0, 'quick'), + ('M', 'Múltiple nacional', 1, 'NATIONAL', 0, 'multiple'), ('R', 'Rectificativa', 1, 'NATIONAL', 0, NULL), ('E', 'Exportación rápida', 0, 'WORLD', 0, 'quick'); @@ -728,41 +748,46 @@ INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agen (6, NULL, 57, util.VN_CURDATE(), 5, 7, 'sixth route', 1.7, 60, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 3), (7, NULL, 57, util.VN_CURDATE(), 6, 8, 'seventh route', 0, 70, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 5); -INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`, `cmrFk`) +INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`, `cmrFk`, `problem`, `risk`) VALUES - (1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1), - (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2), - (3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 3), - (4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, NULL), - (5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, NULL), - (6 , 1, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, NULL), - (7 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (10, 1, 1, 5, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (12, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (13, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE(), NULL, NULL), - (15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (16, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (17, 1, 7, 2, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +12 HOUR), NULL, NULL), - (19, 1, 5, 5, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, util.VN_CURDATE(), NULL, NULL), - (20, 1, 5, 5, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL), - (21, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL), - (22, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL), - (23, NULL, 8, 1, 7, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL, NULL), - (24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL, NULL), - (25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (26 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (28, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (33, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL); + (1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'hasHighRisk', 901.4), + (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2, 'hasHighRisk', 901.4), + (3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 3, NULL, NULL), + (4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, NULL, NULL, NULL), + (5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, NULL, NULL, NULL), + (6 , 1, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, NULL, 'hasHighRisk', 901.4), + (7 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (10, 1, 1, 5, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'isTooLittle', NULL), + (11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasTicketRequest', NULL), + (12, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (13, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, 'isFreezed', NULL), + (16, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, 388.7), + (17, 1, 7, 2, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, 388.7), + (18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +12 HOUR), NULL, NULL, 'isFreezed', NULL), + (19, 1, 5, 5, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, util.VN_CURDATE(), NULL, NULL, 'isTaxDataChecked', NULL), + (20, 1, 5, 5, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL, 'isTaxDataChecked', NULL), + (21, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL, 'isTaxDataChecked', NULL), + (22, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL, 'isTaxDataChecked', NULL), + (23, NULL, 8, 1, 7, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasTicketRequest, hasHighRisk', 901.4), + (24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (26 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, 901.4), + (28, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (33, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (34, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1103, 'BEJAR', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL); + INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`) VALUES (1, 11, 1, 'ready'), @@ -799,16 +824,19 @@ INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `userFk`, `created`) (12, 3, 19, util.VN_NOW()), (13, 3, 19, util.VN_NOW()), (14, 3, 19, util.VN_NOW()), - (15, 2, 19, util.VN_NOW()), + (15, 10, 19, util.VN_NOW()), (16, 3, 19, util.VN_NOW()), (17, 2, 19, util.VN_NOW()), - (18, 2, 19, util.VN_NOW()), + (37, 10, 19, util.VN_NOW()), (19, 2, 19, util.VN_NOW()), (20, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)), (21, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)), (22, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)), (23, 16, 21, util.VN_NOW()), - (24, 16, 21, util.VN_NOW()); + (24, 16, 21, util.VN_NOW()), + (34, 14, 49, util.VN_NOW()), + (35, 14, 18, util.VN_NOW()), + (36, 14, 18, util.VN_NOW()); INSERT INTO `vn`.`deliveryPoint` (`id`, `name`, `ubication`) VALUES @@ -831,9 +859,9 @@ INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`, INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`) VALUES (1, 'Diff', 'diff'), - (2, 'Recover', 'recover'), + (2, 'Recovery', 'recovery'), (3, 'Mana', 'mana'), - (4, 'Reclaim', 'reclaim'), + (4, 'Claim', 'claim'), (5, 'Heritage', 'heritage'), (6, 'Miscellaneous', 'miscellaneous'), (7, 'Freight Pickup', 'freightPickUp'); @@ -970,6 +998,14 @@ INSERT INTO `vn`.`priceFixed`(`id`, `itemFk`, `rate0`, `rate1`, `rate2`, `rate3` (2, 3, 10, 10, 10, 10, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 0, 1, util.VN_CURDATE()), (3, 13, 8.5, 10, 7.5, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 1, 2, util.VN_CURDATE()); +INSERT INTO `vn`.`itemMinimumQuantity`(`itemFk`, `quantity`, `started`, `ended`, `warehouseFk`) + VALUES + (1, 5, util.VN_CURDATE() - INTERVAL 2 MONTH, util.VN_CURDATE() + INTERVAL 1 MONTH, 1), + (2, 10, util.VN_CURDATE() - INTERVAL 2 DAY, util.VN_CURDATE() - INTERVAL 1 DAY, 2), + (3, 15, util.VN_CURDATE() + INTERVAL 3 DAY, util.VN_CURDATE() + INTERVAL 2 WEEK, 3), + (2, 10, util.VN_CURDATE() + INTERVAL 2 MONTH, NULL, 5), + (4, 8, util.VN_CURDATE() - INTERVAL 3 MONTH, NULL, NULL); + INSERT INTO `vn`.`expeditionBoxVol`(`boxFk`, `m3`, `ratio`) VALUES (71,0.141,1); @@ -998,19 +1034,20 @@ INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`) INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `freightItemFk`, `created`, `counter`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`, `hostFk`) VALUES - (1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, 'UR9000006041', 94, 1, 'pc1'), - (2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 18, 'UR9000006041', 94, 1, NULL), - (3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 18, 'UR9000006041', 94, 2, NULL), - (4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 18, 'UR9000006041', 94, 2, NULL), - (5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, NULL, 94, 3, NULL), - (6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 18, NULL, 94, 3, NULL), - (7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 1, 18, NULL, 94, NULL,NULL), - (8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 1, 18, NULL, 94, 1, NULL), - (9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, NULL, 94, 2, NULL), - (10, 7, 7, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL), - (11, 7, 8, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL), - (12, 7, 9, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL), - (13, 1, 10,71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL); + (1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, 'UR9000006041', 94, 1, 'pc1'), + (2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 18, 'UR9000006041', 94, 1, NULL), + (3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 18, 'UR9000006041', 94, 2, NULL), + (4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 18, 'UR9000006041', 94, 2, NULL), + (5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, NULL, 94, 3, NULL), + (6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 18, NULL, 94, 3, NULL), + (7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 1, 18, NULL, 94, NULL,NULL), + (8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 1, 18, NULL, 94, 1, NULL), + (9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, NULL, 94, 2, NULL), + (10, 7, 7, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL), + (11, 7, 8, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL), + (12, 7, 9, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL), + (13, 1, 10, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL), + (14, 1, 37, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL); INSERT INTO `vn`.`expeditionState`(`id`, `created`, `expeditionFk`, `typeFk`, `userFk`) @@ -1028,47 +1065,50 @@ INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`, (2, 2, 2, 1, util.VN_CURDATE(), NULL), (3, 3, 2, 4, util.VN_CURDATE(), NULL); -INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `price`, `discount`, `reserved`, `isPicked`, `created`) +INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `price`, `discount`, `reserved`, `isPicked`, `created`, `problem`) VALUES - (1, 1, 1, 'Ranged weapon longbow 200cm', 5, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (2, 2, 1, 'Melee weapon combat fist 15cm', 10, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (3, 1, 1, 'Ranged weapon longbow 200cm', 2, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (4, 4, 1, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (5, 1, 2, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (6, 1, 3, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)), - (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.74, 0, 0, 0, util.VN_CURDATE()), - (8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE()), - (9, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()), - (10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, util.VN_CURDATE()), - (11, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()), - (12, 4, 16, 'Melee weapon heavy shield 100cm', 20, 1.71, 0, 0, 0, util.VN_CURDATE()), - (13, 2, 8, 'Melee weapon combat fist 15cm', 10, 7.08, 0, 0, 0, util.VN_CURDATE()), - (14, 1, 8, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE()), - (15, 1, 19, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()), - (16, 2, 20, 'Melee weapon combat fist 15cm', 20, 7.07, 0, 0, 0, util.VN_CURDATE()), - (17, 2, 22, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), - (18, 4, 22, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), - (19, 1, 4, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)), - (20, 1, 5, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)), - (21, 1, 6, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (22, 1, 7, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), - (23, 1, 9, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), - (24, 1, 10, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), - (25, 4, 12, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (26, 4, 13, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (27, 4, 14, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (28, 4, 15, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (29, 4, 17, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (30, 4, 18, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, util.VN_CURDATE()), - (32, 1, 24, 'Ranged weapon longbow 200cm', -1, 8.07, 0, 0, 0, util.VN_CURDATE()), - (33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, util.VN_CURDATE()), - (34, 4, 28, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (35, 4, 29, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), - (39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE()); + (1, 1, 1, 'Ranged weapon longbow 200cm', 5, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), + (2, 2, 1, 'Melee weapon combat fist 15cm', 10, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), + (3, 1, 1, 'Ranged weapon longbow 200cm', 2, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), + (4, 4, 1, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), + (5, 1, 2, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), + (6, 1, 3, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 'hasComponentLack'), + (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.74, 0, 0, 0, util.VN_CURDATE(), NULL), + (8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE(), NULL), + (9, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL), + (10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, util.VN_CURDATE(), NULL), + (11, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL), + (12, 4, 16, 'Melee weapon heavy shield 100cm', 20, 1.71, 0, 0, 0, util.VN_CURDATE(), NULL), + (13, 2, 8, 'Melee weapon combat fist 15cm', 10, 7.08, 0, 0, 0, util.VN_CURDATE(), NULL), + (14, 1, 8, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL), + (15, 1, 19, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL), + (16, 2, 20, 'Melee weapon combat fist 15cm', 20, 7.07, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (17, 2, 22, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 'hasComponentLack'), + (18, 4, 22, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 'hasComponentLack'), + (19, 1, 4, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 'hasComponentLack'), + (20, 1, 5, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 'hasComponentLack'), + (21, 1, 6, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), + (22, 1, 7, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (23, 1, 9, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (24, 1, 10, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (25, 4, 12, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (26, 4, 13, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (27, 4, 14, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (28, 4, 15, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (29, 4, 17, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (30, 4, 18, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, util.VN_CURDATE(), NULL), + (32, 1, 24, 'Ranged weapon longbow 200cm', -1, 8.07, 0, 0, 0, util.VN_CURDATE(), NULL), + (33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, util.VN_CURDATE(), NULL), + (34, 4, 28, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (35, 4, 29, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), NULL), + (36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 'hasComponentLack'), + (39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (40, 2, 34, 'Melee weapon combat fist 15cm', 10.00, 3.91, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (41, 2, 35, 'Melee weapon combat fist 15cm', 8.00, 3.01, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (42, 2, 36, 'Melee weapon combat fist 15cm', 6.00, 2.50, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'); INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) VALUES @@ -1205,11 +1245,11 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) (32, 36, -92.324), (32, 39, 0.994); -INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `visible`, `grouping`, `packing`, `userFk`) +INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `visible`, `grouping`, `packing`,`buyFk`, `userFk`) VALUES - (2, 'GVC', 1, 1, 1, 1106), - (4, 'HEJ', 1, 1, 1, 1106), - (1, 'UXN', 2, 12, 12, 1106); + (2, 'GVC', 1, 1, 1, 2,1106), + (4, 'HEJ', 1, 1, 1, NULL,1106), + (1, 'UXN', 2, 12, 12, NULL,1106); INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`) VALUES @@ -1247,14 +1287,20 @@ INSERT INTO `vn`.`operator` (`workerFk`, `numberOfWagons`, `trainFk`, `itemPacki INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`, `created`, `trainFk`) VALUES (1, 1106, 5, DATE_ADD(util.VN_CURDATE(),INTERVAL +1 DAY), 1), - (2, 1106, 14, util.VN_CURDATE(), 1); + (2, 1106, 14, util.VN_CURDATE(), 1), + (4, 49, 5, util.VN_CURDATE(), 1), + (5, 18, 5, util.VN_CURDATE(), 1), + (6, 18, 5, util.VN_CURDATE(), 1); INSERT INTO `vn`.`ticketCollection`(`ticketFk`, `collectionFk`, `level`) VALUES (1, 1, 1), (2, 1, NULL), (3, 2, NULL), - (23, 1, NULL); + (23, 1, NULL), + (34, 4, 1), + (35, 5, 1), + (8, 6, 1); INSERT INTO `vn`.`genus`(`id`, `name`) VALUES @@ -1436,7 +1482,8 @@ INSERT INTO `vn`.`ticketWeekly`(`ticketFk`, `weekDay`) (2, 1), (3, 2), (5, 6), - (15, 6); + (15, 6), + (17, 6); INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk) VALUES @@ -1452,15 +1499,17 @@ INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk (10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1); INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseOutFk`, `agencyModeFk`, `m3`, `kg`,`ref`, `totalEntries`, `cargoSupplierFk`, `awbFK`) - VALUES - (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1), - (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150, 2000, 'second travel', 2, 2, 2), - (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3), - (4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4), - (5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5), - (6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6), - (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7), - (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10); + VALUES (1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 2, 1, 100.00, 1000, 'first travel', 1, 1, 1), + (2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 2, 1, 150.00, 2000, 'second travel', 2, 2, 2), + (3, util.VN_CURDATE(), util.VN_CURDATE(), 1, 2, 1, 0.00, 0.00, 'third travel', 1, 1, 3), + (4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 3, 1, 50.00, 500, 'fourth travel', 0, 2, 4), + (5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5), + (6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6), + (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7), + (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10), + (10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10), + (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4), + (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4); INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`) VALUES @@ -1471,27 +1520,33 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed (5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 0, 'observation five'), (6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 0, 'observation six'), (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 0, 'observation seven'), - (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, ''); + (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, ''), + (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''), + (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, 1, ''), + (99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 0, 0, ''); -INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWaste`, `rate`) +INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`) + VALUES (2, 4, 1); + +INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWasteQuantity`, `saleExternalWaste`, `saleFaultWaste`, `saleContainerWaste`, `saleBreakWaste`, `saleOtherWaste`) VALUES - ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation', 1, 1, '1062', '51', '4.8'), - ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Colombia', 2, 1, '35074', '687', '2.0'), - ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Mini', 3, 1, '1777', '13', '0.7'), - ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Short', 4, 1, '3182', '59', '0.6'), - ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Crisantemo', 5, 1, '1747', '13', '0.7'), - ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Lilium Oriental', 6, 1, '7182', '59', '0.6'), - ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Alstroemeria', 7, 1, '1777', '13', '0.7'), - ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 1, 1, '4181', '59', '0.6'), - ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 2, 1, '7268', '59', '0.6'), - ('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Containers', 2, 1, '-74', '0', '0.0'), - ('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Packagings', 3, 1, '-7', '0', '0.0'), - ('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Freight', 4, 1, '1100', '0', '0.0'), - ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Funeral Accessories', 5, 1, '848', '-187', '-22.1'), - ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Miscellaneous Accessories', 6, 1, '186', '0', '0.0'), - ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Adhesives', 7, 1, '277', '0', '0.0'); + ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 1, 1, '1062', '51', '56.20', '56.20', '56.20', '56.20', '56.20'), + ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 2, 1, '35074', '687', '53.12', '89.69', '56.20', '56.20', '56.20'), + ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 3, 1, '1777', '13', '12.02', '53.12', '56.20', '56.20', '56.20'), + ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 4, 1, '3182', '59', '51', '56.20', '56.20', '56.20', '56.20'), + ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 5, 1, '1747', '13', '53.12', '53.12', '56.20', '56.20', '56.20'), + ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '7182', '59', '51', '53.12', '56.20', '56.20', '56.20'), + ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '1777', '13', '89.69', '89.69', '56.20', '56.20', '56.20'), + ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 8, 1, '4181', '59', '53.12', '53.12', '56.20', '56.20', '56.20'), + ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 9, 1, '7268', '59', '12.02', '56.20', '56.20', '56.20', '56.20'), + ('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 2, 1, '-74', '0', '51', '89.69', '56.20', '56.20', '56.20'), + ('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 3, 1, '-7', '0', '12.02', '53.12', '56.20', '56.20', '56.20'), + ('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 4, 1, '1100', '0', '51', '56.20', '56.20', '56.20', '56.20'), + ('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 5, 1, '848', '-187', '12.02', '89.69', '56.20', '56.20', '56.20'), + ('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '186', '0', '51', '53.12', '56.20', '56.20', '56.20'), + ('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '277', '0', '53.12', '56.20', '56.20', '56.20', '56.20'); -INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`) + INSERT INTO vn.buy(id,entryFk,itemFk,buyingValue,quantity,packagingFk,stickers,freightValue,packageValue,comissionValue,packing,grouping,groupingMode,location,price1,price2,price3,printedStickers,isChecked,isIgnored,weight,created) VALUES (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), @@ -1507,7 +1562,8 @@ INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagi (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()); + (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()), + (16, 99,1,50.0000, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.60, 99.40, 0, 1, 0, 1.00, '2024-07-30 08:13:51.000'); 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 @@ -1868,9 +1924,9 @@ INSERT INTO `vn`.`claimEnd`(`id`, `saleFk`, `claimFk`, `workerFk`, `claimDestina (1, 31, 4, 21, 2), (2, 32, 3, 21, 3); -INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`) +INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`, `monthsToRefund`, `minShipped`) VALUES - (1, 50); + (1, 5, 4, '2016-10-01'); INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`) VALUES @@ -1925,7 +1981,7 @@ INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`) (21, 21), (22, 22); -INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`) +INSERT INTO `vn`.`userMultiConfig` (`userFk`, `warehouseFk`, `companyFk`) VALUES (1, 1, 69), (5, 1, 442), @@ -2388,30 +2444,32 @@ INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`, ` (1107, CONCAT(util.VN_CURDATE(), ' 10:20'), TRUE, 'middle', 1), (1107, CONCAT(util.VN_CURDATE(), ' 14:50'), TRUE, 'out', 1); -INSERT INTO `vn`.`dmsType`(`id`, `name`, `readRoleFk`, `writeRoleFk`, `code`) +INSERT INTO `vn`.`dmsType` + (`id`, `name`, `readRoleFk`, `writeRoleFk`, `code`) VALUES - (1, 'Facturas Recibidas', NULL, NULL, 'invoiceIn'), - (2, 'Doc oficial', NULL, NULL, 'officialDoc'), - (3, 'Laboral', 37, 37, 'hhrrData'), - (4, 'Albaranes recibidos', NULL, NULL, 'deliveryNote'), - (5, 'Otros', 1, 1, 'miscellaneous'), - (6, 'Pruebas', NULL, NULL, 'tests'), - (7, 'IAE Clientes', 1, 1, 'economicActivitiesTax'), - (8, 'Fiscal', NULL, NULL, 'fiscal'), - (9, 'Vehiculos', NULL, NULL, 'vehicles'), - (10, 'Plantillas', NULL, NULL, 'templates'), - (11, 'Contratos', NULL, NULL, 'contracts'), - (12, 'ley de pagos', 1, 1, 'paymentsLaw'), - (13, 'Basura', 1, 1, 'trash'), - (14, 'Ticket', 1, 1, 'ticket'), - (15, 'Presupuestos', NULL, NULL, 'budgets'), - (16, 'Logistica', NULL, NULL, 'logistics'), - (17, 'cmr', 1, 1, 'cmr'), - (18, 'dua', NULL, NULL, 'dua'), - (19, 'inmovilizado', NULL, NULL, 'fixedAssets'), - (20, 'Reclamación', 1, 1, 'claim'), - (21, 'Entrada', 1, 1, 'entry'), - (22, 'Proveedor', 1, 1, 'supplier'); + (1, 'Facturas Recibidas', NULL, NULL, 'invoiceIn'), + (2, 'Doc oficial', NULL, NULL, 'officialDoc'), + (3, 'Laboral', 37, 37, 'hhrrData'), + (4, 'Albaranes recibidos', NULL, NULL, 'deliveryNote'), + (5, 'Otros', 1, 1, 'miscellaneous'), + (6, 'Pruebas', NULL, NULL, 'tests'), + (7, 'IAE Clientes', 1, 1, 'economicActivitiesTax'), + (8, 'Fiscal', NULL, NULL, 'fiscal'), + (9, 'Vehiculos', NULL, NULL, 'vehicles'), + (10, 'Plantillas', NULL, NULL, 'templates'), + (11, 'Contratos', NULL, NULL, 'contracts'), + (12, 'ley de pagos', 1, 1, 'paymentsLaw'), + (13, 'Basura', 1, 1, 'trash'), + (14, 'Ticket', 1, 1, 'ticket'), + (15, 'Presupuestos', NULL, NULL, 'budgets'), + (16, 'Logistica', NULL, NULL, 'logistics'), + (17, 'cmr', 1, 1, 'cmr'), + (18, 'dua', NULL, NULL, 'dua'), + (19, 'inmovilizado', NULL, NULL, 'fixedAssets'), + (20, 'Reclamación', 1, 1, 'claim'), + (21, 'Entrada', 1, 1, 'entry'), + (22, 'Proveedor', 1, 1, 'supplier'), + (23, 'Termografos', 35, 35, 'thermograph'); INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`) VALUES @@ -2419,7 +2477,7 @@ INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `wa (2, 5, '2.txt', 'text/plain', 5, 1, 442, 1, TRUE, 'Client:104', 'Client:104 dms for the client', util.VN_CURDATE()), (3, 5, '3.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Client: 104', 'Client:104 readme', util.VN_CURDATE()), (4, 3, '4.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Worker: 106', 'Worker:106 readme', util.VN_CURDATE()), - (5, 5, '5.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'travel: 1', 'dmsForThermograph', util.VN_CURDATE()), + (5, 23, '5.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'travel: 1', 'dmsForThermograph', util.VN_CURDATE()), (6, 5, '6.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'NotExists', 'DoesNotExists', util.VN_CURDATE()), (7, 20, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()), (8, 20, '8.mp4', 'video/mp4', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()), @@ -2440,7 +2498,7 @@ INSERT INTO `vn`.`clientDms`(`clientFk`, `dmsFk`) (1104, 2), (1104, 3); -INSERT INTO `vn`.`workerDocument`(`id`, `worker`, `document`,`isReadableByWorker`) +INSERT INTO `vn`.`workerDms`(`id`, `workerFk`, `dmsFk`,`isReadableByWorker`) VALUES (1, 1106, 4, TRUE), (2, 1107, 3, FALSE); @@ -2469,14 +2527,15 @@ INSERT INTO `vn`.`thermograph`(`id`, `model`) ('138350-0', 'DISPOSABLE'); -INSERT INTO `vn`.`travelThermograph`(`thermographFk`, `created`, `warehouseFk`, `travelFk`, `temperatureFk`, `result`, `dmsFk`) +INSERT INTO `vn`.`travelThermograph` + (`thermographFk`, `created`, `warehouseFk`, `travelFk`, `temperatureFk`, `minTemperature`, `maxTemperature`, `result`, `dmsFk`) VALUES - ('TMM190901395', util.VN_CURDATE(), 1, 1, 'WARM', 'Ok', NULL), - ('TL.BBA85422', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2, 'COOL', 'Ok', NULL), - ('TL.BBA85422', util.VN_CURDATE(), 2, 1, 'COOL', 'can not read the temperature', NULL), - ('TZ1905012010', util.VN_CURDATE(), 1, 1, 'WARM', 'Temperature in range', 5), - ('138350-0', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', NULL, 5), - ('138350-0', util.VN_CURDATE(), 1, NULL, 'COOL', NULL, NULL); + ('TMM190901395', util.VN_CURDATE(), 1, 1, 'WARM', NULL, NULL, 'Ok', NULL), + ('TL.BBA85422', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2, 'COOL', NULL, NULL, 'Ok', NULL), + ('TL.BBA85422', util.VN_CURDATE(), 2, 1, 'COOL', NULL, NULL, 'can not read the temperature', NULL), + ('TZ1905012010', util.VN_CURDATE(), 1, 1, 'WARM', NULL, NULL, 'Temperature in range', 5), + ('138350-0', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', 2, 12, NULL, 5), + ('138350-0', util.VN_CURDATE(), 1, NULL, 'COOL', NULL, NULL, NULL, NULL); REPLACE INTO `vn`.`incoterms`(`code`, `name`) VALUES @@ -2525,18 +2584,18 @@ INSERT INTO `vn`.`rate`(`dated`, `warehouseFk`, `rate0`, `rate1`, `rate2`, `rate (DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), 1, 10, 15, 20, 25), (util.VN_CURDATE(), 1, 12, 17, 22, 27); -INSERT INTO `vn`.`dua` (id, code, awbFk__, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk) +INSERT INTO `vn`.`dua` (id, code, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk) VALUES - (1, '19ES0028013A481523', 1, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 11276.95, 442), - (2, '21ES00280136115760', 2, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1376.20, 442), - (3, '19ES00280131956004', 3, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 3, 14268.50, 442), - (4, '19ES00280131955995', 4, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 8242.50, 442), - (5, '19ES00280132022070', 5, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 10012.49, 442), - (6, '19ES00280132032308', 6, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 19914.25, 442), - (7, '19ES00280132025489', 7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1934.06, 442), - (8, '19ES00280132025490', 8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 3618.52, 442), - (9, '19ES00280132025491', 9, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 7126.23, 442), - (10, '19ES00280132025492', 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 4631.45, 442); + (1, '19ES0028013A481523', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 11276.95, 442), + (2, '21ES00280136115760', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1376.20, 442), + (3, '19ES00280131956004', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 3, 14268.50, 442), + (4, '19ES00280131955995', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 8242.50, 442), + (5, '19ES00280132022070', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 10012.49, 442), + (6, '19ES00280132032308', util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 19914.25, 442), + (7, '19ES00280132025489', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1934.06, 442), + (8, '19ES00280132025490', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 3618.52, 442), + (9, '19ES00280132025491', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 7126.23, 442), + (10, '19ES00280132025492', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 4631.45, 442); INSERT INTO `vn`.`duaEntry` (`duaFk`, `entryFk`, `value`, `customsValue`, `euroValue`) VALUES @@ -2549,18 +2608,18 @@ INSERT INTO `vn`.`duaEntry` (`duaFk`, `entryFk`, `value`, `customsValue`, `euroV (7, 7, 1.00, 1.00, 1.00), (8, 8, 1.00, 1.00, 1.00); -REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`) +REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`, `bookEntried`) 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, 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, 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, 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); + (1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1,util.VN_CURDATE()), + (2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 0, 442, 1,util.VN_CURDATE()), + (3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1,util.VN_CURDATE()), + (4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1,util.VN_CURDATE()), + (5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 0, 442, 1,util.VN_CURDATE()), + (6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1,util.VN_CURDATE()), + (7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 0, 442, 1,util.VN_CURDATE()), + (8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 0, 442, 1,util.VN_CURDATE()), + (9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1,util.VN_CURDATE()), + (10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1,util.VN_CURDATE()); INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageFarmerWithholdingFk`, `daysAgo`) VALUES @@ -2670,13 +2729,20 @@ INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`) (3, 6, 5), (4, 7, 1); +INSERT INTO `vn`.`roadmapAddress` (`addressFk`) + VALUES + (1), + (2), + (3), + (4); + INSERT INTO `vn`.`roadmap` (`id`, `name`, `tractorPlate`, `trailerPlate`, `phone`, `supplierFk`, `etd`, `observations`, `userFk`, `price`, `driverName`) VALUES - (1, 'val-algemesi', 'RE-001', 'PO-001', '111111111', 1, util.VN_NOW(), 'this is test observation', 1, 15, 'Batman'), - (2, 'alg-valencia', 'RE-002', 'PO-002', '111111111', 1, util.VN_NOW(), 'test observation', 1, 20, 'Robin'), - (3, 'alz-algemesi', 'RE-003', 'PO-003', '222222222', 2, DATE_ADD(util.VN_NOW(), INTERVAL 2 DAY), 'observations...', 2, 25, 'Driverman'); + (1, 'val-algemesi', '1234-BCD', '9876-BCD', '111111111', 1, util.VN_NOW(), 'this is test observation', 1, 15, 'Batman'), + (2, 'alg-valencia', '2345-CDF', '8765-BCD', '111111111', 1, util.VN_NOW(), 'test observation', 1, 20, 'Robin'), + (3, 'alz-algemesi', '3456-DFG', '7654-BCD', '222222222', 2, DATE_ADD(util.VN_NOW(), INTERVAL 2 DAY), 'observations...', 2, 25, 'Driverman'); -INSERT INTO `vn`.`expeditionTruck` (`id`, `roadmapFk`, `warehouseFk`, `eta`, `description`, `userFk`) +INSERT INTO `vn`.`roadmapStop` (`id`, `roadmapFk`, `addressFk`, `eta`, `description`, `userFk`) VALUES (1, 1, 1, DATE_ADD(util.VN_NOW(), INTERVAL 1 DAY), 'Best truck in fleet', 1), (2, 1, 2, DATE_ADD(util.VN_NOW(), INTERVAL '1 2' DAY_HOUR), 'Second truck in fleet', 1), @@ -2844,7 +2910,8 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`) (5, 'modified-entry', 'An entry has been modified'), (6, 'book-entry-deleted', 'accounting entries deleted'), (7, 'zone-included','An email to notify zoneCollisions'), - (8, 'backup-printer-selected','A backup printer has been selected'); + (8, 'backup-printer-selected','A backup printer has been selected'), + (9, 'mrw-deadline','The MRW deadline has passed'); TRUNCATE `util`.`notificationAcl`; INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) @@ -2857,7 +2924,8 @@ INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) (5, 9), (6, 9), (7, 9), - (8, 66); + (8, 66), + (9, 56); TRUNCATE `util`.`notificationQueue`; INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`) @@ -3000,9 +3068,6 @@ INSERT INTO `vn`.`workerTimeControlMail` (`id`, `workerFk`, `year`, `week`, `sta (3, 9, 2000, 51, 'CONFIRMED', util.VN_NOW(), 1, NULL), (4, 9, 2001, 1, 'SENDED', util.VN_NOW(), 1, NULL); -INSERT INTO `vn`.`wagonConfig` (`id`, `width`, `height`, `maxWagonHeight`, `minHeightBetweenTrays`, `maxTrays`) - VALUES - (1, 1350, 1900, 200, 50, 6); INSERT INTO `vn`.`wagonTypeColor` (`id`, `name`, `rgb`) VALUES @@ -3011,15 +3076,19 @@ INSERT INTO `vn`.`wagonTypeColor` (`id`, `name`, `rgb`) (3, 'green', '#00ff00'), (4, 'blue', '#0000ff'); +INSERT INTO `vn`.`wagonConfig` (`id`, `width`, `height`, `maxWagonHeight`, `minHeightBetweenTrays`, `maxTrays`, `defaultTrayColorFk`) + VALUES + (1, 1350, 1900, 200, 50, 6, 1); + INSERT INTO `vn`.`wagonType` (`id`, `name`, `divisible`) VALUES (1, 'Wagon Type #1', 1); -INSERT INTO `vn`.`wagonTypeTray` (`id`, `typeFk`, `height`, `colorFk`) +INSERT INTO `vn`.`wagonTypeTray` (`id`, `wagonTypeFk`, `height`, `wagonTypeColorFk`) VALUES - (1, 1, 100, 1), + (1, 1, 0, 1), (2, 1, 50, 2), - (3, 1, 0, 3); + (3, 1, 100, 3); INSERT INTO `salix`.`accessTokenConfig` (`id`, `renewPeriod`, `courtesyTime`, `renewInterval`) VALUES @@ -3102,6 +3171,18 @@ INSERT INTO `vn`.`entryDms`(`entryFk`, `dmsFk`, `editorFk`) VALUES (1, 9, 9); +INSERT INTO vn.entryType (code,description,isInformal) + VALUES ('devaluation','Devaluation',0), + ('internal','Internal',1), + ('inventory','Inventory',1), + ('life','Life',1), + ('packaging','Packaging',0), + ('payment','Refund',0), + ('product','Product',0), + ('regularization','Regularization',1), + ('return','Return',0), + ('transport','Delivery',0); + INSERT INTO `vn`.`cmr` (id,truckPlate,observations,senderInstruccions,paymentInstruccions,specialAgreements,companyFk,addressToFk,addressFromFk,supplierFk,packagesList,merchandiseDetail,state) VALUES (1,'123456A','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet',442,1,2,1,'Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet'), (2,'123456N','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet',69,3,4,2,'Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet'), @@ -3111,7 +3192,7 @@ UPDATE vn.department SET workerFk = null; INSERT INTO vn.packaging - VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0); + VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0,0,1); INSERT IGNORE INTO vn.intrastat @@ -3194,7 +3275,6 @@ INSERT IGNORE INTO vn.itemType workerFk = 103, isInventory = TRUE, life = 10, - density = 250, itemPackingTypeFk = NULL, temperatureFk = 'warm'; @@ -3705,7 +3785,8 @@ INSERT IGNORE INTO vn.saleGroup SET id = 4, userFk = 1, parkingFk = 9, - sectorFk = 9992; + sectorFk = 9992, + ticketFk = 36; INSERT IGNORE INTO vn.sectorCollectionSaleGroup SET id = 9999, @@ -3788,7 +3869,145 @@ INSERT INTO vn.workerTeam(id, team, workerFk) VALUES (8, 1, 19); -INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment) +INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment) VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL); -UPDATE vn.locker SET workerFk = 1110 WHERE id = 147; \ No newline at end of file +INSERT INTO `vn`.`locker` (code, gender, workerFk) VALUES + ('1M', 'M', 1), + ('2M', 'M', 9), + ('3M', 'M', NULL), + ('4M', 'M', NULL), + ('1F', 'F', 1110), + ('2F', 'F', NULL), + ('3F', 'F', NULL), + ('4F', 'F', NULL); + +INSERT INTO `vn`.`ledgerCompany` SET + fiscalYear = YEAR(util.VN_CURDATE()), + bookEntry = 2; + +INSERT INTO `vn`.`ledgerConfig` SET + maxTolerance = 0.01; + + +INSERT INTO vn.trainingCourse (workerFk,trainingCourseTypeFk,centerFk,started,ended,hasDiscount,hasDiploma) + VALUES + (9,2,1,'2018-06-20 00:00:00.000','2020-06-24 00:00:00.000',0,1), + (9,1,2,'2018-06-20 00:00:00.000','2020-06-24 00:00:00.000',1,0), + (9,2,2,'2018-06-20 00:00:00.000','2020-06-24 00:00:00.000',1,1); + +INSERT INTO vn.sectorCollection + SET id = 2, + userFk = 18, + sectorFk = 1; + +INSERT INTO vn.sectorCollectionSaleGroup + SET id = 8, + sectorCollectionFk = 2, + saleGroupFk = 4; + +INSERT INTO vn.saleGroup (userFk, parkingFk, sectorFk, ticketFk) + VALUES + (1, 1, 1, 37); + +INSERT INTO vn.sectorCollection + SET id = 3, + userFk = 18, + sectorFk = 1; + +INSERT INTO vn.sectorCollectionSaleGroup + SET id = 9, + sectorCollectionFk = 3, + saleGroupFk = 6; + + +INSERT INTO `vn`.`calendarHolidays` (calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) + VALUES + (1, '2001-05-08', 1, 1), + (1, '2001-05-09', 1, 1), + (1, '2001-05-10', 1, 1), + (1, '2001-05-11', 1, 1), + (1, '2001-05-14', 1, 5), + (1, '2001-05-15', 1, 5), + (1, '2001-05-16', 1, 5), + (1, '2001-05-17', 1, 5), + (1, '2001-05-18', 1, 5); + +INSERT INTO vn.medicalReview +(id, workerFk, centerFk, `date`, `time`, isFit, amount, invoice, remark) +VALUES(1, 1106, 1, '2000-01-01', '08:10', 1, 200.0, NULL, ''); +INSERT INTO vn.medicalReview +(id, workerFk, centerFk, `date`, `time`, isFit, amount, invoice, remark) +VALUES(2, 1106, 2, '2001-01-01', '09:10', 0, 10.0, NULL, NULL); +INSERT INTO vn.medicalReview +(id, workerFk, centerFk, `date`, `time`, isFit, amount, invoice, remark) +VALUES(3, 9, 2, '2000-01-01', '8:00', 1, 150.0, NULL, NULL); + +INSERT INTO vn.stockBought (workerFk, bought, reserve, dated) + VALUES(35, 1.00, 1.00, '2001-01-01'); +INSERT INTO vn.auctionConfig (id,conversionCoefficient,warehouseFk) + VALUES (1,0.6,6); + +INSERT INTO vn.payrollComponent +(id, name, isSalaryAgreed, isVariable, isException) + VALUES + (1, 'Salario1', 1, 0, 0), + (2, 'Salario2', 1, 1, 0), + (3, 'Salario3', 1, 0, 1); + + +INSERT INTO vn.workerIncome +(debit, credit, incomeTypeFk, paymentDate, workerFk, concept) + VALUES + (1000.00, 900.00, 2, '2000-01-01', 1106, NULL), + (1001.00, 800.00, 2, '2000-01-01', 1106, NULL); + + +INSERT INTO dipole.printer (id, description) +VALUES(1, ''); + +INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode, +truckName, clientFk, phone, province, agency, m3, workerCode, itemFk, quantity, longName, shelvingFk, comments) +VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, NULL, 'NCC', NULL); + +INSERT INTO vn.accountDetail +(id, value, accountDetailTypeFk, supplierAccountFk) +VALUES + (21, 'ES12345B12345678', 3, 241), + (35, 'ES12346B12345679', 3, 241); + +INSERT INTO vn.accountDetailType +(id, description, code) +VALUES + (1, 'IBAN', 'iban'), + (2, 'SWIFT', 'swift'), + (3, 'Referencia Remesas', 'remRef'), + (4, 'Referencia Transferencias', 'trnRef'), + (5, 'Referencia Nominas', 'payRef'), + (6, 'ABA', 'aba'); + +INSERT IGNORE INTO ormConfig + SET id =1, + selectLimit = 1000; + +INSERT INTO pbx.queueMultiConfig + SET id = 'ring', + strategy = 20, + timeout = 2, + retry = 0, + weight = 0, + maxLen = 0, + ringInUse = 0; + +INSERT INTO pbx.queue (description, name, config) + VALUES ('X-men', '1000', 1), + ('Avengers', '2000', 1); + +INSERT IGNORE INTO pbx.queueMember + SET queue = '1000', + extension = '1010'; + +UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA"; +UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS"; + + diff --git a/db/routines/account/triggers/mailAliasAccount_afterDelete.sql b/db/routines/account/triggers/mailAliasAccount_afterDelete.sql new file mode 100644 index 000000000..83af7169c --- /dev/null +++ b/db/routines/account/triggers/mailAliasAccount_afterDelete.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailAliasAccount_afterDelete` + AFTER DELETE ON `mailAliasAccount` + FOR EACH ROW +BEGIN + INSERT INTO userLog + SET `action` = 'delete', + `changedModel` = 'MailAliasAccount', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/account/triggers/mailAliasAccount_beforeInsert.sql b/db/routines/account/triggers/mailAliasAccount_beforeInsert.sql new file mode 100644 index 000000000..a435832f2 --- /dev/null +++ b/db/routines/account/triggers/mailAliasAccount_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailAliasAccount_beforeInsert` + BEFORE INSERT ON `mailAliasAccount` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/account/triggers/mailAliasAccount_beforeUpdate.sql b/db/routines/account/triggers/mailAliasAccount_beforeUpdate.sql new file mode 100644 index 000000000..471a34900 --- /dev/null +++ b/db/routines/account/triggers/mailAliasAccount_beforeUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailAliasAccount_beforeUpdate` + BEFORE UPDATE ON `mailAliasAccount` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/bi/procedures/claim_ratio_routine.sql b/db/routines/bi/procedures/claim_ratio_routine.sql deleted file mode 100644 index ae87e15a2..000000000 --- a/db/routines/bi/procedures/claim_ratio_routine.sql +++ /dev/null @@ -1,166 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`claim_ratio_routine`() -BEGIN - DECLARE vMonthToRefund INT DEFAULT 4; - - /* - * PAK 2015-11-20 - * Se trata de añadir a la tabla Greuges todos los - * cargos que luego vamos a utilizar para calcular el recobro - */ - - -- Reclamaciones demasiado sensibles - - INSERT INTO vn.greuge(shipped, clientFk, description, - amount, greugeTypeFk, ticketFk) - SELECT c.ticketCreated - , c.clientFk - , concat('Claim ', c.id,' : ', s.concept) - ,round( -1 * ((c.responsibility -1)/4) * s.quantity * - s.price * (100 - s.discount) / 100, 2) - , 4 - , s.ticketFk - FROM vn.sale s - JOIN vn.claimEnd ce ON ce.saleFk = s.id - JOIN vn.claim c ON c.id = ce.claimFk - WHERE ce.claimDestinationFk NOT IN (1,5) - AND NOT ce.isGreuge - AND c.claimStateFk = 3; - - -- Reclamaciones que pasan a Maná - - INSERT INTO vn.greuge(shipped, clientFk, description, - amount, greugeTypeFk, ticketFk) - SELECT c.ticketCreated - , c.clientFk - , concat('Claim_mana ',c.id,' : ', s.concept) - ,round( ((c.responsibility -1)/4) * s.quantity * s.price * (100 - s.discount) / 100, 2) - ,3 - ,s.ticketFk - FROM vn.sale s - JOIN vn.claimEnd ce ON ce.saleFk = s.id - JOIN vn.claim c ON c.id = ce.claimFk - WHERE ce.claimDestinationFk NOT IN (1,5) - AND NOT ce.isGreuge - AND c.claimStateFk = 3 - AND c.isChargedToMana; - - -- Marcamos para no repetir - UPDATE vn.claimEnd ce - JOIN vn.claim c ON c.id = ce.claimFk - SET c.isChargedToMana = TRUE - WHERE ce.claimDestinationFk NOT IN (1,5) - AND NOT ce.isGreuge - AND c.claimStateFk = 3; - - -- Recobros - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; - CREATE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (Id_Ticket)) - SELECT DISTINCT t.id Id_Ticket - FROM vn.saleComponent sc - JOIN vn.sale s ON sc.saleFk = s.id - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.ticketLastState ts ON ts.ticketFk = t.id - JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk - JOIN vn.state st ON st.id = tt.stateFk - WHERE sc.componentFk = 17 - AND sc.isGreuge = 0 - AND t.shipped >= '2016-10-01' - AND t.shipped < util.VN_CURDATE() - AND st.alertLevel >= 3; - - DELETE g.* - FROM vn.greuge g - JOIN tmp.ticket_list t ON g.ticketFk = t.Id_Ticket - WHERE g.greugeTypeFk = 2; - - INSERT INTO vn.greuge(clientFk, description, amount,shipped, - greugeTypeFk, ticketFk) - SELECT t.clientFk - ,concat('recobro ', s.ticketFk), - round(SUM(sc.value*s.quantity),2) - AS dif, - date(t.shipped) - , 2 - ,tt.Id_Ticket - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.id - JOIN vn.saleComponent sc - ON sc.saleFk = s.id AND sc.componentFk = 17 - GROUP BY t.id - HAVING ABS(dif) > 1; - - UPDATE vn.saleComponent sc - JOIN vn.sale s ON s.id = sc.saleFk - JOIN tmp.ticket_list tt ON tt.Id_Ticket = s.ticketFk - SET sc.isGreuge = 1 - WHERE sc.componentFk = 17; - - /* - * Recalculamos la ratio de las reclamaciones, que luego - * se va a utilizar en el recobro - */ - - REPLACE bi.claims_ratio(Id_Cliente, Consumo, Reclamaciones, Ratio, recobro) - SELECT id, 0,0,0,0 - FROM vn.client; - - REPLACE bi.claims_ratio(Id_Cliente, Consumo, Reclamaciones, Ratio, recobro) - SELECT fm.Id_Cliente, 12 * fm.Consumo, Reclamaciones, - round(Reclamaciones / (12*fm.Consumo),4), 0 - FROM bi.facturacion_media_anual fm - LEFT JOIN( - SELECT c.clientFk, round(sum(-1 * ((c.responsibility -1)/4) * - s.quantity * s.price * (100 - s.discount) / 100)) - AS Reclamaciones - FROM vn.sale s - JOIN vn.claimEnd ce ON ce.saleFk = s.id - JOIN vn.claim c ON c.id = ce.claimFk - WHERE ce.claimDestinationFk NOT IN (1,5) - AND c.claimStateFk = 3 - AND c.ticketCreated >= TIMESTAMPADD(YEAR, -1, util.VN_CURDATE()) - GROUP BY c.clientFk - ) claims ON claims.clientFk = fm.Id_Cliente; - - - -- Calculamos el porcentaje del recobro para añadirlo al precio de venta - UPDATE bi.claims_ratio cr - JOIN ( - SELECT clientFk Id_Cliente, IFNULL(SUM(amount), 0) AS Greuge - FROM vn.greuge - WHERE shipped <= util.VN_CURDATE() - GROUP BY clientFk - ) g ON g.Id_Cliente = cr.Id_Cliente - SET recobro = GREATEST(0,round(IFNULL(Greuge, 0) / - (IFNULL(Consumo, 0) * vMonthToRefund / 12 ) ,3)); - - -- Protección neonatos - UPDATE bi.claims_ratio cr - JOIN vn.firstTicketShipped fts ON fts.clientFk = cr.Id_Cliente - SET recobro = 0, Ratio = 0 - WHERE fts.shipped > TIMESTAMPADD(MONTH,-1,util.VN_CURDATE()); - - -- CLIENTE 7983, JULIAN SUAU - UPDATE bi.claims_ratio SET recobro = LEAST(0.05, recobro) WHERE Id_Cliente = 7983; - - -- CLIENTE 4358 - UPDATE bi.claims_ratio SET recobro = GREATEST(0.05, recobro) WHERE Id_Cliente = 4358; - - -- CLIENTE 5523, VERDECORA - UPDATE bi.claims_ratio SET recobro = GREATEST(0.12, recobro) WHERE Id_Cliente = 5523; - - -- CLIENTE 15979, SERVEIS VETERINARIS - UPDATE bi.claims_ratio SET recobro = GREATEST(0.05, recobro) WHERE Id_Cliente = 15979; - - -- CLIENTE 5189 i 8942, son de CSR i son el mateix client - UPDATE bi.claims_ratio cr - JOIN (SELECT sum(Consumo * recobro)/sum(Consumo) as recobro - FROM bi.claims_ratio - WHERE Id_Cliente IN ( 5189,8942) - ) sub - SET cr.recobro = sub.recobro - WHERE Id_Cliente IN ( 5189,8942); -END$$ -DELIMITER ; diff --git a/db/routines/bi/procedures/clean.sql b/db/routines/bi/procedures/clean.sql index ba43b609c..a1eb99166 100644 --- a/db/routines/bi/procedures/clean.sql +++ b/db/routines/bi/procedures/clean.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`clean`() +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`clean`() BEGIN DECLARE vDateShort DATETIME; DECLARE vDateLong DATETIME; @@ -15,5 +15,5 @@ BEGIN DELETE FROM bi.defaulters WHERE `date` < vDateLong; DELETE FROM bi.defaulting WHERE `date` < vDateLong; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/bi/procedures/facturacion_media_anual_update.sql b/db/routines/bi/procedures/facturacion_media_anual_update.sql index b956f353a..e8810cc21 100644 --- a/db/routines/bi/procedures/facturacion_media_anual_update.sql +++ b/db/routines/bi/procedures/facturacion_media_anual_update.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`facturacion_media_anual_update`() +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`facturacion_media_anual_update`() BEGIN TRUNCATE TABLE bs.clientAnnualConsumption; @@ -12,5 +12,5 @@ BEGIN GROUP BY clientFk, year, month ) vol GROUP BY clientFk; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/bi/procedures/rutasAnalyze.sql b/db/routines/bi/procedures/rutasAnalyze.sql index 5f0d55c7a..e277968bf 100644 --- a/db/routines/bi/procedures/rutasAnalyze.sql +++ b/db/routines/bi/procedures/rutasAnalyze.sql @@ -59,7 +59,7 @@ BEGIN JOIN vn.saleComponent sc ON sc.saleFk = s.id JOIN vn.component c ON c.id = sc.componentFk JOIN vn.componentType ct ON ct.id = c.typeFk - WHERE ct.code = 'FREIGHT' + WHERE ct.code = 'freight' AND r.created BETWEEN vDatedFrom AND vDatedTo GROUP BY r.id ) sub ON sub.routeFk = r.Id_Ruta diff --git a/db/routines/bi/views/tarifa_componentes_series.sql b/db/routines/bi/views/tarifa_componentes_series.sql index f231ae420..ed2f8e29a 100644 --- a/db/routines/bi/views/tarifa_componentes_series.sql +++ b/db/routines/bi/views/tarifa_componentes_series.sql @@ -2,7 +2,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `bi`.`tarifa_componentes_series` AS SELECT `ct`.`id` AS `tarifa_componentes_series_id`, - `ct`.`type` AS `Serie`, + `ct`.`name` AS `Serie`, `ct`.`isBase` AS `base`, `ct`.`isMargin` AS `margen` FROM `vn`.`componentType` `ct` diff --git a/db/routines/bs/procedures/carteras_add.sql b/db/routines/bs/procedures/carteras_add.sql index 6de377371..5143b4bb5 100644 --- a/db/routines/bs/procedures/carteras_add.sql +++ b/db/routines/bs/procedures/carteras_add.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`carteras_add`() +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`carteras_add`() BEGIN /** * Inserta en la tabla @bs.carteras las ventas desde el año pasado @@ -23,5 +23,5 @@ BEGIN GROUP BY w.code, t.`year`, t.`month`; DROP TEMPORARY TABLE tmp.time; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/bs/procedures/nightTask_launchAll.sql b/db/routines/bs/procedures/nightTask_launchAll.sql index 59899ee03..e61e88bb6 100644 --- a/db/routines/bs/procedures/nightTask_launchAll.sql +++ b/db/routines/bs/procedures/nightTask_launchAll.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`nightTask_launchAll`() +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`nightTask_launchAll`() BEGIN /** * Runs all nightly tasks. @@ -76,5 +76,5 @@ BEGIN END IF; END LOOP; CLOSE vQueue; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/bs/procedures/salesByItemTypeDay_addLauncher.sql b/db/routines/bs/procedures/salesByItemTypeDay_addLauncher.sql index 3424bac74..63677def6 100644 --- a/db/routines/bs/procedures/salesByItemTypeDay_addLauncher.sql +++ b/db/routines/bs/procedures/salesByItemTypeDay_addLauncher.sql @@ -1,6 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`salesByItemTypeDay_addLauncher`() -BEGIN - CALL bs.salesByItemTypeDay_add(util.VN_CURDATE() - INTERVAL 30 DAY, util.VN_CURDATE()); +BEGIN + CALL bs.salesByItemTypeDay_add(util.VN_CURDATE() - INTERVAL 30 DAY, util.VN_CURDATE()); END$$ DELIMITER ; diff --git a/db/routines/bs/procedures/waste_addSales.sql b/db/routines/bs/procedures/waste_addSales.sql index 0ab328b49..ea4adbc27 100644 --- a/db/routines/bs/procedures/waste_addSales.sql +++ b/db/routines/bs/procedures/waste_addSales.sql @@ -1,31 +1,75 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`() +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`( + vDateFrom DATE, + vDateTo DATE +) BEGIN - DECLARE vWeek INT; - DECLARE vYear INT; +/** + * Recalcula las mermas de un periodo. + * + * @param vDateFrom Fecha desde + * @param vDateTo Fecha hasta + */ + IF vDateFrom IS NULL THEN + SET vDateFrom = util.VN_CURDATE() - INTERVAL WEEKDAY(util.VN_CURDATE()) DAY; + END IF; + + IF vDateTo IS NULL THEN + SET vDateTo = vDateFrom + INTERVAL 6 DAY; + END IF; + + CALL cache.last_buy_refresh(FALSE); - SELECT week, year - INTO vWeek, vYear - FROM vn.time - WHERE dated = util.VN_CURDATE(); - REPLACE bs.waste - SELECT *, 100 * mermas / total as porcentaje - FROM ( - SELECT buyer, - year, - week, - family, - itemFk, - itemTypeFk, - floor(sum(value)) as total, - floor(sum(IF(typeFk = 'loses', value, 0))) as mermas - FROM vn.saleValue - where year = vYear and week = vWeek - - GROUP BY family, itemFk - - ) sub - ORDER BY mermas DESC; + SELECT YEAR(t.shipped), + WEEK(t.shipped, 4), + it.workerFk, + it.id, + s.itemFk, + SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity), + SUM(IF(aw.`type`, s.quantity, 0)), + SUM(IF( + aw.`type` = 'external', + (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, + 0 + ) + ), + SUM(IF( + aw.`type` = 'fault', + (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, + 0 + ) + ), + SUM(IF( + aw.`type` = 'container', + (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, + 0 + ) + ), + SUM(IF( + aw.`type` = 'break', + (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, + 0 + ) + ), + SUM(IF( + aw.`type` = 'other', + (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, + 0 + ) + ) + FROM vn.sale s + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.address a FORCE INDEX (PRIMARY) ON a.id = t.addressFk + LEFT JOIN vn.addressWaste aw ON aw.addressFk = a.id + JOIN vn.warehouse w ON w.id = t.warehouseFk + JOIN cache.last_buy lb ON lb.item_id = i.id + AND lb.warehouse_id = w.id + JOIN vn.buy b ON b.id = lb.buy_id + WHERE t.shipped BETWEEN vDateFrom AND vDateTo + AND w.isManaged + GROUP BY YEAR(t.shipped), WEEK(t.shipped, 4), i.id; END$$ DELIMITER ; diff --git a/db/routines/bs/procedures/waste_addSalesLauncher.sql b/db/routines/bs/procedures/waste_addSalesLauncher.sql new file mode 100644 index 000000000..5eaea9be4 --- /dev/null +++ b/db/routines/bs/procedures/waste_addSalesLauncher.sql @@ -0,0 +1,6 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSalesLauncher`() +BEGIN + CALL waste_addSales(NULL, NULL); +END$$ +DELIMITER ; diff --git a/db/routines/cache/procedures/availableNoRaids_refresh.sql b/db/routines/cache/procedures/availableNoRaids_refresh.sql index 383e35436..37715d270 100644 --- a/db/routines/cache/procedures/availableNoRaids_refresh.sql +++ b/db/routines/cache/procedures/availableNoRaids_refresh.sql @@ -117,7 +117,7 @@ proc: BEGIN )sub GROUP BY sub.itemFk; - DROP TEMPORARY TABLE tmp.itemCalc, tItemRange; + DROP TEMPORARY TABLE tmp.itemCalc, tItemRange, tmp.itemList; CALL cache_calc_end (vCalc); END$$ DELIMITER ; diff --git a/db/routines/cache/procedures/available_refresh.sql b/db/routines/cache/procedures/available_refresh.sql index d0939e568..87c003648 100644 --- a/db/routines/cache/procedures/available_refresh.sql +++ b/db/routines/cache/procedures/available_refresh.sql @@ -1,5 +1,10 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_refresh`(OUT `vCalc` INT, IN `vRefresh` INT, IN `vWarehouse` INT, IN `vDated` DATE) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_refresh`( + OUT `vCalc` INT, + `vRefresh` INT, + `vWarehouse` INT, + `vDated` DATE +) proc: BEGIN DECLARE vStartDate DATE; DECLARE vReserveDate DATETIME; @@ -121,7 +126,7 @@ proc: BEGIN )sub GROUP BY sub.itemFk; - DROP TEMPORARY TABLE tmp.itemCalc, itemRange; + DROP TEMPORARY TABLE tmp.itemCalc, itemRange, tmp.itemList; CALL cache_calc_end (vCalc); END$$ DELIMITER ; diff --git a/db/routines/cache/procedures/available_updateItem.sql b/db/routines/cache/procedures/available_updateItem.sql new file mode 100644 index 000000000..8e94a9d75 --- /dev/null +++ b/db/routines/cache/procedures/available_updateItem.sql @@ -0,0 +1,31 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_updateItem`( + `vItem` INT, + `vWarehouse` INT, + `vDated` DATE, + `vQuantity` INT +) +BEGIN +/** + * Immediately deduct/add an amount from the available cache (if exists). + * + * @param vItem The item id + * @param vWarehouse The warehouse id + * @param vDated Available cache date + * @param vQuantity The amount to be deducted from the cache + */ + DECLARE vCalc INT; + + SELECT id INTO vCalc + FROM cache_calc + WHERE cacheName = 'available' + AND params = CONCAT_WS('/', vWarehouse, vDated); + + IF vCalc IS NOT NULL THEN + UPDATE available + SET available = available - vQuantity + WHERE calc_id = vCalc + AND item_id = vItem; + END IF; +END$$ +DELIMITER ; diff --git a/db/routines/cache/procedures/cache_calc_end.sql b/db/routines/cache/procedures/cache_calc_end.sql index b3a25532b..b74a1b7fd 100644 --- a/db/routines/cache/procedures/cache_calc_end.sql +++ b/db/routines/cache/procedures/cache_calc_end.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`cache_calc_end`(IN `v_calc` INT) +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`cache_calc_end`(IN `v_calc` INT) BEGIN DECLARE v_cache_name VARCHAR(255); DECLARE v_params VARCHAR(255); @@ -21,5 +21,5 @@ BEGIN IF v_cache_name IS NOT NULL THEN DO RELEASE_LOCK(CONCAT_WS('/', v_cache_name, IFNULL(v_params, ''))); END IF; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/cache/procedures/cache_calc_start.sql b/db/routines/cache/procedures/cache_calc_start.sql index 701bb1a68..933d926ef 100644 --- a/db/routines/cache/procedures/cache_calc_start.sql +++ b/db/routines/cache/procedures/cache_calc_start.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`cache_calc_start`(OUT `v_calc` INT, INOUT `v_refresh` INT, IN `v_cache_name` VARCHAR(50), IN `v_params` VARCHAR(100)) +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`cache_calc_start`(OUT `v_calc` INT, INOUT `v_refresh` INT, IN `v_cache_name` VARCHAR(50), IN `v_params` VARCHAR(100)) proc: BEGIN DECLARE v_valid BOOL; DECLARE v_lock_id VARCHAR(100); @@ -83,5 +83,5 @@ proc: BEGIN -- Si se debe recalcular mantiene el bloqueo y devuelve su identificador. SET v_refresh = TRUE; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/cache/procedures/last_buy_refresh.sql b/db/routines/cache/procedures/last_buy_refresh.sql index 49ef4ee5e..86a5e8d8c 100644 --- a/db/routines/cache/procedures/last_buy_refresh.sql +++ b/db/routines/cache/procedures/last_buy_refresh.sql @@ -4,7 +4,7 @@ proc: BEGIN /** * Crea o actualiza la cache con la última compra y fecha de cada * artículo hasta ayer. Para obtener la última compra hasta una fecha - * determinada utilizar el procedimiento vn.buyUltimate(). + * determinada utilizar el procedimiento vn.buy_getUltimate(). * * @param vRefresh %TRUE para forzar el recálculo de la cache */ @@ -30,7 +30,7 @@ proc: BEGIN SELECT inventoried INTO started FROM vn.config LIMIT 1; SET ended = util.VN_CURDATE(); -- TIMESTAMPADD(DAY, -1, util.VN_CURDATE()); - CALL vn.buyUltimateFromInterval(NULL, started, ended); + CALL vn.buy_getUltimateFromInterval(NULL, NULL, started, ended); DELETE FROM last_buy; diff --git a/db/routines/cache/procedures/visible_refresh.sql b/db/routines/cache/procedures/visible_refresh.sql index 63b42dfd9..a673969d2 100644 --- a/db/routines/cache/procedures/visible_refresh.sql +++ b/db/routines/cache/procedures/visible_refresh.sql @@ -1,13 +1,13 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`visible_refresh`(OUT v_calc INT, v_refresh BOOL, v_warehouse INT) -proc: BEGIN +proc:BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN CALL cache_calc_unlock (v_calc); RESIGNAL; END; - CALL cache_calc_start (v_calc, v_refresh, 'visible', v_warehouse); + CALL cache_calc_start (v_calc, v_refresh, 'visible', v_warehouse); IF !v_refresh THEN LEAVE proc; @@ -15,22 +15,26 @@ proc: BEGIN -- Calculamos el stock hasta ayer - CALL `cache`.stock_refresh(false); + CALL cache.stock_refresh(false); CREATE OR REPLACE TEMPORARY TABLE tmp.itemVisible (PRIMARY KEY (item_id)) ENGINE = MEMORY - SELECT item_id, amount stock, amount visible FROM `cache`.stock - WHERE warehouse_id = v_warehouse; + SELECT s.item_id, SUM(s.amount) stock, SUM(s.amount) visible + FROM stock s + JOIN vn.warehouse w ON w.id = s.warehouse_id + WHERE (v_warehouse IS NULL OR s.warehouse_id = v_warehouse) + AND w.isComparative + GROUP BY s.item_id; -- Calculamos los movimientos confirmados de hoy - CALL vn.item_GetVisible(v_warehouse, NULL); + CALL vn.item_calcVisible(NULL, v_warehouse); DELETE FROM visible WHERE calc_id = v_calc; INSERT INTO visible (calc_id, item_id,visible) SELECT v_calc, item_id, visible FROM tmp.itemVisible; - CALL cache_calc_end (v_calc); + CALL cache_calc_end (v_calc); DROP TEMPORARY TABLE tmp.itemVisible; END$$ diff --git a/db/routines/dipole/procedures/expedition_add.sql b/db/routines/dipole/procedures/expedition_add.sql index e224cd2d2..70bc7930e 100644 --- a/db/routines/dipole/procedures/expedition_add.sql +++ b/db/routines/dipole/procedures/expedition_add.sql @@ -46,7 +46,7 @@ BEGIN JOIN vn.address a ON a.id = t.addressFk JOIN vn.province p ON p.id = a.provinceFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk LEFT JOIN vn.beach b ON b.code = rm.beachFk LEFT JOIN vn.`zone`z ON z.id = t.zoneFk JOIN vn.agencyMode am ON t.agencyModeFk = am.id diff --git a/db/routines/edi/events/floramondo.sql b/db/routines/edi/events/floramondo.sql deleted file mode 100644 index 0a38f3537..000000000 --- a/db/routines/edi/events/floramondo.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `edi`.`floramondo` - ON SCHEDULE EVERY 6 MINUTE - STARTS '2022-01-28 09:52:45.000' - ON COMPLETION NOT PRESERVE - DISABLE -DO CALL edi.floramondo_offerRefresh()$$ -DELIMITER ; diff --git a/db/routines/edi/procedures/ekt_refresh.sql b/db/routines/edi/procedures/ekt_refresh.sql index 0e9ed7d3c..8ba438c0a 100644 --- a/db/routines/edi/procedures/ekt_refresh.sql +++ b/db/routines/edi/procedures/ekt_refresh.sql @@ -7,7 +7,6 @@ BEGIN */ DECLARE vRewriteKop INT DEFAULT NULL; DECLARE vTruncatePutOrder INT DEFAULT NULL; - DECLARE vBarcode CHAR(15) DEFAULT NULL; DECLARE vKop INT; DECLARE vPutOrderFk BIGINT; @@ -16,17 +15,6 @@ BEGIN FROM ekt WHERE id = vSelf; - -- Generates the barcode - - SELECT CONCAT( - LPAD(IFNULL(auction,0), 3, 0), - LPAD(IFNULL(klo, 99), 2, 0), - LPAD(DAYOFYEAR(fec), 3, 0), - COALESCE(agj, RIGHT(batchNumber,7), id)) - INTO vBarcode - FROM ekt - WHERE id = vSelf; - -- Rewrites the kop parameter IF vKop IS NULL THEN @@ -46,10 +34,9 @@ BEGIN -- Refresh EKT - UPDATE ekt SET - barcode = vBarcode - ,kop = vKop - ,putOrderFk = vTruncatePutOrder + UPDATE ekt + SET kop = vKop, + putOrderFk = vTruncatePutOrder WHERE id = vSelf; END$$ DELIMITER ; diff --git a/db/routines/edi/procedures/floramondo_offerRefresh.sql b/db/routines/edi/procedures/floramondo_offerRefresh.sql deleted file mode 100644 index 18d3f8b7e..000000000 --- a/db/routines/edi/procedures/floramondo_offerRefresh.sql +++ /dev/null @@ -1,522 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`floramondo_offerRefresh`() -proc: BEGIN - DECLARE vLanded DATETIME; - DECLARE vDone INT DEFAULT FALSE; - DECLARE vFreeId INT; - DECLARE vSupplyResponseFk INT; - DECLARE vLastInserted DATETIME; - DECLARE vIsAuctionDay BOOLEAN; - DECLARE vMaxNewItems INT DEFAULT 10000; - DECLARE vStartingTime DATETIME; - DECLARE vAalsmeerMarketPlaceID VARCHAR(13) DEFAULT '8713783439043'; - DECLARE vDayRange INT; - - DECLARE cur1 CURSOR FOR - SELECT id - FROM edi.item_free; - - DECLARE cur2 CURSOR FOR - SELECT srId - FROM itemToInsert; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DECLARE EXIT HANDLER FOR SQLSTATE '45000' - BEGIN - ROLLBACK; - RESIGNAL; - END; - - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION - BEGIN - DO RELEASE_LOCK('edi.floramondo_offerRefresh'); - SET @isTriggerDisabled = FALSE; - RESIGNAL; - END; - - IF 'test' = (SELECT environment FROM util.config) THEN - LEAVE proc; - END IF; - - IF !GET_LOCK('edi.floramondo_offerRefresh', 0) THEN - LEAVE proc; - END IF; - - SELECT dayRange INTO vDayRange - FROM offerRefreshConfig; - - IF vDayRange IS NULL THEN - CALL util.throw("Variable vDayRange not declared"); - END IF; - - SET vStartingTime = util.VN_NOW(); - - TRUNCATE edi.offerList; - - INSERT INTO edi.offerList(supplier, total) - SELECT v.name, COUNT(DISTINCT sr.ID) total - FROM edi.supplyResponse sr - JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID - WHERE sr.NumberOfUnits > 0 - AND sr.EmbalageCode != 999 - GROUP BY sr.vmpID; - - UPDATE edi.offerList o - JOIN (SELECT v.name, COUNT(*) total - FROM edi.supplyOffer sr - JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID - GROUP BY sr.vmpID) sub ON o.supplier = sub.name - SET o.`filter` = sub.total; - - -- Elimina de la lista de items libres aquellos que ya existen - DELETE itf.* - FROM edi.item_free itf - JOIN vn.item i ON i.id = itf.id; - - CREATE OR REPLACE TEMPORARY TABLE tmp - (INDEX (`Item_ArticleCode`)) - ENGINE = MEMORY - SELECT t.* - FROM ( - SELECT * - FROM edi.supplyOffer - ORDER BY (MarketPlaceID = vAalsmeerMarketPlaceID) DESC, - NumberOfUnits DESC LIMIT 10000000000000000000) t - GROUP BY t.srId; - - CREATE OR REPLACE TEMPORARY TABLE edi.offer (INDEX (`srID`), INDEX (`EmbalageCode`), - INDEX (`ef1`), INDEX (`ef2`), INDEX (`ef3`), INDEX (`ef4`),INDEX (`ef5`), INDEX (`ef6`), - INDEX (`s1Value`), INDEX (`s2Value`), INDEX (`s3Value`), INDEX (`s4Value`),INDEX (`s5Value`), INDEX (`s6Value`)) - ENGINE = MEMORY - SELECT so.*, - ev1.type_description s1Value, - ev2.type_description s2Value, - ev3.type_description s3Value, - ev4.type_description s4Value, - ev5.type_description s5Value, - ev6.type_description s6Value, - eif1.feature ef1, - eif2.feature ef2, - eif3.feature ef3, - eif4.feature ef4, - eif5.feature ef5, - eif6.feature ef6 - FROM tmp so - LEFT JOIN edi.item_feature eif1 ON eif1.item_id = so.Item_ArticleCode - AND eif1.presentation_order = 1 - AND eif1.expiry_date IS NULL - LEFT JOIN edi.item_feature eif2 ON eif2.item_id = so.Item_ArticleCode - AND eif2.presentation_order = 2 - AND eif2.expiry_date IS NULL - LEFT JOIN edi.item_feature eif3 ON eif3.item_id = so.Item_ArticleCode - AND eif3.presentation_order = 3 - AND eif3.expiry_date IS NULL - LEFT JOIN edi.item_feature eif4 ON eif4.item_id = so.Item_ArticleCode - AND eif4.presentation_order = 4 - AND eif4.expiry_date IS NULL - LEFT JOIN edi.item_feature eif5 ON eif5.item_id = so.Item_ArticleCode - AND eif5.presentation_order = 5 - AND eif5.expiry_date IS NULL - LEFT JOIN edi.item_feature eif6 ON eif6.item_id = so.Item_ArticleCode - AND eif6.presentation_order = 6 - AND eif6.expiry_date IS NULL - LEFT JOIN edi.`value` ev1 ON ev1.type_id = eif1.feature - AND so.s1 = ev1.type_value - LEFT JOIN edi.`value` ev2 ON ev2.type_id = eif2.feature - AND so.s2 = ev2.type_value - LEFT JOIN edi.`value` ev3 ON ev3.type_id = eif3.feature - AND so.s3 = ev3.type_value - LEFT JOIN edi.`value` ev4 ON ev4.type_id = eif4.feature - AND so.s4 = ev4.type_value - LEFT JOIN edi.`value` ev5 ON ev5.type_id = eif5.feature - AND so.s5 = ev5.type_value - LEFT JOIN edi.`value` ev6 ON ev6.type_id = eif6.feature - AND so.s6 = ev6.type_value - ORDER BY Price; - - DROP TEMPORARY TABLE tmp; - - DELETE o - FROM edi.offer o - LEFT JOIN vn.tag t1 ON t1.ediTypeFk = o.ef1 AND t1.overwrite = 'size' - LEFT JOIN vn.tag t2 ON t2.ediTypeFk = o.ef2 AND t2.overwrite = 'size' - LEFT JOIN vn.tag t3 ON t3.ediTypeFk = o.ef3 AND t3.overwrite = 'size' - LEFT JOIN vn.tag t4 ON t4.ediTypeFk = o.ef4 AND t4.overwrite = 'size' - LEFT JOIN vn.tag t5 ON t5.ediTypeFk = o.ef5 AND t5.overwrite = 'size' - LEFT JOIN vn.tag t6 ON t6.ediTypeFk = o.ef6 AND t6.overwrite = 'size' - JOIN vn.floramondoConfig fc ON TRUE - WHERE (t1.id IS NOT NULL AND CONVERT(s1Value, UNSIGNED) > fc.itemMaxSize) - OR (t2.id IS NOT NULL AND CONVERT(s2Value, UNSIGNED) > fc.itemMaxSize) - OR (t3.id IS NOT NULL AND CONVERT(s3Value, UNSIGNED) > fc.itemMaxSize) - OR (t4.id IS NOT NULL AND CONVERT(s4Value, UNSIGNED) > fc.itemMaxSize) - OR (t5.id IS NOT NULL AND CONVERT(s5Value, UNSIGNED) > fc.itemMaxSize) - OR (t6.id IS NOT NULL AND CONVERT(s6Value, UNSIGNED) > fc.itemMaxSize); - - START TRANSACTION; - - -- Actualizamos el campo supplyResponseFk para aquellos articulos que ya estan creados y reutilizamos - UPDATE IGNORE edi.offer o - JOIN vn.item i - ON i.name = o.product_name - AND i.subname <=> o.company_name - AND i.value5 <=> o.s1Value - AND i.value6 <=> o.s2Value - AND i.value7 <=> o.s3Value - AND i.value8 <=> o.s4Value - AND i.value9 <=> o.s5Value - AND i.value10 <=> o.s6Value - AND i.NumberOfItemsPerCask <=> o.NumberOfItemsPerCask - AND i.EmbalageCode <=> o.EmbalageCode - AND i.quality <=> o.Quality - JOIN vn.itemType it ON it.id = i.typeFk - LEFT JOIN vn.sale s ON s.itemFk = i.id - LEFT JOIN vn.ticket t ON t.id = s.ticketFk - AND t.shipped > (util.VN_CURDATE() - INTERVAL 1 WEEK) - LEFT JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - LEFT JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID - LEFT JOIN edi.putOrder po ON po.supplyResponseID = i.supplyResponseFk - AND po.OrderTradeLineDateTime > (util.VN_CURDATE() - INTERVAL 1 WEEK) - SET i.supplyResponseFk = o.srID - WHERE (sr.ID IS NULL - OR sr.NumberOfUnits = 0 - OR di.LatestOrderDateTime < util.VN_NOW() - OR di.ID IS NULL) - AND it.isInventory - AND t.id IS NULL - AND po.id IS NULL; - - CREATE OR REPLACE TEMPORARY TABLE itemToInsert - ENGINE = MEMORY - SELECT o.*, CAST(NULL AS DECIMAL(6,0)) itemFk - FROM edi.offer o - LEFT JOIN vn.item i ON i.supplyResponseFk = o.srId - WHERE i.id IS NULL - LIMIT vMaxNewItems; - - -- Reciclado de nº de item - OPEN cur1; - OPEN cur2; - - read_loop: LOOP - - FETCH cur2 INTO vSupplyResponseFk; - FETCH cur1 INTO vFreeId; - - IF vDone THEN - LEAVE read_loop; - END IF; - - UPDATE itemToInsert - SET itemFk = vFreeId - WHERE srId = vSupplyResponseFk; - - END LOOP; - - CLOSE cur1; - CLOSE cur2; - - -- Insertamos todos los items en Articles de la oferta - INSERT INTO vn.item(id, - `name`, - longName, - subName, - expenseFk, - typeFk, - intrastatFk, - originFk, - supplyResponseFk, - numberOfItemsPerCask, - embalageCode, - quality, - isFloramondo) - SELECT iti.itemFk, - iti.product_name, - iti.product_name, - iti.company_name, - iti.expenseFk, - iti.itemTypeFk, - iti.intrastatFk, - iti.originFk, - iti.`srId`, - iti.NumberOfItemsPerCask, - iti.EmbalageCode, - iti.Quality, - TRUE - FROM itemToInsert iti; - - -- Inserta la foto de los articulos nuevos (prioridad alta) - INSERT IGNORE INTO vn.itemImageQueue(itemFk, url) - SELECT i.id, PictureReference - FROM itemToInsert ii - JOIN vn.item i ON i.supplyResponseFk = ii.srId - WHERE PictureReference IS NOT NULL - AND i.image IS NULL; - - INSERT INTO edi.`log`(tableName, fieldName,fieldValue) - SELECT 'itemImageQueue','NumImagenesPtes', COUNT(*) - FROM vn.itemImageQueue - WHERE attempts = 0; - - -- Inserta si se añadiesen tags nuevos - INSERT IGNORE INTO vn.tag (name, ediTypeFk) - SELECT description, type_id FROM edi.type; - - -- Desabilita el trigger para recalcular los tags al final - SET @isTriggerDisabled = TRUE; - - -- Inserta los tags sólo en los articulos nuevos - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , ii.product_name, 1 - FROM itemToInsert ii - JOIN vn.tag t ON t.`name` = 'Producto' - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT ii.product_name IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , ii.Quality, 3 - FROM itemToInsert ii - JOIN vn.tag t ON t.`name` = 'Calidad' - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT ii.Quality IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , ii.company_name, 4 - FROM itemToInsert ii - JOIN vn.tag t ON t.`name` = 'Productor' - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT ii.company_name IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s1Value, 5 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef1 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT s1Value IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s2Value, 6 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef2 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT s2Value IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s3Value, 7 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef3 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT s3Value IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s4Value, 8 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef4 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT s4Value IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s5Value, 9 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef5 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT s5Value IS NULL; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s6Value, 10 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef6 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE NOT s6Value IS NULL; - - INSERT IGNORE INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id, IFNULL(ink.name, ik.color), 11 - FROM itemToInsert ii - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - JOIN vn.tag t ON t.`name` = 'Color' - LEFT JOIN edi.feature f ON f.item_id = ii.Item_ArticleCode - LEFT JOIN edi.`type` tp ON tp.type_id = f.feature_type_id - AND tp.`description` = 'Hoofdkleur 1' - LEFT JOIN vn.ink ON ink.dutchCode = f.feature_value - LEFT JOIN vn.itemInk ik ON ik.longName = i.longName - WHERE ink.name IS NOT NULL - OR ik.color IS NOT NULL; - - CREATE OR REPLACE TABLE tmp.item - (PRIMARY KEY (id)) - SELECT i.id FROM vn.item i - JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId`; - - CALL vn.item_refreshTags(); - - DROP TABLE tmp.item; - - SELECT MIN(LatestDeliveryDateTime) INTO vLanded - FROM edi.supplyResponse sr - JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID - JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID - JOIN vn.floramondoConfig fc - WHERE mp.isLatestOrderDateTimeRelevant - AND di.LatestOrderDateTime > IF( - fc.MaxLatestOrderHour > HOUR(util.VN_NOW()), - util.VN_CURDATE(), - util.VN_CURDATE() + INTERVAL 1 DAY); - - UPDATE vn.floramondoConfig - SET nextLanded = vLanded - WHERE vLanded IS NOT NULL; - - -- Elimina la oferta obsoleta - UPDATE vn.buy b - JOIN vn.entry e ON e.id = b.entryFk - JOIN vn.travel tr ON tr.id = e.travelFk - JOIN vn.agencyMode am ON am.id = tr.agencyModeFk - JOIN vn.item i ON i.id = b.itemFk - LEFT JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID - LEFT JOIN edi.deliveryInformation di ON di.ID = b.deliveryFk - SET b.quantity = 0 - WHERE (IFNULL(di.LatestOrderDateTime,util.VN_NOW()) <= util.VN_NOW() - OR i.supplyResponseFk IS NULL - OR sr.NumberOfUnits = 0) - AND am.name = 'LOGIFLORA' - AND e.isRaid; - - -- Localiza las entradas de cada almacen - UPDATE edi.warehouseFloramondo - SET entryFk = vn.entry_getForLogiflora(vLanded + INTERVAL travellingDays DAY, warehouseFk); - - IF vLanded IS NOT NULL THEN - -- Actualiza la oferta existente - UPDATE vn.buy b - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk - JOIN vn.item i ON i.id = b.itemFk - JOIN edi.offer o ON i.supplyResponseFk = o.`srId` - SET b.quantity = o.NumberOfUnits * o.NumberOfItemsPerCask, - b.buyingValue = o.price - WHERE (b.quantity <> o.NumberOfUnits * o.NumberOfItemsPerCask - OR b.buyingValue <> o.price); - - -- Inserta el resto - SET vLastInserted := util.VN_NOW(); - - -- Inserta la oferta - INSERT INTO vn.buy ( - entryFk, - itemFk, - quantity, - buyingValue, - stickers, - packing, - `grouping`, - groupingMode, - packagingFk, - deliveryFk) - SELECT wf.entryFk, - i.id, - o.NumberOfUnits * o.NumberOfItemsPerCask quantity, - o.Price, - o.NumberOfUnits etiquetas, - o.NumberOfItemsPerCask packing, - GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask `grouping`, - 'packing', - o.embalageCode, - o.diId - FROM edi.offer o - JOIN vn.item i ON i.supplyResponseFk = o.srId - JOIN edi.warehouseFloramondo wf - JOIN vn.packaging p ON p.id - LIKE o.embalageCode - LEFT JOIN vn.buy b ON b.itemFk = i.id - AND b.entryFk = wf.entryFk - WHERE b.id IS NULL; -- Quitar esta linea y mirar de crear los packages a tiempo REAL - - INSERT INTO vn.itemCost( - itemFk, - warehouseFk, - cm3, - cm3delivery) - SELECT b.itemFk, - wf.warehouseFk, - @cm3 := vn.buy_getUnitVolume(b.id), - IFNULL((vc.standardFlowerBox * 1000) / i.packingOut, @cm3) - FROM warehouseFloramondo wf - JOIN vn.volumeConfig vc - JOIN vn.buy b ON b.entryFk = wf.entryFk - JOIN vn.item i ON i.id = b.itemFk - LEFT JOIN vn.itemCost ic ON ic.itemFk = b.itemFk - AND ic.warehouseFk = wf.warehouseFk - WHERE (ic.cm3 IS NULL OR ic.cm3 = 0) - ON DUPLICATE KEY UPDATE cm3 = @cm3, cm3delivery = IFNULL((vc.standardFlowerBox * 1000) / i.packingOut, @cm3); - - CREATE OR REPLACE TEMPORARY TABLE tmp.buyRecalc - SELECT b.id - FROM vn.buy b - JOIN warehouseFloramondo wf ON wf.entryFk = b.entryFk - WHERE b.created >= vLastInserted; - - CALL vn.buy_recalcPrices(); - - UPDATE edi.offerList o - JOIN (SELECT v.name, COUNT(DISTINCT b.itemFk) total - FROM vn.buy b - JOIN vn.item i ON i.id = b.itemFk - JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk - JOIN vn.warehouse w ON w.id = wf.warehouseFk - WHERE w.name = 'VNH' - AND b.quantity > 0 - GROUP BY sr.vmpID) sub ON o.supplier = sub.name - SET o.vnh = sub.total; - - UPDATE edi.offerList o - JOIN (SELECT v.name, COUNT(DISTINCT b.itemFk) total - FROM vn.buy b - JOIN vn.item i ON i.id = b.itemFk - JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk - JOIN vn.warehouse w ON w.id = wf.warehouseFk - WHERE w.name = 'ALGEMESI' - AND b.quantity > 0 - GROUP BY sr.vmpID) sub ON o.supplier = sub.name - SET o.algemesi = sub.total; - END IF; - - DROP TEMPORARY TABLE - edi.offer, - itemToInsert; - - SET @isTriggerDisabled = FALSE; - - COMMIT; - - -- Esto habria que pasarlo a procesos programados o trabajar con tags y dejar las familias - UPDATE vn.item i - SET typeFk = 121 - WHERE i.longName LIKE 'Rosa Garden %' - AND typeFk = 17; - - UPDATE vn.item i - SET typeFk = 156 - WHERE i.longName LIKE 'Rosa ec %' - AND typeFk = 17; - - -- Refresca las fotos de los items existentes que mostramos (prioridad baja) - INSERT IGNORE INTO vn.itemImageQueue(itemFk, url, priority) - SELECT i.id, sr.PictureReference, 100 - FROM edi.supplyResponse sr - JOIN vn.item i ON i.supplyResponseFk = sr.ID - JOIN edi.supplyOffer so ON so.srId = sr.ID - JOIN hedera.image i2 ON i2.name = i.image - AND i2.collectionFk = 'catalog' - WHERE i2.updated <= (UNIX_TIMESTAMP(util.VN_NOW()) - vDayRange) - AND sr.NumberOfUnits; - - INSERT INTO edi.`log` - SET tableName = 'floramondo_offerRefresh', - fieldName = 'Tiempo de proceso', - fieldValue = TIMEDIFF(util.VN_NOW(), vStartingTime); - - DO RELEASE_LOCK('edi.floramondo_offerRefresh'); -END$$ -DELIMITER ; diff --git a/db/routines/edi/views/ektRecent.sql b/db/routines/edi/views/ektRecent.sql index 3e41490ab..66ff7875e 100644 --- a/db/routines/edi/views/ektRecent.sql +++ b/db/routines/edi/views/ektRecent.sql @@ -2,7 +2,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `edi`.`ektRecent` AS SELECT `e`.`id` AS `id`, - `e`.`barcode` AS `barcode`, `e`.`entryYear` AS `entryYear`, `e`.`batchNumber` AS `batchNumber`, `e`.`deliveryNumber` AS `deliveryNumber`, diff --git a/db/routines/floranet/events/clean.sql b/db/routines/floranet/events/clean.sql deleted file mode 100644 index 4477112fd..000000000 --- a/db/routines/floranet/events/clean.sql +++ /dev/null @@ -1,22 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE - DEFINER=`root`@`localhost` - EVENT `floranet`.`clean` - ON SCHEDULE EVERY 1 DAY - STARTS '2024-01-01 23:00:00.000' - ON COMPLETION PRESERVE - ENABLE -DO -BEGIN - DELETE - FROM `order` - WHERE created < CURDATE() - AND isPaid = FALSE; - - DELETE c.* - FROM catalogue c - LEFT JOIN `order` o ON o.catalogueFk = c.id - WHERE c.created < CURDATE() - AND o.id IS NULL; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/floranet/procedures/catalogue_get.sql b/db/routines/floranet/procedures/catalogue_get.sql index 32624f383..1e224c810 100644 --- a/db/routines/floranet/procedures/catalogue_get.sql +++ b/db/routines/floranet/procedures/catalogue_get.sql @@ -1,16 +1,15 @@ -DROP PROCEDURE IF EXISTS floranet.catalogue_get; - DELIMITER $$ $$ -CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_get(vLanded DATE, vPostalCode VARCHAR(15)) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_get(vLanded DATE, vPostalCode VARCHAR(15)) 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, for the designed shop * * @param vLanded Delivery date * @param vPostalCode Delivery address postal code */ + DECLARE vAddressFk INT; DECLARE vLastCatalogueFk INT; DECLARE vLockName VARCHAR(20); DECLARE vLockTime INT; @@ -21,7 +20,7 @@ proc:BEGIN RESIGNAL; END; - + SET vLockName = 'catalogue_get'; SET vLockTime = 15; @@ -32,6 +31,15 @@ proc:BEGIN SELECT MAX(id) INTO vLastCatalogueFk FROM catalogue; + SELECT addressFk + INTO vAddressFk + FROM addressPostCode apc + WHERE apc.dayOfWeek = dayOfWeek(vLanded) + AND NOW() < vLanded - INTERVAL apc.hoursInAdvance HOUR + AND apc.postCode = vPostalCode + -- Aquí hay que incluir los criterios de selección de tienda + LIMIT 1; + INSERT INTO catalogue( name, price, @@ -40,19 +48,25 @@ proc:BEGIN postalCode, `type`, image, - description + description, + addressFk ) - SELECT i.name, - i.`size`, - i.id, + SELECT CONCAT(i.name, ' by ',a.nickname), + r.price + apc.deliveryCost, + r.itemFk, vLanded, vPostalCode, it.name, CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image), - i.description + i.description, + vAddressFk FROM vn.item i + JOIN (SELECT itemFk, SUM(quantity * cost) price + FROM recipe + GROUP BY itemFk) r ON r.itemFk = i.id JOIN vn.itemType it ON it.id = i.typeFk - WHERE it.code IN ('FNR','FNP'); + JOIN addressPostCode apc ON addressFk = vAddressFk + JOIN vn.address a ON a.id = vAddressFk; SELECT * FROM catalogue diff --git a/db/routines/floranet/procedures/contact_request.sql b/db/routines/floranet/procedures/contact_request.sql index 2ca25b87d..2132a86fc 100644 --- a/db/routines/floranet/procedures/contact_request.sql +++ b/db/routines/floranet/procedures/contact_request.sql @@ -13,8 +13,17 @@ BEGIN /** * Set actions for contact request * - * @param vPostalCode Delivery address postal code + * @param vName Name + * @param vPhone Phone number + * @param vEmail e-mail + * @param vMessage text of the message */ - + + CALL vn.mail_insert( + 'floranet@verdnatura.es', + vEmail, + 'Contact request', + CONCAT('Phone: ',vPhone, ' Message: ', vMessage) + ); END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/floranet/procedures/deliveryDate_get.sql b/db/routines/floranet/procedures/deliveryDate_get.sql index 75e9d6257..70cb48818 100644 --- a/db/routines/floranet/procedures/deliveryDate_get.sql +++ b/db/routines/floranet/procedures/deliveryDate_get.sql @@ -1,8 +1,6 @@ -DROP PROCEDURE IF EXISTS floranet.deliveryDate_get; - DELIMITER $$ $$ -CREATE DEFINER=`root`@`localhost` PROCEDURE `floranet`.`deliveryDate_get`(vPostalCode VARCHAR(15)) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `floranet`.`deliveryDate_get`(vPostalCode VARCHAR(15)) READS SQL DATA BEGIN /** @@ -21,7 +19,7 @@ BEGIN apc.dayOfWeek - vCurrentDayOfWeek, 7 - apc.dayOfWeek ) DAY nextDay, - NOW() + INTERVAL apc.hoursInAdvance - 12 HOUR minDeliveryTime + NOW() + INTERVAL apc.hoursInAdvance HOUR minDeliveryTime FROM addressPostCode apc WHERE apc.postCode = vPostalCode HAVING nextDay > minDeliveryTime) sub; diff --git a/db/routines/floranet/procedures/order_confirm.sql b/db/routines/floranet/procedures/order_confirm.sql index b6aec033d..98e15bbab 100644 --- a/db/routines/floranet/procedures/order_confirm.sql +++ b/db/routines/floranet/procedures/order_confirm.sql @@ -1,25 +1,167 @@ -DROP PROCEDURE IF EXISTS floranet.order_confirm; - DELIMITER $$ $$ -CREATE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT) READS SQL DATA -BEGIN -/** Update order.isPaid field. +proc:BEGIN +/** Update order.isPaid field, and makes the ticket * * @param vCatalogueFk floranet.catalogue.id * * @returns floranet.order.isPaid */ + DECLARE vNewTicketFk INT; + DECLARE vCustomerEmail VARCHAR(255); + DECLARE vFloranetEmail VARCHAR(255); + DECLARE vSubjectEmail VARCHAR(100); + DECLARE vBodyEmail TEXT; + DECLARE vZoneFk INT; + + DECLARE exit handler FOR SQLEXCEPTION + BEGIN + ROLLBACK; + + GET DIAGNOSTICS CONDITION 2 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT; + + SELECT CONCAT('ERROR ', IFNULL(@errno,0), ': ', ifnull(@text,'texto')) AS `SQLEXCEPTION`; + + CALL vn.mail_insert( + 'floranet@verdnatura.es,pako@verdnatura.es', + 'noreply@verdnatura.es', + 'Floranet.order_confirm failure', + CONCAT('CatalogueFk: ', vCatalogueFk, '\n','ERROR ', IFNULL(@errno, 0), ': ', ifnull(@text, 'texto')) + ); + END; + + IF (SELECT isPaid FROM `order` WHERE catalogueFk = vCatalogueFk) THEN + SELECT CONCAT('CatalogueFk: ', vCatalogueFk, ' Esta orden ya está confirmada') AS `ERROR`; + LEAVE proc; + END IF; + + START TRANSACTION; + UPDATE `order` SET isPaid = TRUE, payed = NOW() WHERE catalogueFk = vCatalogueFk; - SELECT isPaid + SELECT zoneFk + INTO vZoneFk + FROM ( + SELECT zoneFk, COUNT(*) totalCount + FROM vn.ticket t + JOIN catalogue c ON c.id = vCatalogueFk + WHERE t.shipped > util.VN_CURDATE() - INTERVAL 1 YEAR + AND t.addressFk = c.addressFk + GROUP BY zoneFk + ORDER BY totalCount DESC + LIMIT 10000000000000000000 + ) sub + LIMIT 1; + + INSERT INTO vn.ticket ( + clientFk, + shipped, + addressFk, + agencyModeFk, + nickname, + warehouseFk, + routeFk, + companyFk, + landed, + zoneFk + ) + SELECT a.clientFk, + c.dated - INTERVAL 1 DAY, + c.addressFk, + a.agencyModeFk, + a.nickname, + ag.warehouseFk, + NULL, + co.id, + c.dated, + vZoneFk + FROM vn.address a + JOIN vn.agencyMode am ON am.id = a.agencyModeFk + JOIN vn.agency ag ON ag.id = am.agencyFk + JOIN catalogue c ON c.addressFk = a.id + JOIN vn.company co ON co.code = 'VNL' + WHERE c.id = vCatalogueFk; + + SET vNewTicketFk = LAST_INSERT_ID(); + + INSERT INTO vn.sale( + ticketFk, + itemFk, + concept, + price, + quantity) + SELECT + vNewTicketFk, + c.itemFk, + CONCAT('Entrega: ',c.name), + - apc.deliveryCost, + 1 + FROM catalogue c + JOIN addressPostCode apc + ON apc.addressFk = c.addressFk + AND apc.dayOfWeek = dayOfWeek(c.dated) + WHERE c.id = vCatalogueFk; + + INSERT INTO vn.sale( + ticketFk, + itemFk, + concept, + price, + quantity) + SELECT + vNewTicketFk, + r.elementFk, + i.longName, + 0, + r.quantity + FROM catalogue c + JOIN recipe r ON r.itemFk = c.itemFk + JOIN vn.item i ON i.id = r.elementFk + WHERE c.id = vCatalogueFk; + + SELECT cl.email, + cf.email, + CONCAT('Nuevo pedido FLORANET para entrega el ',c.dated), + CONCAT_WS('\n', + CONCAT('Producto: ', c.name), + CONCAT('Fecha de entrega: ',c.dated), + CONCAT('Destinatario: ', o.deliveryName), + CONCAT('Dirección: ', o.address), + CONCAT('CP: ', c.postalCode), + CONCAT('Foto: ', c.image), + CONCAT('Mensaje: ', IFNULL(o.message,"Ninguno.")), + CONCAT('Teléfono: ',IFNULL(o.deliveryPhone,"--")), + CONCAT('Observaciones: ', IFNULL(o.observations,"No hay.")) + ) + INTO vCustomerEmail, + vFloranetEmail, + vSubjectEmail, + vBodyEmail + FROM vn.client cl + JOIN vn.address a ON a.clientFk = cl.id + JOIN catalogue c ON c.addressFk = a.id + JOIN `order` o ON o.catalogueFk = c.id + JOIN config cf + WHERE c.id = vCatalogueFk; + + CALL vn.mail_insert( + vCustomerEmail, + vFloranetEmail, + vSubjectEmail, + vBodyEmail); + + SELECT isPaid, vNewTicketFk FROM `order` WHERE catalogueFk = vCatalogueFk; + + COMMIT; + END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/floranet/procedures/order_put.sql b/db/routines/floranet/procedures/order_put.sql index 979588f8f..c5eb71472 100644 --- a/db/routines/floranet/procedures/order_put.sql +++ b/db/routines/floranet/procedures/order_put.sql @@ -7,7 +7,7 @@ BEGIN * * @param vJsonData The order data in json format */ - INSERT INTO `order` + REPLACE `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')), @@ -15,7 +15,8 @@ BEGIN 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')); + deliveryPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryPhone')), + observations = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.observations')); 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 0e4aa297a..bafda4732 100644 --- a/db/routines/floranet/procedures/sliders_get.sql +++ b/db/routines/floranet/procedures/sliders_get.sql @@ -9,12 +9,11 @@ BEGIN * Returns list of url for sliders. */ SELECT - CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url, - i.longName - FROM vn.item i - JOIN vn.itemType it ON it.id = i.typeFk - WHERE it.code IN ('FNR','FNP') - LIMIT 3; - + CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url, + i.longName + FROM vn.item i + JOIN vn.itemType it ON it.id = i.typeFk + WHERE it.code IN ('FNR','FNP') + LIMIT 3; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/hedera/procedures/item_calcCatalog.sql b/db/routines/hedera/procedures/item_calcCatalog.sql index e72c2fd06..fae89bd5c 100644 --- a/db/routines/hedera/procedures/item_calcCatalog.sql +++ b/db/routines/hedera/procedures/item_calcCatalog.sql @@ -25,11 +25,7 @@ BEGIN JOIN vn.warehouse w ON w.id = p.warehouseFk ORDER BY warehouseFk, `grouping`; - DROP TEMPORARY TABLE - tmp.ticketCalculateItem, - tmp.ticketComponentPrice, - tmp.ticketComponent, - tmp.ticketLot, - tmp.zoneGetShipped; + CALL vn.ticketCalculatePurge(); + DROP TEMPORARY TABLE tmp.item; END$$ DELIMITER ; diff --git a/db/routines/hedera/procedures/item_getVisible.sql b/db/routines/hedera/procedures/item_getVisible.sql index 8e25eaab3..2f4ef32ab 100644 --- a/db/routines/hedera/procedures/item_getVisible.sql +++ b/db/routines/hedera/procedures/item_getVisible.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`item_getVisible vType INT, vPrefix VARCHAR(255)) BEGIN - + /** * Gets visible items of the specified type at specified date. * @@ -14,7 +14,7 @@ BEGIN * @param vType The type id * @param vPrefix The article prefix to filter or %NULL for all * @return tmp.itemVisible Visible items - */ + */ DECLARE vPrefixLen SMALLINT; DECLARE vFilter VARCHAR(255) DEFAULT NULL; DECLARE vDateInv DATE DEFAULT vn.getInventoryDate(); @@ -23,13 +23,13 @@ BEGIN GET DIAGNOSTICS CONDITION 1 @message = MESSAGE_TEXT; CALL vn.mail_insert( - 'cau@verdnatura.es', - NULL, + 'cau@verdnatura.es', + NULL, CONCAT('hedera.item_getVisible error: ', @message), CONCAT( - 'warehouse: ', IFNULL(vWarehouse, ''), - ', Fecha:', IFNULL(vDate, ''), - ', tipo: ', IFNULL(vType,''), + 'warehouse: ', IFNULL(vWarehouse, ''), + ', Fecha:', IFNULL(vDate, ''), + ', tipo: ', IFNULL(vType,''), ', prefijo: ', IFNULL(vPrefix,''))); RESIGNAL; END; @@ -74,9 +74,10 @@ BEGIN FROM vn.sale m JOIN vn.ticket t ON t.id = m.ticketFk JOIN vn.ticketState s ON s.ticketFk = t.id + JOIN vn.alertLevel al ON al.code = 'DELIVERED' WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE() AND t.warehouseFk = vWarehouse - AND s.alertLevel = 3 + AND s.alertLevel = al.id ) t GROUP BY itemFk HAVING quantity > 0; @@ -108,7 +109,7 @@ BEGIN IF(p.depth > 0, p.depth, 0) depth, p.width, p.height, CEIL(s.quantity / t.packing) etiquetas FROM vn.item i - JOIN `filter` f ON f.itemFk = i.id + JOIN `filter` f ON f.itemFk = i.id JOIN currentStock s ON s.itemFk = i.id LEFT JOIN tmp t ON t.itemFk = i.id LEFT JOIN vn.packaging p ON p.id = t.packagingFk diff --git a/db/routines/hedera/procedures/orderRow_updateOverstocking.sql b/db/routines/hedera/procedures/orderRow_updateOverstocking.sql new file mode 100644 index 000000000..bbfa9432a --- /dev/null +++ b/db/routines/hedera/procedures/orderRow_updateOverstocking.sql @@ -0,0 +1,52 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` +PROCEDURE `hedera`.`orderRow_updateOverstocking`(vOrderFk INT) +BEGIN +/** +* Set amount = 0 to avoid overbooking sales +* +* @param vOrderFk hedera.order.id +*/ + DECLARE vCalcFk INT; + DECLARE vDone BOOL; + DECLARE vWarehouseFk INT; + + DECLARE cWarehouses CURSOR FOR + SELECT DISTINCT warehouseFk + FROM orderRow + WHERE orderFk = vOrderFk + AND shipment = util.VN_CURDATE(); + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + OPEN cWarehouses; + checking: LOOP + SET vDone = FALSE; + + FETCH cWarehouses INTO vWarehouseFk; + + IF vDone THEN + LEAVE checking; + END IF; + + CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, util.VN_CURDATE()); + + UPDATE orderRow r + JOIN `order` o ON o.id = r.orderFk + JOIN orderConfig oc + JOIN cache.available a ON a.calc_id = vCalcFk AND a.item_id = r.itemFk + SET r.amount = 0 + WHERE ADDTIME(o.rowUpdated, oc.reserveTime) < util.VN_NOW() + AND a.available <= 0 + AND r.warehouseFk = vWarehouseFk + AND r.orderFk = vOrderFk; + END LOOP; + CLOSE cWarehouses; +END$$ +DELIMITER ; diff --git a/db/routines/hedera/procedures/order_addItem.sql b/db/routines/hedera/procedures/order_addItem.sql index d9c15c0eb..1470ddf35 100644 --- a/db/routines/hedera/procedures/order_addItem.sql +++ b/db/routines/hedera/procedures/order_addItem.sql @@ -1,8 +1,8 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_addItem`( vSelf INT, - vWarehouse INT, - vItem INT, + vWarehouse INT, + vItem INT, vAmount INT) BEGIN /** @@ -37,7 +37,7 @@ BEGIN ROLLBACK; RESIGNAL; END; - + CALL order_calcCatalogFromItem(vSelf, vItem); START TRANSACTION; @@ -47,20 +47,36 @@ BEGIN FROM tmp.zoneGetShipped WHERE warehouseFk = vWarehouse; - SELECT IFNULL(available, 0) INTO vAvailable + SELECT available INTO vAvailable FROM tmp.ticketLot WHERE warehouseFk = vWarehouse AND itemFk = vItem; + IF vAvailable IS NULL THEN + SET vAvailable = 0; + END IF; + IF vAmount > vAvailable THEN CALL util.throw ('ORDER_ROW_UNAVAILABLE'); END IF; - SELECT IFNULL(minQuantity, 0) INTO vMinQuantity - FROM vn.item - WHERE id = vItem; + WITH itemMinQuantityPriority AS ( + SELECT quantity, + ROW_NUMBER() OVER ( + PARTITION BY itemFk + ORDER BY warehouseFk IS NULL + ) priority + FROM vn.itemMinimumQuantity + WHERE itemFk = vItem + AND `started` <= vShipment + AND (`ended` >= vShipment OR `ended` IS NULL) + AND (warehouseFk = vWarehouse OR warehouseFk IS NULL) + ) + SELECT quantity INTO vMinQuantity + FROM itemMinQuantityPriority + WHERE priority = 1; - IF vAmount < LEAST(vMinQuantity, vAvailable) THEN + IF vAmount < LEAST(IFNULL(vMinQuantity, 0), vAvailable) THEN CALL util.throw ('quantityLessThanMin'); END IF; @@ -90,6 +106,8 @@ BEGIN amount = vAdd, price = vPrice; + CALL cache.available_updateItem(vItem, vWarehouse, vShipment, vAdd); + SET vRow = LAST_INSERT_ID(); INSERT INTO orderRowComponent (rowFk, componentFk, price) @@ -109,6 +127,6 @@ BEGIN END IF; COMMIT; - CALL vn.ticketCalculatePurge; + CALL vn.ticketCalculatePurge; END$$ DELIMITER ; diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 0aeaaf65b..644d68a87 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -1,59 +1,61 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_confirmWithUser`(vSelf INT, vUserId INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_confirmWithUser`( + vSelf INT, + vUserFk INT +) BEGIN /** - * Confirms an order, creating each of its tickets on the corresponding - * date, store and user. + * Confirms an order, creating each of its tickets + * on the corresponding date, store and user. * * @param vSelf The order identifier * @param vUser The user identifier */ - DECLARE vOk BOOL; - DECLARE vDone BOOL DEFAULT FALSE; - DECLARE vWarehouse INT; + DECLARE vHasRows BOOL; + DECLARE vHas0Amount BOOL; + DECLARE vDone BOOL; + DECLARE vWarehouseFk INT; DECLARE vShipment DATE; - DECLARE vTicket INT; + DECLARE vShipmentDayEnd DATETIME; + DECLARE vTicketFk INT; DECLARE vNotes VARCHAR(255); - DECLARE vItem INT; + DECLARE vItemFk INT; DECLARE vConcept VARCHAR(30); DECLARE vAmount INT; DECLARE vPrice DECIMAL(10,2); - DECLARE vSale INT; - DECLARE vRate INT; - DECLARE vRowId INT; + DECLARE vSaleFk INT; + DECLARE vRowFk INT; DECLARE vPriceFixed DECIMAL(10,2); - DECLARE vDelivery DATE; - DECLARE vAddress INT; - DECLARE vIsConfirmed BOOL; - DECLARE vClientId INT; - DECLARE vCompanyId INT; - DECLARE vAgencyModeId INT; - DECLARE TICKET_FREE INT DEFAULT 2; - DECLARE vCalc INT; - DECLARE vIsLogifloraItem BOOL; - DECLARE vOldQuantity INT; - DECLARE vNewQuantity INT; + DECLARE vLanded DATE; + DECLARE vAddressFk INT; + DECLARE vClientFk INT; + DECLARE vCompanyFk INT; + DECLARE vAgencyModeFk INT; DECLARE vIsTaxDataChecked BOOL; - DECLARE cDates CURSOR FOR - SELECT zgs.shipped, r.warehouse_id + DECLARE vDates CURSOR FOR + SELECT zgs.shipped, r.warehouseFk FROM `order` o - JOIN order_row r ON r.order_id = o.id - LEFT JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = r.warehouse_id - WHERE o.id = vSelf AND r.amount != 0 - GROUP BY r.warehouse_id; + JOIN orderRow r ON r.orderFk = o.id + LEFT JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = r.warehouseFk + WHERE o.id = vSelf + AND r.amount + GROUP BY r.warehouseFk; - DECLARE cRows CURSOR FOR - SELECT r.id, r.item_id, i.name, r.amount, r.price, r.rate, i.isFloramondo - FROM order_row r - JOIN vn.item i ON i.id = r.item_id - WHERE r.amount != 0 - AND r.warehouse_id = vWarehouse - AND r.order_id = vSelf + DECLARE vRows CURSOR FOR + SELECT r.id, + r.itemFk, + i.name, + r.amount, + r.price + FROM orderRow r + JOIN vn.item i ON i.id = r.itemFk + WHERE r.amount + AND r.warehouseFk = vWarehouseFk + AND r.orderFk = vSelf ORDER BY r.rate DESC; - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN @@ -62,26 +64,50 @@ BEGIN END; -- Carga los datos del pedido - SELECT o.date_send, o.address_id, o.note, a.clientFk, - o.company_id, o.agency_id, c.isTaxDataChecked - INTO vDelivery, vAddress, vNotes, vClientId, - vCompanyId, vAgencyModeId, vIsTaxDataChecked - FROM hedera.`order` o + SELECT o.date_send, + o.address_id, + o.note, + a.clientFk, + o.company_id, + o.agency_id, + c.isTaxDataChecked + INTO vLanded, + vAddressFk, + vNotes, + vClientFk, + vCompanyFk, + vAgencyModeFk, + vIsTaxDataChecked + FROM `order` o JOIN vn.address a ON a.id = o.address_id JOIN vn.client c ON c.id = a.clientFk WHERE o.id = vSelf; -- Verifica si el cliente tiene los datos comprobados IF NOT vIsTaxDataChecked THEN - CALL util.throw ('clientNotVerified'); + CALL util.throw('clientNotVerified'); END IF; -- Carga las fechas de salida de cada almacen - CALL vn.zone_getShipped (vDelivery, vAddress, vAgencyModeId, FALSE); + CALL vn.zone_getShipped(vLanded, vAddressFk, vAgencyModeFk, FALSE); -- Trabajador que realiza la accion - IF vUserId IS NULL THEN - SELECT employeeFk INTO vUserId FROM orderConfig; + IF vUserFk IS NULL THEN + SELECT employeeFk INTO vUserFk FROM orderConfig; + END IF; + + CALL orderRow_updateOverstocking(vSelf); + + -- Check if any product has a quantity of 0 + SELECT EXISTS ( + SELECT id + FROM orderRow + WHERE orderFk = vSelf + AND amount = 0 + ) INTO vHas0Amount; + + IF vHas0Amount THEN + CALL util.throw('Hay líneas vacías. Por favor, elimínelas'); END IF; START TRANSACTION; @@ -89,206 +115,188 @@ BEGIN CALL order_checkEditable(vSelf); -- Check order is not empty + SELECT COUNT(*) > 0 INTO vHasRows + FROM orderRow + WHERE orderFk = vSelf + AND amount > 0; - SELECT COUNT(*) > 0 INTO vOk - FROM order_row WHERE order_id = vSelf AND amount > 0; - - IF NOT vOk THEN - CALL util.throw ('ORDER_EMPTY'); + IF NOT vHasRows THEN + CALL util.throw('ORDER_EMPTY'); END IF; -- Crea los tickets del pedido - - OPEN cDates; - - lDates: - LOOP - SET vTicket = NULL; + OPEN vDates; + lDates: LOOP + SET vTicketFk = NULL; SET vDone = FALSE; - FETCH cDates INTO vShipment, vWarehouse; + FETCH vDates INTO vShipment, vWarehouseFk; IF vDone THEN LEAVE lDates; END IF; - -- Busca un ticket existente que coincida con los parametros - WITH tPrevia AS - (SELECT DISTINCT s.ticketFk + SET vShipmentDayEnd = util.dayEnd(vShipment); + + -- Busca un ticket libre disponible + WITH tPrevia AS ( + SELECT DISTINCT s.ticketFk FROM vn.sale s JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id JOIN vn.ticket t ON t.id = s.ticketFk - WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) - ) - SELECT t.id INTO vTicket + WHERE t.shipped BETWEEN vShipment AND vShipmentDayEnd + ) + SELECT t.id INTO vTicketFk FROM vn.ticket t + JOIN vn.alertLevel al ON al.code = 'FREE' LEFT JOIN tPrevia tp ON tp.ticketFk = t.id - LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id - JOIN hedera.`order` o - ON o.address_id = t.addressFk - AND vWarehouse = t.warehouseFk - AND o.date_send = t.landed - AND DATE(t.shipped) = vShipment + LEFT JOIN vn.ticketState tls ON tls.ticketFk = t.id + JOIN hedera.`order` o ON o.address_id = t.addressFk + AND t.shipped BETWEEN vShipment AND vShipmentDayEnd + AND t.warehouseFk = vWarehouseFk + AND o.date_send = t.landed WHERE o.id = vSelf AND t.refFk IS NULL AND tp.ticketFk IS NULL - AND IFNULL(tls.alertLevel,0) = 0 + AND (tls.alertLevel IS NULL OR tls.alertLevel = al.id) LIMIT 1; + -- Comprobamos si hay un ticket de previa disponible + IF vTicketFk IS NULL THEN + WITH tItemPackingTypeOrder AS ( + SELECT GROUP_CONCAT( + DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk + ) distinctItemPackingTypes, + o.address_id + FROM vn.item i + JOIN hedera.orderRow oro ON oro.itemFk = i.id + JOIN hedera.`order` o ON o.id = oro.orderFk + WHERE oro.orderFk = vSelf + ), + tItemPackingTypeTicket AS ( + SELECT t.id, + GROUP_CONCAT( + DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk + ) distinctItemPackingTypes + FROM vn.ticket t + JOIN vn.ticketState tls ON tls.ticketFk = t.id + JOIN vn.alertLevel al ON al.id = tls.alertLevel + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN tItemPackingTypeOrder ipto + WHERE t.shipped BETWEEN vShipment AND vShipmentDayEnd + AND t.refFk IS NULL + AND t.warehouseFk = vWarehouseFk + AND t.addressFk = ipto.address_id + AND al.code = 'ON_PREVIOUS' + GROUP BY t.id + ) + SELECT iptt.id INTO vTicketFk + FROM tItemPackingTypeTicket iptt + JOIN tItemPackingTypeOrder ipto + WHERE INSTR(iptt.distinctItemPackingTypes, ipto.distinctItemPackingTypes) + LIMIT 1; + END IF; + -- Crea el ticket en el caso de no existir uno adecuado - IF vTicket IS NULL - THEN - + IF vTicketFk IS NULL THEN SET vShipment = IFNULL(vShipment, util.VN_CURDATE()); - CALL vn.ticket_add( - vClientId, + vClientFk, vShipment, - vWarehouse, - vCompanyId, - vAddress, - vAgencyModeId, + vWarehouseFk, + vCompanyFk, + vAddressFk, + vAgencyModeFk, NULL, - vDelivery, - vUserId, + vLanded, + vUserFk, TRUE, - vTicket + vTicketFk ); ELSE INSERT INTO vn.ticketTracking - SET ticketFk = vTicket, - userFk = vUserId, - stateFk = TICKET_FREE; + SET ticketFk = vTicketFk, + userFk = vUserFk, + stateFk = (SELECT id FROM vn.state WHERE code = 'FREE'); END IF; INSERT IGNORE INTO vn.orderTicket SET orderFk = vSelf, - ticketFk = vTicket; + ticketFk = vTicketFk; -- Añade las notas - - IF vNotes IS NOT NULL AND vNotes != '' - THEN - INSERT INTO vn.ticketObservation SET - ticketFk = vTicket, - observationTypeFk = 4 /* salesperson */ , + IF vNotes IS NOT NULL AND vNotes <> '' THEN + INSERT INTO vn.ticketObservation + SET ticketFk = vTicketFk, + observationTypeFk = (SELECT id FROM vn.observationType WHERE code = 'salesPerson'), `description` = vNotes ON DUPLICATE KEY UPDATE `description` = CONCAT(VALUES(`description`),'. ', `description`); END IF; -- Añade los movimientos y sus componentes - - OPEN cRows; - + OPEN vRows; lRows: LOOP + SET vSaleFk = NULL; SET vDone = FALSE; - FETCH cRows INTO vRowId, vItem, vConcept, vAmount, vPrice, vRate, vIsLogifloraItem; + FETCH vRows INTO vRowFk, vItemFk, vConcept, vAmount, vPrice; IF vDone THEN LEAVE lRows; END IF; - SET vSale = NULL; - - SELECT s.id, s.quantity INTO vSale, vOldQuantity + SELECT s.id INTO vSaleFk FROM vn.sale s - WHERE ticketFk = vTicket + WHERE ticketFk = vTicketFk AND price = vPrice - AND itemFk = vItem + AND itemFk = vItemFk AND discount = 0 LIMIT 1; - IF vSale THEN + IF vSaleFk THEN UPDATE vn.sale SET quantity = quantity + vAmount, originalQuantity = quantity - WHERE id = vSale; - - SELECT s.quantity INTO vNewQuantity - FROM vn.sale s - WHERE id = vSale; + WHERE id = vSaleFk; ELSE -- Obtiene el coste SELECT SUM(rc.`price`) valueSum INTO vPriceFixed FROM orderRowComponent rc JOIN vn.component c ON c.id = rc.componentFk - JOIN vn.componentType ct ON ct.id = c.typeFk AND ct.isBase - WHERE rc.rowFk = vRowId; + JOIN vn.componentType ct ON ct.id = c.typeFk + AND ct.isBase + WHERE rc.rowFk = vRowFk; INSERT INTO vn.sale - SET itemFk = vItem, - ticketFk = vTicket, + SET itemFk = vItemFk, + ticketFk = vTicketFk, concept = vConcept, quantity = vAmount, price = vPrice, priceFixed = vPriceFixed, isPriceFixed = TRUE; - SET vSale = LAST_INSERT_ID(); + SET vSaleFk = LAST_INSERT_ID(); - INSERT INTO vn.saleComponent - (saleFk, componentFk, `value`) - SELECT vSale, rc.componentFk, rc.price + INSERT INTO vn.saleComponent (saleFk, componentFk, `value`) + SELECT vSaleFk, rc.componentFk, rc.price FROM orderRowComponent rc JOIN vn.component c ON c.id = rc.componentFk - WHERE rc.rowFk = vRowId - GROUP BY vSale, rc.componentFk; + WHERE rc.rowFk = vRowFk + GROUP BY vSaleFk, rc.componentFk; END IF; - UPDATE order_row SET Id_Movimiento = vSale - WHERE id = vRowId; - - -- Inserta en putOrder si la compra es de Floramondo - IF vIsLogifloraItem THEN - CALL cache.availableNoRaids_refresh(vCalc,FALSE,vWarehouse,vShipment); - - SET @available := 0; - - SELECT GREATEST(0,available) INTO @available - FROM cache.availableNoRaids - WHERE calc_id = vCalc - AND item_id = vItem; - - UPDATE cache.availableNoRaids - SET available = GREATEST(0,available - vAmount) - WHERE item_id = vItem - AND calc_id = vCalc; - - INSERT INTO edi.putOrder ( - deliveryInformationID, - supplyResponseId, - quantity , - EndUserPartyId, - EndUserPartyGLN, - FHAdminNumber, - saleFk - ) - SELECT di.ID, - i.supplyResponseFk, - CEIL((vAmount - @available)/ sr.NumberOfItemsPerCask), - o.address_id , - vClientId, - IFNULL(ca.fhAdminNumber, fhc.defaultAdminNumber), - vSale - FROM edi.deliveryInformation di - JOIN vn.item i ON i.supplyResponseFk = di.supplyResponseID - JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - LEFT JOIN edi.clientFHAdminNumber ca ON ca.clientFk = vClientId - JOIN edi.floraHollandConfig fhc - JOIN hedera.`order` o ON o.id = vSelf - WHERE i.id = vItem - AND di.LatestOrderDateTime > util.VN_NOW() - AND vAmount > @available - LIMIT 1; - END IF; + UPDATE orderRow + SET saleFk = vSaleFk + WHERE id = vRowFk; END LOOP; - - CLOSE cRows; + CLOSE vRows; END LOOP; + CLOSE vDates; - CLOSE cDates; - - UPDATE `order` SET confirmed = TRUE, confirm_date = util.VN_NOW() + UPDATE `order` + SET confirmed = TRUE, + confirm_date = util.VN_NOW() WHERE id = vSelf; COMMIT; diff --git a/db/routines/hedera/procedures/tpvTransaction_confirm.sql b/db/routines/hedera/procedures/tpvTransaction_confirm.sql index e4a8c932f..60a6d8452 100644 --- a/db/routines/hedera/procedures/tpvTransaction_confirm.sql +++ b/db/routines/hedera/procedures/tpvTransaction_confirm.sql @@ -81,7 +81,7 @@ BEGIN -- Código redundante - DO vn.till_new( + CALL vn.till_new( vCustomer ,vBank ,vAmount / 100 diff --git a/db/routines/hedera/triggers/orderRow_afterInsert.sql b/db/routines/hedera/triggers/orderRow_afterInsert.sql new file mode 100644 index 000000000..7196dce10 --- /dev/null +++ b/db/routines/hedera/triggers/orderRow_afterInsert.sql @@ -0,0 +1,10 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterInsert` + AFTER INSERT ON `orderRow` + FOR EACH ROW +BEGIN + UPDATE `order` + SET rowUpdated = util.VN_NOW() + WHERE id = NEW.orderFk; +END$$ +DELIMITER ; diff --git a/db/routines/pbx/views/queueConf.sql b/db/routines/pbx/views/queueConf.sql index 07c241589..107989801 100644 --- a/db/routines/pbx/views/queueConf.sql +++ b/db/routines/pbx/views/queueConf.sql @@ -10,5 +10,5 @@ AS SELECT `q`.`name` AS `name`, `c`.`ringInUse` AS `ringinuse` FROM ( `pbx`.`queue` `q` - JOIN `pbx`.`queueConfig` `c` ON(`q`.`config` = `c`.`id`) + JOIN `pbx`.`queueMultiConfig` `c` ON(`q`.`config` = `c`.`id`) ) diff --git a/db/routines/sage/procedures/accountingMovements_add.sql b/db/routines/sage/procedures/accountingMovements_add.sql index 575c63f6c..8c129beb2 100644 --- a/db/routines/sage/procedures/accountingMovements_add.sql +++ b/db/routines/sage/procedures/accountingMovements_add.sql @@ -21,7 +21,8 @@ BEGIN DECLARE vTransactionExportTaxFreeFk INT; DECLARE vSerialDua VARCHAR(1) DEFAULT 'D'; DECLARE vInvoiceTypeInformativeCode VARCHAR(1); - DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2) ; + DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2); + DECLARE vCompanyCode INT; SELECT SiglaNacion INTO vCountryCanariasCode FROM Naciones @@ -31,9 +32,6 @@ BEGIN FROM Naciones WHERE Nacion ='CEUTA Y MELILLA'; - SELECT pendingServiceTransactionTypeFk INTO vDuaTransactionFk - FROM config; - SELECT id INTO vTaxImportFk FROM taxType WHERE code = 'import21'; @@ -46,10 +44,14 @@ BEGIN FROM taxType WHERE code = 'import4'; - SELECT definitiveExportTransactionTypeFk INTO vTransactionExportFk - FROM config; - - SELECT shipmentTransactionTypeFk INTO vTransactionExportTaxFreeFk + SELECT shipmentTransactionTypeFk, + definitiveExportTransactionTypeFk, + pendingServiceTransactionTypeFk, + company_getCode(vCompanyFk) + INTO vTransactionExportTaxFreeFk, + vTransactionExportFk, + vDuaTransactionFk, + vCompanyCode FROM config; SELECT codeSage INTO vInvoiceTypeInformativeCode @@ -64,8 +66,6 @@ BEGIN WHERE enlazadoSage = FALSE AND Asiento <> 1 ; - CALL clientSupplier_add(vCompanyFk); - CALL pgc_add(vCompanyFk); CALL invoiceOut_manager(vYear, vCompanyFk); CALL invoiceIn_manager(vYear, vCompanyFk); @@ -158,7 +158,7 @@ BEGIN ) SELECT 'EN' TipoEntrada, YEAR(x.FECHA) Ejercicio, - company_getCode(vCompanyFk) AS CodigoEmpresa, + vCompanyCode CodigoEmpresa, x.ASIEN Asiento, IF(EURODEBE <> 0 OR (EURODEBE = 0 AND EUROHABER IS NULL), 'D', 'H') CargoAbono, @@ -291,20 +291,6 @@ BEGIN WHERE m.CargoAbono = 'D' AND m.enlazadoSage = FALSE; --- Elimina cuentas de cliente/proveedor que no se utilizarán en la importación - DELETE cp - FROM clientesProveedores cp - LEFT JOIN movConta mc ON mc.codigoCuenta = cp.codigoCuenta - AND mc.enlazadoSage = FALSE - WHERE mc.codigoCuenta IS NULL; - --- Elimina cuentas contables que no se utilizarán en la importación - DELETE pc - FROM planCuentasPGC pc - LEFT JOIN movConta mc ON mc.codigoCuenta = pc.codigoCuenta - AND mc.enlazadoSage = FALSE - WHERE mc.codigoCuenta IS NULL; - -- DUAS UPDATE movConta mci JOIN vn.XDiario x ON x.ASIEN = mci.Asiento @@ -411,5 +397,55 @@ BEGIN AND importeDivisa > 0 AND ImporteAsiento < 0; + CREATE OR REPLACE TEMPORARY TABLE tmp.clientSupplier + (INDEX(idClientSupplier, `type`)) + ENGINE = MEMORY + WITH client AS( + SELECT DISTINCT c.id + FROM sage.movConta mc + JOIN vn.client c ON c.accountingAccount = mc.CodigoCuenta + WHERE NOT enlazadoSage + ),supplier AS( + SELECT DISTINCT s.id + FROM sage.movConta mc + JOIN vn.supplier s ON s.account = mc.CodigoCuenta + WHERE NOT enlazadoSage + ),clientSupplierSync AS( + SELECT idClientSupplier, `type` + FROM sage.clientSupplier cs + WHERE isSync + ) + SELECT idClientSupplier, `type` + FROM sage.clientSupplier cs + WHERE NOT isSync + UNION + SELECT id, 'C' + FROM client c + LEFT JOIN clientSupplierSync cs ON cs.idClientSupplier = c.id + AND cs.Type ='C' + WHERE cs.idClientSupplier IS NULL + UNION + SELECT id, 'P' + FROM supplier s + LEFT JOIN clientSupplierSync cs ON cs.idClientSupplier = s.id + AND cs.Type ='P' + WHERE cs.idClientSupplier IS NULL; + + CALL clientSupplier_add(vCompanyFk); + + INSERT IGNORE INTO sage.clientSupplier (companyFk, `type`, idClientSupplier, isSync) + SELECT vCompanyCode, `type`, idClientSupplier, FALSE + FROM tmp.clientSupplier; + + DROP TEMPORARY TABLE tmp.clientSupplier; + + CALL pgc_add(vCompanyFk); +-- Elimina cuentas contables que no se utilizarán en la importación + DELETE pc + FROM planCuentasPGC pc + LEFT JOIN movConta mc ON mc.codigoCuenta = pc.codigoCuenta + AND mc.enlazadoSage = FALSE + WHERE mc.codigoCuenta IS NULL; + END$$ DELIMITER ; diff --git a/db/routines/sage/procedures/clientSupplier_add.sql b/db/routines/sage/procedures/clientSupplier_add.sql index 70f3ef3d0..2d1a51882 100644 --- a/db/routines/sage/procedures/clientSupplier_add.sql +++ b/db/routines/sage/procedures/clientSupplier_add.sql @@ -1,11 +1,16 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`clientSupplier_add`(vCompanyFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`clientSupplier_add`( + vCompanyFk INT +) BEGIN /** - * Prepara los datos de clientes y proveedores para exportarlos a Sage - * @vCompanyFk Empresa dela que se quiere trasladar datos + * Inserta en la tabla sage.clientesProveedores los datos de clientes y proveedores + * que se actualizaran o se daran de alta en Sage + * @vCompanyFk Id de empresa + * @table tmp.clientSupplier(idClientSupplier, `type`) */ DECLARE vCountryCeutaMelillaFk INT; + DECLARE vCompanyCode INT DEFAULT company_getCode(vCompanyFk); DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2); SELECT SiglaNacion INTO vCountryCanariasCode @@ -45,7 +50,7 @@ BEGIN Email1, iban) SELECT - company_getCode(vCompanyFk), + vCompanyCode, 'C', c.id, c.socialName, @@ -53,7 +58,7 @@ BEGIN IFNULL(c.street, ''), c.accountingAccount, @fi := IF(cu.code = LEFT(TRIM(c.fi), 2) AND c.isVies, MID(TRIM(c.fi), 3, LENGTH(TRIM(c.fi))-1), TRIM(c.fi)), - IF(c.isVies, CONCAT(IFNULL(cu.viesCode,cu.code), @fi ), TRIM(c.fi)), + IF(c.isVies, CONCAT(IFNULL(cu.viesCode,cu.code), @fi ), TRIM(c.fi)), IFNULL(c.postcode, ''), IFNULL(c.city, ''), IFNULL(pr.CodigoProvincia, ''), @@ -75,15 +80,14 @@ BEGIN IFNULL(SUBSTR(c.email, 1, LOCATE(',', CONCAT(c.email, ','))-1), ''), IFNULL(c.iban, '') FROM vn.`client` c - JOIN clientLastTwoMonths clm ON clm.clientFk = c.id + JOIN tmp.clientSupplier cs ON cs.idClientSupplier = c.id LEFT JOIN vn.country cu ON cu.id = c.countryFk LEFT JOIN Naciones n ON n.countryFk = cu.id LEFT JOIN vn.province p ON p.id = c.provinceFk LEFT JOIN Provincias pr ON pr.provinceFk = p.id - WHERE c.isRelevant - AND clm.companyFk = vCompanyFk + WHERE cs.type = 'C' UNION ALL - SELECT company_getCode(vCompanyFk), + SELECT vCompanyCode, 'P', s.id, s.name, @@ -107,18 +111,16 @@ BEGIN IFNULL(s.transactionTypeSageFk, 0), IFNULL(s.withholdingSageFk, '0'), IFNULL(SUBSTR(sc.email, 1, (COALESCE(NULLIF(LOCATE(',', sc.email), 0), 99) - 1)), ''), - IFNULL(iban, '') + IFNULL(sa.iban, '') FROM vn.supplier s - JOIN supplierLastThreeMonths pl ON pl.supplierFk = s.id + JOIN tmp.clientSupplier cs ON cs.idClientSupplier = s.id LEFT JOIN vn.country co ON co.id = s.countryFk LEFT JOIN Naciones n ON n.countryFk = co.id LEFT JOIN vn.province p ON p.id = s.provinceFk LEFT JOIN Provincias pr ON pr.provinceFk = p.id LEFT JOIN vn.supplierContact sc ON sc.supplierFk = s.id LEFT JOIN vn.supplierAccount sa ON sa.supplierFk = s.id - WHERE pl.companyFk = vCompanyFk AND - s.isActive AND - s.nif <> '' - GROUP BY pl.supplierFk, pl.companyFk; + WHERE cs.type = 'P' + GROUP BY s.id; END$$ DELIMITER ; diff --git a/db/routines/salix/triggers/ACL_afterDelete.sql b/db/routines/salix/triggers/ACL_afterDelete.sql new file mode 100644 index 000000000..b7e6071fc --- /dev/null +++ b/db/routines/salix/triggers/ACL_afterDelete.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `salix`.`ACL_afterDelete` + AFTER DELETE ON `ACL` + FOR EACH ROW +BEGIN + INSERT INTO ACLLog + SET `action` = 'delete', + `changedModel` = 'Acl', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/salix/triggers/ACL_beforeInsert.sql b/db/routines/salix/triggers/ACL_beforeInsert.sql new file mode 100644 index 000000000..94fb51ada --- /dev/null +++ b/db/routines/salix/triggers/ACL_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `salix`.`ACL_beforeInsert` + BEFORE INSERT ON `ACL` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/salix/triggers/ACL_beforeUpdate.sql b/db/routines/salix/triggers/ACL_beforeUpdate.sql new file mode 100644 index 000000000..b214fc9f6 --- /dev/null +++ b/db/routines/salix/triggers/ACL_beforeUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `salix`.`ACL_beforeUpdate` + BEFORE UPDATE ON `ACL` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/srt/events/moving_clean.sql b/db/routines/srt/events/moving_clean.sql index a6f7792a2..18644a9f8 100644 --- a/db/routines/srt/events/moving_clean.sql +++ b/db/routines/srt/events/moving_clean.sql @@ -1,13 +1,9 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `srt`.`moving_clean` - ON SCHEDULE EVERY 5 MINUTE + ON SCHEDULE EVERY 15 MINUTE STARTS '2022-01-21 00:00:00.000' ON COMPLETION PRESERVE ENABLE COMMENT 'Llama a srt.moving_clean para que elimine y notifique de registr' -DO BEGIN - - CALL srt.moving_clean(); - -END$$ +DO CALL srt.moving_clean()$$ DELIMITER ; diff --git a/db/routines/srt/functions/expedition_getDayMinute.sql b/db/routines/srt/functions/expedition_getDayMinute.sql index 9331f77e5..01ff534f5 100644 --- a/db/routines/srt/functions/expedition_getDayMinute.sql +++ b/db/routines/srt/functions/expedition_getDayMinute.sql @@ -22,7 +22,7 @@ BEGIN LEFT JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.routesMonitor rm ON t.routeFk = rm.routeFk - LEFT JOIN vn.roadmapStop rs ON rm.expeditionTruckFk = rs.id + LEFT JOIN vn.roadmapStop rs ON rm.roadmapStopFk = rs.id WHERE e.id = vExpeditionFk; RETURN vDayMinute; diff --git a/db/routines/srt/procedures/moving_clean.sql b/db/routines/srt/procedures/moving_clean.sql index b8fae7ff4..a5bbc7e70 100644 --- a/db/routines/srt/procedures/moving_clean.sql +++ b/db/routines/srt/procedures/moving_clean.sql @@ -3,61 +3,69 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`moving_clean`() BEGIN /** * Elimina movimientos por inactividad - * */ DECLARE vExpeditionFk INT; - DECLARE vBufferToFk INT; DECLARE vBufferFromFk INT; - DECLARE done BOOL DEFAULT FALSE; - - DECLARE cur CURSOR FOR - SELECT m.expeditionFk, m.bufferToFk, m.bufferFromFk - FROM srt.moving m - JOIN srt.config c - JOIN (SELECT bufferFk, SUM(isActive) hasBox - FROM srt.photocell - GROUP BY bufferFk) sub ON sub.bufferFk = m.bufferFromFk - WHERE m.created < TIMESTAMPADD(MINUTE, - c.movingMaxLife , util.VN_NOW()) + DECLARE vStateOutFk INT + DEFAULT (SELECT id FROM expeditionState WHERE `description` = 'OUT'); + DECLARE vDone BOOL; + DECLARE vSorter CURSOR FOR + SELECT m.expeditionFk, m.bufferFromFk + FROM moving m + JOIN ( + SELECT bufferFk, SUM(isActive) hasBox + FROM photocell + GROUP BY bufferFk + ) sub ON sub.bufferFk = m.bufferFromFk + WHERE m.created < (util.VN_NOW() - INTERVAL (SELECT movingMaxLife FROM config) MINUTE) AND NOT sub.hasBox; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - OPEN cur; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; - bucle: LOOP + OPEN vSorter; + l: LOOP + SET vDone = FALSE; + FETCH vSorter INTO vExpeditionFk, vBufferFromFk; - FETCH cur INTO vExpeditionFk, vBufferToFk, vBufferFromFk; - - IF done THEN - LEAVE bucle; + IF vDone THEN + LEAVE l; END IF; - DELETE FROM srt.moving + START TRANSACTION; + + SELECT id + FROM moving + WHERE expeditionFk = vExpeditionFk + FOR UPDATE; + + DELETE FROM moving WHERE expeditionFk = vExpeditionFk; - UPDATE srt.expedition e - JOIN srt.expeditionState es ON es.description = 'OUT' - SET - bufferFk = NULL, + SELECT id + FROM expedition + WHERE id = vExpeditionFk + OR (bufferFk = vBufferFromFk AND `position` > 0) + FOR UPDATE; + + UPDATE expedition + SET bufferFk = NULL, `position` = NULL, - stateFk = es.id - WHERE e.id = vExpeditionFk; + stateFk = vStateOutFk + WHERE id = vExpeditionFk; - UPDATE srt.expedition e - SET e.`position` = e.`position` - 1 - WHERE e.bufferFk = vBufferFromFk - AND e.`position` > 0; - - CALL vn.mail_insert( - 'pako@verdnatura.es, carles@verdnatura.es', - NULL, - CONCAT('Moving_clean. Expedition: ', vExpeditionFk, ' estaba parada'), - CONCAT('Expedition: ', vExpeditionFk,' vBufferToFk: ', vBufferToFk) - ); - - END LOOP bucle; - - CLOSE cur; + UPDATE expedition + SET `position` = `position` - 1 + WHERE bufferFk = vBufferFromFk + AND `position` > 0; + COMMIT; + END LOOP l; + CLOSE vSorter; END$$ DELIMITER ; diff --git a/db/routines/srt/triggers/buffer_afterDelete.sql b/db/routines/srt/triggers/buffer_afterDelete.sql new file mode 100644 index 000000000..d554e6364 --- /dev/null +++ b/db/routines/srt/triggers/buffer_afterDelete.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`buffer_afterDelete` + AFTER DELETE ON `buffer` + FOR EACH ROW +BEGIN + INSERT INTO buffer + SET `action` = 'delete', + `changedModel` = 'Buffer', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/srt/triggers/buffer_beforeInsert.sql b/db/routines/srt/triggers/buffer_beforeInsert.sql new file mode 100644 index 000000000..6b1e05362 --- /dev/null +++ b/db/routines/srt/triggers/buffer_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`buffer_beforeInsert` + BEFORE INSERT ON `buffer` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/srt/triggers/buffer_beforeUpdate.sql b/db/routines/srt/triggers/buffer_beforeUpdate.sql new file mode 100644 index 000000000..86418a551 --- /dev/null +++ b/db/routines/srt/triggers/buffer_beforeUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`buffer_beforeUpdate` + BEFORE UPDATE ON `buffer` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/srt/triggers/config_afterDelete.sql b/db/routines/srt/triggers/config_afterDelete.sql new file mode 100644 index 000000000..1e4af9104 --- /dev/null +++ b/db/routines/srt/triggers/config_afterDelete.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`config_afterDelete` + AFTER DELETE ON `config` + FOR EACH ROW +BEGIN + INSERT INTO config + SET `action` = 'delete', + `changedModel` = 'Config', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/srt/triggers/config_beforeInsert.sql b/db/routines/srt/triggers/config_beforeInsert.sql new file mode 100644 index 000000000..7d8389646 --- /dev/null +++ b/db/routines/srt/triggers/config_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`config_beforeInsert` + BEFORE INSERT ON `config` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/srt/triggers/config_beforeUpdate.sql b/db/routines/srt/triggers/config_beforeUpdate.sql new file mode 100644 index 000000000..0002fb4d6 --- /dev/null +++ b/db/routines/srt/triggers/config_beforeUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `srt`.`config_beforeUpdate` + BEFORE UPDATE ON `config` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/srt/views/bufferDayMinute.sql b/db/routines/srt/views/bufferDayMinute.sql index 41db2bcf7..d2108e513 100644 --- a/db/routines/srt/views/bufferDayMinute.sql +++ b/db/routines/srt/views/bufferDayMinute.sql @@ -34,7 +34,7 @@ FROM ( ) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`) ) - LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`expeditionTruckFk` = `rs`.`id`) + LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`roadmapStopFk` = `rs`.`id`) ) LEFT JOIN `vn`.`zone` `z` ON(`z`.`id` = `t`.`zoneFk`) ) diff --git a/db/routines/srt/views/bufferStock.sql b/db/routines/srt/views/bufferStock.sql index 7494cf0a9..ca04d3c01 100644 --- a/db/routines/srt/views/bufferStock.sql +++ b/db/routines/srt/views/bufferStock.sql @@ -45,7 +45,7 @@ FROM ( ) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`) ) - LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`expeditionTruckFk` = `rs`.`id`) + LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`roadmapStopFk` = `rs`.`id`) ) JOIN `srt`.`config` `c` ) diff --git a/db/routines/srt/views/upperStickers.sql b/db/routines/srt/views/upperStickers.sql index a230408d9..1cd72c12b 100644 --- a/db/routines/srt/views/upperStickers.sql +++ b/db/routines/srt/views/upperStickers.sql @@ -32,7 +32,7 @@ FROM ( ) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`) ) - LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`expeditionTruckFk` = `rs`.`id`) + LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`roadmapStopFk` = `rs`.`id`) ) JOIN `dipole`.`expedition_PrintOut` `epo` ON(`epo`.`expeditionFk` = `e`.`id`) ) diff --git a/db/routines/stock/procedures/log_refreshSale.sql b/db/routines/stock/procedures/log_refreshSale.sql index 983616dca..3054f8ecb 100644 --- a/db/routines/stock/procedures/log_refreshSale.sql +++ b/db/routines/stock/procedures/log_refreshSale.sql @@ -16,12 +16,13 @@ BEGIN m.created, TIMESTAMPADD(DAY, tp.life, t.shipped) expired, m.quantity < 0 isIn, - m.isPicked OR s.alertLevel > 1 isPicked + m.isPicked OR s.alertLevel > al.id isPicked FROM vn.sale m JOIN vn.ticket t ON t.id = m.ticketFk JOIN vn.ticketState s ON s.ticketFk = t.id JOIN vn.item i ON i.id = m.itemFk JOIN vn.itemType tp ON tp.id = i.typeFk + JOIN vn.alertLevel al ON al.code = 'ON_PREPARATION' WHERE ( vTableId IS NULL OR (vTableName = 'ticket' AND t.id = vTableId) diff --git a/db/routines/util/events/log_clean.sql b/db/routines/util/events/log_clean.sql new file mode 100644 index 000000000..8447069e6 --- /dev/null +++ b/db/routines/util/events/log_clean.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `util`.`log_clean` + ON SCHEDULE EVERY 1 DAY + STARTS '2024-07-09 00:30:00.000' + ON COMPLETION PRESERVE + ENABLE +DO CALL util.log_clean$$ +DELIMITER ; diff --git a/db/routines/util/functions/midnight.sql b/db/routines/util/functions/midnight.sql index c80abdbb0..b37415682 100644 --- a/db/routines/util/functions/midnight.sql +++ b/db/routines/util/functions/midnight.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`midnight`() RETURNS datetime - NOT DETERMINISTIC + DETERMINISTIC READS SQL DATA BEGIN diff --git a/db/routines/util/procedures/debugAdd.sql b/db/routines/util/procedures/debugAdd.sql index 8c690376e..a8f7b3aa2 100644 --- a/db/routines/util/procedures/debugAdd.sql +++ b/db/routines/util/procedures/debugAdd.sql @@ -1,5 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`debugAdd`(vVariable VARCHAR(255), vValue VARCHAR(255)) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`debugAdd`( + vVariable VARCHAR(255), + vValue TEXT +) MODIFIES SQL DATA BEGIN /** diff --git a/db/routines/util/procedures/log_clean.sql b/db/routines/util/procedures/log_clean.sql new file mode 100644 index 000000000..aeed9dc44 --- /dev/null +++ b/db/routines/util/procedures/log_clean.sql @@ -0,0 +1,54 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`log_clean`() +BEGIN +/** + * Hace limpieza de los datos de las tablas log, + * dejando únicamente los días de retención configurados. + */ + DECLARE vSchemaName VARCHAR(65); + DECLARE vSchemaNameQuoted VARCHAR(65); + DECLARE vTableName VARCHAR(65); + DECLARE vTableNameQuoted VARCHAR(65); + DECLARE vRetentionDays INT; + DECLARE vStarted DATETIME; + DECLARE vDated DATE; + DECLARE vDone BOOL; + + DECLARE vQueue CURSOR FOR + SELECT schemaName, tableName, retentionDays + FROM logCleanMultiConfig + ORDER BY `order`; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vQueue; + l: LOOP + SET vDone = FALSE; + FETCH vQueue INTO vSchemaName, vTableName, vRetentionDays; + + IF vDone THEN + LEAVE l; + END IF; + + IF vRetentionDays THEN + SET vStarted = VN_NOW(); + SET vSchemaNameQuoted = quoteIdentifier(vSchemaName); + SET vTableNameQuoted = quoteIdentifier(vTableName); + SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY; + + EXECUTE IMMEDIATE CONCAT( + 'DELETE FROM ', vSchemaNameQuoted, + '.', vTableNameQuoted, + " WHERE creationDate < '", vDated, "'" + ); + + UPDATE logCleanMultiConfig + SET `started` = vStarted, + `finished` = VN_NOW() + WHERE schemaName = vSchemaName + AND tableName = vTableName; + END IF; + END LOOP; + CLOSE vQueue; +END$$ +DELIMITER ; diff --git a/db/routines/util/procedures/tx_commit.sql b/db/routines/util/procedures/tx_commit.sql index fdf2f3ddb..35f96df8d 100644 --- a/db/routines/util/procedures/tx_commit.sql +++ b/db/routines/util/procedures/tx_commit.sql @@ -1,12 +1,12 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_commit`(isTx BOOL) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_commit`(vIsTx BOOL) BEGIN /** * Confirma los cambios asociados a una transacción. * - * @param isTx es true si existe transacción asociada + * @param vIsTx es true si existe transacción asociada */ - IF isTx THEN + IF vIsTx THEN COMMIT; END IF; END$$ diff --git a/db/routines/util/procedures/tx_rollback.sql b/db/routines/util/procedures/tx_rollback.sql index 96571af2c..4b00f9ec1 100644 --- a/db/routines/util/procedures/tx_rollback.sql +++ b/db/routines/util/procedures/tx_rollback.sql @@ -1,12 +1,12 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_rollback`(isTx BOOL) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_rollback`(vIsTx BOOL) BEGIN /** * Deshace los cambios asociados a una transacción. * - * @param isTx es true si existe transacción asociada + * @param vIsTx es true si existe transacción asociada */ - IF isTx THEN + IF vIsTx THEN ROLLBACK; END IF; END$$ diff --git a/db/routines/util/procedures/tx_start.sql b/db/routines/util/procedures/tx_start.sql index 9d9f16bb7..41f8c94ee 100644 --- a/db/routines/util/procedures/tx_start.sql +++ b/db/routines/util/procedures/tx_start.sql @@ -1,12 +1,12 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_start`(isTx BOOL) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_start`(vIsTx BOOL) BEGIN /** * Inicia una transacción. * - * @param isTx es true si existe transacción asociada + * @param vIsTx es true si existe transacción asociada */ - IF isTx THEN + IF vIsTx THEN START TRANSACTION; END IF; END$$ diff --git a/db/routines/vn/events/claim_changeState.sql b/db/routines/vn/events/claim_changeState.sql new file mode 100644 index 000000000..2d8968af8 --- /dev/null +++ b/db/routines/vn/events/claim_changeState.sql @@ -0,0 +1,22 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`claim_changeState` + ON SCHEDULE EVERY 1 DAY + STARTS '2024-06-06 07:52:46.000' + ON COMPLETION PRESERVE + ENABLE +DO BEGIN + + DECLARE vClaimState INT; + + SELECT id INTO vClaimState + FROM claimState cs + WHERE cs.code = 'canceled'; + + UPDATE claim c + JOIN claimState cs ON cs.id = c.claimStateFk + SET c.claimStateFk = vClaimState + WHERE c.created < util.VN_CURDATE() - INTERVAL 2 MONTH + AND cs.code IN('incomplete','coming','waiting','out'); + +END$$ +DELIMITER ; diff --git a/db/routines/vn/events/client_unassignSalesPerson.sql b/db/routines/vn/events/client_unassignSalesPerson.sql index 46ad414b1..ffd83fbf6 100644 --- a/db/routines/vn/events/client_unassignSalesPerson.sql +++ b/db/routines/vn/events/client_unassignSalesPerson.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`client_unassignSalesPerson` +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`client_unassignSalesPerson` ON SCHEDULE EVERY 1 DAY STARTS '2023-06-01 03:30:00.000' ON COMPLETION PRESERVE diff --git a/db/routines/vn/events/client_userDisable.sql b/db/routines/vn/events/client_userDisable.sql index b3354f8fd..6ecc05add 100644 --- a/db/routines/vn/events/client_userDisable.sql +++ b/db/routines/vn/events/client_userDisable.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`client_userDisable` +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`client_userDisable` ON SCHEDULE EVERY 1 MONTH STARTS '2023-06-01 00:00:00.000' ON COMPLETION PRESERVE diff --git a/db/routines/vn/events/collection_make.sql b/db/routines/vn/events/collection_make.sql index 1c6bd0fcb..940b11d93 100644 --- a/db/routines/vn/events/collection_make.sql +++ b/db/routines/vn/events/collection_make.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`collection_make` +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`collection_make` ON SCHEDULE EVERY 5 MINUTE STARTS '2022-09-15 00:00:00.000' ON COMPLETION PRESERVE diff --git a/db/routines/vn/events/department_doCalc.sql b/db/routines/vn/events/department_doCalc.sql index b3ce49fa5..09734fbde 100644 --- a/db/routines/vn/events/department_doCalc.sql +++ b/db/routines/vn/events/department_doCalc.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`department_doCalc` +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`department_doCalc` ON SCHEDULE EVERY 15 SECOND STARTS '2019-11-15 00:00:00.000' ON COMPLETION PRESERVE diff --git a/db/routines/vn/events/envialiaThreHoldChecker.sql b/db/routines/vn/events/envialiaThreHoldChecker.sql index a5440ef67..46f27c2ac 100644 --- a/db/routines/vn/events/envialiaThreHoldChecker.sql +++ b/db/routines/vn/events/envialiaThreHoldChecker.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`envialiaThreHoldChecker` +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`envialiaThreHoldChecker` ON SCHEDULE EVERY 1 DAY STARTS '2022-01-28 09:52:46.000' ON COMPLETION NOT PRESERVE diff --git a/db/routines/vn/events/greuge_notify.sql b/db/routines/vn/events/greuge_notify.sql index 8c23dbe36..c89373d54 100644 --- a/db/routines/vn/events/greuge_notify.sql +++ b/db/routines/vn/events/greuge_notify.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`greuge_notify` +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`greuge_notify` ON SCHEDULE EVERY 1 DAY STARTS '2023-01-01 00:07:00.000' ON COMPLETION NOT PRESERVE diff --git a/db/routines/vn/events/itemImageQueue_check.sql b/db/routines/vn/events/itemImageQueue_check.sql index 680faa37f..01a97613b 100644 --- a/db/routines/vn/events/itemImageQueue_check.sql +++ b/db/routines/vn/events/itemImageQueue_check.sql @@ -1,11 +1,11 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`itemImageQueue_check` +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`itemImageQueue_check` ON SCHEDULE EVERY 1 HOUR STARTS '2023-07-28 00:00:00.000' ON COMPLETION PRESERVE ENABLE -DO BEGIN - DELETE FROM itemImageQueue - WHERE attempts >= (SELECT downloadMaxAttempts FROM itemConfig); +DO BEGIN + DELETE FROM itemImageQueue + WHERE attempts >= (SELECT downloadMaxAttempts FROM itemConfig); END$$ DELIMITER ; diff --git a/db/routines/vn/events/itemShelvingSale_doReserve.sql b/db/routines/vn/events/itemShelvingSale_doReserve.sql new file mode 100644 index 000000000..b8a1a14ec --- /dev/null +++ b/db/routines/vn/events/itemShelvingSale_doReserve.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`itemShelvingSale_doReserve` + ON SCHEDULE EVERY 15 SECOND + STARTS '2023-10-16 00:00:00' + ON COMPLETION PRESERVE + ENABLE +DO CALL vn.itemShelvingSale_doReserve$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/events/mysqlConnectionsSorter_kill.sql b/db/routines/vn/events/mysqlConnectionsSorter_kill.sql index 1f5d46b18..1d87ceb82 100644 --- a/db/routines/vn/events/mysqlConnectionsSorter_kill.sql +++ b/db/routines/vn/events/mysqlConnectionsSorter_kill.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`mysqlConnectionsSorter_kill` +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`mysqlConnectionsSorter_kill` ON SCHEDULE EVERY 1 MINUTE STARTS '2021-10-28 09:56:27.000' ON COMPLETION NOT PRESERVE diff --git a/db/routines/vn/events/printQueue_check.sql b/db/routines/vn/events/printQueue_check.sql index 262ddc7c8..cddba8cf8 100644 --- a/db/routines/vn/events/printQueue_check.sql +++ b/db/routines/vn/events/printQueue_check.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`printQueue_check` +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`printQueue_check` ON SCHEDULE EVERY 10 MINUTE STARTS '2022-01-28 09:52:46.000' ON COMPLETION PRESERVE diff --git a/db/routines/vn/events/raidUpdate.sql b/db/routines/vn/events/raidUpdate.sql index 619dadb48..c0c6f03c5 100644 --- a/db/routines/vn/events/raidUpdate.sql +++ b/db/routines/vn/events/raidUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`raidUpdate` +CREATE OR REPLACE DEFINER=`vn`@`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/route_doRecalc.sql b/db/routines/vn/events/route_doRecalc.sql index 62f75a3bc..4e6a77674 100644 --- a/db/routines/vn/events/route_doRecalc.sql +++ b/db/routines/vn/events/route_doRecalc.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`route_doRecalc` +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`route_doRecalc` ON SCHEDULE EVERY 10 SECOND STARTS '2021-07-08 07:32:23.000' ON COMPLETION PRESERVE diff --git a/db/routines/vn/events/travel_setDelivered.sql b/db/routines/vn/events/travel_setDelivered.sql new file mode 100644 index 000000000..396f3e144 --- /dev/null +++ b/db/routines/vn/events/travel_setDelivered.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`travel_setDelivered` + ON SCHEDULE EVERY 1 DAY + STARTS '2024-07-12 00:10:00.000' + ON COMPLETION PRESERVE + ENABLE +DO BEGIN + UPDATE travel t + SET t.isDelivered = TRUE + WHERE t.shipped < util.VN_CURDATE(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/events/vehicle_notify.sql b/db/routines/vn/events/vehicle_notify.sql index d974e1817..edeecd1f8 100644 --- a/db/routines/vn/events/vehicle_notify.sql +++ b/db/routines/vn/events/vehicle_notify.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`vehicle_notify` +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`vehicle_notify` ON SCHEDULE EVERY 1 DAY STARTS '2022-01-01 00:07:00.000' ON COMPLETION NOT PRESERVE diff --git a/db/routines/vn/events/workerJourney_doRecalc.sql b/db/routines/vn/events/workerJourney_doRecalc.sql index 61077fc5b..a3f19929d 100644 --- a/db/routines/vn/events/workerJourney_doRecalc.sql +++ b/db/routines/vn/events/workerJourney_doRecalc.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`workerJourney_doRecalc` +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`workerJourney_doRecalc` ON SCHEDULE EVERY 1 DAY STARTS '2023-07-22 04:00:00.000' ON COMPLETION PRESERVE diff --git a/db/routines/vn/events/worker_updateChangedBusiness.sql b/db/routines/vn/events/worker_updateChangedBusiness.sql index 02f7af8aa..6f6c15650 100644 --- a/db/routines/vn/events/worker_updateChangedBusiness.sql +++ b/db/routines/vn/events/worker_updateChangedBusiness.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`worker_updateChangedBusiness` +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`worker_updateChangedBusiness` ON SCHEDULE EVERY 1 DAY STARTS '2000-01-01 00:00:05.000' ON COMPLETION NOT PRESERVE diff --git a/db/routines/vn/events/zoneGeo_doCalc.sql b/db/routines/vn/events/zoneGeo_doCalc.sql index 579141e13..ca2a54f94 100644 --- a/db/routines/vn/events/zoneGeo_doCalc.sql +++ b/db/routines/vn/events/zoneGeo_doCalc.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`zoneGeo_doCalc` +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`zoneGeo_doCalc` ON SCHEDULE EVERY 15 SECOND STARTS '2019-09-13 15:30:47.000' ON COMPLETION PRESERVE diff --git a/db/routines/vn/functions/MIDNIGHT.sql b/db/routines/vn/functions/MIDNIGHT.sql deleted file mode 100644 index c2df0c0c6..000000000 --- a/db/routines/vn/functions/MIDNIGHT.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`MIDNIGHT`(vDate DATE) - RETURNS datetime - DETERMINISTIC -BEGIN - RETURN TIMESTAMP(vDate,'23:59:59'); -END$$ -DELIMITER ; diff --git a/db/routines/vn/functions/addressTaxArea.sql b/db/routines/vn/functions/addressTaxArea.sql index 1d4e9e2f0..3cad7a55d 100644 --- a/db/routines/vn/functions/addressTaxArea.sql +++ b/db/routines/vn/functions/addressTaxArea.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`addressTaxArea`(vAddresId INT, vCompanyId INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`addressTaxArea`(vAddresId INT, vCompanyId INT) RETURNS varchar(25) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/address_getGeo.sql b/db/routines/vn/functions/address_getGeo.sql index 1a9f5ddb8..04155c30c 100644 --- a/db/routines/vn/functions/address_getGeo.sql +++ b/db/routines/vn/functions/address_getGeo.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`address_getGeo`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`address_getGeo`(vSelf INT) RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/barcodeToItem.sql b/db/routines/vn/functions/barcodeToItem.sql index ee0315118..14d19fe4e 100644 --- a/db/routines/vn/functions/barcodeToItem.sql +++ b/db/routines/vn/functions/barcodeToItem.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`barcodeToItem`(vBarcode VARCHAR(22)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`barcodeToItem`(vBarcode VARCHAR(22)) RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/buy_getUnitVolume.sql b/db/routines/vn/functions/buy_getUnitVolume.sql index baf300450..473ea8fc0 100644 --- a/db/routines/vn/functions/buy_getUnitVolume.sql +++ b/db/routines/vn/functions/buy_getUnitVolume.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`buy_getUnitVolume`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getUnitVolume`(vSelf INT) RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/buy_getVolume.sql b/db/routines/vn/functions/buy_getVolume.sql index c29c0a57c..55027d7e5 100644 --- a/db/routines/vn/functions/buy_getVolume.sql +++ b/db/routines/vn/functions/buy_getVolume.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`buy_getVolume`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getVolume`(vSelf INT) RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/catalog_componentReverse.sql b/db/routines/vn/functions/catalog_componentReverse.sql index f37b20890..c333654da 100644 --- a/db/routines/vn/functions/catalog_componentReverse.sql +++ b/db/routines/vn/functions/catalog_componentReverse.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`catalog_componentReverse`(vWarehouse INT, +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`catalog_componentReverse`(vWarehouse INT, vCost DECIMAL(10,3), vM3 DECIMAL(10,3), vAddressFk INT, diff --git a/db/routines/vn/functions/clientGetMana.sql b/db/routines/vn/functions/clientGetMana.sql index fa983c2b2..4c26ae79b 100644 --- a/db/routines/vn/functions/clientGetMana.sql +++ b/db/routines/vn/functions/clientGetMana.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`clientGetMana`(vClient INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`clientGetMana`(vClient INT) RETURNS decimal(10,2) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/clientGetSalesPerson.sql b/db/routines/vn/functions/clientGetSalesPerson.sql index 4b8601be3..2502aa196 100644 --- a/db/routines/vn/functions/clientGetSalesPerson.sql +++ b/db/routines/vn/functions/clientGetSalesPerson.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`clientGetSalesPerson`(vClientFk INT, vDated DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`clientGetSalesPerson`(vClientFk INT, vDated DATE) RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/clientTaxArea.sql b/db/routines/vn/functions/clientTaxArea.sql index f03520b0b..1c2f776f1 100644 --- a/db/routines/vn/functions/clientTaxArea.sql +++ b/db/routines/vn/functions/clientTaxArea.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`clientTaxArea`(vClientId INT, vCompanyId INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`clientTaxArea`(vClientId INT, vCompanyId INT) RETURNS varchar(25) CHARSET utf8mb3 COLLATE utf8mb3_general_ci NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/client_getDebt.sql b/db/routines/vn/functions/client_getDebt.sql index 8c715d2db..c35e61c30 100644 --- a/db/routines/vn/functions/client_getDebt.sql +++ b/db/routines/vn/functions/client_getDebt.sql @@ -1,8 +1,8 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`client_getDebt`(`vClient` INT, `vDate` DATE) - RETURNS decimal(10,2) - NOT DETERMINISTIC - READS SQL DATA +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`client_getDebt`(`vClient` INT, `vDate` DATE) + RETURNS decimal(10,2) + NOT DETERMINISTIC + READS SQL DATA BEGIN /** * Returns the risk of a customer. @@ -34,5 +34,5 @@ BEGIN tmp.risk; RETURN vDebt; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/vn/functions/client_getFromPhone.sql b/db/routines/vn/functions/client_getFromPhone.sql index c6ded691b..3ddf3419c 100644 --- a/db/routines/vn/functions/client_getFromPhone.sql +++ b/db/routines/vn/functions/client_getFromPhone.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`client_getFromPhone`(vPhone VARCHAR(255)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`client_getFromPhone`(vPhone VARCHAR(255)) RETURNS int(11) DETERMINISTIC BEGIN @@ -11,10 +11,7 @@ BEGIN */ DECLARE vClient INT DEFAULT NULL; - -- SET vPhone = vPhone COLLATE 'utf8_unicode_ci'; - - DROP TEMPORARY TABLE IF EXISTS tClient; - CREATE TEMPORARY TABLE tClient + CREATE OR REPLACE TEMPORARY TABLE tClient ENGINE = MEMORY SELECT id clientFk FROM `client` @@ -27,13 +24,14 @@ BEGIN OR mobile = vPhone UNION SELECT clientFk - FROM vn.clientContact + FROM clientContact WHERE phone = vPhone; SELECT t.clientFk INTO vClient FROM tClient t JOIN `client` c ON c.id = t.clientFk WHERE c.isActive + AND c.salesPersonFk LIMIT 1; DROP TEMPORARY TABLE tClient; diff --git a/db/routines/vn/functions/client_getSalesPerson.sql b/db/routines/vn/functions/client_getSalesPerson.sql index c53816f7f..d0152e0aa 100644 --- a/db/routines/vn/functions/client_getSalesPerson.sql +++ b/db/routines/vn/functions/client_getSalesPerson.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`client_getSalesPerson`(vClientFk INT, vDated DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`client_getSalesPerson`(vClientFk INT, vDated DATE) RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/client_getSalesPersonByTicket.sql b/db/routines/vn/functions/client_getSalesPersonByTicket.sql index 640df11ce..4c98ac526 100644 --- a/db/routines/vn/functions/client_getSalesPersonByTicket.sql +++ b/db/routines/vn/functions/client_getSalesPersonByTicket.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`client_getSalesPersonByTicket`(vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`client_getSalesPersonByTicket`(vTicketFk INT) RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/client_getSalesPersonCode.sql b/db/routines/vn/functions/client_getSalesPersonCode.sql index 69b8424d8..b238f26bf 100644 --- a/db/routines/vn/functions/client_getSalesPersonCode.sql +++ b/db/routines/vn/functions/client_getSalesPersonCode.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`client_getSalesPersonCode`(vClientFk INT, vDated DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`client_getSalesPersonCode`(vClientFk INT, vDated DATE) RETURNS varchar(3) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/client_getSalesPersonCodeByTicket.sql b/db/routines/vn/functions/client_getSalesPersonCodeByTicket.sql index 3ec5a8e9d..9e63708f3 100644 --- a/db/routines/vn/functions/client_getSalesPersonCodeByTicket.sql +++ b/db/routines/vn/functions/client_getSalesPersonCodeByTicket.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`client_getSalesPersonCodeByTicket`(vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`client_getSalesPersonCodeByTicket`(vTicketFk INT) RETURNS varchar(3) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/client_hasDifferentCountries.sql b/db/routines/vn/functions/client_hasDifferentCountries.sql index a90b774c7..5f4831069 100644 --- a/db/routines/vn/functions/client_hasDifferentCountries.sql +++ b/db/routines/vn/functions/client_hasDifferentCountries.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`client_hasDifferentCountries`(vClientFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`client_hasDifferentCountries`(vClientFk INT) RETURNS tinyint(1) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/collection_isPacked.sql b/db/routines/vn/functions/collection_isPacked.sql index 9f148273f..f7d81b4c0 100644 --- a/db/routines/vn/functions/collection_isPacked.sql +++ b/db/routines/vn/functions/collection_isPacked.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`collection_isPacked`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`collection_isPacked`(vSelf INT) RETURNS tinyint(1) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/currency_getCommission.sql b/db/routines/vn/functions/currency_getCommission.sql index b0a591c23..1b5d51ee6 100644 --- a/db/routines/vn/functions/currency_getCommission.sql +++ b/db/routines/vn/functions/currency_getCommission.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`currency_getCommission`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`currency_getCommission`(vSelf INT) RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/currentRate.sql b/db/routines/vn/functions/currentRate.sql index 57870fca4..6d18b9613 100644 --- a/db/routines/vn/functions/currentRate.sql +++ b/db/routines/vn/functions/currentRate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`currentRate`(vCurrencyFk INT, vDated DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`currentRate`(vCurrencyFk INT, vDated DATE) RETURNS decimal(10,4) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/deviceProductionUser_accessGranted.sql b/db/routines/vn/functions/deviceProductionUser_accessGranted.sql index a2d39a0ab..b0c5f0e90 100644 --- a/db/routines/vn/functions/deviceProductionUser_accessGranted.sql +++ b/db/routines/vn/functions/deviceProductionUser_accessGranted.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`deviceProductionUser_accessGranted`(vUserFK INT(10) , android_id VARCHAR(50)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`deviceProductionUser_accessGranted`(vUserFK INT(10) , android_id VARCHAR(50)) RETURNS tinyint(1) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/duaTax_getRate.sql b/db/routines/vn/functions/duaTax_getRate.sql index a11015066..ee74a24fe 100644 --- a/db/routines/vn/functions/duaTax_getRate.sql +++ b/db/routines/vn/functions/duaTax_getRate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`duaTax_getRate`(vDuaFk INT, vTaxClassFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`duaTax_getRate`(vDuaFk INT, vTaxClassFk INT) RETURNS decimal(5,2) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/ekt_getEntry.sql b/db/routines/vn/functions/ekt_getEntry.sql index c629098a6..4e6824682 100644 --- a/db/routines/vn/functions/ekt_getEntry.sql +++ b/db/routines/vn/functions/ekt_getEntry.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ekt_getEntry`(vEktFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ekt_getEntry`(vEktFk INT) RETURNS int(11) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/ekt_getTravel.sql b/db/routines/vn/functions/ekt_getTravel.sql index 4cf7f5631..a4466eb84 100644 --- a/db/routines/vn/functions/ekt_getTravel.sql +++ b/db/routines/vn/functions/ekt_getTravel.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ekt_getTravel`(vEntryAssignFk INT, vEktFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ekt_getTravel`(vEntryAssignFk INT, vEktFk INT) RETURNS int(11) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/entry_getCommission.sql b/db/routines/vn/functions/entry_getCommission.sql index 62946407a..4a19f4e63 100644 --- a/db/routines/vn/functions/entry_getCommission.sql +++ b/db/routines/vn/functions/entry_getCommission.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`entry_getCommission`(vTravelFk INT, +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`entry_getCommission`(vTravelFk INT, vCurrencyFk INT, vSupplierFk INT ) diff --git a/db/routines/vn/functions/entry_getCurrency.sql b/db/routines/vn/functions/entry_getCurrency.sql index 4cfce19db..ffde8e029 100644 --- a/db/routines/vn/functions/entry_getCurrency.sql +++ b/db/routines/vn/functions/entry_getCurrency.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`entry_getCurrency`(vCurrency INT, +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`entry_getCurrency`(vCurrency INT, vSupplierFk INT ) RETURNS int(11) diff --git a/db/routines/vn/functions/entry_getForLogiflora.sql b/db/routines/vn/functions/entry_getForLogiflora.sql deleted file mode 100644 index 71f0b585c..000000000 --- a/db/routines/vn/functions/entry_getForLogiflora.sql +++ /dev/null @@ -1,64 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`entry_getForLogiflora`(vLanded DATE, vWarehouseFk INT) - RETURNS int(11) - NOT DETERMINISTIC - READS SQL DATA -BEGIN - - /** - * Devuelve una entrada para Logiflora. Si no existe la crea. - * - * @param vLanded Fecha de llegada al almacén - * @param vWarehouseFk Identificador de vn.warehouse - */ - - DECLARE vTravelFk INT; - DECLARE vEntryFk INT; - DECLARE previousEntryFk INT; - - SET vTravelFk = vn.travel_getForLogiflora(vLanded, vWarehouseFk); - - IF vLanded THEN - - SELECT IFNULL(MAX(id),0) INTO vEntryFk - FROM vn.entry - WHERE travelFk = vTravelFk - AND isRaid; - - IF NOT vEntryFk THEN - - INSERT INTO vn.entry(travelFk, supplierFk, commission, companyFk, currencyFk, isRaid) - SELECT vTravelFk, s.id, 4, c.id, cu.id, TRUE - FROM vn.supplier s - JOIN vn.company c ON c.code = 'VNL' - JOIN vn.currency cu ON cu.code = 'EUR' - WHERE s.name = 'KONINKLIJE COOPERATIEVE BLOEMENVEILING FLORAHOLLAN'; - - SELECT MAX(id) INTO vEntryFk - FROM vn.entry - WHERE travelFk = vTravelFk; - - END IF; - - END IF; - - SELECT entryFk INTO previousEntryFk - FROM edi.warehouseFloramondo wf - WHERE wf.warehouseFk = vWarehouseFk; - - IF IFNULL(previousEntryFk,0) != vEntryFk THEN - - UPDATE buy b - SET b.printedStickers = 0 - WHERE entryFk = previousEntryFk; - - DELETE FROM buy WHERE entryFk = previousEntryFk; - - DELETE FROM entry WHERE id = previousEntryFk; - - END IF; - - RETURN vEntryFk; - -END$$ -DELIMITER ; diff --git a/db/routines/vn/functions/entry_isIntrastat.sql b/db/routines/vn/functions/entry_isIntrastat.sql index 8d46b4a02..79eb7fd86 100644 --- a/db/routines/vn/functions/entry_isIntrastat.sql +++ b/db/routines/vn/functions/entry_isIntrastat.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`entry_isIntrastat`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`entry_isIntrastat`(vSelf INT) RETURNS int(11) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/entry_isInventoryOrPrevious.sql b/db/routines/vn/functions/entry_isInventoryOrPrevious.sql index 4acbf060d..7779f7288 100644 --- a/db/routines/vn/functions/entry_isInventoryOrPrevious.sql +++ b/db/routines/vn/functions/entry_isInventoryOrPrevious.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`entry_isInventoryOrPrevious`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`entry_isInventoryOrPrevious`(vSelf INT) RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/expedition_checkRoute.sql b/db/routines/vn/functions/expedition_checkRoute.sql index 9b2929797..ce27ea391 100644 --- a/db/routines/vn/functions/expedition_checkRoute.sql +++ b/db/routines/vn/functions/expedition_checkRoute.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`expedition_checkRoute`(vPalletFk INT,vExpeditionFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`expedition_checkRoute`(vPalletFk INT,vExpeditionFk INT) RETURNS tinyint(1) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/firstDayOfWeek.sql b/db/routines/vn/functions/firstDayOfWeek.sql index 25ab4480c..d4742771a 100644 --- a/db/routines/vn/functions/firstDayOfWeek.sql +++ b/db/routines/vn/functions/firstDayOfWeek.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`firstDayOfWeek`(vYear INT, vWeek INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`firstDayOfWeek`(vYear INT, vWeek INT) RETURNS date DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/getAlert3State.sql b/db/routines/vn/functions/getAlert3State.sql index f3a7aae53..620ac8d01 100644 --- a/db/routines/vn/functions/getAlert3State.sql +++ b/db/routines/vn/functions/getAlert3State.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`getAlert3State`(vTicket INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`getAlert3State`(vTicket INT) RETURNS varchar(45) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/getDueDate.sql b/db/routines/vn/functions/getDueDate.sql index 694117a52..c2793cb06 100644 --- a/db/routines/vn/functions/getDueDate.sql +++ b/db/routines/vn/functions/getDueDate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`getDueDate`(vDated DATE, vDayToPay INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`getDueDate`(vDated DATE, vDayToPay INT) RETURNS date NOT DETERMINISTIC NO SQL diff --git a/db/routines/vn/functions/getInventoryDate.sql b/db/routines/vn/functions/getInventoryDate.sql index b67f1c384..9c1a5349f 100644 --- a/db/routines/vn/functions/getInventoryDate.sql +++ b/db/routines/vn/functions/getInventoryDate.sql @@ -1,8 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`getInventoryDate`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`getInventoryDate`() RETURNS date DETERMINISTIC -BEGIN - RETURN (SELECT inventoried FROM config LIMIT 1); +BEGIN + RETURN (SELECT inventoried FROM config LIMIT 1); END$$ DELIMITER ; diff --git a/db/routines/vn/functions/getNewItemId.sql b/db/routines/vn/functions/getNewItemId.sql index 2cb9b275b..24c13e28c 100644 --- a/db/routines/vn/functions/getNewItemId.sql +++ b/db/routines/vn/functions/getNewItemId.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`getNewItemId`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`getNewItemId`() RETURNS int(11) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/getNextDueDate.sql b/db/routines/vn/functions/getNextDueDate.sql index 8e8691ec5..d0f923d65 100644 --- a/db/routines/vn/functions/getNextDueDate.sql +++ b/db/routines/vn/functions/getNextDueDate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`getNextDueDate`(vDated DATE, vGapDays INT, vPayDay INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`getNextDueDate`(vDated DATE, vGapDays INT, vPayDay INT) RETURNS date NOT DETERMINISTIC NO SQL diff --git a/db/routines/vn/functions/getShipmentHour.sql b/db/routines/vn/functions/getShipmentHour.sql index 9eca04ac4..5fdd8db32 100644 --- a/db/routines/vn/functions/getShipmentHour.sql +++ b/db/routines/vn/functions/getShipmentHour.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`getShipmentHour`(vTicket INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`getShipmentHour`(vTicket INT) RETURNS int(11) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/getSpecialPrice.sql b/db/routines/vn/functions/getSpecialPrice.sql index 2cc5f2b99..bcb3251f2 100644 --- a/db/routines/vn/functions/getSpecialPrice.sql +++ b/db/routines/vn/functions/getSpecialPrice.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`getSpecialPrice`(vItemFk int(11),vClientFk int(11)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`getSpecialPrice`(vItemFk int(11),vClientFk int(11)) RETURNS decimal(10,2) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/getTicketTrolleyLabelCount.sql b/db/routines/vn/functions/getTicketTrolleyLabelCount.sql index b978db73a..8344e1c69 100644 --- a/db/routines/vn/functions/getTicketTrolleyLabelCount.sql +++ b/db/routines/vn/functions/getTicketTrolleyLabelCount.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`getTicketTrolleyLabelCount`(vTicket INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`getTicketTrolleyLabelCount`(vTicket INT) RETURNS int(11) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/getUser.sql b/db/routines/vn/functions/getUser.sql index eb85b8346..311394b17 100644 --- a/db/routines/vn/functions/getUser.sql +++ b/db/routines/vn/functions/getUser.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`getUser`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`getUser`() RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/getUserId.sql b/db/routines/vn/functions/getUserId.sql index 9afcb8912..d68dabc84 100644 --- a/db/routines/vn/functions/getUserId.sql +++ b/db/routines/vn/functions/getUserId.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`getUserId`(userName varchar(30)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`getUserId`(userName varchar(30)) RETURNS int(11) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/hasAnyNegativeBase.sql b/db/routines/vn/functions/hasAnyNegativeBase.sql index 97d1e7328..d3ca25858 100644 --- a/db/routines/vn/functions/hasAnyNegativeBase.sql +++ b/db/routines/vn/functions/hasAnyNegativeBase.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`hasAnyNegativeBase`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`hasAnyNegativeBase`() RETURNS tinyint(1) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/hasAnyPositiveBase.sql b/db/routines/vn/functions/hasAnyPositiveBase.sql index 7222c3b2a..ea7d8f14b 100644 --- a/db/routines/vn/functions/hasAnyPositiveBase.sql +++ b/db/routines/vn/functions/hasAnyPositiveBase.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`hasAnyPositiveBase`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`hasAnyPositiveBase`() RETURNS tinyint(1) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/hasItemsInSector.sql b/db/routines/vn/functions/hasItemsInSector.sql index 4aa4edb9c..7a5c4cf60 100644 --- a/db/routines/vn/functions/hasItemsInSector.sql +++ b/db/routines/vn/functions/hasItemsInSector.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`hasItemsInSector`(vTicketFk INT, vSectorFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`hasItemsInSector`(vTicketFk INT, vSectorFk INT) RETURNS tinyint(1) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/hasSomeNegativeBase.sql b/db/routines/vn/functions/hasSomeNegativeBase.sql index ea7efe777..af435a6c5 100644 --- a/db/routines/vn/functions/hasSomeNegativeBase.sql +++ b/db/routines/vn/functions/hasSomeNegativeBase.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`hasSomeNegativeBase`(vTicket INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`hasSomeNegativeBase`(vTicket INT) RETURNS tinyint(1) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/intrastat_estimateNet.sql b/db/routines/vn/functions/intrastat_estimateNet.sql index 350cb788a..645fb6406 100644 --- a/db/routines/vn/functions/intrastat_estimateNet.sql +++ b/db/routines/vn/functions/intrastat_estimateNet.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`intrastat_estimateNet`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`intrastat_estimateNet`( vSelf INT, vStems INT ) diff --git a/db/routines/vn/functions/invoiceOutAmount.sql b/db/routines/vn/functions/invoiceOutAmount.sql index 6c66a46f3..447c0883e 100644 --- a/db/routines/vn/functions/invoiceOutAmount.sql +++ b/db/routines/vn/functions/invoiceOutAmount.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`invoiceOutAmount`(vInvoiceRef VARCHAR(15)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`invoiceOutAmount`(vInvoiceRef VARCHAR(15)) RETURNS decimal(10,2) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/invoiceOut_getMaxIssued.sql b/db/routines/vn/functions/invoiceOut_getMaxIssued.sql index dc1a59eaa..687f82dfc 100644 --- a/db/routines/vn/functions/invoiceOut_getMaxIssued.sql +++ b/db/routines/vn/functions/invoiceOut_getMaxIssued.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`invoiceOut_getMaxIssued`(vSerial VARCHAR(2), +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`invoiceOut_getMaxIssued`(vSerial VARCHAR(2), vCompanyFk INT, vYear INT ) diff --git a/db/routines/vn/functions/invoiceOut_getPath.sql b/db/routines/vn/functions/invoiceOut_getPath.sql index 1e174a4cf..7e8850e15 100644 --- a/db/routines/vn/functions/invoiceOut_getPath.sql +++ b/db/routines/vn/functions/invoiceOut_getPath.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`invoiceOut_getPath`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`invoiceOut_getPath`(vSelf INT) RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/invoiceOut_getWeight.sql b/db/routines/vn/functions/invoiceOut_getWeight.sql index 1302c0341..3c16191bb 100644 --- a/db/routines/vn/functions/invoiceOut_getWeight.sql +++ b/db/routines/vn/functions/invoiceOut_getWeight.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`invoiceOut_getWeight`(vInvoiceRef VARCHAR(15) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`invoiceOut_getWeight`(vInvoiceRef VARCHAR(15) ) RETURNS decimal(10,2) NOT DETERMINISTIC diff --git a/db/routines/vn/functions/invoiceSerial.sql b/db/routines/vn/functions/invoiceSerial.sql index 66448ac9c..9c0edf1c3 100644 --- a/db/routines/vn/functions/invoiceSerial.sql +++ b/db/routines/vn/functions/invoiceSerial.sql @@ -1,26 +1,43 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`invoiceSerial`(vClientFk INT, vCompanyFk INT, vType CHAR(1)) - RETURNS char(1) CHARSET utf8mb3 COLLATE utf8mb3_general_ci +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`invoiceSerial`( + vClientFk INT, + vCompanyFk INT, + vType CHAR(15) +) + RETURNS char(2) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN - /** - * Obtiene la serie de de una factura - * dependiendo del area del cliente. - * - * @param vClientFk Id del cliente - * @param vCompanyFk Id de la empresa - * @param vType Tipo de factura ["R", "M", "G"] - * @return Serie de la factura - */ - DECLARE vTaxArea VARCHAR(25); - DECLARE vSerie CHAR(1); +/** +* Obtiene la serie de una factura +* dependiendo del area del cliente. +* +* @param vClientFk Id del cliente +* @param vCompanyFk Id de la empresa +* @param vType Tipo de factura (vn.invoiceOutSerial.type[ENUM]) +* @return vSerie de la factura +*/ + DECLARE vTaxArea VARCHAR(25) COLLATE utf8mb3_general_ci; + DECLARE vTransactionCode INT(2); + DECLARE vSerie CHAR(2); IF (SELECT hasInvoiceSimplified FROM client WHERE id = vClientFk) THEN RETURN 'S'; END IF; - SELECT clientTaxArea(vClientFk, vCompanyFk) INTO vTaxArea; - SELECT invoiceSerialArea(vType,vTaxArea) INTO vSerie; + SELECT addressTaxArea(defaultAddressFk, vCompanyFk) INTO vTaxArea + FROM client + WHERE id = vClientFk; + + SELECT CodigoTransaccion INTO vTransactionCode + FROM taxArea + WHERE code = vTaxArea; + + SELECT ios.code INTO vSerie + FROM invoiceOutSerial ios + JOIN taxArea ta ON ta.code = ios.taxAreaFk + WHERE ios.`type` = vType + AND ta.CodigoTransaccion = vTransactionCode; + RETURN vSerie; END$$ DELIMITER ; diff --git a/db/routines/vn/functions/invoiceSerialArea.sql b/db/routines/vn/functions/invoiceSerialArea.sql deleted file mode 100644 index 02edd83f2..000000000 --- a/db/routines/vn/functions/invoiceSerialArea.sql +++ /dev/null @@ -1,34 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`invoiceSerialArea`(vType CHAR(1), vTaxArea VARCHAR(25)) - RETURNS char(1) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci - DETERMINISTIC -BEGIN - DECLARE vSerie CHAR(1); - - IF vType = 'R' THEN - SELECT - CASE vTaxArea - WHEN 'CEE' THEN 'H' - WHEN 'WORLD' THEN 'E' - ELSE 'T' - END INTO vSerie; - -- Factura multiple - ELSEIF vType = 'M' THEN - SELECT - CASE vTaxArea - WHEN 'CEE' THEN 'H' - WHEN 'WORLD' THEN 'E' - ELSE 'M' - END INTO vSerie; - -- Factura global - ELSEIF vType = 'G' THEN - SELECT - CASE vTaxArea - WHEN 'CEE' THEN 'V' - WHEN 'WORLD' THEN 'X' - ELSE 'A' - END INTO vSerie; - END IF; - RETURN vSerie; -END$$ -DELIMITER ; diff --git a/db/routines/vn/functions/isLogifloraDay.sql b/db/routines/vn/functions/isLogifloraDay.sql index 8e9c9b264..27e8e7551 100644 --- a/db/routines/vn/functions/isLogifloraDay.sql +++ b/db/routines/vn/functions/isLogifloraDay.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`isLogifloraDay`(vShipped DATE, vWarehouse INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`isLogifloraDay`(vShipped DATE, vWarehouse INT) RETURNS tinyint(1) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/itemPacking.sql b/db/routines/vn/functions/itemPacking.sql index 6856c12cd..cc5dfae7a 100644 --- a/db/routines/vn/functions/itemPacking.sql +++ b/db/routines/vn/functions/itemPacking.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`itemPacking`(vBarcode VARCHAR(22), vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`itemPacking`(vBarcode VARCHAR(22), vWarehouseFk INT) RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/itemShelvingPlacementSupply_ClosestGet.sql b/db/routines/vn/functions/itemShelvingPlacementSupply_ClosestGet.sql index 6b5fc3ae3..805045021 100644 --- a/db/routines/vn/functions/itemShelvingPlacementSupply_ClosestGet.sql +++ b/db/routines/vn/functions/itemShelvingPlacementSupply_ClosestGet.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`itemShelvingPlacementSupply_ClosestGet`(vParkingFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`itemShelvingPlacementSupply_ClosestGet`(vParkingFk INT) RETURNS int(11) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/itemTag_getIntValue.sql b/db/routines/vn/functions/itemTag_getIntValue.sql index fa5a03552..3996f71f8 100644 --- a/db/routines/vn/functions/itemTag_getIntValue.sql +++ b/db/routines/vn/functions/itemTag_getIntValue.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`itemTag_getIntValue`(vValue VARCHAR(255)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`itemTag_getIntValue`(vValue VARCHAR(255)) RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/item_getFhImage.sql b/db/routines/vn/functions/item_getFhImage.sql index 13e02e8fe..d5aef592d 100644 --- a/db/routines/vn/functions/item_getFhImage.sql +++ b/db/routines/vn/functions/item_getFhImage.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`item_getFhImage`(itemFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`item_getFhImage`(itemFk INT) RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/item_getPackage.sql b/db/routines/vn/functions/item_getPackage.sql index 894abe4cf..88e40399f 100644 --- a/db/routines/vn/functions/item_getPackage.sql +++ b/db/routines/vn/functions/item_getPackage.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`item_getPackage`(vItemFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`item_getPackage`(vItemFk INT) RETURNS varchar(50) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/item_getVolume.sql b/db/routines/vn/functions/item_getVolume.sql index afcb32c93..f4156e5a6 100644 --- a/db/routines/vn/functions/item_getVolume.sql +++ b/db/routines/vn/functions/item_getVolume.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`item_getVolume`(vSelf INT, vPackaging VARCHAR(10)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`item_getVolume`(vSelf INT, vPackaging VARCHAR(10)) RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/itemsInSector_get.sql b/db/routines/vn/functions/itemsInSector_get.sql index 9054087b3..254ebe1b5 100644 --- a/db/routines/vn/functions/itemsInSector_get.sql +++ b/db/routines/vn/functions/itemsInSector_get.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`itemsInSector_get`(vTicketFk INT, vSectorFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`itemsInSector_get`(vTicketFk INT, vSectorFk INT) RETURNS int(11) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/lastDayOfWeek.sql b/db/routines/vn/functions/lastDayOfWeek.sql index 464bf5afe..0aba5ab7b 100644 --- a/db/routines/vn/functions/lastDayOfWeek.sql +++ b/db/routines/vn/functions/lastDayOfWeek.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`lastDayOfWeek`(vYear INT, vWeek INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`lastDayOfWeek`(vYear INT, vWeek INT) RETURNS date DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/machine_checkPlate.sql b/db/routines/vn/functions/machine_checkPlate.sql index d08ed97c5..8660163e4 100644 --- a/db/routines/vn/functions/machine_checkPlate.sql +++ b/db/routines/vn/functions/machine_checkPlate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`machine_checkPlate`(vPlate VARCHAR(10)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`machine_checkPlate`(vPlate VARCHAR(10)) RETURNS tinyint(1) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/messageSend.sql b/db/routines/vn/functions/messageSend.sql index 8a95118e7..22cca43ec 100644 --- a/db/routines/vn/functions/messageSend.sql +++ b/db/routines/vn/functions/messageSend.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`messageSend`(vRecipient VARCHAR(255) CHARSET utf8, vMessage TEXT CHARSET utf8) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`messageSend`(vRecipient VARCHAR(255) CHARSET utf8, vMessage TEXT CHARSET utf8) RETURNS int(11) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/messageSendWithUser.sql b/db/routines/vn/functions/messageSendWithUser.sql index 1d5b730a8..f8bfde2e4 100644 --- a/db/routines/vn/functions/messageSendWithUser.sql +++ b/db/routines/vn/functions/messageSendWithUser.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`messageSendWithUser`(vSenderFK INT, vRecipient VARCHAR(255) CHARSET utf8, vMessage TEXT CHARSET utf8) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`messageSendWithUser`(vSenderFK INT, vRecipient VARCHAR(255) CHARSET utf8, vMessage TEXT CHARSET utf8) RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/orderTotalVolume.sql b/db/routines/vn/functions/orderTotalVolume.sql index 962baa8ec..7962a9a73 100644 --- a/db/routines/vn/functions/orderTotalVolume.sql +++ b/db/routines/vn/functions/orderTotalVolume.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`orderTotalVolume`(vOrderId INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`orderTotalVolume`(vOrderId INT) RETURNS decimal(10,3) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/orderTotalVolumeBoxes.sql b/db/routines/vn/functions/orderTotalVolumeBoxes.sql index cbc0e94ac..3474534c4 100644 --- a/db/routines/vn/functions/orderTotalVolumeBoxes.sql +++ b/db/routines/vn/functions/orderTotalVolumeBoxes.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`orderTotalVolumeBoxes`(vOrderId INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`orderTotalVolumeBoxes`(vOrderId INT) RETURNS decimal(10,3) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/packaging_calculate.sql b/db/routines/vn/functions/packaging_calculate.sql index c9aaf07b9..01ec8b843 100644 --- a/db/routines/vn/functions/packaging_calculate.sql +++ b/db/routines/vn/functions/packaging_calculate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`packaging_calculate`(isPackageReturnable TINYINT(1), +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`packaging_calculate`(isPackageReturnable TINYINT(1), packagingReturnFk INT(11), base DECIMAL(10,2), price DECIMAL(10,2), diff --git a/db/routines/vn/functions/priceFixed_getRate2.sql b/db/routines/vn/functions/priceFixed_getRate2.sql index d97a20e59..61e5abe9b 100644 --- a/db/routines/vn/functions/priceFixed_getRate2.sql +++ b/db/routines/vn/functions/priceFixed_getRate2.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`priceFixed_getRate2`(vFixedPriceFk INT, vRate3 DOUBLE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`priceFixed_getRate2`(vFixedPriceFk INT, vRate3 DOUBLE) RETURNS double NOT DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/routeProposal.sql b/db/routines/vn/functions/routeProposal.sql index 81b5d9048..14b626a39 100644 --- a/db/routines/vn/functions/routeProposal.sql +++ b/db/routines/vn/functions/routeProposal.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`routeProposal`(vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`routeProposal`(vTicketFk INT) RETURNS int(11) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/routeProposal_.sql b/db/routines/vn/functions/routeProposal_.sql deleted file mode 100644 index b4559c10c..000000000 --- a/db/routines/vn/functions/routeProposal_.sql +++ /dev/null @@ -1,30 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`routeProposal_`(vTicketFk INT) - RETURNS int(11) - NOT DETERMINISTIC - READS SQL DATA -BEGIN - - DECLARE vRouteFk INT; - DECLARE vAddressFk INT; - DECLARE vShipped DATETIME; - - SELECT addressFk, date(shipped) INTO vAddressFk, vShipped - FROM vn.ticket - WHERE id = vTicketFk; - - SELECT routeFk INTO vRouteFk - FROM - (SELECT t.routeFk, sum(af.friendship) friendshipSum - FROM vn.ticket t - JOIN cache.addressFriendship af ON af.addressFk2 = t.addressFk AND af.addressFk1 = vAddressFk - WHERE t.shipped BETWEEN vShipped and MIDNIGHT(vShipped) - AND t.routeFk - GROUP BY routeFk - ORDER BY friendshipSum DESC - ) sub - LIMIT 1; - - RETURN vRouteFk; -END$$ -DELIMITER ; diff --git a/db/routines/vn/functions/routeProposal_beta.sql b/db/routines/vn/functions/routeProposal_beta.sql index 4ec17d3ed..d6db4d361 100644 --- a/db/routines/vn/functions/routeProposal_beta.sql +++ b/db/routines/vn/functions/routeProposal_beta.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`routeProposal_beta`(vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`routeProposal_beta`(vTicketFk INT) RETURNS int(11) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/sale_hasComponentLack.sql b/db/routines/vn/functions/sale_hasComponentLack.sql index 912d5f107..a7ccfeec6 100644 --- a/db/routines/vn/functions/sale_hasComponentLack.sql +++ b/db/routines/vn/functions/sale_hasComponentLack.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`sale_hasComponentLack`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`sale_hasComponentLack`( vSelf INT )RETURNS tinyint(1) READS SQL DATA diff --git a/db/routines/vn/functions/specie_IsForbidden.sql b/db/routines/vn/functions/specie_IsForbidden.sql index 5e7275ae7..a8ed12a50 100644 --- a/db/routines/vn/functions/specie_IsForbidden.sql +++ b/db/routines/vn/functions/specie_IsForbidden.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`specie_IsForbidden`(vItemFk INT, vAddressFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`specie_IsForbidden`(vItemFk INT, vAddressFk INT) RETURNS tinyint(1) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/testCIF.sql b/db/routines/vn/functions/testCIF.sql index ba2cc8345..f6acd8fb9 100644 --- a/db/routines/vn/functions/testCIF.sql +++ b/db/routines/vn/functions/testCIF.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`testCIF`(vCIF VARCHAR(9)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`testCIF`(vCIF VARCHAR(9)) RETURNS varchar(10) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/testNIE.sql b/db/routines/vn/functions/testNIE.sql index 6843becad..fdc371233 100644 --- a/db/routines/vn/functions/testNIE.sql +++ b/db/routines/vn/functions/testNIE.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`testNIE`(vNIE VARCHAR(9)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`testNIE`(vNIE VARCHAR(9)) RETURNS tinyint(1) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/testNIF.sql b/db/routines/vn/functions/testNIF.sql index 5b6654312..59e59a456 100644 --- a/db/routines/vn/functions/testNIF.sql +++ b/db/routines/vn/functions/testNIF.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`testNIF`(vNIF VARCHAR(9)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`testNIF`(vNIF VARCHAR(9)) RETURNS tinyint(1) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/ticketCollection_getNoPacked.sql b/db/routines/vn/functions/ticketCollection_getNoPacked.sql index a9f04cc88..10065faf5 100644 --- a/db/routines/vn/functions/ticketCollection_getNoPacked.sql +++ b/db/routines/vn/functions/ticketCollection_getNoPacked.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticketCollection_getNoPacked`(vCollectionFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticketCollection_getNoPacked`(vCollectionFk INT) RETURNS varchar(100) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/ticketGetTotal.sql b/db/routines/vn/functions/ticketGetTotal.sql index ced02e3c5..a45cbbec8 100644 --- a/db/routines/vn/functions/ticketGetTotal.sql +++ b/db/routines/vn/functions/ticketGetTotal.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticketGetTotal`(vTicketId INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticketGetTotal`(vTicketId INT) RETURNS decimal(10,2) DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/ticketPositionInPath.sql b/db/routines/vn/functions/ticketPositionInPath.sql index 5e75d868d..c7a6b9094 100644 --- a/db/routines/vn/functions/ticketPositionInPath.sql +++ b/db/routines/vn/functions/ticketPositionInPath.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticketPositionInPath`(vTicketId INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticketPositionInPath`(vTicketId INT) RETURNS varchar(10) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/ticketSplitCounter.sql b/db/routines/vn/functions/ticketSplitCounter.sql index e82c079ae..eb1058a57 100644 --- a/db/routines/vn/functions/ticketSplitCounter.sql +++ b/db/routines/vn/functions/ticketSplitCounter.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticketSplitCounter`(vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticketSplitCounter`(vTicketFk INT) RETURNS varchar(15) CHARSET utf8mb3 COLLATE utf8mb3_general_ci NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/ticketTotalVolume.sql b/db/routines/vn/functions/ticketTotalVolume.sql index dc861ab6c..1fe9b3d39 100644 --- a/db/routines/vn/functions/ticketTotalVolume.sql +++ b/db/routines/vn/functions/ticketTotalVolume.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticketTotalVolume`(vTicketId INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticketTotalVolume`(vTicketId INT) RETURNS decimal(10,3) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/ticketTotalVolumeBoxes.sql b/db/routines/vn/functions/ticketTotalVolumeBoxes.sql index eb529bab9..1fec10977 100644 --- a/db/routines/vn/functions/ticketTotalVolumeBoxes.sql +++ b/db/routines/vn/functions/ticketTotalVolumeBoxes.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticketTotalVolumeBoxes`(vTicketId INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticketTotalVolumeBoxes`(vTicketId INT) RETURNS decimal(10,1) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/ticketWarehouseGet.sql b/db/routines/vn/functions/ticketWarehouseGet.sql index 705949f24..b1c7b9bc2 100644 --- a/db/routines/vn/functions/ticketWarehouseGet.sql +++ b/db/routines/vn/functions/ticketWarehouseGet.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticketWarehouseGet`(vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticketWarehouseGet`(vTicketFk INT) RETURNS int(11) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/ticket_CC_volume.sql b/db/routines/vn/functions/ticket_CC_volume.sql index 2572ae12d..f0c65931b 100644 --- a/db/routines/vn/functions/ticket_CC_volume.sql +++ b/db/routines/vn/functions/ticket_CC_volume.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticket_CC_volume`(vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticket_CC_volume`(vTicketFk INT) RETURNS decimal(10,1) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/ticket_HasUbication.sql b/db/routines/vn/functions/ticket_HasUbication.sql index 344a34aa9..7559cf360 100644 --- a/db/routines/vn/functions/ticket_HasUbication.sql +++ b/db/routines/vn/functions/ticket_HasUbication.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticket_HasUbication`(vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticket_HasUbication`(vTicketFk INT) RETURNS tinyint(1) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/ticket_get.sql b/db/routines/vn/functions/ticket_get.sql index 1f0e9a25a..ac8d0c642 100644 --- a/db/routines/vn/functions/ticket_get.sql +++ b/db/routines/vn/functions/ticket_get.sql @@ -1,64 +1,44 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticket_get`(vParamFk INT) - RETURNS int(11) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticket_get`(vParamFk INT) + RETURNS INT(11) NOT DETERMINISTIC READS SQL DATA -proc:BEGIN - - /* Devuelve el número de ticket o collection consultando en varias tablas posibles - * - * @param vParamFk Número a validar - * @return vValidFk Identificador validado - */ - - DECLARE vValidFk INT; +BEGIN +/** + * Devuelve el número de ticket / collection / sectorCollection consultando + * en que tabla se encuantra en la última semana + * + * @param vParamFk Número a validar + * @return vReturn Identificador validado + */ + DECLARE vReturn INT DEFAULT NULL; + DECLARE vDated DATE; - -- Tabla vn.saleGroup - SELECT s.ticketFk INTO vValidFk - FROM vn.sale s - JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id - JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk - WHERE sg.id = vParamFk - AND sg.created > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE()) - LIMIT 1; - - IF vValidFk THEN - - RETURN vValidFk; - - LEAVE proc; - - END IF; + SET vDated = util.VN_CURDATE() - INTERVAL 1 WEEK; - -- Tabla vn.collection - SELECT c.id INTO vValidFk - FROM vn.collection c - WHERE c.id = vParamFk - AND c.created > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE()); - - IF vValidFk THEN - - RETURN vValidFk; - - LEAVE proc; - - END IF; + SELECT COALESCE( + (SELECT s.ticketFk + FROM sale s + JOIN saleGroupDetail sgd ON sgd.saleFk = s.id + JOIN saleGroup sg ON sg.id = sgd.saleGroupFk + WHERE sg.id = vParamFk + AND sg.created > vDated + LIMIT 1), + (SELECT c.id + FROM collection c + WHERE c.id = vParamFk + AND c.created > vDated), + (SELECT id + FROM ticket + WHERE id = vParamFk + AND shipped > vDated), + (SELECT id + FROM sectorCollection + WHERE id = vParamFk + AND created > vDated) + ) INTO vReturn; - -- Tabla vn.ticket - SELECT t.id INTO vValidFk - FROM vn.ticket t - WHERE t.id = vParamFk - AND t.shipped > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE()); - - IF vValidFk THEN - - RETURN vValidFk; - - LEAVE proc; - - END IF; - - RETURN NULL; + RETURN vReturn; END$$ DELIMITER ; diff --git a/db/routines/vn/functions/ticket_getFreightCost.sql b/db/routines/vn/functions/ticket_getFreightCost.sql index 61905aff2..c5ddf561d 100644 --- a/db/routines/vn/functions/ticket_getFreightCost.sql +++ b/db/routines/vn/functions/ticket_getFreightCost.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticket_getFreightCost`(vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticket_getFreightCost`(vTicketFk INT) RETURNS decimal(10,2) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/ticket_getWeight.sql b/db/routines/vn/functions/ticket_getWeight.sql index 32f84cac7..d0298d63f 100644 --- a/db/routines/vn/functions/ticket_getWeight.sql +++ b/db/routines/vn/functions/ticket_getWeight.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticket_getWeight`(vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticket_getWeight`(vTicketFk INT) RETURNS decimal(10,3) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/ticket_isOutClosureZone.sql b/db/routines/vn/functions/ticket_isOutClosureZone.sql index ebddcf505..fcd7de858 100644 --- a/db/routines/vn/functions/ticket_isOutClosureZone.sql +++ b/db/routines/vn/functions/ticket_isOutClosureZone.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticket_isOutClosureZone`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticket_isOutClosureZone`(vSelf INT) RETURNS tinyint(1) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/ticket_isProblemCalcNeeded.sql b/db/routines/vn/functions/ticket_isProblemCalcNeeded.sql new file mode 100644 index 000000000..aa821a8e5 --- /dev/null +++ b/db/routines/vn/functions/ticket_isProblemCalcNeeded.sql @@ -0,0 +1,27 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticket_isProblemCalcNeeded`( + vSelf INT +) + RETURNS BOOL + DETERMINISTIC +BEGIN +/** + * Check if the ticket requires to update column vn.ticket.problem + * + * @param vSelf Id ticket + * @return BOOL + */ + DECLARE vIsProblemCalcNeeded BOOL; + + SELECT COUNT(*) INTO vIsProblemCalcNeeded + FROM ticket t + JOIN client c ON c.id = t.clientFk + JOIN agencyMode am ON am.id = t.agencyModeFk + JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + WHERE t.id = vSelf + AND dm.code IN ('AGENCY','DELIVERY','PICKUP') + AND c.typeFk = 'normal'; + + RETURN vIsProblemCalcNeeded; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/functions/ticket_isTooLittle.sql b/db/routines/vn/functions/ticket_isTooLittle.sql index 2ce24f0fa..a3444c863 100644 --- a/db/routines/vn/functions/ticket_isTooLittle.sql +++ b/db/routines/vn/functions/ticket_isTooLittle.sql @@ -1,8 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticket_isTooLittle`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticket_isTooLittle`( vSelf INT ) - RETURNS tinyint(1) + RETURNS BOOL READS SQL DATA BEGIN /** @@ -11,14 +11,21 @@ BEGIN * @param vSelf Id ticket * @return BOOL */ - DECLARE vIsTooLittle TINYINT(1); - + DECLARE vIsTooLittle BOOL; + + WITH ticketData AS ( + SELECT addressFk, DATE(shipped) dated + FROM vn.ticket + WHERE id = vSelf + ) SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume - OR IFNULL(t.totalWithoutVat, 0) < vc.minTicketValue) INTO vIsTooLittle - FROM ticket t - LEFT JOIN saleVolume sv ON sv.ticketFk = t.id - JOIN volumeConfig vc - WHERE t.id = vSelf; + AND SUM(IFNULL(t.totalWithoutVat, 0)) < vc.minTicketValue) INTO vIsTooLittle + FROM ticketData td + JOIN vn.ticket t ON t.addressFk = td.addressFk + LEFT JOIN vn.saleVolume sv ON sv.ticketFk = t.id + JOIN vn.volumeConfig vc + WHERE t.shipped BETWEEN td.dated AND util.dayEnd(td.dated) + AND ticket_isProblemCalcNeeded(t.id); RETURN vIsTooLittle; END$$ diff --git a/db/routines/vn/functions/till_new.sql b/db/routines/vn/functions/till_new.sql index 24f4f2b79..2b235a91d 100644 --- a/db/routines/vn/functions/till_new.sql +++ b/db/routines/vn/functions/till_new.sql @@ -1,79 +1,73 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`till_new`(vClient INT - ,vBank INT - ,vAmount DOUBLE - ,vConcept VARCHAR(25) - ,vDated DATE - ,vSerie CHAR(1) - ,vBatch TINYINT - ,vNumber INT - ,vCompany SMALLINT - ,vWorker INT +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`till_new`( + vClient INT, + vBank INT, + vAmount DOUBLE, + vConcept VARCHAR(25), + vDated DATE, + vSerie CHAR(1), + vBatch TINYINT, + vNumber INT, + vCompany SMALLINT, + vWorker INT ) - RETURNS int(11) - DETERMINISTIC BEGIN DECLARE vAccount VARCHAR(12); DECLARE vSubaccount VARCHAR(12); DECLARE vAsiento INT DEFAULT NULL; -- Inserta el registro en cajas - INSERT INTO till SET - workerFk = vWorker - ,bankFk = vBank - ,`in` = vAmount - ,concept = vConcept - ,dated = vDated - ,serie = vSerie - ,isAccountable = vBatch - ,`number` = vNumber - ,companyFk = vCompany; + workerFk = vWorker, + bankFk = vBank, + `in` = vAmount, + concept = vConcept, + dated = vDated, + serie = vSerie, + isAccountable = vBatch, + `number` = vNumber, + companyFk = vCompany; -- Inserta los asientos contables - SELECT account INTO vAccount FROM accounting WHERE id = vBank; SELECT accountingAccount INTO vSubaccount FROM `client` WHERE id = vClient; - SET vAsiento = xdiario_new - ( - vAsiento - ,vDated - ,vAccount - ,vSubaccount - ,vConcept - ,vAmount - ,0 - ,0 - ,NULL -- Serie - ,NULL -- Factura - ,NULL -- IVA - ,NULL -- Recargo - ,FALSE -- Auxiliar - ,vCompany - ); - DO xdiario_new - ( - vAsiento - ,vDated - ,vSubaccount - ,vAccount - ,vConcept - ,0 - ,vAmount - ,0 - ,NULL -- Serie - ,NULL -- Factura - ,NULL -- IVA - ,NULL -- Recargo - ,FALSE -- Auxiliar - ,vCompany - ); + CALL xdiario_new( + vAsiento, + vDated, + vAccount, + vSubaccount, + vConcept, + vAmount, + 0, + 0, + NULL, -- Serie + NULL, -- Factura + NULL, -- IVA + NULL, -- Recargo + FALSE, -- Auxiliar + vCompany, + vAsiento); - RETURN NULL; + CALL xdiario_new( + vAsiento, + vDated, + vSubaccount, + vAccount, + vConcept, + 0, + vAmount, + 0, + NULL, -- Serie + NULL, -- Factura + NULL, -- IVA + NULL, -- Recargo + FALSE, -- Auxiliar + vCompany, + vAsiento); END$$ DELIMITER ; diff --git a/db/routines/vn/functions/timeWorkerControl_getDirection.sql b/db/routines/vn/functions/timeWorkerControl_getDirection.sql index 518e4aeb5..c0f1e67ea 100644 --- a/db/routines/vn/functions/timeWorkerControl_getDirection.sql +++ b/db/routines/vn/functions/timeWorkerControl_getDirection.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`timeWorkerControl_getDirection`(vUserFk INT, vTimed DATETIME) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`timeWorkerControl_getDirection`(vUserFk INT, vTimed DATETIME) RETURNS varchar(6) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/time_getSalesYear.sql b/db/routines/vn/functions/time_getSalesYear.sql index 658a1112a..d9022890d 100644 --- a/db/routines/vn/functions/time_getSalesYear.sql +++ b/db/routines/vn/functions/time_getSalesYear.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`time_getSalesYear`(vMonth INT, vYear INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`time_getSalesYear`(vMonth INT, vYear INT) RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/travel_getForLogiflora.sql b/db/routines/vn/functions/travel_getForLogiflora.sql deleted file mode 100644 index cb3f0dac0..000000000 --- a/db/routines/vn/functions/travel_getForLogiflora.sql +++ /dev/null @@ -1,52 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`travel_getForLogiflora`(vLanded DATE, vWarehouseFk INT) - RETURNS int(11) - NOT DETERMINISTIC - READS SQL DATA -BEGIN - - /** - * Devuelve un número de travel para compras de Logiflora a partir de la fecha de llegada y del almacén. - * Si no existe lo genera. - * - * @param vLanded Fecha de llegada al almacén - * @param vWarehouseFk Identificador de vn.warehouse - */ - - DECLARE vTravelFk INT; - - IF vLanded THEN - - SELECT IFNULL(MAX(tr.id),0) INTO vTravelFk - FROM vn.travel tr - JOIN vn.warehouse wIn ON wIn.id = tr.warehouseInFk - JOIN vn.warehouse wOut ON wOut.id = tr.warehouseOutFk - JOIN vn.agencyMode am ON am.id = tr.agencyModeFk - WHERE wIn.id = vWarehouseFk - AND wOut.name = 'Holanda' - AND am.name = 'LOGIFLORA' - AND landed = vLanded; - - IF NOT vTravelFk THEN - - INSERT INTO vn.travel(landed, shipped, warehouseInFk, warehouseOutFk, agencyModeFk) - SELECT vLanded, util.VN_CURDATE(), vWarehouseFk, wOut.id, am.id - FROM vn.warehouse wOut - JOIN vn.agencyMode am ON am.name = 'LOGIFLORA' - WHERE wOut.name = 'Holanda'; - - SELECT MAX(tr.id) INTO vTravelFk - FROM vn.travel tr - JOIN vn.warehouse wIn ON wIn.id = tr.warehouseInFk - JOIN vn.warehouse wOut ON wOut.id = tr.warehouseOutFk - WHERE wIn.id = vWarehouseFk - AND wOut.name = 'Holanda' - AND landed = vLanded; - END IF; - - END IF; - - RETURN vTravelFk; - -END$$ -DELIMITER ; diff --git a/db/routines/vn/functions/travel_hasUniqueAwb.sql b/db/routines/vn/functions/travel_hasUniqueAwb.sql index e918f1a26..d98986753 100644 --- a/db/routines/vn/functions/travel_hasUniqueAwb.sql +++ b/db/routines/vn/functions/travel_hasUniqueAwb.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`travel_hasUniqueAwb`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`travel_hasUniqueAwb`( vSelf INT ) RETURNS BOOL diff --git a/db/routines/vn/functions/validationCode.sql b/db/routines/vn/functions/validationCode.sql index 75d603d24..ab0acedaa 100644 --- a/db/routines/vn/functions/validationCode.sql +++ b/db/routines/vn/functions/validationCode.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`validationCode`(vString VARCHAR(255)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`validationCode`(vString VARCHAR(255)) RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/validationCode_beta.sql b/db/routines/vn/functions/validationCode_beta.sql index 0e27a4722..afeb1273a 100644 --- a/db/routines/vn/functions/validationCode_beta.sql +++ b/db/routines/vn/functions/validationCode_beta.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`validationCode_beta`(vString VARCHAR(255)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`validationCode_beta`(vString VARCHAR(255)) RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/workerMachinery_isRegistered.sql b/db/routines/vn/functions/workerMachinery_isRegistered.sql index 89a1c44ac..60f458e9e 100644 --- a/db/routines/vn/functions/workerMachinery_isRegistered.sql +++ b/db/routines/vn/functions/workerMachinery_isRegistered.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`workerMachinery_isRegistered`(vWorkerFk VARCHAR(10)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`workerMachinery_isRegistered`(vWorkerFk VARCHAR(10)) RETURNS tinyint(1) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/workerNigthlyHours_calculate.sql b/db/routines/vn/functions/workerNigthlyHours_calculate.sql index 0828b30f9..1b4835712 100644 --- a/db/routines/vn/functions/workerNigthlyHours_calculate.sql +++ b/db/routines/vn/functions/workerNigthlyHours_calculate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`workerNigthlyHours_calculate`(vTimeIn DATETIME, vTimeOut DATETIME) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`workerNigthlyHours_calculate`(vTimeIn DATETIME, vTimeOut DATETIME) RETURNS decimal(5,2) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/worker_getCode.sql b/db/routines/vn/functions/worker_getCode.sql index d3d63dccc..76ec94d1b 100644 --- a/db/routines/vn/functions/worker_getCode.sql +++ b/db/routines/vn/functions/worker_getCode.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`worker_getCode`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`worker_getCode`() RETURNS varchar(3) CHARSET utf8mb3 COLLATE utf8mb3_general_ci NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/worker_isBoss.sql b/db/routines/vn/functions/worker_isBoss.sql index 7efada705..8ab3a1fa9 100644 --- a/db/routines/vn/functions/worker_isBoss.sql +++ b/db/routines/vn/functions/worker_isBoss.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`worker_isBoss`(vUserId INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`worker_isBoss`(vUserId INT) RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/worker_isInDepartment.sql b/db/routines/vn/functions/worker_isInDepartment.sql index 8eee3656e..6f6146d0b 100644 --- a/db/routines/vn/functions/worker_isInDepartment.sql +++ b/db/routines/vn/functions/worker_isInDepartment.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`worker_isInDepartment`(vDepartmentCode VARCHAR(255)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`worker_isInDepartment`(vDepartmentCode VARCHAR(255)) RETURNS int(11) DETERMINISTIC BEGIN diff --git a/db/routines/vn/functions/worker_isWorking.sql b/db/routines/vn/functions/worker_isWorking.sql index 3db333bd0..455b78805 100644 --- a/db/routines/vn/functions/worker_isWorking.sql +++ b/db/routines/vn/functions/worker_isWorking.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`worker_isWorking`(vWorkerFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`worker_isWorking`(vWorkerFk INT) RETURNS tinyint(1) NOT DETERMINISTIC READS SQL DATA diff --git a/db/routines/vn/functions/xdiario_new.sql b/db/routines/vn/functions/xdiario_new.sql deleted file mode 100644 index 4f4b3f3fd..000000000 --- a/db/routines/vn/functions/xdiario_new.sql +++ /dev/null @@ -1,45 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`xdiario_new`( - vBookNumber INT, - vDated DATE, - vSubaccount VARCHAR(12), - vAccount VARCHAR(12), - vConcept VARCHAR(25), - vDebit DOUBLE, - vCredit DOUBLE, - vEuro DOUBLE, - vSerie CHAR(1), - vInvoice VARCHAR(8), - vVat DOUBLE, - vRe DOUBLE, - vAux TINYINT, - vCompanyFk INT -) - RETURNS int(11) - NOT DETERMINISTIC - NO SQL -BEGIN - IF vBookNumber IS NULL THEN - CALL ledger_next(YEAR(vDated), vBookNumber); - END IF; - - INSERT INTO XDiario - SET ASIEN = vBookNumber, - FECHA = vDated, - SUBCTA = vSubaccount, - CONTRA = vAccount, - CONCEPTO = vConcept, - EURODEBE = vDebit, - EUROHABER = vCredit, - BASEEURO = vEuro, - SERIE = vSerie, - FACTURA = vInvoice, - IVA = vVat, - RECEQUIV = vRe, - AUXILIAR = IF(vAux = FALSE, NULL, '*'), - MONEDAUSO = 2, - empresa_id = vCompanyFk; - - RETURN vBookNumber; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/functions/zoneGeo_new.sql b/db/routines/vn/functions/zoneGeo_new.sql index 65b045962..47ec3dec7 100644 --- a/db/routines/vn/functions/zoneGeo_new.sql +++ b/db/routines/vn/functions/zoneGeo_new.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`zoneGeo_new`(vType VARCHAR(255), vName VARCHAR(255), vParentFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`zoneGeo_new`(vType VARCHAR(255), vName VARCHAR(255), vParentFk INT) RETURNS int(11) NOT DETERMINISTIC NO SQL diff --git a/db/routines/vn/procedures/XDiario_check.sql b/db/routines/vn/procedures/XDiario_check.sql index 0fb1c410d..a8f33adde 100644 --- a/db/routines/vn/procedures/XDiario_check.sql +++ b/db/routines/vn/procedures/XDiario_check.sql @@ -1,24 +1,11 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`XDiario_check`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`XDiario_check`() BEGIN /** * Realiza la revisión diaria de los asientos contables, * identificando y notificando los asientos descuadrados * y ajustando los saldos en caso necesario. */ - INSERT INTO mail (receiver, subject, body) - SELECT 'cau@verdnatura.es', - 'Asientos descuadrados', - GROUP_CONCAT(CONCAT(' Asiento: ', ASIEN, ' - Importe:', recon) SEPARATOR ' | \n') - FROM ( - SELECT ASIEN, - SUM(IFNULL(ROUND(Eurodebe, 2), 0)) - SUM(IFNULL(ROUND(EUROHABER, 2), 0)) recon - FROM XDiario - WHERE NOT enlazado - GROUP BY ASIEN - HAVING ABS(SUM(IFNULL(ROUND(Eurodebe, 2), 0)) - SUM(IFNULL(ROUND(EUROHABER, 2), 0))) > 0.01 - ) sub - HAVING COUNT(*); UPDATE XDiario xd JOIN ( diff --git a/db/routines/vn/procedures/XDiario_checkDate.sql b/db/routines/vn/procedures/XDiario_checkDate.sql index b481d1f36..8b961a1fa 100644 --- a/db/routines/vn/procedures/XDiario_checkDate.sql +++ b/db/routines/vn/procedures/XDiario_checkDate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`XDiario_checkDate`(vDate DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`XDiario_checkDate`(vDate DATE) proc: BEGIN /** * Comprueba si la fecha pasada esta en el rango diff --git a/db/routines/vn/procedures/absoluteInventoryHistory.sql b/db/routines/vn/procedures/absoluteInventoryHistory.sql index 627b7c8be..d2a2029f0 100644 --- a/db/routines/vn/procedures/absoluteInventoryHistory.sql +++ b/db/routines/vn/procedures/absoluteInventoryHistory.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`( vItemFk INT, vWarehouseFk INT, vDate DATETIME diff --git a/db/routines/vn/procedures/addAccountReconciliation.sql b/db/routines/vn/procedures/addAccountReconciliation.sql index 8effbd76c..1aa3c28fd 100644 --- a/db/routines/vn/procedures/addAccountReconciliation.sql +++ b/db/routines/vn/procedures/addAccountReconciliation.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`addAccountReconciliation`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`addAccountReconciliation`() BEGIN /** * Updates duplicate records in the accountReconciliation table, diff --git a/db/routines/vn/procedures/addNoteFromDelivery.sql b/db/routines/vn/procedures/addNoteFromDelivery.sql index 61295b7db..57b7bef24 100644 --- a/db/routines/vn/procedures/addNoteFromDelivery.sql +++ b/db/routines/vn/procedures/addNoteFromDelivery.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`addNoteFromDelivery`(idTicket INT,nota TEXT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`addNoteFromDelivery`(idTicket INT,nota TEXT) BEGIN DECLARE observationTypeFk INT DEFAULT 3; /*3 = REPARTIDOR*/ diff --git a/db/routines/vn/procedures/addressTaxArea.sql b/db/routines/vn/procedures/addressTaxArea.sql index 5deb01fa4..a1bb0dec0 100644 --- a/db/routines/vn/procedures/addressTaxArea.sql +++ b/db/routines/vn/procedures/addressTaxArea.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`addressTaxArea`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`addressTaxArea`() READS SQL DATA BEGIN /** diff --git a/db/routines/vn/procedures/address_updateCoordinates.sql b/db/routines/vn/procedures/address_updateCoordinates.sql new file mode 100644 index 000000000..815c7b7a7 --- /dev/null +++ b/db/routines/vn/procedures/address_updateCoordinates.sql @@ -0,0 +1,25 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`address_updateCoordinates`( + vTicketFk INT, + vLongitude DECIMAL(11,7), + vLatitude DECIMAL(11,7)) +BEGIN +/** + * Actualiza las coordenadas de una dirección. + * + * @param vTicketFk Id del ticket + * @param vLongitude Longitud de la dirección + * @param vLatitude Latitud de la dirección + */ + DECLARE vAddressFK INT; + + SELECT addressFK INTO vAddressFK + FROM ticket + WHERE id = vTicketFk; + + UPDATE address + SET longitude = vLongitude, + latitude = vLatitude + WHERE id = vAddressFK; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/agencyHourGetFirstShipped.sql b/db/routines/vn/procedures/agencyHourGetFirstShipped.sql index 4bd1c4222..dc584d0f9 100644 --- a/db/routines/vn/procedures/agencyHourGetFirstShipped.sql +++ b/db/routines/vn/procedures/agencyHourGetFirstShipped.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`agencyHourGetFirstShipped`(vAgencyMode INT, vAddress INT, vWarehouse INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`agencyHourGetFirstShipped`(vAgencyMode INT, vAddress INT, vWarehouse INT) BEGIN /** * DEPRECATED usar zoneGetFirstShipped diff --git a/db/routines/vn/procedures/agencyHourGetLanded.sql b/db/routines/vn/procedures/agencyHourGetLanded.sql index ee48388a0..6e766d739 100644 --- a/db/routines/vn/procedures/agencyHourGetLanded.sql +++ b/db/routines/vn/procedures/agencyHourGetLanded.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`agencyHourGetLanded`(vDated DATE, vAddress INT, vAgency INT, vWarehouse INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`agencyHourGetLanded`(vDated DATE, vAddress INT, vAgency INT, vWarehouse INT) BEGIN /** * DEPRECATED usar zoneGetLanded diff --git a/db/routines/vn/procedures/agencyHourGetWarehouse.sql b/db/routines/vn/procedures/agencyHourGetWarehouse.sql index 7fc524fce..0e27e4437 100644 --- a/db/routines/vn/procedures/agencyHourGetWarehouse.sql +++ b/db/routines/vn/procedures/agencyHourGetWarehouse.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`agencyHourGetWarehouse`(vAddress INT, vDate DATE, vWarehouse INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`agencyHourGetWarehouse`(vAddress INT, vDate DATE, vWarehouse INT) BEGIN /** * DEPRECATED usar zoneGetWarehouse diff --git a/db/routines/vn/procedures/agencyHourListGetShipped.sql b/db/routines/vn/procedures/agencyHourListGetShipped.sql index b4cf35f77..3a0b0db65 100644 --- a/db/routines/vn/procedures/agencyHourListGetShipped.sql +++ b/db/routines/vn/procedures/agencyHourListGetShipped.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`agencyHourListGetShipped`(vDate DATE, vAddress INT, vAgency INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`agencyHourListGetShipped`(vDate DATE, vAddress INT, vAgency INT) BEGIN /* * DEPRECATED usar zoneGetShipped */ diff --git a/db/routines/vn/procedures/agencyVolume.sql b/db/routines/vn/procedures/agencyVolume.sql index ef47834ba..451b089fc 100644 --- a/db/routines/vn/procedures/agencyVolume.sql +++ b/db/routines/vn/procedures/agencyVolume.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`agencyVolume`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`agencyVolume`() BEGIN /** * Calculates and presents information on shipment and packaging volumes diff --git a/db/routines/vn/procedures/available_calc.sql b/db/routines/vn/procedures/available_calc.sql index 8c806d41d..ddfba8bad 100644 --- a/db/routines/vn/procedures/available_calc.sql +++ b/db/routines/vn/procedures/available_calc.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`available_calc`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`available_calc`( vDate DATE, vAddress INT, vAgencyMode INT) diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql index d33a8e10e..03eb376ab 100644 --- a/db/routines/vn/procedures/available_traslate.sql +++ b/db/routines/vn/procedures/available_traslate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`available_traslate`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`available_traslate`( vWarehouseLanding INT, vDated DATE, vWarehouseShipment INT) @@ -47,7 +47,7 @@ proc: BEGIN -- Tabla con el ultimo dia de last_buy para cada producto -- que hace un replace de la anterior. - CALL buyUltimate(vWarehouseShipment, util.VN_CURDATE()); + CALL buy_getUltimate (NULL, vWarehouseShipment, util.VN_CURDATE()); INSERT INTO tItemRange SELECT t.itemFk, tr.landed diff --git a/db/routines/vn/procedures/balanceNestTree_addChild.sql b/db/routines/vn/procedures/balanceNestTree_addChild.sql index 5cd1ab470..2bf4157c4 100644 --- a/db/routines/vn/procedures/balanceNestTree_addChild.sql +++ b/db/routines/vn/procedures/balanceNestTree_addChild.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_addChild`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`balanceNestTree_addChild`( vSelf INT, vName VARCHAR(45) ) diff --git a/db/routines/vn/procedures/balanceNestTree_delete.sql b/db/routines/vn/procedures/balanceNestTree_delete.sql index 1d6a9efff..bb0b83bf5 100644 --- a/db/routines/vn/procedures/balanceNestTree_delete.sql +++ b/db/routines/vn/procedures/balanceNestTree_delete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_delete`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`balanceNestTree_delete`( vSelf INT ) BEGIN diff --git a/db/routines/vn/procedures/balanceNestTree_move.sql b/db/routines/vn/procedures/balanceNestTree_move.sql index ce29de1d9..a05a618b7 100644 --- a/db/routines/vn/procedures/balanceNestTree_move.sql +++ b/db/routines/vn/procedures/balanceNestTree_move.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_move`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`balanceNestTree_move`( vSelf INT, vFather INT ) diff --git a/db/routines/vn/procedures/balance_create.sql b/db/routines/vn/procedures/balance_create.sql index 366707e58..6363b4c00 100644 --- a/db/routines/vn/procedures/balance_create.sql +++ b/db/routines/vn/procedures/balance_create.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balance_create`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`balance_create`( vStartingMonth INT, vEndingMonth INT, vCompany INT, diff --git a/db/routines/vn/procedures/bankEntity_checkBic.sql b/db/routines/vn/procedures/bankEntity_checkBic.sql index 2f05ae654..069c2a0d7 100644 --- a/db/routines/vn/procedures/bankEntity_checkBic.sql +++ b/db/routines/vn/procedures/bankEntity_checkBic.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`bankEntity_checkBic`(vBic VARCHAR(255)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`bankEntity_checkBic`(vBic VARCHAR(255)) BEGIN /** * If the bic length is Incorrect throw exception diff --git a/db/routines/vn/procedures/bankPolicy_notifyExpired.sql b/db/routines/vn/procedures/bankPolicy_notifyExpired.sql index 61216938d..cdcd212f3 100644 --- a/db/routines/vn/procedures/bankPolicy_notifyExpired.sql +++ b/db/routines/vn/procedures/bankPolicy_notifyExpired.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`bankPolicy_notifyExpired`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`bankPolicy_notifyExpired`() BEGIN /** * diff --git a/db/routines/vn/procedures/buyUltimate.sql b/db/routines/vn/procedures/buyUltimate.sql deleted file mode 100644 index 4346ef640..000000000 --- a/db/routines/vn/procedures/buyUltimate.sql +++ /dev/null @@ -1,39 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimate`(vWarehouseFk SMALLINT, vDated DATE) -BEGIN -/** - * Calcula las últimas compras realizadas hasta una fecha - * - * @param vWarehouseFk Id del almacén - * @param vDated Compras hasta fecha - * @return tmp.buyUltimate - */ - CALL cache.last_buy_refresh (FALSE); - - DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimate; - CREATE TEMPORARY TABLE tmp.buyUltimate - (PRIMARY KEY (itemFk, warehouseFk), - INDEX(itemFk)) - ENGINE = MEMORY - SELECT item_id itemFk, buy_id buyFk, warehouse_id warehouseFk, landing - FROM cache.last_buy - WHERE warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL; - - CALL buyUltimateFromInterval(vWarehouseFk, util.VN_CURDATE(), vDated); - - REPLACE INTO tmp.buyUltimate - SELECT itemFk, buyFk, warehouseFk, landed landing - FROM tmp.buyUltimateFromInterval - WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) - AND landed <= vDated - AND NOT isIgnored; - - INSERT IGNORE INTO tmp.buyUltimate - SELECT itemFk, buyFk, warehouseFk, landed landing - FROM tmp.buyUltimateFromInterval - WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) - AND landed > vDated - ORDER BY isIgnored = FALSE DESC; - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/buyUltimateFromInterval.sql b/db/routines/vn/procedures/buyUltimateFromInterval.sql deleted file mode 100644 index e264b500d..000000000 --- a/db/routines/vn/procedures/buyUltimateFromInterval.sql +++ /dev/null @@ -1,137 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimateFromInterval`(vWarehouseFk SMALLINT, vStarted DATE, vEnded DATE) -BEGIN -/** - * Calcula las últimas compras realizadas - * desde un rango de fechas. - * - * @param vWarehouseFk Id del almacén si es NULL se actualizan todos - * @param vStarted Fecha inicial - * @param vEnded Fecha fin - * @return tmp.buyUltimateFromInterval - */ - IF vEnded IS NULL THEN - SET vEnded = vStarted; - END IF; - - IF vEnded < vStarted THEN - SET vStarted = TIMESTAMPADD(MONTH, -1, vEnded); - END IF; - - -- Item - DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; - CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval - (PRIMARY KEY (itemFk, warehouseFk), INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) - ENGINE = MEMORY - SELECT itemFk, - warehouseFk, - buyFk, - MAX(landed) landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT - b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed > vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - AND NOT b.isIgnored - GROUP BY itemFk, warehouseInFk; - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT - b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.quantity = 0 - GROUP BY itemFk, warehouseInFk; - - -- ItemOriginal - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - MAX(landed) landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - itemOriginalFk, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - AND NOT b.isIgnored - AND b.quantity > 0 - AND itemOriginalFk - ORDER BY t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemOriginalFk, warehouseFk; - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT - b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed > vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - AND NOT b.isIgnored - AND itemOriginalFk - GROUP BY itemOriginalFk, warehouseInFk; - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT - b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.quantity = 0 - AND itemOriginalFk - GROUP BY itemOriginalFk, warehouseInFk; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/buy_afterUpsert.sql b/db/routines/vn/procedures/buy_afterUpsert.sql index 17e84177c..7ff7dd841 100644 --- a/db/routines/vn/procedures/buy_afterUpsert.sql +++ b/db/routines/vn/procedures/buy_afterUpsert.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_afterUpsert`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_afterUpsert`( + vSelf INT +) BEGIN /** * Triggered actions when a buy is updated or inserted. @@ -16,7 +18,7 @@ BEGIN DECLARE vIsFeedStock BOOL; DECLARE vWeight DECIMAL(10,2); DECLARE vPacking INT; - + SELECT b.entryFk, b.itemFk, i.packingOut, @@ -47,8 +49,11 @@ BEGIN WHERE e.id = vEntryFk; IF vIsMerchandise THEN + IF vWarehouse IS NULL THEN + CALL util.throw('The entry does not have travel'); + END IF; - REPLACE itemCost SET + REPLACE itemCost SET itemFk = vItemFk, warehouseFk = vWarehouse, cm3 = buy_getUnitVolume(vSelf), @@ -74,7 +79,7 @@ BEGIN WHERE b.id = vSelf; END IF; - CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck + CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck SELECT vSelf id; CALL buy_checkItem(); END$$ diff --git a/db/routines/vn/procedures/buy_checkGrouping.sql b/db/routines/vn/procedures/buy_checkGrouping.sql index 11c727fb1..7d2830ab2 100644 --- a/db/routines/vn/procedures/buy_checkGrouping.sql +++ b/db/routines/vn/procedures/buy_checkGrouping.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_checkGrouping`(vGrouping INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_checkGrouping`(vGrouping INT) BEGIN /** * Checks the buy grouping, throws an error if it's invalid. diff --git a/db/routines/vn/procedures/buy_chekItem.sql b/db/routines/vn/procedures/buy_checkItem.sql similarity index 54% rename from db/routines/vn/procedures/buy_chekItem.sql rename to db/routines/vn/procedures/buy_checkItem.sql index e8cf05fed..1144db889 100644 --- a/db/routines/vn/procedures/buy_chekItem.sql +++ b/db/routines/vn/procedures/buy_checkItem.sql @@ -1,14 +1,15 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_checkItem`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_checkItem`() BEGIN /** * Checks if the item has weightByPiece or size null on any buy. * * @param tmp.buysToCheck(id as INT). */ - DECLARE hasVolumetricAgency INT; + DECLARE vHasVolumetricAgency INT; + DECLARE vItemFk INT; - SELECT a.hasWeightVolumetric INTO hasVolumetricAgency + SELECT a.hasWeightVolumetric, i.id INTO vHasVolumetricAgency, vItemFk FROM entry e JOIN travel t ON t.id = e.travelFk JOIN agencyMode a ON a.id = t.agencyModeFk @@ -19,10 +20,10 @@ BEGIN AND a.hasWeightVolumetric LIMIT 1; - DROP TEMPORARY TABLE tmp.buysToCheck; + DROP TEMPORARY TABLE tmp.buysToCheck; - IF hasVolumetricAgency THEN - CALL util.throw('Item lacks size/weight in purchase line at agency'); - END IF; + IF vHasVolumetricAgency THEN + CALL util.throw(CONCAT('Missing size/weight in buy line at agency, item: ', vItemFk)); + END IF; END$$ -DELIMITER ; \ No newline at end of file +DELIMITER ; diff --git a/db/routines/vn/procedures/buy_clone.sql b/db/routines/vn/procedures/buy_clone.sql index 7b77204c9..888531746 100644 --- a/db/routines/vn/procedures/buy_clone.sql +++ b/db/routines/vn/procedures/buy_clone.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_clone`(vEntryFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_clone`(vEntryFk INT) BEGIN /** * Clone buys to an entry diff --git a/db/routines/vn/procedures/buy_getSplit.sql b/db/routines/vn/procedures/buy_getSplit.sql index 73cc1dda7..087a4de4d 100644 --- a/db/routines/vn/procedures/buy_getSplit.sql +++ b/db/routines/vn/procedures/buy_getSplit.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getSplit`(vSelf INT, vDated DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_getSplit`(vSelf INT, vDated DATE) BEGIN /** * Devuelve tantos registros como etiquetas se necesitan para cada uno de los cubos o cajas de diff --git a/db/routines/vn/procedures/buy_getUltimate.sql b/db/routines/vn/procedures/buy_getUltimate.sql new file mode 100644 index 000000000..1532222ad --- /dev/null +++ b/db/routines/vn/procedures/buy_getUltimate.sql @@ -0,0 +1,47 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_getUltimate`( + vItemFk INT, + vWarehouseFk SMALLINT, + vDated DATE +) +BEGIN +/** + * Calcula las últimas compras realizadas hasta una fecha. + * + * @param vItemFk Id del artículo + * @param vWarehouseFk Id del almacén + * @param vDated Compras hasta fecha + * @return tmp.buyUltimate + */ + CALL cache.last_buy_refresh(FALSE); + + CREATE OR REPLACE TEMPORARY TABLE tmp.buyUltimate + (PRIMARY KEY (itemFk, warehouseFk), + INDEX(itemFk)) + ENGINE = MEMORY + SELECT item_id itemFk, buy_id buyFk, warehouse_id warehouseFk, landing + FROM cache.last_buy + WHERE (warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL) + AND (item_id = vItemFk OR vItemFk IS NULL); + + IF vDated >= util.VN_CURDATE() THEN + CALL buy_getUltimateFromInterval(vItemFk, vWarehouseFk, util.VN_CURDATE(), vDated); + + REPLACE INTO tmp.buyUltimate + SELECT itemFk, buyFk, warehouseFk, landed landing + FROM tmp.buyUltimateFromInterval + WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) + AND (itemFk = vItemFk OR vItemFk IS NULL) + AND landed <= vDated + AND NOT isIgnored; + + INSERT IGNORE INTO tmp.buyUltimate + SELECT itemFk, buyFk, warehouseFk, landed landing + FROM tmp.buyUltimateFromInterval + WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) + AND (itemFk = vItemFk OR vItemFk IS NULL) + AND landed > vDated + ORDER BY isIgnored = FALSE DESC; + END IF; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/buy_getUltimateFromInterval.sql b/db/routines/vn/procedures/buy_getUltimateFromInterval.sql new file mode 100644 index 000000000..24a843eb0 --- /dev/null +++ b/db/routines/vn/procedures/buy_getUltimateFromInterval.sql @@ -0,0 +1,175 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_getUltimateFromInterval`( + vItemFk INT, + vWarehouseFk SMALLINT, + vStarted DATE, + vEnded DATE +) +BEGIN +/** + * Calcula las últimas compras realizadas + * desde un rango de fechas. + * + * @param vItemFk Id del artículo + * @param vWarehouseFk Id del almacén si es NULL se actualizan todos + * @param vStarted Fecha inicial + * @param vEnded Fecha fin + * @return tmp.buyUltimateFromInterval + */ + IF vEnded IS NULL THEN + SET vEnded = vStarted; + END IF; + + IF vEnded < vStarted THEN + SET vStarted = vEnded - INTERVAL 1 MONTH; + END IF; + + -- Item + + CREATE OR REPLACE TEMPORARY TABLE tmp.buyUltimateFromInterval + (PRIMARY KEY (itemFk, warehouseFk), + INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) + ENGINE = MEMORY + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed > vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.quantity = 0 + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + -- ItemOriginal + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + itemOriginalFk, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + AND b.quantity > 0 + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed > vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM + (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.quantity = 0 + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/buy_getVolume.sql b/db/routines/vn/procedures/buy_getVolume.sql index 633be7ec0..227bfac3c 100644 --- a/db/routines/vn/procedures/buy_getVolume.sql +++ b/db/routines/vn/procedures/buy_getVolume.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getVolume`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_getVolume`() BEGIN /** * Cálculo de volumen en líneas de compra diff --git a/db/routines/vn/procedures/buy_getVolumeByAgency.sql b/db/routines/vn/procedures/buy_getVolumeByAgency.sql deleted file mode 100644 index 2f63c2bdf..000000000 --- a/db/routines/vn/procedures/buy_getVolumeByAgency.sql +++ /dev/null @@ -1,20 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getVolumeByAgency`(vDated DATE, vAgencyFk INT) -BEGIN - - DROP TEMPORARY TABLE IF EXISTS tmp.buy; - CREATE TEMPORARY TABLE tmp.buy (buyFk INT NOT NULL, PRIMARY KEY (buyFk)) ENGINE = MEMORY; - - INSERT INTO tmp.buy - SELECT b.id - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed = vDated - AND t.agencyModeFk IN (0, vAgencyFk); - - CALL buy_getVolume(); - DROP TEMPORARY TABLE tmp.buy; - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/buy_getVolumeByEntry.sql b/db/routines/vn/procedures/buy_getVolumeByEntry.sql index e9a2bca2e..436a49654 100644 --- a/db/routines/vn/procedures/buy_getVolumeByEntry.sql +++ b/db/routines/vn/procedures/buy_getVolumeByEntry.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getVolumeByEntry`(vEntryFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_getVolumeByEntry`(vEntryFk INT) BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.buy; diff --git a/db/routines/vn/procedures/buy_recalcPrices.sql b/db/routines/vn/procedures/buy_recalcPrices.sql index 35eb00cf1..dea272379 100644 --- a/db/routines/vn/procedures/buy_recalcPrices.sql +++ b/db/routines/vn/procedures/buy_recalcPrices.sql @@ -1,52 +1,59 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_recalcPrices`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_recalcPrices`() BEGIN /** - * Recalcula los precios para las compras insertadas en tmp.buyRecalc + * Recalcula los precios para las compras insertadas en tmp.buyRecalc. * * @param tmp.buyRecalc (id) */ DECLARE vLanded DATE; DECLARE vWarehouseFk INT; - DECLARE vHasNotPrice BOOL; - DECLARE vBuyingValue DECIMAL(10,4); - DECLARE vPackagingFk VARCHAR(10); DECLARE vIsWarehouseFloramondo BOOL; + DECLARE vDone BOOL; + DECLARE vTravels CURSOR FOR + SELECT t.landed, t.warehouseInFk, (w.code = 'flm') + FROM tmp.buyRecalc br + JOIN buy b ON b.id = br.id + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + JOIN warehouse w ON w.id = t.warehouseInFk + GROUP BY t.landed, t.warehouseInFk; - SELECT t.landed, t.warehouseInFk, (w.`name` = 'Floramondo') - INTO vLanded, vWarehouseFk, vIsWarehouseFloramondo - FROM tmp.buyRecalc br - JOIN buy b ON b.id = br.id - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseInFk - LIMIT 1; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - CALL rate_getPrices(vLanded, vWarehouseFk); + OPEN vTravels; + l: LOOP + SET vDone = FALSE; + FETCH vTravels INTO vLanded, vWarehouseFk, vIsWarehouseFloramondo; - UPDATE buy b - JOIN tmp.buyRecalc br ON br.id = b.id AND (@buyId := b.id) - LEFT JOIN packaging p ON p.id = b.packagingFk - JOIN item i ON i.id = b.itemFk - JOIN entry e ON e.id = b.entryFk - JOIN itemType it ON it.id = i.typeFk - JOIN travel tr ON tr.id = e.travelFk - JOIN agencyMode am ON am.id = tr.agencyModeFk - JOIN tmp.rate r - JOIN volumeConfig vc - SET b.freightValue = @PF:= IFNULL(((am.m3 * @m3:= item_getVolume(b.itemFk, b.packagingFk) / 1000000) - / b.packing) * IF(am.hasWeightVolumetric, GREATEST(b.weight / @m3 / vc.aerealVolumetricDensity, 1), 1), 0), - b.comissionValue = @CF:= ROUND(IFNULL(e.commission * b.buyingValue / 100, 0), 3), - b.packageValue = @EF:= IF(vIsWarehouseFloramondo, 0, IFNULL(ROUND(IF(p.isPackageReturnable, p.returnCost / b.packing , p.`value` / b.packing), 3),0)), - b.price3 = @t3:= IF(r.rate3 = 0, b.buyingValue,ROUND((b.buyingValue + @CF + @EF + @PF) / ((100 - r.rate3 - it.promo ) /100) ,2)), -- He añadido que el coste sea igual a tarifa3 si t3 = 0 - b.price2 = @t2:= round(@t3 * (1 + ((r.rate2 - r.rate3)/100)),2), - b.price2 = @t2:= IF(@t2 <= @t3,@t3 , @t2); + IF vDone THEN + LEAVE l; + END IF; - SELECT (b.buyingValue = b.price2), b.buyingValue, b.packagingFk - INTO vHasNotPrice, vBuyingValue, vPackagingFk - FROM vn.buy b - WHERE b.id = @buyId AND b.buyingValue <> 0.01; + CALL rate_getPrices(vLanded, vWarehouseFk); - DROP TEMPORARY TABLE tmp.rate; + UPDATE buy b + JOIN tmp.buyRecalc br ON br.id = b.id AND (@buyId := b.id) + LEFT JOIN packaging p ON p.id = b.packagingFk + JOIN item i ON i.id = b.itemFk + JOIN entry e ON e.id = b.entryFk + JOIN itemType it ON it.id = i.typeFk + JOIN travel tr ON tr.id = e.travelFk + JOIN agencyMode am ON am.id = tr.agencyModeFk + JOIN tmp.rate r + JOIN volumeConfig vc + SET b.freightValue = @PF:= IFNULL(((am.m3 * @m3:= item_getVolume(b.itemFk, b.packagingFk) / 1000000) + / b.packing) * IF(am.hasWeightVolumetric, GREATEST(b.weight / @m3 / vc.aerealVolumetricDensity, 1), 1), 0), + b.comissionValue = @CF:= ROUND(IFNULL(e.commission * b.buyingValue / 100, 0), 3), + b.packageValue = @EF:= IF(vIsWarehouseFloramondo, 0, IFNULL(ROUND(IF(p.isPackageReturnable, p.returnCost / b.packing , p.`value` / b.packing), 3),0)), + b.price3 = @t3:= IF(r.rate3 = 0, b.buyingValue,ROUND((b.buyingValue + @CF + @EF + @PF) / ((100 - r.rate3 - it.promo ) /100) ,2)), -- He añadido que el coste sea igual a tarifa3 si t3 = 0 + b.price2 = @t2:= round(@t3 * (1 + ((r.rate2 - r.rate3)/100)),2), + b.price2 = @t2:= IF(@t2 <= @t3,@t3 , @t2) + WHERE tr.landed = vLanded + AND tr.warehouseInFk = vWarehouseFk; + + DROP TEMPORARY TABLE tmp.rate; + END LOOP; + CLOSE vTravels; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/buy_recalcPricesByAwb.sql b/db/routines/vn/procedures/buy_recalcPricesByAwb.sql index 6f6baf305..fafc4763e 100644 --- a/db/routines/vn/procedures/buy_recalcPricesByAwb.sql +++ b/db/routines/vn/procedures/buy_recalcPricesByAwb.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_recalcPricesByAwb`(IN awbFk varchar(18)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_recalcPricesByAwb`(IN awbFk varchar(18)) BEGIN /** * inserta en tmp.buyRecalc las compras de un awb diff --git a/db/routines/vn/procedures/buy_recalcPricesByBuy.sql b/db/routines/vn/procedures/buy_recalcPricesByBuy.sql index b699e42d7..0801a9bea 100644 --- a/db/routines/vn/procedures/buy_recalcPricesByBuy.sql +++ b/db/routines/vn/procedures/buy_recalcPricesByBuy.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_recalcPricesByBuy`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_recalcPricesByBuy`( vBuyFk INT(11) ) BEGIN diff --git a/db/routines/vn/procedures/buy_recalcPricesByEntry.sql b/db/routines/vn/procedures/buy_recalcPricesByEntry.sql index 8d70d3626..e13548680 100644 --- a/db/routines/vn/procedures/buy_recalcPricesByEntry.sql +++ b/db/routines/vn/procedures/buy_recalcPricesByEntry.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_recalcPricesByEntry`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_recalcPricesByEntry`( vEntryFk INT(11) ) BEGIN diff --git a/db/routines/vn/procedures/buy_scan.sql b/db/routines/vn/procedures/buy_scan.sql index 0d4e8fcdb..e0c7c52de 100644 --- a/db/routines/vn/procedures/buy_scan.sql +++ b/db/routines/vn/procedures/buy_scan.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_scan`(vBarcode VARCHAR(512)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_scan`(vBarcode VARCHAR(512)) BEGIN /** * Busca compras a partir de un código de barras de subasta, las marca como diff --git a/db/routines/vn/procedures/buy_updateGrouping.sql b/db/routines/vn/procedures/buy_updateGrouping.sql index fb7adc0a3..b1b30dd2b 100644 --- a/db/routines/vn/procedures/buy_updateGrouping.sql +++ b/db/routines/vn/procedures/buy_updateGrouping.sql @@ -1,5 +1,9 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_updateGrouping`(vWarehouseFk INT, vItemFk INT, vGrouping INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_updateGrouping`( + vWarehouseFk INT, + vItemFk INT, + vGrouping INT +) BEGIN /** * Actualiza el grouping de las últimas compras de un artículo @@ -8,9 +12,9 @@ BEGIN * @param vItemFk Id del Artículo * @param vGrouping Cantidad de grouping */ - CALL vn.buyUltimate(vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(vItemFk, vWarehouseFk, util.VN_CURDATE()); - UPDATE vn.buy b + UPDATE buy b JOIN tmp.buyUltimate bu ON b.id = bu.buyFk SET b.`grouping` = vGrouping WHERE bu.warehouseFk = vWarehouseFk diff --git a/db/routines/vn/procedures/buy_updatePacking.sql b/db/routines/vn/procedures/buy_updatePacking.sql index d86edc98f..ad25352f2 100644 --- a/db/routines/vn/procedures/buy_updatePacking.sql +++ b/db/routines/vn/procedures/buy_updatePacking.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_updatePacking`(vWarehouseFk INT, vItemFk INT, vPacking INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_updatePacking`(vWarehouseFk INT, vItemFk INT, vPacking INT) BEGIN /** * Actualiza packing @@ -8,7 +8,7 @@ BEGIN * @param vItemFk id del item * @param vPacking packing a actualizar */ - CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(vItemFk, vWarehouseFk, util.VN_CURDATE()); UPDATE buy b JOIN tmp.buyUltimate bu ON b.id = bu.buyFk diff --git a/db/routines/vn/procedures/catalog_calcFromItem.sql b/db/routines/vn/procedures/catalog_calcFromItem.sql index 497fd107c..528cf0403 100644 --- a/db/routines/vn/procedures/catalog_calcFromItem.sql +++ b/db/routines/vn/procedures/catalog_calcFromItem.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`catalog_calcFromItem`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`catalog_calcFromItem`( vLanded DATE, vAddressFk INT, vAgencyModeFk INT, diff --git a/db/routines/vn/procedures/catalog_calculate.sql b/db/routines/vn/procedures/catalog_calculate.sql index bb52020df..39bf2b441 100644 --- a/db/routines/vn/procedures/catalog_calculate.sql +++ b/db/routines/vn/procedures/catalog_calculate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`catalog_calculate`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`catalog_calculate`( vLanded DATE, vAddressFk INT, vAgencyModeFk INT, @@ -29,7 +29,7 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, vShowExpiredZones); + CALL zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, vShowExpiredZones); DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; CREATE TEMPORARY TABLE tmp.ticketLot( @@ -45,8 +45,7 @@ BEGIN CALL catalog_componentPrepare(); - DROP TEMPORARY TABLE IF EXISTS tmp.ticketCalculateItem; - CREATE TEMPORARY TABLE tmp.ticketCalculateItem( + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem( itemFk INT(11) NOT NULL, available INT(11), producer VARCHAR(50), @@ -60,11 +59,11 @@ BEGIN price DECIMAL(10,2), priceKg DECIMAL(10,2), `grouping` INT(10) UNSIGNED, + minQuantity INT(10) UNSIGNED, PRIMARY KEY `itemFk` (`itemFk`) ) ENGINE = MEMORY DEFAULT CHARSET=utf8; OPEN cTravelTree; - l: LOOP SET vDone = FALSE; FETCH cTravelTree INTO vZoneFk, vWarehouseFk, vShipped; @@ -73,9 +72,9 @@ BEGIN LEAVE l; END IF; - CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped); - CALL `cache`.availableNoRaids_refresh (vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped); - CALL vn.buyUltimate(vWarehouseFk, vShipped); + CALL `cache`.available_refresh(vAvailableCalc, FALSE, vWarehouseFk, vShipped); + CALL `cache`.availableNoRaids_refresh(vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped); + CALL buy_getUltimate(NULL, vWarehouseFk, vShipped); INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk) SELECT vWarehouseFk, @@ -87,17 +86,17 @@ BEGIN LEFT JOIN cache.availableNoRaids anr ON anr.item_id = a.item_id AND anr.calc_id = vAvailableNoRaidsCalc JOIN tmp.item i ON i.itemFk = a.item_id - JOIN vn.item it ON it.id = i.itemFk - JOIN vn.`zone` z ON z.id = vZoneFk + JOIN item it ON it.id = i.itemFk + JOIN `zone` z ON z.id = vZoneFk LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = a.item_id LEFT JOIN edi.supplyResponse sr ON sr.ID = it.supplyResponseFk LEFT JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID LEFT JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID LEFT JOIN (SELECT isVNHSupplier, isEarlyBird, TRUE AS itemAllowed - FROM vn.addressFilter af + FROM addressFilter af JOIN (SELECT ad.provinceFk, p.countryFk, ad.isLogifloraAllowed - FROM vn.address ad - JOIN vn.province p ON p.id = ad.provinceFk + FROM address ad + JOIN province p ON p.id = ad.provinceFk WHERE ad.id = vAddressFk ) sub2 ON sub2.provinceFk <=> IFNULL(af.provinceFk, sub2.provinceFk) AND sub2.countryFk <=> IFNULL(af.countryFk, sub2.countryFk) @@ -109,34 +108,37 @@ BEGIN OR ISNULL(af.afterDated)) ) sub ON sub.isVNHSupplier = v.isVNHSupplier AND (sub.isEarlyBird = mp.isEarlyBird OR ISNULL(sub.isEarlyBird)) - JOIN vn.agencyMode am ON am.id = vAgencyModeFk - JOIN vn.agency ag ON ag.id = am.agencyFk - JOIN vn.itemType itt ON itt.id = it.typeFk - JOIN vn.itemCategory itc on itc.id = itt.categoryFk - JOIN vn.address ad ON ad.id = vAddressFk - LEFT JOIN vn.clientItemType cit + JOIN agencyMode am ON am.id = vAgencyModeFk + JOIN agency ag ON ag.id = am.agencyFk + JOIN itemType itt ON itt.id = it.typeFk + JOIN itemCategory itc on itc.id = itt.categoryFk + JOIN address ad ON ad.id = vAddressFk + LEFT JOIN clientItemType cit ON cit.clientFk = ad.clientFk AND cit.itemTypeFk = itt.id - LEFT JOIN vn.zoneItemType zit + LEFT JOIN zoneItemType zit ON zit.zoneFk = vZoneFk AND zit.itemTypeFk = itt.id - LEFT JOIN vn.agencyModeItemType ait + LEFT JOIN agencyModeItemType ait ON ait.agencyModeFk = vAgencyModeFk AND ait.itemTypeFk = itt.id WHERE a.calc_id = vAvailableCalc AND a.available > 0 AND (sub.itemAllowed OR NOT it.isFloramondo OR anr.available > 0) AND (ag.isAnyVolumeAllowed OR NOT itt.isUnconventionalSize) - AND (itc.isReclining OR it.`size` IS NULL OR it.`size` < z.itemMaxSize OR z.itemMaxSize IS NULL) + AND (it.`size` IS NULL + OR IF(itc.isReclining, + it.size <= z.itemMaxLength OR z.itemMaxLength IS NULL, + it.size <= z.itemMaxSize OR z.itemMaxSize IS NULL)) AND cit.id IS NULL AND zit.id IS NULL AND ait.id IS NULL; DROP TEMPORARY TABLE tmp.buyUltimate; - CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); + CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); - INSERT INTO tmp.ticketCalculateItem ( + INSERT INTO tmp.ticketCalculateItem( itemFk, available, producer, @@ -149,9 +151,9 @@ BEGIN origin, price, priceKg, - `grouping`) - SELECT - tl.itemFk, + `grouping`, + minQuantity) + SELECT tl.itemFk, SUM(tl.available) available, p.name producer, i.name item, @@ -163,7 +165,8 @@ BEGIN o.code origin, bl.price, bl.priceKg, - bl.`grouping` + bl.`grouping`, + mq.quantity FROM tmp.ticketLot tl JOIN item i ON tl.itemFk = i.id LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible @@ -179,12 +182,28 @@ BEGIN ) sub GROUP BY itemFk ) bl ON bl.itemFk = tl.itemFk - WHERE tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk + LEFT JOIN ( + WITH itemMinQuantityPriority AS ( + SELECT itemFk, + quantity, + ROW_NUMBER() OVER ( + PARTITION BY itemFk + ORDER BY warehouseFk IS NULL + ) priority + FROM vn.itemMinimumQuantity + WHERE `started` <= vShipped + AND (`ended` >= vShipped OR `ended` IS NULL) + AND (warehouseFk = vWarehouseFk OR warehouseFk IS NULL) + ) + SELECT itemFk, quantity + FROM itemMinQuantityPriority + WHERE priority = 1 + ) mq ON mq.itemFk = tl.itemFk + WHERE tl.zoneFk = vZoneFk + AND tl.warehouseFk = vWarehouseFk GROUP BY tl.itemFk ON DUPLICATE KEY UPDATE available = available + VALUES(available); - END LOOP; - CLOSE cTravelTree; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/catalog_componentCalculate.sql b/db/routines/vn/procedures/catalog_componentCalculate.sql index 92fe233c5..e29e13a8c 100644 --- a/db/routines/vn/procedures/catalog_componentCalculate.sql +++ b/db/routines/vn/procedures/catalog_componentCalculate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`catalog_componentCalculate`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`catalog_componentCalculate`( vZoneFk INT, vAddressFk INT, vShipped DATE, @@ -7,7 +7,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`catalog_componentCa ) BEGIN /** - * Calcula los componentes de los articulos de tmp.ticketLot + * Calcula los componentes de los articulos de la tabla tmp.ticketLot * * @param vZoneFk para calcular el transporte * @param vAddressFk Consignatario @@ -25,18 +25,41 @@ BEGIN FROM address WHERE id = vAddressFk; - CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice + CREATE OR REPLACE TEMPORARY TABLE tPriceDelta (INDEX (itemFk)) - ENGINE = MEMORY - SELECT * FROM ( + ENGINE = MEMORY + SELECT i.id itemFk, + SUM(IFNULL(pd.absIncreasing,0)) absIncreasing, + SUM(IFNULL(pd.ratIncreasing,0)) ratIncreasing, + pd.warehouseFk + FROM item i + JOIN priceDelta pd + ON pd.itemTypeFk = i.typeFk + AND (pd.minSize IS NULL OR pd.minSize <= i.`size`) + AND (pd.maxSize IS NULL OR pd.maxSize >= i.`size`) + AND (pd.inkFk IS NULL OR pd.inkFk = i.inkFk) + AND (pd.originFk IS NULL OR pd.originFk = i.originFk) + AND (pd.producerFk IS NULL OR pd.producerFk = i.producerFk) + AND (pd.warehouseFk IS NULL OR pd.warehouseFk = vWarehouseFk) + LEFT JOIN zoneGeo zg ON zg.id = pd.zoneGeoFk + LEFT JOIN zoneGeo zg2 ON zg2.id = address_getGeo(vAddressFk) + WHERE (pd.fromDated IS NULL OR pd.fromDated <= vShipped) + AND (pd.toDated IS NULL OR pd.toDated >= vShipped) + AND (pd.zoneGeoFk IS NULL OR zg2.lft BETWEEN zg.lft AND zg.rgt) + GROUP BY itemFk; + + CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice + (INDEX (itemFk)) + ENGINE = MEMORY + SELECT * FROM ( SELECT * - FROM specialPrice - WHERE (clientFk = vClientFk OR clientFk IS NULL) - AND started <= vShipped - AND (ended >= vShipped OR ended IS NULL) - ORDER BY (clientFk = vClientFk) DESC, id DESC - LIMIT 10000000000000000000) t - GROUP BY itemFk; + FROM specialPrice + WHERE (clientFk = vClientFk OR clientFk IS NULL) + AND started <= vShipped + AND (ended >= vShipped OR ended IS NULL) + ORDER BY (clientFk = vClientFk) DESC, id DESC + LIMIT 10000000000000000000) t + GROUP BY itemFk; CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentCalculate (PRIMARY KEY (itemFk, warehouseFk)) @@ -108,6 +131,19 @@ BEGIN JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tc.itemFk AND tcc.warehouseFk = tc.warehouseFk GROUP BY tc.itemFk, warehouseFk; + -- Bonus del comprador a un rango de productos + INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) + SELECT + tcb.warehouseFk, + tcb.itemFk, + c.id, + IFNULL(tcb.base * tpd.ratIncreasing / 100,0) + IFNULL(tpd.absIncreasing,0) + FROM tmp.ticketComponentBase tcb + JOIN component c ON c.code = 'bonus' + JOIN tPriceDelta tpd + ON tpd.itemFk = tcb.itemFk + AND tpd.warehouseFk = tcb.warehouseFk; + -- RECOBRO INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) SELECT tcb.warehouseFk, tcb.itemFk, c2.id, @@ -303,6 +339,7 @@ BEGIN tmp.ticketComponentBase, tmp.ticketComponentRate, tmp.ticketComponentCopy, - tSpecialPrice; + tPriceDelta, + tSpecialPrice; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/catalog_componentPrepare.sql b/db/routines/vn/procedures/catalog_componentPrepare.sql index 2e58a28e2..b16baf1c2 100644 --- a/db/routines/vn/procedures/catalog_componentPrepare.sql +++ b/db/routines/vn/procedures/catalog_componentPrepare.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`catalog_componentPrepare`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`catalog_componentPrepare`() BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; diff --git a/db/routines/vn/procedures/catalog_componentPurge.sql b/db/routines/vn/procedures/catalog_componentPurge.sql index c6a19ba62..448396a16 100644 --- a/db/routines/vn/procedures/catalog_componentPurge.sql +++ b/db/routines/vn/procedures/catalog_componentPurge.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`catalog_componentPurge`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`catalog_componentPurge`() BEGIN DROP TEMPORARY TABLE tmp.ticketComponentPrice, diff --git a/db/routines/vn/procedures/claimRatio_add.sql b/db/routines/vn/procedures/claimRatio_add.sql new file mode 100644 index 000000000..8c3213644 --- /dev/null +++ b/db/routines/vn/procedures/claimRatio_add.sql @@ -0,0 +1,190 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`claimRatio_add`() +BEGIN +/* +* Añade a la tabla greuges todos los cargos necesario y +* que luego lo utilizamos para calcular el recobro. +*/ + DECLARE vMonthToRefund INT + DEFAULT (SELECT monthsToRefund FROM claimConfig); + DECLARE vRecoveryGreugeType INT + DEFAULT (SELECT id FROM greugeType WHERE code = 'recovery'); + DECLARE vManaGreugeType INT + DEFAULT (SELECT id FROM greugeType WHERE code = 'mana'); + DECLARE vClaimGreugeType INT + DEFAULT (SELECT id FROM greugeType WHERE code = 'claim'); + DECLARE vDebtComponentType INT + DEFAULT (SELECT id FROM component WHERE code = 'debtCollection'); + + IF vMonthToRefund IS NULL + OR vRecoveryGreugeType IS NULL + OR vManaGreugeType IS NULL + OR vClaimGreugeType IS NULL + OR vDebtComponentType IS NULL THEN + + CALL util.throw('Required variables not found'); + END IF; + + -- Reclamaciones demasiado sensibles + INSERT INTO greuge( + shipped, + clientFk, + `description`, + amount, + greugeTypeFk, + ticketFk + ) + SELECT c.ticketCreated, + c.clientFk, + CONCAT('Claim ', c.id,' : ', s.concept), + ROUND(-1 * ((c.responsibility - 1) / 4) * s.quantity * + s.price * (100 - s.discount) / 100, 2), + vClaimGreugeType, + s.ticketFk + FROM sale s + JOIN claimEnd ce ON ce.saleFk = s.id + JOIN claimDestination cd ON cd.id = ce.claimDestinationFk + JOIN claim c ON c.id = ce.claimFk + JOIN claimState cs ON cs.id = c.claimStateFk + WHERE cd.description NOT IN ('Bueno', 'Corregido') + AND NOT ce.isGreuge + AND cs.code = 'resolved'; + + -- Reclamaciones que pasan a Maná + INSERT INTO greuge( + shipped, + clientFk, + `description`, + amount, + greugeTypeFk, + ticketFk + ) + SELECT c.ticketCreated, + c.clientFk, + CONCAT('Claim_mana ', c.id,' : ', s.concept), + ROUND(((c.responsibility - 1) / 4) * s.quantity * + s.price * (100 - s.discount) / 100, 2), + vManaGreugeType, + s.ticketFk + FROM sale s + JOIN claimEnd ce ON ce.saleFk = s.id + JOIN claimDestination cd ON cd.id = ce.claimDestinationFk + JOIN claim c ON c.id = ce.claimFk + JOIN claimState cs ON cs.id = c.claimStateFk + WHERE cd.description NOT IN ('Bueno', 'Corregido') + AND NOT ce.isGreuge + AND cs.code = 'resolved' + AND c.isChargedToMana; + + -- Marcamos para no repetir + UPDATE claimEnd ce + JOIN claimDestination cd ON cd.id = ce.claimDestinationFk + JOIN claim c ON c.id = ce.claimFk + JOIN claimState cs ON cs.id = c.claimStateFk + SET ce.isGreuge = TRUE + WHERE cd.description NOT IN ('Bueno', 'Corregido') + AND NOT ce.isGreuge + AND cs.code = 'resolved'; + + -- Recobros + CREATE OR REPLACE TEMPORARY TABLE tTicketList + (PRIMARY KEY (ticketFk)) + ENGINE = MEMORY + SELECT DISTINCT s.ticketFk + FROM saleComponent sc + JOIN sale s ON sc.saleFk = s.id + JOIN ticket t ON t.id = s.ticketFk + JOIN ticketLastState ts ON ts.ticketFk = t.id + JOIN ticketTracking tt ON tt.id = ts.ticketTrackingFk + JOIN state st ON st.id = tt.stateFk + JOIN alertLevel al ON al.id = st.alertLevel + WHERE sc.componentFk = vDebtComponentType + AND NOT sc.isGreuge + AND t.shipped >= (SELECT minShipped FROM claimConfig) + AND t.shipped < util.VN_CURDATE() + AND al.code = 'DELIVERED'; + + DELETE g.* + FROM greuge g + JOIN tTicketList t ON t.ticketFk = g.ticketFk + WHERE g.greugeTypeFk = vRecoveryGreugeType; + + INSERT INTO greuge( + clientFk, + `description`, + amount, + shipped, + greugeTypeFk, + ticketFk + ) + SELECT t.clientFk, + 'Recobro', + - ROUND(SUM(sc.value * s.quantity), 2) dif, + DATE(t.shipped), + vRecoveryGreugeType, + tl.ticketFk + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN tTicketList tl ON tl.ticketFk = t.id + JOIN saleComponent sc ON sc.saleFk = s.id + AND sc.componentFk = vDebtComponentType + GROUP BY t.id + HAVING ABS(dif) > 1; + + UPDATE saleComponent sc + JOIN sale s ON s.id = sc.saleFk + JOIN tTicketList tl ON tl.ticketFk = s.ticketFk + SET sc.isGreuge = TRUE + WHERE sc.componentFk = vDebtComponentType; + + REPLACE claimRatio( + clientFk, + yearSale, + claimAmount, + claimingRate, + priceIncreasing + ) + SELECT c.id, + 12 * cac.invoiced, + totalClaims, + ROUND(totalClaims / (12 * cac.invoiced), 4), + 0 + FROM client c + LEFT JOIN bs.clientAnnualConsumption cac ON cac.clientFk = c.id + LEFT JOIN ( + SELECT c.clientFk, + ROUND(SUM(-1 * ((c.responsibility - 1) / 4) * + s.quantity * s.price * (100 - s.discount) + / 100)) totalClaims + FROM sale s + JOIN claimEnd ce ON ce.saleFk = s.id + JOIN claimDestination cd ON cd.id = ce.claimDestinationFk + JOIN claim c ON c.id = ce.claimFk + JOIN claimState cs ON cs.id = c.claimStateFk + WHERE cd.description NOT IN ('Bueno', 'Corregido') + AND cs.code = 'resolved' + AND c.ticketCreated >= util.VN_CURDATE() - INTERVAL 1 YEAR + GROUP BY c.clientFk + ) sub ON sub.clientFk = c.id; + + -- Calculamos el porcentaje del recobro para añadirlo al precio de venta + UPDATE claimRatio cr + JOIN ( + SELECT clientFk, IFNULL(SUM(amount), 0) greuge + FROM greuge + WHERE shipped <= util.VN_CURDATE() + GROUP BY clientFk + ) sub ON sub.clientFk = cr.clientFk + SET cr.priceIncreasing = GREATEST(0, ROUND(IFNULL(sub.greuge, 0) / + (IFNULL(cr.yearSale, 0) * vMonthToRefund / 12 ), 3)); + + -- Protección neonatos + UPDATE claimRatio cr + JOIN firstTicketShipped fts ON fts.clientFk = cr.clientFk + SET cr.priceIncreasing = 0, + cr.claimingRate = 0 + WHERE fts.shipped > util.VN_CURDATE() - INTERVAL 1 MONTH; + + DROP TEMPORARY TABLE tTicketList; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index 6645b9cb2..d3fed0242 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`clean`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`clean`() BEGIN /** * Purges outdated data to optimize performance. @@ -19,15 +19,24 @@ BEGIN DELETE FROM workerActivity WHERE created < v2Years; DELETE FROM ticketParking WHERE created < v2Months; DELETE FROM routesMonitor WHERE dated < v2Months; - DELETE FROM workerTimeControlLog WHERE created < v2Months; DELETE FROM `message` WHERE sendDate < v2Months; DELETE FROM messageInbox WHERE sendDate < v2Months; DELETE FROM messageInbox WHERE sendDate < v2Months; DELETE FROM workerTimeControl WHERE timed < v4Years; + DELETE FROM itemShelvingSale + WHERE itemShelvingFk IN ( + SELECT id + FROM itemShelving + WHERE created < util.VN_CURDATE() + AND visible = 0 + ); DELETE FROM itemShelving WHERE created < util.VN_CURDATE() AND visible = 0; DELETE FROM ticketDown WHERE created < util.yesterday(); - DELETE FROM entryLog WHERE creationDate < v2Months; DELETE IGNORE FROM expedition WHERE created < v26Months; + DELETE cs + FROM sms s + JOIN clientSms cs ON cs.smsFk = s.id + WHERE s.created < v18Months; DELETE FROM sms WHERE created < v18Months; DELETE FROM saleTracking WHERE created < v1Years; DELETE FROM productionError WHERE dated < v1Years; @@ -48,20 +57,11 @@ BEGIN DELETE FROM claim WHERE ticketCreated < v4Years; -- Robert ubicacion anterior de travelLog comentario para debug DELETE FROM zoneEvent WHERE `type` = 'day' AND dated < v3Months; - DELETE bm - FROM buyMark bm - JOIN buy b ON b.id = bm.id - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed <= v2Months; DELETE b FROM buy b JOIN entryConfig e ON e.defaultEntry = b.entryFk WHERE b.created < v2Months; - DELETE FROM itemShelvingLog WHERE created < v2Months; - DELETE FROM stockBuyed WHERE creationDate < v2Months; - DELETE FROM itemCleanLog WHERE created < util.VN_NOW() - INTERVAL 1 YEAR; + DELETE FROM stockBought WHERE dated < v2Months; DELETE FROM printQueue WHERE statusCode = 'printed' AND created < v2Months; - DELETE FROM ticketLog WHERE creationDate <= v5Years; -- Equipos duplicados DELETE w.* FROM workerTeam w @@ -170,7 +170,6 @@ BEGIN -- Borra los registros de collection y ticketcollection DELETE FROM collection WHERE created < v2Months; - DELETE FROM travelLog WHERE creationDate < v3Months; CALL shelving_clean(); diff --git a/db/routines/vn/procedures/clean_logiflora.sql b/db/routines/vn/procedures/clean_logiflora.sql index dd08410fd..fd645a158 100644 --- a/db/routines/vn/procedures/clean_logiflora.sql +++ b/db/routines/vn/procedures/clean_logiflora.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`clean_logiflora`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`clean_logiflora`() BEGIN /** * Elimina las compras y los artículos residuales de logiflora. diff --git a/db/routines/vn/procedures/clearShelvingList.sql b/db/routines/vn/procedures/clearShelvingList.sql deleted file mode 100644 index dbaca2747..000000000 --- a/db/routines/vn/procedures/clearShelvingList.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`clearShelvingList`(vShelvingFk VARCHAR(8)) -BEGIN - UPDATE vn.itemShelving - SET visible = 0 - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk COLLATE utf8_unicode_ci; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/clientDebtSpray.sql b/db/routines/vn/procedures/clientDebtSpray.sql index 687c08fe2..5248432fe 100644 --- a/db/routines/vn/procedures/clientDebtSpray.sql +++ b/db/routines/vn/procedures/clientDebtSpray.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`clientDebtSpray`(vClientFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`clientDebtSpray`(vClientFk INT) BEGIN /* Reparte el saldo de un cliente en greuge en la cartera que corresponde, y desasigna el comercial diff --git a/db/routines/vn/procedures/clientFreeze.sql b/db/routines/vn/procedures/clientFreeze.sql index c89db2316..727311174 100644 --- a/db/routines/vn/procedures/clientFreeze.sql +++ b/db/routines/vn/procedures/clientFreeze.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`clientFreeze`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`clientFreeze`() BEGIN /** * Congela diariamente aquellos clientes que son morosos sin recobro, diff --git a/db/routines/vn/procedures/clientGetDebtDiary.sql b/db/routines/vn/procedures/clientGetDebtDiary.sql index bd7a0b292..c4a52ab74 100644 --- a/db/routines/vn/procedures/clientGetDebtDiary.sql +++ b/db/routines/vn/procedures/clientGetDebtDiary.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`clientGetDebtDiary`(vClientFK INT, vCompanyFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`clientGetDebtDiary`(vClientFK INT, vCompanyFk INT) BEGIN /** * Devuelve el registro de deuda diff --git a/db/routines/vn/procedures/clientGreugeSpray.sql b/db/routines/vn/procedures/clientGreugeSpray.sql index c337e2dd3..2007d13a5 100644 --- a/db/routines/vn/procedures/clientGreugeSpray.sql +++ b/db/routines/vn/procedures/clientGreugeSpray.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`clientGreugeSpray`(IN vClientFk INT, IN onlyForHisOwner BOOL, IN vWorkerCode VARCHAR(3), IN vWithMana BOOLEAN) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`clientGreugeSpray`(IN vClientFk INT, IN onlyForHisOwner BOOL, IN vWorkerCode VARCHAR(3), IN vWithMana BOOLEAN) BEGIN DECLARE vGreuge DECIMAL(10,2); diff --git a/db/routines/vn/procedures/clientPackagingOverstock.sql b/db/routines/vn/procedures/clientPackagingOverstock.sql index fcd34c41b..901236bf8 100644 --- a/db/routines/vn/procedures/clientPackagingOverstock.sql +++ b/db/routines/vn/procedures/clientPackagingOverstock.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`clientPackagingOverstock`(vClientFk INT, vGraceDays INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`clientPackagingOverstock`(vClientFk INT, vGraceDays INT) BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.clientPackagingOverstock; CREATE TEMPORARY TABLE tmp.clientPackagingOverstock diff --git a/db/routines/vn/procedures/clientPackagingOverstockReturn.sql b/db/routines/vn/procedures/clientPackagingOverstockReturn.sql index ac37bbc8d..a05e11d1b 100644 --- a/db/routines/vn/procedures/clientPackagingOverstockReturn.sql +++ b/db/routines/vn/procedures/clientPackagingOverstockReturn.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`clientPackagingOverstockReturn`(vClientFk INT, vGraceDays INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`clientPackagingOverstockReturn`(vClientFk INT, vGraceDays INT) BEGIN DECLARE vNewTicket INT DEFAULT 0; DECLARE vWarehouseFk INT; diff --git a/db/routines/vn/procedures/clientRemoveWorker.sql b/db/routines/vn/procedures/clientRemoveWorker.sql index 15d247c67..e2a6b8013 100644 --- a/db/routines/vn/procedures/clientRemoveWorker.sql +++ b/db/routines/vn/procedures/clientRemoveWorker.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`clientRemoveWorker`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`clientRemoveWorker`() BEGIN DECLARE vDone BOOL DEFAULT FALSE; DECLARE vClientFk INT; diff --git a/db/routines/vn/procedures/clientRisk_update.sql b/db/routines/vn/procedures/clientRisk_update.sql index 30ab3265f..2a7644b30 100644 --- a/db/routines/vn/procedures/clientRisk_update.sql +++ b/db/routines/vn/procedures/clientRisk_update.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`clientRisk_update`(vClientId INT, vCompanyId INT, vAmount DECIMAL(10,2)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`clientRisk_update`(vClientId INT, vCompanyId INT, vAmount DECIMAL(10,2)) BEGIN IF vAmount IS NOT NULL THEN diff --git a/db/routines/vn/procedures/client_RandomList.sql b/db/routines/vn/procedures/client_RandomList.sql index 2bd0d609b..92b460522 100644 --- a/db/routines/vn/procedures/client_RandomList.sql +++ b/db/routines/vn/procedures/client_RandomList.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_RandomList`(vNumber INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`client_RandomList`(vNumber INT) BEGIN DECLARE i INT DEFAULT 0; diff --git a/db/routines/vn/procedures/client_checkBalance.sql b/db/routines/vn/procedures/client_checkBalance.sql index 210fcc00f..c5ea717a2 100644 --- a/db/routines/vn/procedures/client_checkBalance.sql +++ b/db/routines/vn/procedures/client_checkBalance.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_checkBalance`(IN vDateTo DATETIME, IN vIsConciliated BOOL) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`client_checkBalance`(IN vDateTo DATETIME, IN vIsConciliated BOOL) BEGIN /** * Compara los datos de nuestros clientes con diff --git a/db/routines/vn/procedures/client_create.sql b/db/routines/vn/procedures/client_create.sql index d5d7258a1..3df3df905 100644 --- a/db/routines/vn/procedures/client_create.sql +++ b/db/routines/vn/procedures/client_create.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_create`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`client_create`( vFirstname VARCHAR(50), vSurnames VARCHAR(50), vFi VARCHAR(9), @@ -34,20 +34,25 @@ BEGIN DECLARE vIsTaxDataChecked TINYINT(1); DECLARE vHasCoreVnl BOOLEAN; DECLARE vMandateTypeFk INT; + DECLARE vHasDailyInvoice BOOLEAN; - SELECT defaultPayMethodFk, - defaultDueDay, - defaultCredit, - defaultIsTaxDataChecked, - defaultHasCoreVnl, - defaultMandateTypeFk + SELECT cc.defaultPayMethodFk, + cc.defaultDueDay, + cc.defaultCredit, + cc.defaultIsTaxDataChecked, + cc.defaultHasCoreVnl, + cc.defaultMandateTypeFk, + c.hasDailyInvoice INTO vPayMethodFk, vDueDay, vDefaultCredit, vIsTaxDataChecked, vHasCoreVnl, - vMandateTypeFk - FROM clientConfig; + vMandateTypeFk, + vHasDailyInvoice + FROM clientConfig cc + LEFT JOIN province p ON p.id = vProvinceFk + LEFT JOIN country c ON c.id = p.countryFk; INSERT INTO `client` SET id = vUserFk, @@ -65,7 +70,8 @@ BEGIN credit = vDefaultCredit, isTaxDataChecked = vIsTaxDataChecked, hasCoreVnl = vHasCoreVnl, - isEqualizated = FALSE + isEqualizated = FALSE, + hasDailyInvoice = vHasDailyInvoice ON duplicate KEY UPDATE payMethodFk = vPayMethodFk, dueDay = vDueDay, diff --git a/db/routines/vn/procedures/client_getDebt.sql b/db/routines/vn/procedures/client_getDebt.sql index 3eaace4e9..e5726f2c1 100644 --- a/db/routines/vn/procedures/client_getDebt.sql +++ b/db/routines/vn/procedures/client_getDebt.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_getDebt`(vDate DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`client_getDebt`(vDate DATE) BEGIN /** * Calculates the risk for active clients diff --git a/db/routines/vn/procedures/client_getMana.sql b/db/routines/vn/procedures/client_getMana.sql index f5bb5747d..7b5e01e38 100644 --- a/db/routines/vn/procedures/client_getMana.sql +++ b/db/routines/vn/procedures/client_getMana.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_getMana`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`client_getMana`() BEGIN /** * Devuelve el mana de los clientes de la tabla tmp.client(id) diff --git a/db/routines/vn/procedures/client_getRisk.sql b/db/routines/vn/procedures/client_getRisk.sql index 106284c2f..afe34a5e1 100644 --- a/db/routines/vn/procedures/client_getRisk.sql +++ b/db/routines/vn/procedures/client_getRisk.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_getRisk`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`client_getRisk`( vDate DATE ) BEGIN diff --git a/db/routines/vn/procedures/client_unassignSalesPerson.sql b/db/routines/vn/procedures/client_unassignSalesPerson.sql index f939ae68b..720a94722 100644 --- a/db/routines/vn/procedures/client_unassignSalesPerson.sql +++ b/db/routines/vn/procedures/client_unassignSalesPerson.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_unassignSalesPerson`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`client_unassignSalesPerson`() BEGIN /** * Elimina la asignación de salesPersonFk de la ficha del clientes @@ -26,6 +26,7 @@ BEGIN JOIN province p ON p.id = c.provinceFk LEFT JOIN autonomy a ON a.id = p.autonomyFk JOIN country co ON co.id = p.countryFk + JOIN bs.clientDiedPeriod cdp ON cdp.countryFk = co.id WHERE cd.warning = 'third' AND cp.clientFk IS NULL AND sp.salesPersonFk IS NULL diff --git a/db/routines/vn/procedures/client_userDisable.sql b/db/routines/vn/procedures/client_userDisable.sql index f2ba65c1c..1a7c9846b 100644 --- a/db/routines/vn/procedures/client_userDisable.sql +++ b/db/routines/vn/procedures/client_userDisable.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_userDisable`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`client_userDisable`() BEGIN /** * Desactiva los clientes inactivos en los últimos X meses. @@ -21,6 +21,7 @@ BEGIN AND a.id IS NULL AND u.active AND c.created < util.VN_CURDATE() - INTERVAL vMonths MONTH + AND NOT u.role = (SELECT id FROM `role` WHERE name = 'supplier') AND u.id NOT IN ( SELECT DISTINCT c.id FROM client c diff --git a/db/routines/vn/procedures/cmrPallet_add.sql b/db/routines/vn/procedures/cmrPallet_add.sql index 2267cd312..befd3d09c 100644 --- a/db/routines/vn/procedures/cmrPallet_add.sql +++ b/db/routines/vn/procedures/cmrPallet_add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`cmrPallet_add`(vExpeditionPalletFk INT, vCmrFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`cmrPallet_add`(vExpeditionPalletFk INT, vCmrFk INT) BEGIN /** * Añade registro a tabla cmrPallet. diff --git a/db/routines/vn/procedures/collectionPlacement_get.sql b/db/routines/vn/procedures/collectionPlacement_get.sql index 3fb3339e7..239dbd3a2 100644 --- a/db/routines/vn/procedures/collectionPlacement_get.sql +++ b/db/routines/vn/procedures/collectionPlacement_get.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collectionPlacement_get`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collectionPlacement_get`( vParamFk INT(11), vIsPicker bool) BEGIN @@ -55,24 +55,20 @@ BEGIN SELECT ts.saleFk, ts.itemFk, CAST(0 AS DECIMAL(10,0)) saleOrder, - IF(ish.visible > 0 OR iss.id, 1, 100000) * - IFNULL(p2.pickingOrder, p.pickingOrder) `order`, - TO_SECONDS(IF(iss.id, - iss.created - INTERVAL vCurrentYear YEAR, - ish.created - INTERVAL YEAR(ish.created) YEAR)) priority, + (IF(ish.visible > 0 OR iss.id, 1, 100000) * + COALESCE(p2.pickingOrder, p.pickingOrder)) `order`, + TO_SECONDS(COALESCE(iss.created, ish.created)) - TO_SECONDS(MAKEDATE(IFNULL(YEAR(iss.created), YEAR(ish.created)), 1)) priority, CONCAT( - IF(iss.id, - CONCAT('< ', IFNULL(wk.`code`, '---'),' > '), - ''), - p.`code`) COLLATE utf8_general_ci placement, + IF(iss.id, CONCAT('< ', COALESCE(wk.`code`, '---'),' > '), ''), + p.`code` + ) COLLATE utf8_general_ci placement, sh.priority shelvingPriority, sh.code COLLATE utf8_general_ci shelving, ish.created, ish.visible, - IFNULL( - IF(st.code = 'previousByPacking', ish.packing, g.`grouping`), - 1) `grouping`, - st.code = 'previousPrepared' isPreviousPrepared, + COALESCE( + IF(st.code = 'previousByPacking', ish.packing, g.`grouping`),1) `grouping`, + (st.code = 'previousPrepared') isPreviousPrepared, iss.id itemShelvingSaleFk, ts.ticketFk, iss.id, @@ -80,11 +76,12 @@ BEGIN iss.userFk, ts.quantity FROM tSale ts - LEFT JOIN (SELECT DISTINCT saleFk - FROM saleTracking st - JOIN state s ON s.id = st.stateFk - WHERE st.isChecked - AND s.semaphore = 1) st ON st.saleFk = ts.saleFk + LEFT JOIN (SELECT st.saleFk + FROM saleTracking st + JOIN state s ON s.id = st.stateFk + WHERE st.isChecked + AND s.semaphore = 1 + GROUP BY st.saleFk) st ON st.saleFk = ts.saleFk JOIN itemShelving ish ON ish.itemFk = ts.itemFk JOIN shelving sh ON sh.code = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk @@ -93,14 +90,14 @@ BEGIN JOIN warehouse w ON w.id = sc.warehouseFk LEFT JOIN tGrouping g ON g.itemFk = ts.itemFk LEFT JOIN itemShelvingSale iss ON iss.saleFk = ts.saleFk - AND iss.itemShelvingFk = ish.id + AND iss.itemShelvingFk = ish.id LEFT JOIN worker wk ON wk.id = iss.userFk LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = ts.saleFk LEFT JOIN saleGroup sg ON sg.id = sgd.saleGroupFk LEFT JOIN parking p2 ON p2.id = sg.parkingFk WHERE w.id = vWarehouseFk - AND NOT sc.isHideForPickers - HAVING (iss.id AND st.saleFk) OR salePreviousPrepared IS NULL; + AND NOT sc.isHideForPickers + AND ((iss.id AND st.saleFk) OR st.saleFk IS NULL); CREATE OR REPLACE TEMPORARY TABLE tSalePlacementList2 (INDEX(saleFk), INDEX(olderPriority)) diff --git a/db/routines/vn/procedures/collection_addItem.sql b/db/routines/vn/procedures/collection_addItem.sql index b5bc91c67..7cd374181 100644 --- a/db/routines/vn/procedures/collection_addItem.sql +++ b/db/routines/vn/procedures/collection_addItem.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_addItem`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_addItem`( vBarccodeFk INT, vQuantity INT, vTicketFk INT diff --git a/db/routines/vn/procedures/collection_addWithReservation.sql b/db/routines/vn/procedures/collection_addWithReservation.sql new file mode 100644 index 000000000..cc0b7fd9b --- /dev/null +++ b/db/routines/vn/procedures/collection_addWithReservation.sql @@ -0,0 +1,90 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_addWithReservation`( + vItemFk INT, + vQuantity INT, + vTicketFk INT, + vSaleGroupFk INT, + vSectorFk INT +) +BEGIN +/** + * En el ámbito de las colecciones se añade una línea de sale a un ticket + * de una colección en caso de tener disponible y se realiza la reserva. + * + * @param vItemFk id of item + * @param vQuantity quantity to be added to the ticket + * @param vTicketFk ticket to which the sales line is added + * @param vSaleGroupFk saleGroupFk id to add saleGroupDetail + */ + + DECLARE vWarehouseFk INT; + DECLARE vCacheAvailableFk INT; + DECLARE vAvailable INT; + DECLARE vSaleFk INT; + DECLARE vConcept VARCHAR(50); + DECLARE vItemName VARCHAR(50); + DECLARE vHasThrow BOOLEAN DEFAULT FALSE; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + SELECT t.warehouseFk INTO vWarehouseFk + FROM ticket t + JOIN ticketCollection tc ON tc.ticketFk = t.id + WHERE t.id = vTicketFk; + + CALL cache.available_refresh( + vCacheAvailableFk, + FALSE, + vWarehouseFk, + util.VN_CURDATE()); + + SELECT available INTO vAvailable + FROM cache.available + WHERE calc_id = vCacheAvailableFk + AND item_id = vItemFk; + + IF vAvailable < vQuantity THEN + SET vHasThrow = TRUE; + ELSE + SELECT `name`, + CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name) + INTO vItemName, vConcept + FROM item + WHERE id = vItemFk; + + START TRANSACTION; + + INSERT INTO sale + SET itemFk = vItemFk, + ticketFk = vTicketFk, + concept = vConcept, + quantity = vQuantity, + isAdded = TRUE; + + SELECT LAST_INSERT_ID() INTO vSaleFk; + + CALL sale_calculateComponent(vSaleFk, NULL); + CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk); + + IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN + SET vHasThrow = TRUE; + END IF; + END IF; + + IF vHasThrow THEN + CALL util.throw("There is no available for the selected item"); + END IF; + + IF vSaleGroupFk THEN + INSERT INTO saleGroupDetail + SET saleFk = vSaleFk, + saleGroupFk = vSaleGroupFk; + END IF; + + COMMIT; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index c2b6e538e..a4c861c96 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -1,9 +1,9 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_assign`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_assign`( vUserFk INT, OUT vCollectionFk INT ) -BEGIN +BEGIN /** * Comprueba si existen colecciones libres que se ajustan * al perfil del usuario y le asigna la más antigua. @@ -13,100 +13,130 @@ BEGIN * @param vCollectionFk Id de colección */ DECLARE vHasTooMuchCollections BOOL; - DECLARE vItemPackingTypeFk VARCHAR(1); - DECLARE vWarehouseFk INT; - DECLARE vLockName VARCHAR(215); - DECLARE vLockTime INT DEFAULT 30; + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vCollectionWorker INT; + DECLARE vMaxNotAssignedCollectionLifeTime TIME; + + DECLARE vCollections CURSOR FOR + WITH collections AS ( + SELECT tc.collectionFk, + SUM(sv.volume) volume, + c.saleTotalCount, + c.itemPackingTypeFk, + c.trainFk, + c.warehouseFk, + c.wagons + FROM vn.ticketCollection tc + JOIN vn.collection c ON c.id = tc.collectionFk + JOIN vn.saleVolume sv ON sv.ticketFk = tc.ticketFk + WHERE c.workerFk IS NULL + AND sv.shipped >= util.VN_CURDATE() + GROUP BY tc.collectionFk + ) SELECT c.collectionFk + FROM collections c + JOIN vn.operator o + WHERE o.workerFk = vUserFk + AND (c.saleTotalCount <= o.linesLimit OR o.linesLimit IS NULL) + AND (c.itemPackingTypeFk = o.itemPackingTypeFk OR o.itemPackingTypeFk IS NULL) + AND o.numberOfWagons = c.wagons + AND o.trainFk = c.trainFk + AND o.warehouseFk = c.warehouseFk; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + -- Si hay colecciones sin terminar, sale del proceso DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN - IF vLockName IS NOT NULL THEN - DO RELEASE_LOCK(vLockName); - END IF; - + ROLLBACK; RESIGNAL; END; - -- Si hay colecciones sin terminar, sale del proceso CALL collection_get(vUserFk); - SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, - collection_assign_lockname - INTO vHasTooMuchCollections, - vLockName + SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, pc.maxNotAssignedCollectionLifeTime + INTO vHasTooMuchCollections, vMaxNotAssignedCollectionLifeTime FROM productionConfig pc - LEFT JOIN tCollection ON TRUE; + LEFT JOIN tmp.collection ON TRUE; - DROP TEMPORARY TABLE tCollection; + DROP TEMPORARY TABLE tmp.collection; IF vHasTooMuchCollections THEN CALL util.throw('Hay colecciones pendientes'); END IF; - SELECT warehouseFk, itemPackingTypeFk - INTO vWarehouseFk, vItemPackingTypeFk - FROM operator - WHERE workerFk = vUserFk; - - SET vLockName = CONCAT_WS('/', - vLockName, - vWarehouseFk, - vItemPackingTypeFk - ); - - IF NOT GET_LOCK(vLockName, vLockTime) THEN - CALL util.throw(CONCAT('Cannot get lock: ', vLockName)); - END IF; - -- Se eliminan las colecciones sin asignar que estan obsoletas - INSERT INTO ticketTracking(stateFk, ticketFk) - SELECT s.id, tc.ticketFk - FROM `collection` c - JOIN ticketCollection tc ON tc.collectionFk = c.id - JOIN `state` s ON s.code = 'PRINTED_AUTO' - JOIN productionConfig pc - WHERE c.workerFk IS NULL - AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime; - DELETE c.* - FROM `collection` c - JOIN productionConfig pc - WHERE c.workerFk IS NULL - AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime; + INSERT INTO ticketTracking(stateFk, ticketFk) + SELECT s.id, tc.ticketFk + FROM `collection` c + JOIN ticketCollection tc ON tc.collectionFk = c.id + JOIN `state` s ON s.code = 'PRINTED_AUTO' + WHERE c.workerFk IS NULL + AND TIMEDIFF(util.VN_NOW(), c.created) > vMaxNotAssignedCollectionLifeTime; + + DELETE FROM `collection` + WHERE workerFk IS NULL + AND TIMEDIFF(util.VN_NOW(), created) > vMaxNotAssignedCollectionLifeTime; -- Se añade registro al semillero - INSERT INTO collectionHotbed(userFk) - VALUES(vUserFk); + + INSERT INTO collectionHotbed(userFk) VALUES(vUserFk); -- Comprueba si hay colecciones disponibles que se ajustan a su configuracion - SELECT MIN(c.id) - INTO vCollectionFk - FROM `collection` c - JOIN operator o - ON (o.itemPackingTypeFk = c.itemPackingTypeFk OR c.itemPackingTypeFk IS NULL) - AND o.numberOfWagons = c.wagons - AND o.trainFk = c.trainFk - AND o.warehouseFk = c.warehouseFk - AND c.workerFk IS NULL - AND (c.saleTotalCount <= o.linesLimit OR o.linesLimit IS NULL) - JOIN ( - SELECT tc.collectionFk, SUM(sv.volume) volume - FROM ticketCollection tc - JOIN saleVolume sv ON sv.ticketFk = tc.ticketFk - WHERE sv.shipped >= util.VN_CURDATE() - GROUP BY tc.collectionFk - ) sub ON sub.collectionFk = c.id - AND (volume <= o.volumeLimit OR o.volumeLimit IS NULL) - WHERE o.workerFk = vUserFk; + + OPEN vCollections; + l: LOOP + SET vDone = FALSE; + FETCH vCollections INTO vCollectionFk; + + IF vDone THEN + LEAVE l; + END IF; + + BEGIN + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + SET vCollectionFk = NULL; + RESIGNAL; + END; + + START TRANSACTION; + + SELECT workerFk INTO vCollectionWorker + FROM `collection` + WHERE id = vCollectionFk FOR UPDATE; + + IF vCollectionWorker IS NULL THEN + UPDATE `collection` + SET workerFk = vUserFk + WHERE id = vCollectionFk; + + COMMIT; + LEAVE l; + END IF; + + ROLLBACK; + END; + END LOOP; + CLOSE vCollections; IF vCollectionFk IS NULL THEN CALL collection_new(vUserFk, vCollectionFk); + + START TRANSACTION; + + SELECT workerFk INTO vCollectionWorker + FROM `collection` + WHERE id = vCollectionFk FOR UPDATE; + + IF vCollectionWorker IS NULL THEN + UPDATE `collection` + SET workerFk = vUserFk + WHERE id = vCollectionFk; + END IF; + + COMMIT; END IF; - - UPDATE `collection` - SET workerFk = vUserFk - WHERE id = vCollectionFk; - - DO RELEASE_LOCK(vLockName); END$$ -DELIMITER ; +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/collection_get.sql b/db/routines/vn/procedures/collection_get.sql index 372d963c0..7da3d364e 100644 --- a/db/routines/vn/procedures/collection_get.sql +++ b/db/routines/vn/procedures/collection_get.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_get`(vWorkerFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_get`(vWorkerFk INT) BEGIN /** * Obtiene colección del sacador si tiene líneas pendientes. @@ -7,27 +7,32 @@ BEGIN * @param vWorkerFk id del worker. * @table Devuelve tabla temporal con las colecciones pendientes */ - DROP TEMPORARY TABLE IF EXISTS tCollection; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + RESIGNAL; + END; - CREATE TEMPORARY TABLE tCollection - SELECT c.id collectionFk, - date(c.created) created, - COUNT(DISTINCT tc.ticketFk) ticketTotalCount - FROM collection c - JOIN ticketCollection tc ON tc.collectionFk = c.id - JOIN sale s ON s.ticketFk = tc.ticketFk - JOIN ticketState ts ON ts.ticketFk = tc.ticketFk - JOIN state s2 ON s2.id = ts.stateFk - JOIN productionConfig pc - JOIN vn.state ss on ss.code = 'PREPARED' - LEFT JOIN vn.saleTracking st on st.saleFk = s.id AND st.stateFk = ss.id - WHERE c.workerFk = vWorkerFk - AND TIMESTAMPDIFF(HOUR, c.created , util.VN_NOW()) < pc.pendingCollectionsAge - AND s.quantity != 0 - AND s2.order < pc.pendingCollectionsOrder - GROUP BY c.id - HAVING COUNT(*) > COUNT(DISTINCT st.id); + CREATE OR REPLACE TEMPORARY TABLE tmp.collection + ENGINE = MEMORY + SELECT c.id collectionFk, + DATE(c.created) created, + COUNT(DISTINCT tc.ticketFk) ticketTotalCount + FROM collection c + JOIN ticketCollection tc ON tc.collectionFk = c.id + JOIN sale s ON s.ticketFk = tc.ticketFk + JOIN ticketState ts ON ts.ticketFk = tc.ticketFk + JOIN state s2 ON s2.id = ts.stateFk + JOIN productionConfig pc + JOIN vn.state ss ON ss.code = 'PREPARED' + LEFT JOIN vn.saleTracking st ON st.saleFk = s.id + AND st.stateFk = ss.id + WHERE c.workerFk = vWorkerFk + AND TIMESTAMPDIFF(HOUR, c.created , util.VN_NOW()) < pc.pendingCollectionsAge + AND s.quantity + AND s2.order < pc.pendingCollectionsOrder + GROUP BY c.id + HAVING COUNT(*) > COUNT(DISTINCT st.id); - SELECT * FROM tCollection; + SELECT * FROM tmp.collection; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/collection_getAssigned.sql b/db/routines/vn/procedures/collection_getAssigned.sql new file mode 100644 index 000000000..7151129bf --- /dev/null +++ b/db/routines/vn/procedures/collection_getAssigned.sql @@ -0,0 +1,143 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_getAssigned`( + vUserFk INT, + OUT vCollectionFk INT +) +BEGIN +/** + * Comprueba si existen colecciones libres que se ajustan + * al perfil del usuario y le asigna la más antigua. + * Añade un registro al semillero de colecciones. + * + * @param vUserFk Id de usuario + * @param vCollectionFk Id de colección + */ + DECLARE vHasTooMuchCollections BOOL; + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vCollectionWorker INT; + DECLARE vMaxNotAssignedCollectionLifeTime TIME; + + DECLARE vCollections CURSOR FOR + WITH collections AS ( + SELECT tc.collectionFk, + SUM(sv.volume) volume, + c.saleTotalCount, + c.itemPackingTypeFk, + c.trainFk, + c.warehouseFk, + c.wagons + FROM vn.ticketCollection tc + JOIN vn.collection c ON c.id = tc.collectionFk + JOIN vn.saleVolume sv ON sv.ticketFk = tc.ticketFk + WHERE c.workerFk IS NULL + AND sv.shipped >= util.VN_CURDATE() + GROUP BY tc.collectionFk + ) SELECT c.collectionFk + FROM collections c + JOIN vn.operator o + WHERE o.workerFk = vUserFk + AND (c.saleTotalCount <= o.linesLimit OR o.linesLimit IS NULL) + AND (c.itemPackingTypeFk = o.itemPackingTypeFk OR o.itemPackingTypeFk IS NULL) + AND o.numberOfWagons = c.wagons + AND o.trainFk = c.trainFk + AND o.warehouseFk = c.warehouseFk; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + -- Si hay colecciones sin terminar, sale del proceso + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + CALL collection_get(vUserFk); + + SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, pc.maxNotAssignedCollectionLifeTime + INTO vHasTooMuchCollections, vMaxNotAssignedCollectionLifeTime + FROM productionConfig pc + LEFT JOIN tmp.collection ON TRUE; + + DROP TEMPORARY TABLE tmp.collection; + + IF vHasTooMuchCollections THEN + CALL util.throw('Hay colecciones pendientes'); + END IF; + + -- Se eliminan las colecciones sin asignar que estan obsoletas + + INSERT INTO ticketTracking(stateFk, ticketFk) + SELECT s.id, tc.ticketFk + FROM `collection` c + JOIN ticketCollection tc ON tc.collectionFk = c.id + JOIN `state` s ON s.code = 'PRINTED_AUTO' + WHERE c.workerFk IS NULL + AND TIMEDIFF(util.VN_NOW(), c.created) > vMaxNotAssignedCollectionLifeTime; + + DELETE FROM `collection` + WHERE workerFk IS NULL + AND TIMEDIFF(util.VN_NOW(), created) > vMaxNotAssignedCollectionLifeTime; + + -- Se añade registro al semillero + + INSERT INTO collectionHotbed(userFk) VALUES(vUserFk); + + -- Comprueba si hay colecciones disponibles que se ajustan a su configuracion + + OPEN vCollections; + l: LOOP + SET vDone = FALSE; + FETCH vCollections INTO vCollectionFk; + + IF vDone THEN + LEAVE l; + END IF; + + BEGIN + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + SET vCollectionFk = NULL; + RESIGNAL; + END; + + START TRANSACTION; + + SELECT workerFk INTO vCollectionWorker + FROM `collection` + WHERE id = vCollectionFk FOR UPDATE; + + IF vCollectionWorker IS NULL THEN + UPDATE `collection` + SET workerFk = vUserFk + WHERE id = vCollectionFk; + + COMMIT; + LEAVE l; + END IF; + + ROLLBACK; + END; + END LOOP; + CLOSE vCollections; + + IF vCollectionFk IS NULL THEN + CALL collection_new(vUserFk, vCollectionFk); + + START TRANSACTION; + + SELECT workerFk INTO vCollectionWorker + FROM `collection` + WHERE id = vCollectionFk FOR UPDATE; + + IF vCollectionWorker IS NULL THEN + UPDATE `collection` + SET workerFk = vUserFk + WHERE id = vCollectionFk; + END IF; + + COMMIT; + END IF; + CALL itemShelvingSale_addByCollection(vCollectionFk); +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/collection_getTickets.sql b/db/routines/vn/procedures/collection_getTickets.sql index 0a71ada78..fed7a3eb6 100644 --- a/db/routines/vn/procedures/collection_getTickets.sql +++ b/db/routines/vn/procedures/collection_getTickets.sql @@ -1,62 +1,89 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_getTickets`(vParamFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_getTickets`(vParamFk INT) BEGIN /** - * Selecciona los tickets de una colección/ticket - * @param vParamFk ticketFk/collectionFk - * @return Retorna ticketFk, level, agencyName, warehouseFk, salesPersonFk, observaciones + * Selecciona los tickets de una colección/ticket/sectorCollection + * @param vParamFk ticketFk/collectionFk/sectorCollection + * @return Retorna ticketFk, level, agencyName, warehouseFk, salesPersonFk, observation */ DECLARE vItemPackingTypeFk VARCHAR(1); + DECLARE vYesterday DATE; -- Si los sacadores son los de pruebas, pinta los colores - SELECT itemPackingTypeFk INTO vItemPackingTypeFk - FROM vn.collection + SELECT itemPackingTypeFk + INTO vItemPackingTypeFk + FROM collection WHERE id = vParamFk; + + SET vYesterday = util.yesterday(); - SELECT t.id ticketFk, - IF (!(vItemPackingTypeFk <=> 'V'), cc.code,CONCAT(SUBSTRING('ABCDEFGH',tc.wagon, 1),'-',tc.`level` )) `level`, - am.name agencyName, - t.warehouseFk, - w.id salesPersonFk, - IFNULL(tob.description,'') observaciones, - cc.rgb - FROM vn.ticket t - LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk - LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk -- PAK 23/12/21 - LEFT JOIN vn.collectionColors cc - ON cc.wagon = tc.wagon - AND cc.shelve = tc.`level` - AND cc.trainFk = c2.trainFk -- PAK 23/12/21 - LEFT JOIN vn.zone z ON z.id = t.zoneFk - LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk - LEFT JOIN vn.client c ON c.id = t.clientFk - LEFT JOIN vn.worker w ON w.id = c.salesPersonFk - LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id - AND tob.observationTypeFk = 1 - WHERE t.id = vParamFk - AND t.shipped >= util.yesterday() - UNION ALL + WITH observation AS ( + SELECT tob.ticketFk, tob.description + FROM vn.ticketObservation tob + JOIN vn.ticketCollection tc ON tc.ticketFk = tob.ticketFk + JOIN vn.observationType ot ON ot.id = tob.observationTypeFk AND ot.`code` = 'itemPicker' + WHERE tc.collectionFk = vParamFk OR tc.ticketFk = vParamFk + ) SELECT t.id ticketFk, IF(!(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`, am.name agencyName, t.warehouseFk, - w.id salesPersonFk, - IFNULL(tob.description, '') observaciones, - IF(!(vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb` + w.id salesPersonFk, + IFNULL(ob.description,'') observaciones, + cc.rgb FROM vn.ticket t - JOIN vn.ticketCollection tc ON t.id = tc.ticketFk - LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk -- PAK 23/12/21 + LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk + LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk LEFT JOIN vn.collectionColors cc ON cc.wagon = tc.wagon - AND cc.shelve = tc.`level` - AND cc.trainFk = c2.trainFk -- PAK 23/12/21 + AND cc.shelve = tc.`level` + AND cc.trainFk = c2.trainFk LEFT JOIN vn.zone z ON z.id = t.zoneFk LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk LEFT JOIN vn.client c ON c.id = t.clientFk LEFT JOIN vn.worker w ON w.id = c.salesPersonFk - LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id - AND tob.observationTypeFk = 1 - WHERE tc.collectionFk = vParamFk; - + LEFT JOIN observation ob ON ob.ticketFk = t.id + WHERE t.id = vParamFk + AND t.shipped >= vYesterday + UNION + SELECT t.id ticketFk, + IF(NOT(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`, + am.name agencyName, + t.warehouseFk, + w.id salesPersonFk, + ob.description, + IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb` + FROM vn.ticket t + JOIN vn.ticketCollection tc ON t.id = tc.ticketFk + LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk + LEFT JOIN vn.collectionColors cc + ON cc.wagon = tc.wagon + AND cc.shelve = tc.`level` + AND cc.trainFk = c2.trainFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN vn.worker w ON w.id = c.salesPersonFk + LEFT JOIN observation ob ON ob.ticketFk = t.id + WHERE tc.collectionFk = vParamFk + UNION + SELECT sg.ticketFk, + NULL `level`, + am.name agencyName, + t.warehouseFk, + c.salesPersonFk, + ob.description, + NULL `rgb` + FROM vn.sectorCollection sc + JOIN vn.sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id + JOIN vn.saleGroup sg ON sg.id = ss.saleGroupFk + JOIN vn.ticket t ON t.id = sg.ticketFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN observation ob ON ob.ticketFk = t.id + LEFT JOIN vn.client c ON c.id = t.clientFk + WHERE sc.id = vParamFk + AND t.shipped >= vYesterday + GROUP BY ticketFk; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/collection_kill.sql b/db/routines/vn/procedures/collection_kill.sql index f80fea512..298e4a7d1 100644 --- a/db/routines/vn/procedures/collection_kill.sql +++ b/db/routines/vn/procedures/collection_kill.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_kill`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_kill`(vSelf INT) BEGIN /** * Elimina una coleccion y coloca sus tickets en OK diff --git a/db/routines/vn/procedures/collection_make.sql b/db/routines/vn/procedures/collection_make.sql index b5b728000..5deb54f74 100644 --- a/db/routines/vn/procedures/collection_make.sql +++ b/db/routines/vn/procedures/collection_make.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_make`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_make`() proc:BEGIN /** * Genera colecciones de tickets sin asignar trabajador a partir de la tabla diff --git a/db/routines/vn/procedures/collection_mergeSales.sql b/db/routines/vn/procedures/collection_mergeSales.sql new file mode 100644 index 000000000..297bdb97e --- /dev/null +++ b/db/routines/vn/procedures/collection_mergeSales.sql @@ -0,0 +1,29 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_mergeSales`(vCollectionFk INT) +BEGIN + DECLARE vDone BOOL; + DECLARE vTicketFk INT; + + DECLARE vTickets CURSOR FOR + SELECT ticketFk + FROM ticketCollection + WHERE collectionFk = vCollectionFk; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + OPEN vTickets; + l: LOOP + SET vDone = FALSE; + + FETCH vTickets INTO vTicketFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL ticket_mergeSales(vTicketFk); + END LOOP; + CLOSE vTickets; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index 8a1eff4a1..480a88f35 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -1,5 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_new`(vUserFk INT, OUT vCollectionFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_new`( + vUserFk INT, + OUT vCollectionFk INT +) BEGIN /** * Genera colecciones de tickets sin asignar trabajador. @@ -9,30 +12,32 @@ BEGIN DECLARE vWarehouseFk INT; DECLARE vWagons INT; DECLARE vTrainFk INT; - DECLARE vLinesLimit INT DEFAULT NULL; + DECLARE vLinesLimit INT; DECLARE vTicketLines INT; - DECLARE vVolumeLimit DECIMAL DEFAULT NULL; + DECLARE vVolumeLimit DECIMAL; + DECLARE vSizeLimit INT; DECLARE vTicketVolume DECIMAL; DECLARE vMaxTickets INT; - DECLARE vStateFk VARCHAR(45); + DECLARE vStateCode VARCHAR(45); DECLARE vFirstTicketFk INT; - DECLARE vHour INT; - DECLARE vMinute INT; DECLARE vWorkerCode VARCHAR(3); - DECLARE vWagonCounter INT DEFAULT 0; + DECLARE vWagonCounter INT DEFAULT 1; DECLARE vTicketFk INT; DECLARE vItemPackingTypeFk VARCHAR(1); - DECLARE vHasAssignedTickets BOOLEAN; + DECLARE vHasAssignedTickets BOOL; DECLARE vHasUniqueCollectionTime BOOL; - DECLARE vDone INT DEFAULT FALSE; - DECLARE vLockName VARCHAR(215); - DECLARE vLockTime INT DEFAULT 30; + DECLARE vHeight INT; + DECLARE vVolume INT; + DECLARE vLiters INT; + DECLARE vLines INT; + DECLARE vTotalLines INT DEFAULT 0; + DECLARE vTotalVolume INT DEFAULT 0; DECLARE vFreeWagonFk INT; + DECLARE vDone INT DEFAULT FALSE; - DECLARE c1 CURSOR FOR + DECLARE vTickets CURSOR FOR SELECT ticketFk, `lines`, m3 FROM tmp.productionBuffer - WHERE ticketFk <> vFirstTicketFk ORDER BY HH, mm, productionOrder DESC, @@ -45,15 +50,6 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - IF vLockName IS NOT NULL THEN - DO RELEASE_LOCK(vLockName); - END IF; - - RESIGNAL; - END; - SELECT pc.ticketTrolleyMax * o.numberOfWagons, pc.hasUniqueCollectionTime, w.code, @@ -64,34 +60,26 @@ BEGIN o.trainFk, o.linesLimit, o.volumeLimit, - pc.collection_new_lockname + o.sizeLimit INTO vMaxTickets, - vHasUniqueCollectionTime, - vWorkerCode, - vWarehouseFk, - vItemPackingTypeFk, - vStateFk, - vWagons, - vTrainFk, - vLinesLimit, - vVolumeLimit, - vLockName - FROM productionConfig pc - JOIN worker w ON w.id = vUserFk + vHasUniqueCollectionTime, + vWorkerCode, + vWarehouseFk, + vItemPackingTypeFk, + vStateCode, + vWagons, + vTrainFk, + vLinesLimit, + vVolumeLimit, + vSizeLimit + FROM worker w + JOIN operator o ON o.workerFk = w.id JOIN state st ON st.`code` = 'ON_PREPARATION' - JOIN operator o ON o.workerFk = vUserFk; - - SET vLockName = CONCAT_WS('/', - vLockName, - vWarehouseFk, - vItemPackingTypeFk - ); - - IF NOT GET_LOCK(vLockName, vLockTime) THEN - CALL util.throw(CONCAT('Cannot get lock: ', vLockName)); - END IF; + JOIN productionConfig pc + WHERE w.id = vUserFk; -- Se prepara el tren, con tantos vagones como sea necesario. + CREATE OR REPLACE TEMPORARY TABLE tTrain (wagon INT, shelve INT, @@ -102,63 +90,72 @@ BEGIN PRIMARY KEY(wagon, shelve)) ENGINE = MEMORY; - WHILE vWagons > vWagonCounter DO - SET vWagonCounter = vWagonCounter + 1; - - INSERT INTO tTrain(wagon, shelve, liters, `lines`, height) - SELECT vWagonCounter, cv.`level` , cv.liters , cv.`lines` , cv.height - FROM collectionVolumetry cv - WHERE cv.trainFk = vTrainFk + INSERT INTO tTrain (wagon, shelve, liters, `lines`, height) + WITH RECURSIVE wagonSequence AS ( + SELECT vWagonCounter wagon + UNION ALL + SELECT wagon + 1 wagon + FROM wagonSequence + WHERE wagon < vWagonCounter + vWagons -1 + ) + SELECT ws.wagon, cv.`level`, cv.liters, cv.`lines`, cv.height + FROM wagonSequence ws + JOIN vn.collectionVolumetry cv ON cv.trainFk = vTrainFk AND cv.itemPackingTypeFk = vItemPackingTypeFk; - END WHILE; -- Esto desaparecerá cuando tengamos la table cache.ticket + CALL productionControl(vWarehouseFk, 0); ALTER TABLE tmp.productionBuffer ADD COLUMN liters INT, ADD COLUMN height INT; - -- Se obtiene nº de colección. - INSERT INTO collection - SET itemPackingTypeFk = vItemPackingTypeFk, - trainFk = vTrainFk, - wagons = vWagons, - warehouseFk = vWarehouseFk; - - SELECT LAST_INSERT_ID() INTO vCollectionFk; - -- Los tickets de recogida en Algemesí sólo se sacan si están asignados. -- Los pedidos con riesgo no se sacan aunque se asignen. - DELETE pb.* + + DELETE pb FROM tmp.productionBuffer pb JOIN state s ON s.id = pb.state WHERE (pb.agency = 'REC_ALGEMESI' AND s.code <> 'PICKER_DESIGNED') OR pb.problem LIKE '%RIESGO%'; - -- Comprobamos si hay tickets asignados. En ese caso, nos centramos - -- exclusivamente en esos tickets y los sacamos independientemente - -- de problemas o tamaños - SELECT COUNT(*) INTO vHasAssignedTickets - FROM tmp.productionBuffer pb - JOIN state s ON s.id = pb.state - WHERE s.code = 'PICKER_DESIGNED' - AND pb.workerCode = vWorkerCode; + -- Si hay tickets asignados, nos centramos exclusivamente en esos tickets + -- y los sacamos independientemente de problemas o tamaños - -- Se dejan en la tabla tmp.productionBuffer sólo aquellos tickets adecuados - IF vHasAssignedTickets THEN - DELETE pb.* + SELECT EXISTS ( + SELECT TRUE FROM tmp.productionBuffer pb JOIN state s ON s.id = pb.state - WHERE s.code <> 'PICKER_DESIGNED' - OR pb.workerCode <> vWorkerCode; + WHERE (s.code = 'PICKER_DESIGNED' + AND pb.workerCode = vWorkerCode) + OR s.code = 'LAST_CALL' + ) INTO vHasAssignedTickets; + + -- Se dejan en la tabla tmp.productionBuffer sólo aquellos tickets adecuados + + IF vHasAssignedTickets THEN + DELETE pb + FROM tmp.productionBuffer pb + JOIN state s ON s.id = pb.state + WHERE (s.code <> 'PICKER_DESIGNED' + OR pb.workerCode <> vWorkerCode) + AND s.code <> 'LAST_CALL'; ELSE - DELETE pb.* + DELETE pb FROM tmp.productionBuffer pb JOIN state s ON s.id = pb.state JOIN agencyMode am ON am.id = pb.agencyModeFk JOIN agency a ON a.id = am.agencyFk + LEFT JOIN ( + SELECT pb.ticketFk, MAX(i.`size`) maxSize + FROM tmp.productionBuffer pb + JOIN ticket t ON t.id = pb.ticketfk + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + GROUP BY pb.ticketFk + ) sub ON sub.ticketFk = pb.ticketFk JOIN productionConfig pc WHERE pb.shipped <> util.VN_CURDATE() OR (pb.ubicacion IS NULL AND a.isOwn) @@ -169,24 +166,25 @@ BEGIN OR (NOT pb.H AND pb.V > 0 AND vItemPackingTypeFk = 'H') OR (NOT pb.V AND vItemPackingTypeFk = 'V') OR (pc.isPreviousPreparationRequired AND pb.previousWithoutParking) - OR LENGTH(pb.problem) > 0 - OR (pb.lines >= vLinesLimit AND vLinesLimit IS NOT NULL) - OR (pb.m3 >= vVolumeLimit AND vVolumeLimit IS NOT NULL); + OR LENGTH(pb.problem) + OR pb.lines > vLinesLimit + OR pb.m3 > vVolumeLimit + OR sub.maxSize > vSizeLimit + OR pb.hasPlantTray; END IF; - -- Es importante que el primer ticket se coja en todos los casos - SELECT ticketFk, - HH, - mm, - `lines`, - m3 - INTO vFirstTicketFk, - vHour, - vMinute, - vTicketLines, - vTicketVolume + -- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede + + IF vHasUniqueCollectionTime THEN + DELETE pb + FROM tmp.productionBuffer pb + JOIN tmp.productionBuffer pb2 ON pb2.ticketFk = vFirstTicketFk + AND (pb.HH <> pb2.HH OR pb.mm <> pb2.mm); + END IF; + + SELECT ticketFk INTO vFirstTicketFk FROM tmp.productionBuffer - ORDER BY HH, + ORDER BY HH, mm, productionOrder DESC, m3 DESC, @@ -196,44 +194,37 @@ BEGIN ticketFk LIMIT 1; - -- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede - IF vHasUniqueCollectionTime THEN - DELETE FROM tmp.productionBuffer - WHERE HH <> vHour - OR mm <> vMinute; - END IF; - - SET vTicketFk = vFirstTicketFk; - SET @lines = 0; - SET @volume = 0; - - OPEN c1; - read_loop: LOOP + OPEN vTickets; + l: LOOP SET vDone = FALSE; + FETCH vTickets INTO vTicketFk, vTicketLines, vTicketVolume; + + IF vDone THEN + LEAVE l; + END IF; -- Buscamos un ticket que cumpla con los requisitos en el listado - IF ((vTicketLines + @lines) <= vLinesLimit OR vLinesLimit IS NULL) - AND ((vTicketVolume + @volume) <= vVolumeLimit OR vVolumeLimit IS NULL) THEN + + IF (vLinesLimit IS NULL OR (vTotalLines + vTicketLines) <= vLinesLimit) + AND (vVolumeLimit IS NULL OR (vTotalVolume + vTicketVolume) <= vVolumeLimit) THEN CALL ticket_splitItemPackingType(vTicketFk, vItemPackingTypeFk); DROP TEMPORARY TABLE tmp.ticketIPT; + SELECT COUNT(*), SUM(litros), MAX(i.`size`), SUM(sv.volume) + INTO vLines, vLiters, vHeight, vVolume + FROM saleVolume sv + JOIN sale s ON s.id = sv.saleFk + JOIN item i ON i.id = s.itemFk + WHERE sv.ticketFk = vTicketFk; + + SET vTotalVolume = vTotalVolume + vVolume, + vTotalLines = vTotalLines + vLines; + UPDATE tmp.productionBuffer pb - JOIN ( - SELECT SUM(litros) liters, - @lines:= COUNT(*) + @lines, - COUNT(*) `lines`, - MAX(i.`size`) height, - @volume := SUM(sv.volume) + @volume, - SUM(sv.volume) volume - FROM saleVolume sv - JOIN sale s ON s.id = sv.saleFk - JOIN item i ON i.id = s.itemFk - WHERE sv.ticketFk = vTicketFk - ) sub - SET pb.liters = sub.liters, - pb.`lines` = sub.`lines`, - pb.height = sub.height + SET pb.liters = vLiters, + pb.`lines` = vLines, + pb.height = vHeight WHERE pb.ticketFk = vTicketFk; UPDATE tTrain tt @@ -250,17 +241,13 @@ BEGIN tt.height LIMIT 1; - -- Si no le encuentra una balda adecuada, intentamos darle un carro entero si queda alguno libre + -- Si no le encuentra una balda, intentamos darle un carro entero libre + IF NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN - SELECT tt.wagon - INTO vFreeWagonFk - FROM tTrain tt - LEFT JOIN ( - SELECT DISTINCT wagon - FROM tTrain - WHERE ticketFk IS NOT NULL - ) nn ON nn.wagon = tt.wagon - WHERE nn.wagon IS NULL + SELECT wagon INTO vFreeWagonFk + FROM tTrain + GROUP BY wagon + HAVING COUNT(ticketFk) = 0 ORDER BY wagon LIMIT 1; @@ -269,38 +256,35 @@ BEGIN SET ticketFk = vFirstTicketFk WHERE wagon = vFreeWagonFk; - -- Se anulan el resto de carros libres para que sólo uno lleve un pedido excesivo - DELETE tt.* - FROM tTrain tt - LEFT JOIN ( - SELECT DISTINCT wagon - FROM tTrain - WHERE ticketFk IS NOT NULL - ) nn ON nn.wagon = tt.wagon - WHERE nn.wagon IS NULL; - END IF; - END IF; + -- Se anulan el resto de carros libres, + -- máximo un carro con pedido excesivo - FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume; - IF vDone OR NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk IS NULL) THEN - LEAVE read_loop; - END IF; - ELSE - FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume; - IF vDone THEN - LEAVE read_loop; - END IF; + DELETE tt + FROM tTrain tt + JOIN (SELECT wagon + FROM tTrain + GROUP BY wagon + HAVING COUNT(ticketFk) = 0 + ) sub ON sub.wagon = tt.wagon; + END IF; + END IF; END IF; END LOOP; - CLOSE c1; + CLOSE vTickets; IF (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN - UPDATE collection c - JOIN state st ON st.code = 'ON_PREPARATION' - SET c.stateFk = st.id - WHERE c.id = vCollectionFk; + -- Se obtiene nº de colección + + INSERT INTO collection + SET itemPackingTypeFk = vItemPackingTypeFk, + trainFk = vTrainFk, + wagons = vWagons, + warehouseFk = vWarehouseFk; + + SELECT LAST_INSERT_ID() INTO vCollectionFk; -- Asigna las bandejas + INSERT IGNORE INTO ticketCollection(ticketFk, collectionFk, `level`, wagon, liters) SELECT tt.ticketFk, vCollectionFk, tt.shelve, tt.wagon, tt.liters FROM tTrain tt @@ -308,39 +292,36 @@ BEGIN ORDER BY tt.wagon, tt.shelve; -- Actualiza el estado de los tickets - CALL collection_setState(vCollectionFk, vStateFk); + + CALL collection_setState(vCollectionFk, vStateCode); -- Aviso para la preparacion previa + INSERT INTO ticketDown(ticketFk, collectionFk) SELECT tc.ticketFk, tc.collectionFk FROM ticketCollection tc WHERE tc.collectionFk = vCollectionFk; - CALL sales_mergeByCollection(vCollectionFk); + CALL collection_mergeSales(vCollectionFk); UPDATE `collection` c - JOIN ( + JOIN( SELECT COUNT(*) saleTotalCount, SUM(s.isPicked <> 0) salePickedCount FROM ticketCollection tc JOIN sale s ON s.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk - AND s.quantity > 0 - ) sub + WHERE tc.collectionFk = vCollectionFk + AND s.quantity > 0 + )sub SET c.saleTotalCount = sub.saleTotalCount, c.salePickedCount = sub.salePickedCount WHERE c.id = vCollectionFk; - ELSE - DELETE FROM `collection` - WHERE id = vCollectionFk; - SET vCollectionFk = NULL; + SET vCollectionFk = NULL; END IF; - DO RELEASE_LOCK(vLockName); - DROP TEMPORARY TABLE tTrain, tmp.productionBuffer; END$$ -DELIMITER ; +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/collection_printSticker.sql b/db/routines/vn/procedures/collection_printSticker.sql index 50259152d..a18d4d7d9 100644 --- a/db/routines/vn/procedures/collection_printSticker.sql +++ b/db/routines/vn/procedures/collection_printSticker.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_printSticker`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_printSticker`( vSelf INT, vLabelCount INT ) diff --git a/db/routines/vn/procedures/collection_setParking.sql b/db/routines/vn/procedures/collection_setParking.sql index 73aa87bfb..68b81ba30 100644 --- a/db/routines/vn/procedures/collection_setParking.sql +++ b/db/routines/vn/procedures/collection_setParking.sql @@ -1,15 +1,18 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_setParking`(IN `vCollectionFk` VARCHAR(8), IN `vParkingFk` INT) -proc: BEGIN +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_setParking`( + vSelf INT, + vParkingFk INT +) +BEGIN /** * Aparca una colección en un parking. * - * @param vCollectionFk Id de la colección - * @param vParkingFk Id del parking + * @param vSelf Id colección + * @param vParkingFk Id parking */ - REPLACE vn.ticketParking(ticketFk, parkingFk) + REPLACE ticketParking(ticketFk, parkingFk) SELECT tc.ticketFk, vParkingFk - FROM vn.ticketCollection tc - WHERE tc.collectionFk = vCollectionFk; + FROM ticketCollection tc + WHERE tc.collectionFk = vSelf; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/collection_setState.sql b/db/routines/vn/procedures/collection_setState.sql index 2d33c53d6..5f8a7afa2 100644 --- a/db/routines/vn/procedures/collection_setState.sql +++ b/db/routines/vn/procedures/collection_setState.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_setState`(vSelf INT, vStateCode VARCHAR(255) COLLATE utf8_general_ci) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_setState`(vSelf INT, vStateCode VARCHAR(255) COLLATE utf8_general_ci) BEGIN /** * Modifica el estado de los tickets de una colección. diff --git a/db/routines/vn/procedures/company_getFiscaldata.sql b/db/routines/vn/procedures/company_getFiscaldata.sql index 7c56382e9..675e19379 100644 --- a/db/routines/vn/procedures/company_getFiscaldata.sql +++ b/db/routines/vn/procedures/company_getFiscaldata.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`company_getFiscaldata`(workerFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`company_getFiscaldata`(workerFk INT) BEGIN DECLARE vCompanyFk INT; @@ -7,7 +7,7 @@ DECLARE vCompanyFk INT; SELECT IFNULL(uc.companyFk, rc.defaultCompanyFk) INTO vCompanyFk FROM vn.routeConfig rc - LEFT JOIN userConfig uc ON uc.userFk = workerFk; + LEFT JOIN userMultiConfig uc ON uc.userFk = workerFk; SELECT diff --git a/db/routines/vn/procedures/company_getSuppliersDebt.sql b/db/routines/vn/procedures/company_getSuppliersDebt.sql index 83043f337..84d931542 100644 --- a/db/routines/vn/procedures/company_getSuppliersDebt.sql +++ b/db/routines/vn/procedures/company_getSuppliersDebt.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`company_getSuppliersDebt`(vSelf INT, vMonthsAgo INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`company_getSuppliersDebt`(vSelf INT, vMonthsAgo INT) BEGIN /** * Generates a temporary table containing outstanding payments to suppliers. diff --git a/db/routines/vn/procedures/comparative_add.sql b/db/routines/vn/procedures/comparative_add.sql index 44f9686aa..5aaa440aa 100644 --- a/db/routines/vn/procedures/comparative_add.sql +++ b/db/routines/vn/procedures/comparative_add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`comparative_add`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`comparative_add`() BEGIN /** * Inserts sales records less than one month old in comparative. diff --git a/db/routines/vn/procedures/confection_controlSource.sql b/db/routines/vn/procedures/confection_controlSource.sql index f011a52e9..837916038 100644 --- a/db/routines/vn/procedures/confection_controlSource.sql +++ b/db/routines/vn/procedures/confection_controlSource.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`confection_controlSource`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`confection_controlSource`( vDated DATE, vScopeDays INT, vMaxAlertLevel INT, diff --git a/db/routines/vn/procedures/conveyorExpedition_Add.sql b/db/routines/vn/procedures/conveyorExpedition_Add.sql index daaf33f2f..a63cd4946 100644 --- a/db/routines/vn/procedures/conveyorExpedition_Add.sql +++ b/db/routines/vn/procedures/conveyorExpedition_Add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`conveyorExpedition_Add`(vStarted DATETIME, vEnded DATETIME) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`conveyorExpedition_Add`(vStarted DATETIME, vEnded DATETIME) BEGIN @@ -34,7 +34,7 @@ BEGIN LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk LEFT JOIN vn.agency a ON a.id = am.agencyFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk JOIN vn.packagingConfig pc WHERE t.warehouseFk IN (60,1,44) AND e.created BETWEEN vStarted AND vEnded diff --git a/db/routines/vn/procedures/copyComponentsFromSaleList.sql b/db/routines/vn/procedures/copyComponentsFromSaleList.sql index 17cf487b1..24d2705d0 100644 --- a/db/routines/vn/procedures/copyComponentsFromSaleList.sql +++ b/db/routines/vn/procedures/copyComponentsFromSaleList.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`copyComponentsFromSaleList`(vTargetTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`copyComponentsFromSaleList`(vTargetTicketFk INT) BEGIN /* Copy sales and components to the target ticket @@ -16,9 +16,9 @@ BEGIN SET @order = 0; - DROP TEMPORARY TABLE IF EXISTS tmp.newSaleList; + DROP TEMPORARY TABLE IF EXISTS tNewSaleList; - CREATE TEMPORARY TABLE tmp.newSaleList + CREATE TEMPORARY TABLE tNewSaleList SELECT id as saleFk, @order := @order + 1 as orden FROM vn.sale WHERE ticketFk = vTargetTicketFk @@ -28,7 +28,8 @@ BEGIN SELECT ns.saleFk, sc.componentFk, sc.value FROM vn.saleComponent sc JOIN tmp.saleList s ON s.saleFk = sc.saleFk - JOIN tmp.newSaleList ns ON ns.orden = s.orden; + JOIN tNewSaleList ns ON ns.orden = s.orden; + DROP TEMPORARY TABLE tNewSaleList; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/createPedidoInterno.sql b/db/routines/vn/procedures/createPedidoInterno.sql index ecc5e57a5..2adf9e9f3 100644 --- a/db/routines/vn/procedures/createPedidoInterno.sql +++ b/db/routines/vn/procedures/createPedidoInterno.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`createPedidoInterno`(vItemFk INT,vQuantity INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`createPedidoInterno`(vItemFk INT,vQuantity INT) BEGIN diff --git a/db/routines/vn/procedures/creditInsurance_getRisk.sql b/db/routines/vn/procedures/creditInsurance_getRisk.sql index eccc37ca1..5562c91d4 100644 --- a/db/routines/vn/procedures/creditInsurance_getRisk.sql +++ b/db/routines/vn/procedures/creditInsurance_getRisk.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`creditInsurance_getRisk`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`creditInsurance_getRisk`() BEGIN /** * Devuelve el riesgo de los clientes que estan asegurados @@ -10,7 +10,7 @@ BEGIN SELECT * FROM ( SELECT cc.client clientFk, ci.grade FROM creditClassification cc - JOIN creditInsurance ci ON cc.id = ci.creditClassification + JOIN creditInsurance ci ON cc.id = ci.creditClassificationFk WHERE dateEnd IS NULL ORDER BY ci.creationDate DESC LIMIT 10000000000000000000) t1 diff --git a/db/routines/vn/procedures/creditRecovery.sql b/db/routines/vn/procedures/creditRecovery.sql index 687d652dd..afdb10dc8 100644 --- a/db/routines/vn/procedures/creditRecovery.sql +++ b/db/routines/vn/procedures/creditRecovery.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`creditRecovery`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`creditRecovery`() BEGIN /** * Actualiza el crédito de los clientes diff --git a/db/routines/vn/procedures/crypt.sql b/db/routines/vn/procedures/crypt.sql index b3517b1ad..54a698f66 100644 --- a/db/routines/vn/procedures/crypt.sql +++ b/db/routines/vn/procedures/crypt.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`crypt`(vText VARCHAR(255), vKey VARCHAR(255), OUT vResult VARCHAR(255) ) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`crypt`(vText VARCHAR(255), vKey VARCHAR(255), OUT vResult VARCHAR(255) ) BEGIN DECLARE vEncryptedText VARCHAR(255) DEFAULT ''; diff --git a/db/routines/vn/procedures/cryptOff.sql b/db/routines/vn/procedures/cryptOff.sql index e0677a0e2..1ad33aa6d 100644 --- a/db/routines/vn/procedures/cryptOff.sql +++ b/db/routines/vn/procedures/cryptOff.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`cryptOff`(vText VARCHAR(255), vKey VARCHAR(255), OUT vResult VARCHAR(255)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`cryptOff`(vText VARCHAR(255), vKey VARCHAR(255), OUT vResult VARCHAR(255)) BEGIN DECLARE vUncryptedText VARCHAR(255) DEFAULT ''; diff --git a/db/routines/vn/procedures/department_calcTree.sql b/db/routines/vn/procedures/department_calcTree.sql index 5a265bd41..4f67cda86 100644 --- a/db/routines/vn/procedures/department_calcTree.sql +++ b/db/routines/vn/procedures/department_calcTree.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`department_calcTree`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`department_calcTree`() BEGIN /** * Calculates the #path, #lft, #rgt, #sons and #depth columns of diff --git a/db/routines/vn/procedures/department_calcTreeRec.sql b/db/routines/vn/procedures/department_calcTreeRec.sql index 77054b17f..bae39f4c5 100644 --- a/db/routines/vn/procedures/department_calcTreeRec.sql +++ b/db/routines/vn/procedures/department_calcTreeRec.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`department_calcTreeRec`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`department_calcTreeRec`( vSelf INT, vPath VARCHAR(255), vDepth INT, diff --git a/db/routines/vn/procedures/department_doCalc.sql b/db/routines/vn/procedures/department_doCalc.sql index 915b9f191..11801a8d1 100644 --- a/db/routines/vn/procedures/department_doCalc.sql +++ b/db/routines/vn/procedures/department_doCalc.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`department_doCalc`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`department_doCalc`() proc: BEGIN /** * Recalculates the department tree. diff --git a/db/routines/vn/procedures/department_getHasMistake.sql b/db/routines/vn/procedures/department_getHasMistake.sql index 394105a16..21a89a21d 100644 --- a/db/routines/vn/procedures/department_getHasMistake.sql +++ b/db/routines/vn/procedures/department_getHasMistake.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`department_getHasMistake`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`department_getHasMistake`() BEGIN /** diff --git a/db/routines/vn/procedures/department_getLeaves.sql b/db/routines/vn/procedures/department_getLeaves.sql index 7f1e3cc35..ca8641e35 100644 --- a/db/routines/vn/procedures/department_getLeaves.sql +++ b/db/routines/vn/procedures/department_getLeaves.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`department_getLeaves`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`department_getLeaves`( vParentFk INT, vSearch VARCHAR(255) ) diff --git a/db/routines/vn/procedures/deviceLog_add.sql b/db/routines/vn/procedures/deviceLog_add.sql index 8d2310633..5743cd4db 100644 --- a/db/routines/vn/procedures/deviceLog_add.sql +++ b/db/routines/vn/procedures/deviceLog_add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`deviceLog_add`(vWorkerFk INT, vAppName VARCHAR(45), vAppVersion VARCHAR(45), vAndroid_id VARCHAR(64)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`deviceLog_add`(vWorkerFk INT, vAppName VARCHAR(45), vAppVersion VARCHAR(45), vAndroid_id VARCHAR(64)) BEGIN /** * Inserta registro en tabla devicelog el log del usuario conectado. diff --git a/db/routines/vn/procedures/deviceProductionUser_exists.sql b/db/routines/vn/procedures/deviceProductionUser_exists.sql index f5be6e94f..9b2442c4b 100644 --- a/db/routines/vn/procedures/deviceProductionUser_exists.sql +++ b/db/routines/vn/procedures/deviceProductionUser_exists.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`deviceProductionUser_exists`(vUserFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`deviceProductionUser_exists`(vUserFk INT) BEGIN /* SELECT COUNT(*) AS UserExists diff --git a/db/routines/vn/procedures/deviceProductionUser_getWorker.sql b/db/routines/vn/procedures/deviceProductionUser_getWorker.sql index b18339108..d603405cf 100644 --- a/db/routines/vn/procedures/deviceProductionUser_getWorker.sql +++ b/db/routines/vn/procedures/deviceProductionUser_getWorker.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`deviceProductionUser_getWorker`(vAndroid_id VARCHAR(64)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`deviceProductionUser_getWorker`(vAndroid_id VARCHAR(64)) BEGIN /** * Selecciona si hay registrado un device con un android_id diff --git a/db/routines/vn/procedures/deviceProduction_getnameDevice.sql b/db/routines/vn/procedures/deviceProduction_getnameDevice.sql index c8a5abfaf..748798e82 100644 --- a/db/routines/vn/procedures/deviceProduction_getnameDevice.sql +++ b/db/routines/vn/procedures/deviceProduction_getnameDevice.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`deviceProduction_getnameDevice`(vAndroid_id VARCHAR(64)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`deviceProduction_getnameDevice`(vAndroid_id VARCHAR(64)) BEGIN /** * Selecciona el id del dispositivo que corresponde al vAndroid_id. diff --git a/db/routines/vn/procedures/device_checkLogin.sql b/db/routines/vn/procedures/device_checkLogin.sql index db566a068..7094eb84a 100644 --- a/db/routines/vn/procedures/device_checkLogin.sql +++ b/db/routines/vn/procedures/device_checkLogin.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`device_checkLogin`(vUserFk INT, vAndroidID VARCHAR(50)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`device_checkLogin`(vUserFk INT, vAndroidID VARCHAR(50)) BEGIN /* diff --git a/db/routines/vn/procedures/duaEntryValueUpdate.sql b/db/routines/vn/procedures/duaEntryValueUpdate.sql index f688191de..c3c57dd45 100644 --- a/db/routines/vn/procedures/duaEntryValueUpdate.sql +++ b/db/routines/vn/procedures/duaEntryValueUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaEntryValueUpdate`(vDuaFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`duaEntryValueUpdate`(vDuaFk INT) BEGIN UPDATE duaEntry de diff --git a/db/routines/vn/procedures/duaInvoiceInBooking.sql b/db/routines/vn/procedures/duaInvoiceInBooking.sql index 981f3026d..b4329a8bb 100644 --- a/db/routines/vn/procedures/duaInvoiceInBooking.sql +++ b/db/routines/vn/procedures/duaInvoiceInBooking.sql @@ -1,17 +1,20 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaInvoiceInBooking`(vDuaFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`duaInvoiceInBooking`( + vDuaFk INT +) BEGIN /** * Genera el asiento de un DUA y marca las entradas como confirmadas * * @param vDuaFk Id del dua a recalcular */ - DECLARE done BOOL DEFAULT FALSE; + DECLARE vDone BOOL DEFAULT FALSE; DECLARE vInvoiceFk INT; - DECLARE vASIEN BIGINT DEFAULT 0; - DECLARE vCounter INT DEFAULT 0; + DECLARE vBookEntry INT; + DECLARE vFiscalYear INT; + DECLARE vIncorrectInvoiceInDueDay INT; - DECLARE rs CURSOR FOR + DECLARE vInvoicesIn CURSOR FOR SELECT DISTINCT e.invoiceInFk FROM entry e JOIN duaEntry de ON de.entryFk = e.id @@ -20,9 +23,20 @@ BEGIN AND de.customsValue AND ii.isBooked = FALSE; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - OPEN rs; + SELECT GROUP_CONCAT(ii.id) INTO vIncorrectInvoiceInDueDay + FROM invoiceInDueDay iidd + JOIN invoiceIn ii ON iidd.invoiceInFk = ii.id + JOIN `entry` e ON e.invoiceInFk = ii.id + JOIN duaEntry de ON de.entryFk = e.id + JOIN invoiceInConfig iic + WHERE de.duaFk = vDuaFk + AND iidd.dueDated < util.VN_CURDATE() + INTERVAL iic.dueDateMarginDays DAY; + + IF vIncorrectInvoiceInDueDay THEN + CALL util.throw(CONCAT('Incorrect due date, invoice: ', vIncorrectInvoiceInDueDay)); + END IF; UPDATE invoiceIn ii JOIN entry e ON e.invoiceInFk = ii.id @@ -31,48 +45,67 @@ BEGIN SET ii.booked = IFNULL(ii.booked, d.booked), ii.operated = IFNULL(ii.operated, d.operated), ii.issued = IFNULL(ii.issued, d.issued), - ii.bookEntried = IFNULL(ii.bookEntried, d.bookEntried), - e.isBooked = TRUE, - e.isConfirmed = TRUE + ii.bookEntried = IFNULL(ii.bookEntried, d.bookEntried) WHERE d.id = vDuaFk; - SELECT IFNULL(ASIEN,0) INTO vASIEN - FROM dua - WHERE id = vDuaFk; + SELECT ASIEN INTO vBookEntry FROM dua WHERE id = vDuaFk; - FETCH rs INTO vInvoiceFk; + IF vBookEntry IS NULL THEN + SELECT YEAR(IFNULL(ii.bookEntried, d.bookEntried)) INTO vFiscalYear + FROM invoiceIn ii + JOIN `entry` e ON e.invoiceInFk = ii.id + JOIN duaEntry de ON de.entryFk = e.id + JOIN dua d ON d.id = de.duaFk + WHERE d.id = vDuaFk + LIMIT 1; + CALL ledger_nextTx(vFiscalYear, vBookEntry); + END IF; - WHILE NOT done DO + OPEN vInvoicesIn; - CALL invoiceIn_booking(vInvoiceFk); - - IF vCounter > 0 OR vASIEN > 0 THEN - - UPDATE XDiario x - JOIN ledgerConfig lc ON lc.lastBookEntry = x.ASIEN - SET x.ASIEN = vASIEN; - - ELSE - - SELECT lastBookEntry INTO vASIEN FROM ledgerConfig; + l: LOOP + SET vDone = FALSE; + FETCH vInvoicesIn INTO vInvoiceFk; + IF vDone THEN + LEAVE l; END IF; - SET vCounter = vCounter + 1; + CALL invoiceIn_booking(vInvoiceFk, vBookEntry); + END LOOP; - FETCH rs INTO vInvoiceFk; - - END WHILE; - - CLOSE rs; + CLOSE vInvoicesIn; UPDATE dua - SET ASIEN = vASIEN + SET ASIEN = vBookEntry WHERE id = vDuaFk; UPDATE invoiceIn ii JOIN duaInvoiceIn dii ON dii.invoiceInFk = ii.id SET ii.isBooked = TRUE WHERE dii.duaFk = vDuaFk; + + UPDATE `entry` e + JOIN ( + WITH entries AS ( + SELECT e.id, de.duaFk + FROM vn.`entry` e + JOIN vn.duaEntry de ON de.entryFk = e.id + WHERE de.duaFk = vDuaFk + AND (NOT e.isBooked OR NOT e.isConfirmed) + ), + notBookedEntries AS ( + SELECT entryFk + FROM vn.duaEntry + WHERE duaFk = vDuaFk + AND NOT customsValue + ) + SELECT e.id + FROM entries e + LEFT JOIN notBookedEntries nbe ON nbe.entryFk = e.id + WHERE nbe.entryFk IS NULL + ) sub ON sub.id = e.id + SET e.isBooked = TRUE, + e.isConfirmed = TRUE; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/duaParcialMake.sql b/db/routines/vn/procedures/duaParcialMake.sql index cbb56e16d..063f26468 100644 --- a/db/routines/vn/procedures/duaParcialMake.sql +++ b/db/routines/vn/procedures/duaParcialMake.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaParcialMake`(vDuaFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`duaParcialMake`(vDuaFk INT) BEGIN DECLARE vNewDuaFk INT; diff --git a/db/routines/vn/procedures/duaTaxBooking.sql b/db/routines/vn/procedures/duaTaxBooking.sql index 5d4a98933..2c9201231 100644 --- a/db/routines/vn/procedures/duaTaxBooking.sql +++ b/db/routines/vn/procedures/duaTaxBooking.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaTaxBooking`(vDuaFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`duaTaxBooking`(vDuaFk INT) BEGIN DECLARE vBookNumber INT; DECLARE vBookDated DATE; @@ -12,7 +12,7 @@ BEGIN WHERE id = vDuaFk; IF vBookNumber IS NULL OR NOT vBookNumber THEN - CALL ledger_next(YEAR(vBookDated), vBookNumber); + CALL ledger_nextTx(YEAR(vBookDated), vBookNumber); END IF; -- Apunte de la aduana diff --git a/db/routines/vn/procedures/duaTax_doRecalc.sql b/db/routines/vn/procedures/duaTax_doRecalc.sql index e2d2b347f..fedc4c56b 100644 --- a/db/routines/vn/procedures/duaTax_doRecalc.sql +++ b/db/routines/vn/procedures/duaTax_doRecalc.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaTax_doRecalc`(vDuaFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`duaTax_doRecalc`(vDuaFk INT) BEGIN /** * Borra los valores de duaTax y los vuelve a crear en base a la tabla duaEntry diff --git a/db/routines/vn/procedures/ediTables_Update.sql b/db/routines/vn/procedures/ediTables_Update.sql index 3f0c6df04..9ae759fbd 100644 --- a/db/routines/vn/procedures/ediTables_Update.sql +++ b/db/routines/vn/procedures/ediTables_Update.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ediTables_Update`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ediTables_Update`() BEGIN INSERT IGNORE INTO vn.genus(name) diff --git a/db/routines/vn/procedures/ektEntryAssign_setEntry.sql b/db/routines/vn/procedures/ektEntryAssign_setEntry.sql index d80215e37..eecdb32d4 100644 --- a/db/routines/vn/procedures/ektEntryAssign_setEntry.sql +++ b/db/routines/vn/procedures/ektEntryAssign_setEntry.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ektEntryAssign_setEntry`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ektEntryAssign_setEntry`() BEGIN DECLARE done INT DEFAULT FALSE; diff --git a/db/routines/vn/procedures/energyMeter_record.sql b/db/routines/vn/procedures/energyMeter_record.sql index 113f73e19..07fb7afd0 100644 --- a/db/routines/vn/procedures/energyMeter_record.sql +++ b/db/routines/vn/procedures/energyMeter_record.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`energyMeter_record`(vInput INT, vActiveTime INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`energyMeter_record`(vInput INT, vActiveTime INT) BEGIN DECLARE vConsumption INT; diff --git a/db/routines/vn/procedures/entryDelivered.sql b/db/routines/vn/procedures/entryDelivered.sql index e948770e8..7a6e22b4b 100644 --- a/db/routines/vn/procedures/entryDelivered.sql +++ b/db/routines/vn/procedures/entryDelivered.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entryDelivered`(vDated DATE, vEntryFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entryDelivered`(vDated DATE, vEntryFk INT) BEGIN DECLARE vTravelFk INT; diff --git a/db/routines/vn/procedures/entryWithItem.sql b/db/routines/vn/procedures/entryWithItem.sql index 30dd99fbf..f28a69f61 100644 --- a/db/routines/vn/procedures/entryWithItem.sql +++ b/db/routines/vn/procedures/entryWithItem.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entryWithItem`(vShipmentWarehouse INT, vLandingWarehouse INT,vSale INT, vVolume INT, netCost DECIMAL(10,2), vInOutDate DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entryWithItem`(vShipmentWarehouse INT, vLandingWarehouse INT,vSale INT, vVolume INT, netCost DECIMAL(10,2), vInOutDate DATE) BEGIN DECLARE vTravel INT; diff --git a/db/routines/vn/procedures/entry_checkBooked.sql b/db/routines/vn/procedures/entry_checkBooked.sql deleted file mode 100644 index 7ee1fee22..000000000 --- a/db/routines/vn/procedures/entry_checkBooked.sql +++ /dev/null @@ -1,22 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_checkBooked`( - vSelf INT -) -BEGIN -/** - * Comprueba si una entrada está contabilizada, - * y si lo está retorna un throw. - * - * @param vSelf Id de entrada - */ - DECLARE vIsBooked BOOL; - - SELECT isBooked INTO vIsBooked - FROM `entry` - WHERE id = vSelf; - - IF vIsBooked AND NOT IFNULL(@isModeInventory, FALSE) THEN - CALL util.throw('Entry is already booked'); - END IF; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/entry_checkPackaging.sql b/db/routines/vn/procedures/entry_checkPackaging.sql index 7ba47b3d5..f9ed03212 100644 --- a/db/routines/vn/procedures/entry_checkPackaging.sql +++ b/db/routines/vn/procedures/entry_checkPackaging.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_checkPackaging`(vEntryFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_checkPackaging`(vEntryFk INT) BEGIN /** * Comprueba que los campos package y packaging no sean nulos diff --git a/db/routines/vn/procedures/entry_clone.sql b/db/routines/vn/procedures/entry_clone.sql index 4f38447c8..a0ed39c29 100644 --- a/db/routines/vn/procedures/entry_clone.sql +++ b/db/routines/vn/procedures/entry_clone.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_clone`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_clone`(vSelf INT) BEGIN /** * clones an entry. diff --git a/db/routines/vn/procedures/entry_cloneHeader.sql b/db/routines/vn/procedures/entry_cloneHeader.sql index 7f9426663..c988cc592 100644 --- a/db/routines/vn/procedures/entry_cloneHeader.sql +++ b/db/routines/vn/procedures/entry_cloneHeader.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_cloneHeader`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_cloneHeader`( vSelf INT, OUT vNewEntryFk INT, vTravelFk INT diff --git a/db/routines/vn/procedures/entry_cloneWithoutBuy.sql b/db/routines/vn/procedures/entry_cloneWithoutBuy.sql index 8d75d8d51..af661ce0a 100644 --- a/db/routines/vn/procedures/entry_cloneWithoutBuy.sql +++ b/db/routines/vn/procedures/entry_cloneWithoutBuy.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_cloneWithoutBuy`(vSelf INT, OUT vNewEntryFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_cloneWithoutBuy`(vSelf INT, OUT vNewEntryFk INT) BEGIN /** * Clona una entrada sin compras diff --git a/db/routines/vn/procedures/entry_copyBuys.sql b/db/routines/vn/procedures/entry_copyBuys.sql index 9bf4a55e4..8446249c7 100644 --- a/db/routines/vn/procedures/entry_copyBuys.sql +++ b/db/routines/vn/procedures/entry_copyBuys.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_copyBuys`(vSelf INT, vDestinationEntryFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_copyBuys`(vSelf INT, vDestinationEntryFk INT) BEGIN /** * Copies all buys from an entry to an entry. diff --git a/db/routines/vn/procedures/entry_fixMisfit.sql b/db/routines/vn/procedures/entry_fixMisfit.sql index 986a0ae9e..c950f9a95 100644 --- a/db/routines/vn/procedures/entry_fixMisfit.sql +++ b/db/routines/vn/procedures/entry_fixMisfit.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_fixMisfit`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_fixMisfit`( vSelf INT ) BEGIN diff --git a/db/routines/vn/procedures/entry_getRate.sql b/db/routines/vn/procedures/entry_getRate.sql index 2220ef999..e715fae9b 100644 --- a/db/routines/vn/procedures/entry_getRate.sql +++ b/db/routines/vn/procedures/entry_getRate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_getRate`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_getRate`(vSelf INT) BEGIN /** * Prepara una tabla con las tarifas aplicables en funcion de la fecha diff --git a/db/routines/vn/procedures/entry_getTransfer.sql b/db/routines/vn/procedures/entry_getTransfer.sql index 165c87dc7..c83556408 100644 --- a/db/routines/vn/procedures/entry_getTransfer.sql +++ b/db/routines/vn/procedures/entry_getTransfer.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_getTransfer`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_getTransfer`( vSelf INT ) BEGIN @@ -97,7 +97,7 @@ BEGIN FROM tmp.itemList; END IF; - CALL buyUltimateFromInterval(vWarehouseIn,vInventoryDate, vDateLanded); + CALL buy_getUltimateFromInterval(NULL, vWarehouseIn,vInventoryDate, vDateLanded); CREATE OR REPLACE TEMPORARY TABLE tTransfer ENGINE = MEMORY diff --git a/db/routines/vn/procedures/entry_isEditable.sql b/db/routines/vn/procedures/entry_isEditable.sql new file mode 100644 index 000000000..12b6d0ef6 --- /dev/null +++ b/db/routines/vn/procedures/entry_isEditable.sql @@ -0,0 +1,24 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_isEditable`( + vSelf INT +) +BEGIN +/** + * Comprueba si una entrada se puede actualizar + * si no se puede retorna un throw. + * + * @param vSelf Id de entrada + */ + DECLARE vIsEditable BOOL; + + SELECT e.isBooked INTO vIsEditable + FROM `entry` e + JOIN entryType et ON et.code = e.typeFk + WHERE NOT et.isInformal + AND e.id = vSelf; + + IF vIsEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN + CALL util.throw(CONCAT('Entry ', vSelf, ' is not editable')); + END IF; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/entry_lock.sql b/db/routines/vn/procedures/entry_lock.sql index 8ec50323b..51e0f40b4 100644 --- a/db/routines/vn/procedures/entry_lock.sql +++ b/db/routines/vn/procedures/entry_lock.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_lock`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_lock`(vSelf INT) BEGIN /** * Lock the indicated entry diff --git a/db/routines/vn/procedures/entry_moveNotPrinted.sql b/db/routines/vn/procedures/entry_moveNotPrinted.sql index 3a12007d1..3d15681ee 100644 --- a/db/routines/vn/procedures/entry_moveNotPrinted.sql +++ b/db/routines/vn/procedures/entry_moveNotPrinted.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_moveNotPrinted`(vSelf INT, +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_moveNotPrinted`(vSelf INT, vDays INT, vChangeEntry BOOL, OUT vNewEntryFk INT) diff --git a/db/routines/vn/procedures/entry_notifyChanged.sql b/db/routines/vn/procedures/entry_notifyChanged.sql index 11e6fe4c0..5e48699bf 100644 --- a/db/routines/vn/procedures/entry_notifyChanged.sql +++ b/db/routines/vn/procedures/entry_notifyChanged.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_notifyChanged`(vSelf INT, vBuyFk INT, vOldValues VARCHAR(512), vNewValues VARCHAR(512)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_notifyChanged`(vSelf INT, vBuyFk INT, vOldValues VARCHAR(512), vNewValues VARCHAR(512)) BEGIN DECLARE vEmail VARCHAR(255); DECLARE vFields VARCHAR(100); diff --git a/db/routines/vn/procedures/entry_recalc.sql b/db/routines/vn/procedures/entry_recalc.sql index b426a9b5b..516c5c193 100644 --- a/db/routines/vn/procedures/entry_recalc.sql +++ b/db/routines/vn/procedures/entry_recalc.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_recalc`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_recalc`() BEGIN /** * Comprueba que las ventas creadas entre un rango de fechas tienen componentes diff --git a/db/routines/vn/procedures/entry_splitByShelving.sql b/db/routines/vn/procedures/entry_splitByShelving.sql index 2898141ea..fbf0cef90 100644 --- a/db/routines/vn/procedures/entry_splitByShelving.sql +++ b/db/routines/vn/procedures/entry_splitByShelving.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_splitByShelving`(vShelvingFk VARCHAR(3), vFromEntryFk INT, vToEntryFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_splitByShelving`(vShelvingFk VARCHAR(3), vFromEntryFk INT, vToEntryFk INT) BEGIN /** * Divide las compras entre dos entradas de acuerdo con lo ubicado en una matr�cula @@ -13,60 +13,44 @@ BEGIN DECLARE vBuyStickers INT; DECLARE vDone BOOLEAN DEFAULT FALSE; - DECLARE cur CURSOR FOR + DECLARE cur CURSOR FOR SELECT bb.id buyFk, - FLOOR(ish.visible / ish.packing) ishStickers, + LEAST(bb.stickers, FLOOR(ish.visible / ish.packing)) ishStickers, bb.stickers buyStickers - FROM vn.itemShelving ish + FROM itemShelving ish JOIN (SELECT b.id, b.itemFk, b.stickers - FROM vn.buy b - WHERE b.entryFk = vFromEntryFk - ORDER BY b.stickers DESC - LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk - AND bb.stickers >= FLOOR(ish.visible / ish.packing) - WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci - GROUP BY ish.id; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - -- Cantidades de la matrícula que exceden la de las entradas - SELECT ish.itemFk, - i.longName, - FLOOR(ish.visible / ish.packing) AS etiEnMatricula, - bb.stickers etiEnEntrada - FROM vn.itemShelving ish - JOIN vn.item i ON i.id = ish.itemFk - LEFT JOIN (SELECT b.id, b.itemFk, b.stickers - FROM vn.buy b + FROM buy b WHERE b.entryFk = vFromEntryFk ORDER BY b.stickers DESC LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk - WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci - AND IFNULL(bb.stickers,0) < FLOOR(ish.visible / ish.packing) + WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci + AND NOT ish.isSplit GROUP BY ish.id; - + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + OPEN cur; read_loop: LOOP SET vDone = FALSE; FETCH cur INTO vBuyFk, vIshStickers, vBuyStickers; - + IF vDone THEN LEAVE read_loop; END IF; - + IF vIshStickers = vBuyStickers THEN - UPDATE vn.buy + UPDATE buy SET entryFk = vToEntryFk WHERE id = vBuyFk; ELSE - UPDATE vn.buy + UPDATE buy SET stickers = stickers - vIshStickers, quantity = stickers * packing WHERE id = vBuyFk; - - INSERT INTO vn.buy(entryFk, + + INSERT INTO buy(entryFk, itemFk, quantity, buyingValue, @@ -117,13 +101,16 @@ BEGIN weight, deliveryFk, itemOriginalFk - FROM vn.buy + FROM buy WHERE id = vBuyFk; UPDATE buy SET printedStickers = vIshStickers WHERE id = LAST_INSERT_ID(); END IF; - END LOOP; + UPDATE itemShelving + SET isSplit = TRUE + WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci; + END LOOP; CLOSE cur; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/entry_splitMisfit.sql b/db/routines/vn/procedures/entry_splitMisfit.sql index 476c52689..a21b2c9c4 100644 --- a/db/routines/vn/procedures/entry_splitMisfit.sql +++ b/db/routines/vn/procedures/entry_splitMisfit.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_splitMisfit`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_splitMisfit`(vSelf INT) BEGIN /* Divide una entrada, pasando los registros que ha insertado vn.entry_fixMisfit de la entrada original diff --git a/db/routines/vn/procedures/entry_unlock.sql b/db/routines/vn/procedures/entry_unlock.sql index 1dab48974..4ecdf2797 100644 --- a/db/routines/vn/procedures/entry_unlock.sql +++ b/db/routines/vn/procedures/entry_unlock.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_unlock`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_unlock`(vSelf INT) BEGIN /** * Unlock the indicated entry diff --git a/db/routines/vn/procedures/entry_updateComission.sql b/db/routines/vn/procedures/entry_updateComission.sql index ceed20d78..e2de2a4a5 100644 --- a/db/routines/vn/procedures/entry_updateComission.sql +++ b/db/routines/vn/procedures/entry_updateComission.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_updateComission`(vCurrency INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_updateComission`(vCurrency INT) BEGIN /** * Actualiza la comision de las entradas de hoy a futuro y las recalcula @@ -23,7 +23,8 @@ BEGIN JOIN vn.travel t ON t.id = e.travelFk JOIN vn.warehouse w ON w.id = t.warehouseInFk WHERE t.shipped >= util.VN_CURDATE() - AND e.currencyFk = vCurrency; + AND e.currencyFk = vCurrency + AND NOT e.isBooked; SET vComission = currency_getCommission(vCurrency); diff --git a/db/routines/vn/procedures/expeditionGetFromRoute.sql b/db/routines/vn/procedures/expeditionGetFromRoute.sql index 46c3c5d70..6191428e6 100644 --- a/db/routines/vn/procedures/expeditionGetFromRoute.sql +++ b/db/routines/vn/procedures/expeditionGetFromRoute.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionGetFromRoute`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionGetFromRoute`( vExpeditionFk INT) BEGIN /** diff --git a/db/routines/vn/procedures/expeditionPallet_Del.sql b/db/routines/vn/procedures/expeditionPallet_Del.sql index 451815ca0..e69992032 100644 --- a/db/routines/vn/procedures/expeditionPallet_Del.sql +++ b/db/routines/vn/procedures/expeditionPallet_Del.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionPallet_Del`(vPalletFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionPallet_Del`(vPalletFk INT) BEGIN DELETE FROM vn.expeditionPallet diff --git a/db/routines/vn/procedures/expeditionPallet_List.sql b/db/routines/vn/procedures/expeditionPallet_List.sql index db7cd6f0e..e419f8793 100644 --- a/db/routines/vn/procedures/expeditionPallet_List.sql +++ b/db/routines/vn/procedures/expeditionPallet_List.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionPallet_List`(vTruckFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionPallet_List`(vTruckFk INT) BEGIN SELECT ep.id Pallet, diff --git a/db/routines/vn/procedures/expeditionPallet_View.sql b/db/routines/vn/procedures/expeditionPallet_View.sql index fe410b2fb..31e0d6c96 100644 --- a/db/routines/vn/procedures/expeditionPallet_View.sql +++ b/db/routines/vn/procedures/expeditionPallet_View.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionPallet_View`(vPalletFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionPallet_View`(vPalletFk INT) BEGIN SELECT ep.id Pallet, diff --git a/db/routines/vn/procedures/expeditionPallet_build.sql b/db/routines/vn/procedures/expeditionPallet_build.sql index 9fbb60100..a33439061 100644 --- a/db/routines/vn/procedures/expeditionPallet_build.sql +++ b/db/routines/vn/procedures/expeditionPallet_build.sql @@ -1,34 +1,37 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionPallet_build`(IN vExpeditions JSON, IN vArcId INT, IN vWorkerFk INT, OUT vPalletFk INT) -BEGIN -/** Construye un pallet de expediciones. +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionPallet_build`( + vExpeditions JSON, + vArcId INT, + vWorkerFk INT, + OUT vPalletFk INT +) +proc: BEGIN +/** + * Builds an expedition pallet. * - * Primero comprueba si esas expediciones ya pertenecen a otro pallet, - * en cuyo caso actualiza ese pallet. + * First, it checks if these expeditions already belong to another pallet, + * in which case it returns an error. * - * @param vExpeditions JSON_ARRAY con esta estructura [exp1, exp2, exp3, ...] - * @param vArcId INT Identificador de vn.arcRead - * @param vWorkerFk INT Identificador de vn.worker - * @param out vPalletFk Identificador de vn.expeditionPallet + * @param vExpeditions JSON_ARRAY with this structure [exp1, exp2, exp3, ...] + * @param vArcId INT Identifier of arcRead + * @param vWorkerFk INT Identifier of worker + * @param out vPalletFk Identifier of expeditionPallet */ + DECLARE vCounter INT; DECLARE vExpeditionFk INT; DECLARE vTruckFk INT; DECLARE vPrinterFk INT; + DECLARE vExpeditionStateTypeFk INT; + DECLARE vFreeExpeditionCount INT; + DECLARE vExpeditionWithPallet INT; - DROP TEMPORARY TABLE IF EXISTS tExpedition; - CREATE TEMPORARY TABLE tExpedition - SELECT - e.id expeditionFk, - r.id routeFk, - ep.id palletFk - FROM - vn.expedition e, - vn.route r, - vn.expeditionPallet ep - LIMIT 0; - - ALTER TABLE tExpedition ADD PRIMARY KEY (expeditionFk); + CREATE OR REPLACE TEMPORARY TABLE tExpedition ( + expeditionFk INT, + routeFk INT, + palletFk INT, + PRIMARY KEY (expeditionFk) + ); SET vCounter = JSON_LENGTH(vExpeditions); @@ -39,53 +42,73 @@ BEGIN INSERT IGNORE INTO tExpedition(expeditionFk, routeFk, palletFk) SELECT vExpeditionFk, t.routeFk, es.palletFk - FROM vn.expedition e - LEFT JOIN vn.ticket t ON t.id = e.ticketFk - LEFT JOIN vn.expeditionScan es ON es.expeditionFk = e.id + FROM expedition e + LEFT JOIN ticket t ON t.id = e.ticketFk + LEFT JOIN expeditionScan es ON es.expeditionFk = e.id WHERE e.id = vExpeditionFk; END WHILE; - SELECT palletFk INTO vPalletFk - FROM ( - SELECT palletFk, count(*) n - FROM tExpedition - WHERE palletFk > 0 - GROUP BY palletFk - ORDER BY n DESC - LIMIT 100 ) sub - LIMIT 1; + SELECT COUNT(expeditionFk) INTO vFreeExpeditionCount + FROM tExpedition + WHERE palletFk IS NULL; - IF vPalletFk IS NULL THEN - SELECT expeditionTruckFk - INTO vTruckFk - FROM ( - SELECT rm.expeditionTruckFk, count(*) n - FROM vn.routesMonitor rm - JOIN tExpedition e ON e.routeFk = rm.routeFk - GROUP BY expeditionTruckFk - ORDER BY n DESC - LIMIT 1) sub; + SELECT COUNT(expeditionFk) INTO vExpeditionWithPallet + FROM tExpedition + WHERE palletFk; - IF vTruckFk IS NULL THEN - CALL util.throw ('TRUCK_NOT_AVAILABLE'); - END IF; - - INSERT INTO vn.expeditionPallet(truckFk) - VALUES(vTruckFk); - - SET vPalletFk = LAST_INSERT_ID(); + IF vExpeditionWithPallet THEN + UPDATE arcRead + SET error = ( + SELECT GROUP_CONCAT(expeditionFk SEPARATOR ', ') + FROM tExpedition + WHERE palletFk + ) + WHERE id = vArcId; + LEAVE proc; END IF; - INSERT INTO vn.expeditionScan(expeditionFk, palletFk, workerFk) + IF NOT vFreeExpeditionCount THEN + CALL util.throw ('NO_FREE_EXPEDITIONS'); + END IF; + + SELECT roadmapStopFk INTO vTruckFk + FROM ( + SELECT rm.roadmapStopFk, count(*) n + FROM routesMonitor rm + JOIN tExpedition e ON e.routeFk = rm.routeFk + WHERE e.palletFk IS NULL + GROUP BY roadmapStopFk + ORDER BY n DESC + LIMIT 1 + ) sub; + + IF vTruckFk IS NULL THEN + CALL util.throw ('TRUCK_NOT_AVAILABLE'); + END IF; + + INSERT INTO expeditionPallet SET truckFk = vTruckFk; + + SET vPalletFk = LAST_INSERT_ID(); + + INSERT INTO expeditionScan(expeditionFk, palletFk, workerFk) SELECT expeditionFk, vPalletFk, vWorkerFk FROM tExpedition - ON DUPLICATE KEY UPDATE palletFk = vPalletFk, workerFk = vWorkerFk; + WHERE palletFk IS NULL; - SELECT printerFk INTO vPrinterFk - FROM vn.arcRead - WHERE id = vArcId; + SELECT id INTO vExpeditionStateTypeFk + FROM expeditionStateType + WHERE code = 'PALLETIZED'; + + INSERT INTO expeditionState(expeditionFk, typeFk) + SELECT expeditionFk, vExpeditionStateTypeFk + FROM tExpedition + WHERE palletFk IS NULL; - CALL vn.report_print( + UPDATE arcRead SET error = NULL WHERE id = vArcId; + + SELECT printerFk INTO vPrinterFk FROM arcRead WHERE id = vArcId; + + CALL report_print( 'LabelPalletExpedition', vPrinterFk, account.myUser_getId(), @@ -93,7 +116,7 @@ BEGIN 'high' ); - UPDATE vn.expeditionPallet SET isPrint = TRUE WHERE id = vPalletFk; + UPDATE expeditionPallet SET isPrint = TRUE WHERE id = vPalletFk; DROP TEMPORARY TABLE tExpedition; END$$ diff --git a/db/routines/vn/procedures/expeditionPallet_printLabel.sql b/db/routines/vn/procedures/expeditionPallet_printLabel.sql index ada11daab..0a35d2a6b 100644 --- a/db/routines/vn/procedures/expeditionPallet_printLabel.sql +++ b/db/routines/vn/procedures/expeditionPallet_printLabel.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionPallet_printLabel`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionPallet_printLabel`(vSelf INT) BEGIN /** * Calls the report_print procedure and passes it @@ -9,7 +9,16 @@ BEGIN */ DECLARE vPrinterFk INT; DECLARE vUserFk INT DEFAULT account.myUser_getId(); - + DECLARE vIsInExpeditionPallet BOOL; + + SELECT COUNT(id) INTO vIsInExpeditionPallet + FROM expeditionPallet + WHERE id = vSelf; + + IF NOT vIsInExpeditionPallet THEN + CALL util.throw("ExpeditionPallet not exists"); + END IF; + SELECT o.labelerFk INTO vPrinterFk FROM operator o WHERE o.workerFk = vUserFk; diff --git a/db/routines/vn/procedures/expeditionScan_Add.sql b/db/routines/vn/procedures/expeditionScan_Add.sql index 6ab19e8d0..98eeb265b 100644 --- a/db/routines/vn/procedures/expeditionScan_Add.sql +++ b/db/routines/vn/procedures/expeditionScan_Add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionScan_Add`(vPalletFk INT, vTruckFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionScan_Add`(vPalletFk INT, vTruckFk INT) BEGIN DECLARE vTotal INT DEFAULT 0; diff --git a/db/routines/vn/procedures/expeditionScan_Del.sql b/db/routines/vn/procedures/expeditionScan_Del.sql index ecbfdad4b..8e082d18c 100644 --- a/db/routines/vn/procedures/expeditionScan_Del.sql +++ b/db/routines/vn/procedures/expeditionScan_Del.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionScan_Del`(vScanFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionScan_Del`(vScanFk INT) BEGIN DELETE FROM vn.expeditionScan diff --git a/db/routines/vn/procedures/expeditionScan_List.sql b/db/routines/vn/procedures/expeditionScan_List.sql index b0d53053f..7f3ddd3fd 100644 --- a/db/routines/vn/procedures/expeditionScan_List.sql +++ b/db/routines/vn/procedures/expeditionScan_List.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionScan_List`(vPalletFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionScan_List`(vPalletFk INT) BEGIN SELECT es.id, diff --git a/db/routines/vn/procedures/expeditionScan_Put.sql b/db/routines/vn/procedures/expeditionScan_Put.sql index 9744a7cd7..fc7d4da23 100644 --- a/db/routines/vn/procedures/expeditionScan_Put.sql +++ b/db/routines/vn/procedures/expeditionScan_Put.sql @@ -1,11 +1,18 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionScan_Put`(vPalletFk INT, vExpeditionFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionScan_Put`( + vPalletFk INT, + vExpeditionFk INT +) BEGIN - - REPLACE vn.expeditionScan(expeditionFk, palletFk) - VALUES(vExpeditionFk, vPalletFk); - - SELECT LAST_INSERT_ID() INTO vPalletFk; - + IF NOT (SELECT TRUE FROM expedition WHERE id = vExpeditionFk LIMIT 1) THEN + CALL util.throw('Expedition not exists'); + END IF; + + IF NOT (SELECT TRUE FROM expeditionPallet WHERE id = vPalletFk LIMIT 1) THEN + CALL util.throw('Pallet not exists'); + END IF; + + REPLACE expeditionScan(expeditionFk, palletFk) + VALUES(vExpeditionFk, vPalletFk); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/expeditionState_add.sql b/db/routines/vn/procedures/expeditionState_add.sql index 299f11b04..974fc4d3e 100644 --- a/db/routines/vn/procedures/expeditionState_add.sql +++ b/db/routines/vn/procedures/expeditionState_add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionState_add`(vParam INT, vStateCode VARCHAR(100)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionState_add`(vParam INT, vStateCode VARCHAR(100)) BEGIN /** diff --git a/db/routines/vn/procedures/expeditionState_addByAdress.sql b/db/routines/vn/procedures/expeditionState_addByAdress.sql index 1d8de9745..3925ea000 100644 --- a/db/routines/vn/procedures/expeditionState_addByAdress.sql +++ b/db/routines/vn/procedures/expeditionState_addByAdress.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionState_addByAdress`(vAdressFk INT, vRouteFk INT, vStateCode VARCHAR(100)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionState_addByAdress`(vAdressFk INT, vRouteFk INT, vStateCode VARCHAR(100)) BEGIN /** diff --git a/db/routines/vn/procedures/expeditionState_addByExpedition.sql b/db/routines/vn/procedures/expeditionState_addByExpedition.sql index 6fbc205e5..fbc075b88 100644 --- a/db/routines/vn/procedures/expeditionState_addByExpedition.sql +++ b/db/routines/vn/procedures/expeditionState_addByExpedition.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionState_addByExpedition`(vExpeditionFk INT, vStateCode VARCHAR(100)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionState_addByExpedition`(vExpeditionFk INT, vStateCode VARCHAR(100)) BEGIN /** diff --git a/db/routines/vn/procedures/expeditionState_addByPallet.sql b/db/routines/vn/procedures/expeditionState_addByPallet.sql index af99b444d..5ebebb748 100644 --- a/db/routines/vn/procedures/expeditionState_addByPallet.sql +++ b/db/routines/vn/procedures/expeditionState_addByPallet.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionState_addByPallet`(vPalletFk INT, vStateCode VARCHAR(100)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionState_addByPallet`(vPalletFk INT, vStateCode VARCHAR(100)) BEGIN /** * Inserta nuevos registros en la tabla vn.expeditionState diff --git a/db/routines/vn/procedures/expeditionState_addByRoute.sql b/db/routines/vn/procedures/expeditionState_addByRoute.sql index 5e438287b..c375f95a8 100644 --- a/db/routines/vn/procedures/expeditionState_addByRoute.sql +++ b/db/routines/vn/procedures/expeditionState_addByRoute.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionState_addByRoute`(vRouteFk INT, vStateCode VARCHAR(100)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expeditionState_addByRoute`(vRouteFk INT, vStateCode VARCHAR(100)) BEGIN /** diff --git a/db/routines/vn/procedures/expeditionTruck_Add.sql b/db/routines/vn/procedures/expeditionTruck_Add.sql deleted file mode 100644 index eabfa452c..000000000 --- a/db/routines/vn/procedures/expeditionTruck_Add.sql +++ /dev/null @@ -1,9 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionTruck_Add`(vHour VARCHAR(5), vDescription VARCHAR(45)) -BEGIN - - INSERT INTO vn.roadmapStop(eta,description) - VALUES(CONCAT(util.VN_CURDATE(), ' ', vHour), vDescription); - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/expeditionTruck_List.sql b/db/routines/vn/procedures/expeditionTruck_List.sql deleted file mode 100644 index c358df5e3..000000000 --- a/db/routines/vn/procedures/expeditionTruck_List.sql +++ /dev/null @@ -1,12 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionTruck_List`() -BEGIN - - SELECT id truckFk, - eta, - description Destino - FROM roadmapStop - WHERE eta BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) - ORDER BY eta; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/expedition_StateGet.sql b/db/routines/vn/procedures/expedition_StateGet.sql index e58ec3afd..a871cf3b6 100644 --- a/db/routines/vn/procedures/expedition_StateGet.sql +++ b/db/routines/vn/procedures/expedition_StateGet.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expedition_StateGet`(vExpeditionFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expedition_StateGet`(vExpeditionFk INT) BEGIN /* Devuelve una "ficha" con todos los datos relativos a la expedición @@ -67,7 +67,7 @@ BEGIN LEFT JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id - LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk WHERE e.id = vExpeditionFk; END$$ diff --git a/db/routines/vn/procedures/expedition_getFromRoute.sql b/db/routines/vn/procedures/expedition_getFromRoute.sql index 2b4de5662..f95936413 100644 --- a/db/routines/vn/procedures/expedition_getFromRoute.sql +++ b/db/routines/vn/procedures/expedition_getFromRoute.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expedition_getFromRoute`(vRouteFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expedition_getFromRoute`(vRouteFk INT) BEGIN /** * Obtiene las expediciones a partir de una ruta @@ -15,7 +15,8 @@ BEGIN t.addressFk, a.nickname, sub2.itemPackingTypeConcat, - est.code + est.code, + es.isScanned FROM expedition e JOIN ticket t ON t.id = e.ticketFk JOIN ticketState ts ON ts.ticketFk = e.ticketFk @@ -33,6 +34,10 @@ BEGIN GROUP BY sub.ticketFk ) sub2 ON sub2.ticketFk = t.id LEFT JOIN expeditionStateType est ON est.id = e.stateTypeFk + LEFT JOIN expeditionState es ON es.id = ( + SELECT MAX(id) + FROM expeditionState es + WHERE expeditionFk = e.id) WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE ORDER BY r.created, t.priority DESC; END$$ diff --git a/db/routines/vn/procedures/expedition_getState.sql b/db/routines/vn/procedures/expedition_getState.sql index f3f94a889..f2e873a6b 100644 --- a/db/routines/vn/procedures/expedition_getState.sql +++ b/db/routines/vn/procedures/expedition_getState.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expedition_getState`(vExpeditionFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expedition_getState`(vExpeditionFk INT) BEGIN DECLARE vTicketsPendientes INT; @@ -50,7 +50,7 @@ BEGIN LEFT JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id - LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk WHERE e.id = vExpeditionFk; END$$ diff --git a/db/routines/vn/procedures/freelance_getInfo.sql b/db/routines/vn/procedures/freelance_getInfo.sql index 0f85ab4bd..64d44c347 100644 --- a/db/routines/vn/procedures/freelance_getInfo.sql +++ b/db/routines/vn/procedures/freelance_getInfo.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`freelance_getInfo`(workerFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`freelance_getInfo`(workerFk INT) BEGIN SELECT s.name, s.street, s.city, s.nif, s.postCode FROM route r diff --git a/db/routines/vn/procedures/getDayExpeditions.sql b/db/routines/vn/procedures/getDayExpeditions.sql index b708c8b0e..5f83937a7 100644 --- a/db/routines/vn/procedures/getDayExpeditions.sql +++ b/db/routines/vn/procedures/getDayExpeditions.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`getDayExpeditions`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`getDayExpeditions`() BEGIN SELECT diff --git a/db/routines/vn/procedures/getInfoDelivery.sql b/db/routines/vn/procedures/getInfoDelivery.sql index c240560e9..0663cbbc3 100644 --- a/db/routines/vn/procedures/getInfoDelivery.sql +++ b/db/routines/vn/procedures/getInfoDelivery.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`getInfoDelivery`(vRouteFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`getInfoDelivery`(vRouteFk INT) BEGIN SELECT s.name, s.street, s.city, s.nif, s.postCode FROM vn.route r JOIN vn.agencyMode am ON r.agencyModeFk = am.id diff --git a/db/routines/vn/procedures/getPedidosInternos.sql b/db/routines/vn/procedures/getPedidosInternos.sql index 973e110ef..d6efdc364 100644 --- a/db/routines/vn/procedures/getPedidosInternos.sql +++ b/db/routines/vn/procedures/getPedidosInternos.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`getPedidosInternos`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`getPedidosInternos`() BEGIN SELECT id,name as description,upToDown as quantity FROM vn.item WHERE upToDown; diff --git a/db/routines/vn/procedures/getTaxBases.sql b/db/routines/vn/procedures/getTaxBases.sql index 54932aa4f..15a6ce85b 100644 --- a/db/routines/vn/procedures/getTaxBases.sql +++ b/db/routines/vn/procedures/getTaxBases.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`getTaxBases`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`getTaxBases`() BEGIN /** * Calcula y devuelve en número de bases imponibles postivas y negativas diff --git a/db/routines/vn/procedures/greuge_add.sql b/db/routines/vn/procedures/greuge_add.sql index b2241ab83..f69e97caa 100644 --- a/db/routines/vn/procedures/greuge_add.sql +++ b/db/routines/vn/procedures/greuge_add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`greuge_add`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`greuge_add`() BEGIN /** * Group inserts into vn.greuge and then deletes the records just inserted diff --git a/db/routines/vn/procedures/greuge_notifyEvents.sql b/db/routines/vn/procedures/greuge_notifyEvents.sql index ec00c1bde..bf6755c9a 100644 --- a/db/routines/vn/procedures/greuge_notifyEvents.sql +++ b/db/routines/vn/procedures/greuge_notifyEvents.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`greuge_notifyEvents`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`greuge_notifyEvents`() BEGIN /** * Notify to detect wrong greuges. diff --git a/db/routines/vn/procedures/inventoryFailureAdd.sql b/db/routines/vn/procedures/inventoryFailureAdd.sql index 38765cbda..e2b5fa4a0 100644 --- a/db/routines/vn/procedures/inventoryFailureAdd.sql +++ b/db/routines/vn/procedures/inventoryFailureAdd.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`inventoryFailureAdd`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`inventoryFailureAdd`() BEGIN DECLARE done BOOL DEFAULT FALSE; diff --git a/db/routines/vn/procedures/inventoryMake.sql b/db/routines/vn/procedures/inventoryMake.sql index 30bea6690..91065771a 100644 --- a/db/routines/vn/procedures/inventoryMake.sql +++ b/db/routines/vn/procedures/inventoryMake.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`inventoryMake`(vInventoryDate DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`inventoryMake`(vInventoryDate DATE) BEGIN /** * Recalculate the inventories diff --git a/db/routines/vn/procedures/inventoryMakeLauncher.sql b/db/routines/vn/procedures/inventoryMakeLauncher.sql index 717e3c163..1822e1d8d 100644 --- a/db/routines/vn/procedures/inventoryMakeLauncher.sql +++ b/db/routines/vn/procedures/inventoryMakeLauncher.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`inventoryMakeLauncher`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`inventoryMakeLauncher`() BEGIN /** * Recalculate the inventories of all warehouses diff --git a/db/routines/vn/procedures/inventory_repair.sql b/db/routines/vn/procedures/inventory_repair.sql index 93527d84b..9c8300321 100644 --- a/db/routines/vn/procedures/inventory_repair.sql +++ b/db/routines/vn/procedures/inventory_repair.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`inventory_repair`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`inventory_repair`() BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.lastEntry; diff --git a/db/routines/vn/procedures/invoiceExpenseMake.sql b/db/routines/vn/procedures/invoiceExpenseMake.sql index a1fe69ff5..ad336e2db 100644 --- a/db/routines/vn/procedures/invoiceExpenseMake.sql +++ b/db/routines/vn/procedures/invoiceExpenseMake.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceExpenseMake`(IN vInvoice INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceExpenseMake`(IN vInvoice INT) BEGIN /* Inserta las partidas de gasto correspondientes a la factura * REQUIERE tabla tmp.ticketToInvoice diff --git a/db/routines/vn/procedures/invoiceFromAddress.sql b/db/routines/vn/procedures/invoiceFromAddress.sql index 2879460ce..24b247f5b 100644 --- a/db/routines/vn/procedures/invoiceFromAddress.sql +++ b/db/routines/vn/procedures/invoiceFromAddress.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceFromAddress`(vMaxTicketDate DATETIME,vAddress INT,vCompany INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceFromAddress`(vMaxTicketDate DATETIME,vAddress INT,vCompany INT) BEGIN DECLARE vMinDateTicket DATE DEFAULT TIMESTAMPADD(MONTH, -3, util.VN_CURDATE()); diff --git a/db/routines/vn/procedures/invoiceFromClient.sql b/db/routines/vn/procedures/invoiceFromClient.sql index 29cee5d4f..1a0dfa4c3 100644 --- a/db/routines/vn/procedures/invoiceFromClient.sql +++ b/db/routines/vn/procedures/invoiceFromClient.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceFromClient`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceFromClient`( IN vMaxTicketDate datetime, IN vClientFk INT, IN vCompanyFk INT) diff --git a/db/routines/vn/procedures/invoiceFromTicket.sql b/db/routines/vn/procedures/invoiceFromTicket.sql index e5ea00e62..c00a9bab4 100644 --- a/db/routines/vn/procedures/invoiceFromTicket.sql +++ b/db/routines/vn/procedures/invoiceFromTicket.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceFromTicket`(IN vTicket INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceFromTicket`(IN vTicket INT) BEGIN DROP TEMPORARY TABLE IF EXISTS `tmp`.`ticketToInvoice`; diff --git a/db/routines/vn/procedures/invoiceInDueDay_calculate.sql b/db/routines/vn/procedures/invoiceInDueDay_calculate.sql index e51b5f64d..d488b79db 100644 --- a/db/routines/vn/procedures/invoiceInDueDay_calculate.sql +++ b/db/routines/vn/procedures/invoiceInDueDay_calculate.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInDueDay_calculate`(vInvoiceInFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceInDueDay_calculate`( + vInvoiceInFk INT +) BEGIN /** * Calcula los vctos. de una factura recibida @@ -56,12 +58,13 @@ BEGIN COUNT(DISTINCT(pdd.detail)) cont, s.payDay, ii.issued, - DATE(ii.created) + INTERVAL 2 DAY created + DATE(ii.created) + INTERVAL iic.dueDateMarginDays DAY created FROM invoiceIn ii JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id LEFT JOIN sage.TiposIva ti ON ti.CodigoIva= iit.taxTypeSageFk JOIN supplier s ON s.id = ii.supplierFk - JOIN payDemDetail pdd ON pdd.id = s.payDemFk + JOIN payDemDetail pdd ON pdd.id = s.payDemFk + JOIN invoiceInConfig iic WHERE ii.id = vInvoiceInFk GROUP BY ii.id )sub diff --git a/db/routines/vn/procedures/invoiceInDueDay_recalc.sql b/db/routines/vn/procedures/invoiceInDueDay_recalc.sql index 7d2b0a5ed..b3a9f5aef 100644 --- a/db/routines/vn/procedures/invoiceInDueDay_recalc.sql +++ b/db/routines/vn/procedures/invoiceInDueDay_recalc.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInDueDay_recalc`(vInvoiceInFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceInDueDay_recalc`(vInvoiceInFk INT) BEGIN DELETE FROM invoiceInDueDay diff --git a/db/routines/vn/procedures/invoiceInTaxMakeByDua.sql b/db/routines/vn/procedures/invoiceInTaxMakeByDua.sql index 3453516cc..4c16346b2 100644 --- a/db/routines/vn/procedures/invoiceInTaxMakeByDua.sql +++ b/db/routines/vn/procedures/invoiceInTaxMakeByDua.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTaxMakeByDua`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceInTaxMakeByDua`( vDuaFk INT ) BEGIN diff --git a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql index 60ec34696..da3faefbf 100644 --- a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql +++ b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTax_afterUpsert`(vInvoiceInFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceInTax_afterUpsert`(vInvoiceInFk INT) BEGIN /** * Triggered actions when a invoiceInTax is updated or inserted. @@ -8,7 +8,6 @@ BEGIN */ DECLARE vTaxRowLimit INT; DECLARE vLines INT; - DECLARE vHasDistinctTransactions INT; SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig; @@ -20,17 +19,5 @@ BEGIN IF vLines >= vTaxRowLimit THEN CALL util.throw (CONCAT('The maximum number of lines is ', vTaxRowLimit)); END IF; - - SELECT COUNT(DISTINCT transactionTypeSageFk) INTO vHasDistinctTransactions - FROM invoiceIn ii - JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id - JOIN invoiceInSerial iis ON iis.code = ii.serial - WHERE ii.id = vInvoiceInFk - AND iis.taxAreaFk = 'CEE' - AND transactionTypeSageFk; - - IF vHasDistinctTransactions > 1 THEN - CALL util.throw ('This invoice does not allow different types of transactions'); - END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/invoiceInTax_getFromDua.sql b/db/routines/vn/procedures/invoiceInTax_getFromDua.sql index bf2cbe61e..c3a890ddd 100644 --- a/db/routines/vn/procedures/invoiceInTax_getFromDua.sql +++ b/db/routines/vn/procedures/invoiceInTax_getFromDua.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTax_getFromDua`(vDuaFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceInTax_getFromDua`(vDuaFk INT) BEGIN /** * Borra los valores de duaTax y sus vctos. y los vuelve a crear en base a la tabla duaEntry diff --git a/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql b/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql index 5f2ceeb4f..186104a73 100644 --- a/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql +++ b/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTax_getFromEntries`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceInTax_getFromEntries`( IN vInvoiceInFk INT ) BEGIN diff --git a/db/routines/vn/procedures/invoiceInTax_recalc.sql b/db/routines/vn/procedures/invoiceInTax_recalc.sql index 4e20b01d3..0daf87103 100644 --- a/db/routines/vn/procedures/invoiceInTax_recalc.sql +++ b/db/routines/vn/procedures/invoiceInTax_recalc.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTax_recalc`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceInTax_recalc`( vInvoiceInFk INT ) BEGIN diff --git a/db/routines/vn/procedures/invoiceIn_booking.sql b/db/routines/vn/procedures/invoiceIn_booking.sql index 4b015750f..36189afcc 100644 --- a/db/routines/vn/procedures/invoiceIn_booking.sql +++ b/db/routines/vn/procedures/invoiceIn_booking.sql @@ -1,8 +1,31 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_booking`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceIn_booking`( + vSelf INT, + vBookNumber INT +) BEGIN - DECLARE vBookNumber INT; +/** + * Genera la contabilidad para una factura y la marca como contabilizada + * Cuadra el asiento generado en si encuentra problemas derivados + * de los calculos con decimales + * + * @param vSelf Id invoiceIn + * @param vBookEntry Id de asiento, si es NULL se genera uno nuevo + */ DECLARE vFiscalYear INT; + DECLARE vHasRepeatedTransactions BOOL; + + SELECT TRUE INTO vHasRepeatedTransactions + FROM invoiceInTax iit + JOIN invoiceIn ii ON ii.id = iit.invoiceInFk + WHERE ii.id = vSelf + AND ii.serial = 'E' + HAVING COUNT(DISTINCT iit.transactionTypeSageFk) > 1 + LIMIT 1; + + IF vHasRepeatedTransactions THEN + CALL util.throw ('This invoice contains different types of transactions'); + END IF; CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn ENGINE = MEMORY @@ -58,7 +81,10 @@ BEGIN WHERE ii.id = vSelf; SELECT YEAR(bookEntried) INTO vFiscalYear FROM tInvoiceIn LIMIT 1; - CALL ledger_next(vFiscalYear, vBookNumber); + + IF vBookNumber IS NULL THEN + CALL ledger_nextTx(vFiscalYear, vBookNumber); + END IF; -- Apunte del proveedor INSERT INTO XDiario( @@ -187,7 +213,7 @@ BEGIN LEFT JOIN ( SELECT e.id FROM tInvoiceIn tii - JOIN expense e ON e.id = tii.expenseFk + JOIN expense e ON e.id = tii.expenseFk WHERE e.isWithheld LIMIT 1 ) eWithheld ON TRUE diff --git a/db/routines/vn/procedures/invoiceIn_checkBooked.sql b/db/routines/vn/procedures/invoiceIn_checkBooked.sql index 862870eb4..b9966a9b6 100644 --- a/db/routines/vn/procedures/invoiceIn_checkBooked.sql +++ b/db/routines/vn/procedures/invoiceIn_checkBooked.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_checkBooked`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceIn_checkBooked`( vSelf INT ) BEGIN diff --git a/db/routines/vn/procedures/invoiceOutAgain.sql b/db/routines/vn/procedures/invoiceOutAgain.sql index 82cebc18d..21b43fdf9 100644 --- a/db/routines/vn/procedures/invoiceOutAgain.sql +++ b/db/routines/vn/procedures/invoiceOutAgain.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOutAgain`(IN vInvoiceRef VARCHAR(15), vTaxArea VARCHAR(25)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceOutAgain`(IN vInvoiceRef VARCHAR(15), vTaxArea VARCHAR(25)) BEGIN /* Para tickets ya facturados, vuelve a repetir el proceso de facturación. diff --git a/db/routines/vn/procedures/invoiceOutBooking.sql b/db/routines/vn/procedures/invoiceOutBooking.sql index 913035576..86f64ffcb 100644 --- a/db/routines/vn/procedures/invoiceOutBooking.sql +++ b/db/routines/vn/procedures/invoiceOutBooking.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOutBooking`(IN vInvoice INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceOutBooking`(IN vInvoice INT) BEGIN /** * Asienta una factura emitida @@ -61,7 +61,7 @@ BEGIN WHERE io.id = vInvoice; SELECT YEAR(FECHA) INTO vFiscalYear FROM rs LIMIT 1; - CALL ledger_next(vFiscalYear, vBookNumber); + CALL ledger_nextTx(vFiscalYear, vBookNumber); -- Linea del cliente INSERT INTO XDiario( ASIEN, diff --git a/db/routines/vn/procedures/invoiceOutBookingRange.sql b/db/routines/vn/procedures/invoiceOutBookingRange.sql index 57d973f01..e053e51eb 100644 --- a/db/routines/vn/procedures/invoiceOutBookingRange.sql +++ b/db/routines/vn/procedures/invoiceOutBookingRange.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOutBookingRange`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceOutBookingRange`() BEGIN /* Reasentar facturas diff --git a/db/routines/vn/procedures/invoiceOutListByCompany.sql b/db/routines/vn/procedures/invoiceOutListByCompany.sql index 09ebfc1a4..13145dd6b 100644 --- a/db/routines/vn/procedures/invoiceOutListByCompany.sql +++ b/db/routines/vn/procedures/invoiceOutListByCompany.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOutListByCompany`(vCompany INT, vStarted DATE, vEnded DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceOutListByCompany`(vCompany INT, vStarted DATE, vEnded DATE) BEGIN SELECT diff --git a/db/routines/vn/procedures/invoiceOutTaxAndExpense.sql b/db/routines/vn/procedures/invoiceOutTaxAndExpense.sql index c263fe8d3..4bae6b245 100644 --- a/db/routines/vn/procedures/invoiceOutTaxAndExpense.sql +++ b/db/routines/vn/procedures/invoiceOutTaxAndExpense.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOutTaxAndExpense`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceOutTaxAndExpense`() BEGIN /* Para tickets ya facturados, vuelve a repetir el proceso de facturación. diff --git a/db/routines/vn/procedures/invoiceOut_exportationFromClient.sql b/db/routines/vn/procedures/invoiceOut_exportationFromClient.sql index 5fce7c428..1e870ca75 100644 --- a/db/routines/vn/procedures/invoiceOut_exportationFromClient.sql +++ b/db/routines/vn/procedures/invoiceOut_exportationFromClient.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOut_exportationFromClient`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceOut_exportationFromClient`( vMaxTicketDate DATETIME, vClientFk INT, vCompanyFk INT) diff --git a/db/routines/vn/procedures/invoiceOut_new.sql b/db/routines/vn/procedures/invoiceOut_new.sql index 1b486df86..723f33df5 100644 --- a/db/routines/vn/procedures/invoiceOut_new.sql +++ b/db/routines/vn/procedures/invoiceOut_new.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOut_new`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceOut_new`( vSerial VARCHAR(255), vInvoiceDate DATE, vTaxArea VARCHAR(25), @@ -80,8 +80,8 @@ BEGIN OR t.isDeleted OR c.hasToInvoice = FALSE OR itc.id IS NULL - OR a.id IS NULL - OR (vTaxArea = 'WORLD' + OR a.id IS NULL + OR (vTaxArea = 'WORLD' AND (a.customsAgentFk IS NULL OR a.incotermsFk IS NULL)); SELECT SUM(s.quantity * s.price * (100 - s.discount)/100) <> 0 @@ -97,7 +97,7 @@ BEGIN AND (vCorrectingSerial = vSerial OR NOT hasAnyNegativeBase()) THEN - -- el trigger añade el siguiente Id_Factura correspondiente a la vSerial + -- el trigger añade el siguiente ref correspondiente a la vSerial INSERT INTO invoiceOut( ref, serial, @@ -153,7 +153,9 @@ BEGIN FROM tmp.ticketToInvoice ti LEFT JOIN ticketState ts ON ti.id = ts.ticketFk JOIN state s - WHERE IFNULL(ts.alertLevel, 0) < 3 and s.`code` = getAlert3State(ti.id); + JOIN alertLevel al ON al.code = 'DELIVERED' + WHERE (ts.alertLevel IS NULL OR ts.alertLevel < al.id) + AND s.`code` = getAlert3State(ti.id); INSERT INTO ticketTracking(stateFk, ticketFk, userFk) SELECT * FROM tmp.updateInter; @@ -214,7 +216,7 @@ BEGIN i.transactionTypeSageFk, @vTaxCodeGeneral := i.taxClassCodeFk FROM tmp.ticketServiceTax tst - JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tst.code + JOIN invoiceOutTaxMultiConfig i ON i.taxClassCodeFk = tst.code WHERE i.isService HAVING taxableBase ) sub; @@ -227,7 +229,7 @@ BEGIN i.taxTypeSageFk , i.transactionTypeSageFk FROM tmp.ticketTax tt - JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tt.code + JOIN invoiceOutTaxMultiConfig i ON i.taxClassCodeFk = tt.code WHERE !i.isService GROUP BY tt.pgcFk HAVING taxableBase diff --git a/db/routines/vn/procedures/invoiceOut_newFromAddress.sql b/db/routines/vn/procedures/invoiceOut_newFromAddress.sql new file mode 100644 index 000000000..495ace608 --- /dev/null +++ b/db/routines/vn/procedures/invoiceOut_newFromAddress.sql @@ -0,0 +1,56 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceOut_newFromAddress`( + IN vAddressFk INT, + IN vSerial CHAR(2), + IN vMaxShipped DATE, + IN vCompanyFk INT, + IN vTaxArea VARCHAR(25), + IN vRef VARCHAR(25), + OUT vInvoiceId INT) +BEGIN +/** + * Factura los tickets de un consignatario hasta una fecha dada + * @param vAddressFk Id del consignatario a facturar + * @param vSerial Serie de factura + * @param vMaxShipped Fecha hasta la cual cogerá tickets para facturar + * @param vCompanyFk Id de la empresa desde la que se factura + * @param vTaxArea Tipo de iva en relacion a la empresa y al cliente, NULL por defecto + * @param vRef Referencia de la factura en caso que se quiera forzar, NULL por defecto + * @return vInvoiceId factura + */ + DECLARE vIsRefEditable BOOLEAN; + + IF vRef IS NOT NULL AND vSerial IS NOT NULL THEN + SELECT isRefEditable INTO vIsRefEditable + FROM invoiceOutSerial + WHERE code = vSerial; + + IF NOT vIsRefEditable THEN + CALL util.throw('serial non editable'); + END IF; + END IF; + + DROP TEMPORARY TABLE IF EXISTS `tmp`.`ticketToInvoice`; + CREATE TEMPORARY TABLE `tmp`.`ticketToInvoice` + (PRIMARY KEY (`id`)) + ENGINE = MEMORY + SELECT id FROM ticket t + WHERE t.addressFk = vAddressFk + AND t.refFk IS NULL + AND t.companyFk = vCompanyFk + AND t.shipped BETWEEN + util.firstDayOfYear(vMaxShipped - INTERVAL 1 YEAR) + AND util.dayend(vMaxShipped); + + CALL invoiceOut_new(vSerial, util.VN_CURDATE(), vTaxArea, vInvoiceId); + + UPDATE invoiceOut + SET `ref` = vRef + WHERE id = vInvoiceId + AND vRef IS NOT NULL; + + IF vSerial <> 'R' AND NOT ISNULL(vInvoiceId) AND vInvoiceId <> 0 THEN + CALL invoiceOutBooking(vInvoiceId); + END IF; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/invoiceOut_newFromClient.sql b/db/routines/vn/procedures/invoiceOut_newFromClient.sql index e6fc7b78a..74c4aa71d 100644 --- a/db/routines/vn/procedures/invoiceOut_newFromClient.sql +++ b/db/routines/vn/procedures/invoiceOut_newFromClient.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOut_newFromClient`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceOut_newFromClient`( IN vClientFk INT, IN vSerial CHAR(2), IN vMaxShipped DATE, diff --git a/db/routines/vn/procedures/invoiceOut_newFromTicket.sql b/db/routines/vn/procedures/invoiceOut_newFromTicket.sql index 3ee7cd678..41919f6ea 100644 --- a/db/routines/vn/procedures/invoiceOut_newFromTicket.sql +++ b/db/routines/vn/procedures/invoiceOut_newFromTicket.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOut_newFromTicket`(IN vTicketFk int, IN vSerial char(2), IN vTaxArea varchar(25), +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceOut_newFromTicket`(IN vTicketFk int, IN vSerial char(2), IN vTaxArea varchar(25), IN vRef varchar(25), OUT vInvoiceId int) BEGIN /** diff --git a/db/routines/vn/procedures/invoiceTaxMake.sql b/db/routines/vn/procedures/invoiceTaxMake.sql index 30296dc26..5b1ba6a95 100644 --- a/db/routines/vn/procedures/invoiceTaxMake.sql +++ b/db/routines/vn/procedures/invoiceTaxMake.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceTaxMake`(vInvoice INT, vTaxArea VARCHAR(25)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceTaxMake`(vInvoice INT, vTaxArea VARCHAR(25)) BEGIN /** * Factura un conjunto de tickets. diff --git a/db/routines/vn/procedures/itemBarcode_update.sql b/db/routines/vn/procedures/itemBarcode_update.sql index e2f13dc93..6341d8091 100644 --- a/db/routines/vn/procedures/itemBarcode_update.sql +++ b/db/routines/vn/procedures/itemBarcode_update.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemBarcode_update`(vItemFk INT,vCode VARCHAR(22), vDelete BOOL) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemBarcode_update`(vItemFk INT,vCode VARCHAR(22), vDelete BOOL) BEGIN IF vDelete THEN DELETE FROM vn.itemBarcode WHERE itemFk = vItemFk AND code = vCode; diff --git a/db/routines/vn/procedures/itemFuentesBalance.sql b/db/routines/vn/procedures/itemFuentesBalance.sql deleted file mode 100644 index e60273340..000000000 --- a/db/routines/vn/procedures/itemFuentesBalance.sql +++ /dev/null @@ -1,79 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemFuentesBalance`(vDaysInFuture INT) -BEGIN - - /* Se utiliza para calcular la necesidad de mover mercancia entre el almacén de fuentes y el nuestro - * - * @param vDaysInFuture Rango de dias para calcular entradas y salidas - * - */ - - DECLARE vWarehouseFk INT; - - SELECT s.warehouseFk INTO vWarehouseFk - FROM vn.sector s - WHERE s.code = 'FUENTES_PICASSE'; - - CALL cache.stock_refresh(FALSE); - - SELECT i.id itemFk, - i.longName, - i.size, - i.subName, - v.amount - IFNULL(fue.Fuentes,0) - IFNULL(alb.albenfruit,0) as visible, - fue.Fuentes, - alb.Albenfruit, - sale.venta, - IFNULL(buy.compra,0) + IFNULL(mov.traslado,0) as compra, - IFNULL(v.amount,0) + IFNULL(sale.venta,0) + IFNULL(buy.compra,0) + IFNULL(mov.traslado,0) - - IFNULL(fue.Fuentes,0) - IFNULL(alb.albenfruit,0) as saldo - FROM vn.item i - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN ( - SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS Fuentes - FROM vn.itemShelving ish - JOIN vn.shelving sh ON sh.code = ish.shelvingFk - JOIN vn.parking p ON p.id = sh.parkingFk - JOIN vn.sector s ON s.id = p.sectorFk - WHERE s.code = 'FUENTES_PICASSE' - GROUP BY ish.itemFk - ) fue ON fue.itemFk = i.id - LEFT JOIN ( - SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS Albenfruit - FROM vn.itemShelving ish - JOIN vn.shelving sh ON sh.code = ish.shelvingFk - JOIN vn.parking p ON p.id = sh.parkingFk - JOIN vn.sector s ON s.id = p.sectorFk - WHERE s.code = 'ALBENFRUIT' - GROUP BY ish.itemFk - ) alb ON alb.itemFk = i.id - LEFT JOIN cache.stock v ON i.id = v.item_id AND v.warehouse_id = vWarehouseFk - LEFT JOIN ( - SELECT itemFk item_id, CAST(sum(quantity)AS DECIMAL(10,0)) as venta - FROM itemTicketOut - WHERE shipped BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE())) - AND warehouseFk = vWarehouseFk - GROUP BY itemFk - ) sale ON sale.item_id = i.id - LEFT JOIN ( - SELECT itemFk item_id, CAST(sum(quantity)AS DECIMAL(10,0)) as compra - FROM itemEntryIn - WHERE landed BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE())) - AND warehouseInFk = vWarehouseFk - AND isVirtualStock = FALSE - GROUP BY itemFk - ) buy ON buy.item_id = i.id - LEFT JOIN ( - SELECT itemFk item_id, CAST(sum(quantity)AS DECIMAL(10,0)) as traslado - FROM itemEntryOut - WHERE shipped BETWEEN util.VN_CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(util.VN_CURDATE())) - AND warehouseOutFk = vWarehouseFk - GROUP BY itemFk - ) mov ON mov.item_id = i.id - WHERE (v.amount OR fue.Fuentes OR alb.Albenfruit) - AND i.itemPackingTypeFk = 'H' - AND ic.shortLife; - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/itemMinimumQuantity_check.sql b/db/routines/vn/procedures/itemMinimumQuantity_check.sql new file mode 100644 index 000000000..a4b15b90a --- /dev/null +++ b/db/routines/vn/procedures/itemMinimumQuantity_check.sql @@ -0,0 +1,28 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemMinimumQuantity_check`( + vSelf INT, + vItemFk INT, + vStarted DATE, + vEnded DATE, + vWarehouseFk INT +) +BEGIN + DECLARE vHasCollision BOOL; + + IF vStarted IS NULL THEN + CALL util.throw('The field "started" cannot be null'); + END IF; + + SELECT COUNT(*) INTO vHasCollision + FROM itemMinimumQuantity + WHERE vItemFk = itemFk + AND ((vStarted <= ended OR ended IS NULL) + AND (vStarted >= `started` OR vEnded IS NULL)) + AND (vWarehouseFk <=> warehouseFk) + AND vSelf <> id; + + IF vHasCollision THEN + CALL util.throw('A line with the same configuration already exists'); + END IF; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemPlacementFromTicket.sql b/db/routines/vn/procedures/itemPlacementFromTicket.sql index 1a1a735e5..922bde5d4 100644 --- a/db/routines/vn/procedures/itemPlacementFromTicket.sql +++ b/db/routines/vn/procedures/itemPlacementFromTicket.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemPlacementFromTicket`(vTicket INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementFromTicket`(vTicket INT) BEGIN /** * Llama a itemPlacementUpdateVisible diff --git a/db/routines/vn/procedures/itemPlacementSupplyAiming.sql b/db/routines/vn/procedures/itemPlacementSupplyAiming.sql index ee9125a7b..b96860623 100644 --- a/db/routines/vn/procedures/itemPlacementSupplyAiming.sql +++ b/db/routines/vn/procedures/itemPlacementSupplyAiming.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyAiming`(vShelvingFk VARCHAR(10), quantity INT, vItemFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyAiming`(vShelvingFk VARCHAR(10), quantity INT, vItemFk INT) BEGIN SELECT ish.itemFk, diff --git a/db/routines/vn/procedures/itemPlacementSupplyCloseOrder.sql b/db/routines/vn/procedures/itemPlacementSupplyCloseOrder.sql index 9c4457a5e..935d062a1 100644 --- a/db/routines/vn/procedures/itemPlacementSupplyCloseOrder.sql +++ b/db/routines/vn/procedures/itemPlacementSupplyCloseOrder.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyCloseOrder`(vId INT, vQuantity INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyCloseOrder`(vId INT, vQuantity INT) BEGIN UPDATE vn.itemPlacementSupply diff --git a/db/routines/vn/procedures/itemPlacementSupplyGetOrder.sql b/db/routines/vn/procedures/itemPlacementSupplyGetOrder.sql index b23f69fe7..958dc7e78 100644 --- a/db/routines/vn/procedures/itemPlacementSupplyGetOrder.sql +++ b/db/routines/vn/procedures/itemPlacementSupplyGetOrder.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyGetOrder`(vSector INT ) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyGetOrder`(vSector INT ) BEGIN DECLARE vId INT; diff --git a/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql b/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql index 86d62cad4..cefa64d13 100644 --- a/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql +++ b/db/routines/vn/procedures/itemPlacementSupplyStockGetTargetList.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyStockGetTargetList`(vItemFk INT,vSectorFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyStockGetTargetList`(vItemFk INT,vSectorFk INT) BEGIN /** * Devuelve la lista de ubicaciones para itemFk en ese sector. Se utiliza en la preparación previa. diff --git a/db/routines/vn/procedures/itemRefreshTags.sql b/db/routines/vn/procedures/itemRefreshTags.sql index 21af20c0f..cec133ad1 100644 --- a/db/routines/vn/procedures/itemRefreshTags.sql +++ b/db/routines/vn/procedures/itemRefreshTags.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemRefreshTags`(IN vItem INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemRefreshTags`(IN vItem INT) BEGIN /** * Crea la tabla temporal necesaria para el procedimiento item_refreshTags diff --git a/db/routines/vn/procedures/itemSale_byWeek.sql b/db/routines/vn/procedures/itemSale_byWeek.sql index bc43b7b16..31235f89a 100644 --- a/db/routines/vn/procedures/itemSale_byWeek.sql +++ b/db/routines/vn/procedures/itemSale_byWeek.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemSale_byWeek`(vWeek INT, IN vYear INT, vItemFk INT, vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemSale_byWeek`(vWeek INT, IN vYear INT, vItemFk INT, vWarehouseFk INT) BEGIN DECLARE vStarted DATE; diff --git a/db/routines/vn/procedures/itemSaveMin.sql b/db/routines/vn/procedures/itemSaveMin.sql index 510638348..fb7c7d2f8 100644 --- a/db/routines/vn/procedures/itemSaveMin.sql +++ b/db/routines/vn/procedures/itemSaveMin.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemSaveMin`(min INT,vBarcode VARCHAR(22)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemSaveMin`(min INT,vBarcode VARCHAR(22)) BEGIN DECLARE vItemFk INT; diff --git a/db/routines/vn/procedures/itemSearchShelving.sql b/db/routines/vn/procedures/itemSearchShelving.sql index 8c2c6c7c8..1fef9b2f6 100644 --- a/db/routines/vn/procedures/itemSearchShelving.sql +++ b/db/routines/vn/procedures/itemSearchShelving.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemSearchShelving`(`vShelvingFk` VARCHAR(3)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemSearchShelving`(`vShelvingFk` VARCHAR(3)) BEGIN SELECT p.`column` AS col , p.`row` FROM vn.shelving s diff --git a/db/routines/vn/procedures/itemShelvingDelete.sql b/db/routines/vn/procedures/itemShelvingDelete.sql index f895782d3..a8799af11 100644 --- a/db/routines/vn/procedures/itemShelvingDelete.sql +++ b/db/routines/vn/procedures/itemShelvingDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingDelete`(vId INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingDelete`(vId INT) BEGIN DELETE FROM vn.itemShelving WHERE id = vId; diff --git a/db/routines/vn/procedures/itemShelvingLog_get.sql b/db/routines/vn/procedures/itemShelvingLog_get.sql index ad67ea5cd..52e7a273f 100644 --- a/db/routines/vn/procedures/itemShelvingLog_get.sql +++ b/db/routines/vn/procedures/itemShelvingLog_get.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingLog_get`(vShelvingFk VARCHAR(10) ) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingLog_get`(vShelvingFk VARCHAR(10) ) BEGIN /** diff --git a/db/routines/vn/procedures/itemShelvingMakeFromDate.sql b/db/routines/vn/procedures/itemShelvingMakeFromDate.sql deleted file mode 100644 index 2dde68829..000000000 --- a/db/routines/vn/procedures/itemShelvingMakeFromDate.sql +++ /dev/null @@ -1,58 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingMakeFromDate`(IN `vShelvingFk` VARCHAR(8), IN `vBarcode` VARCHAR(22), IN `vQuantity` INT, IN `vPackagingFk` VARCHAR(10), IN `vGrouping` INT, IN `vPacking` INT, IN `vWarehouseFk` INT, `vCreated` VARCHAR(22)) -BEGIN - - DECLARE vItemFk INT; - - SELECT vn.barcodeToItem(vBarcode) INTO vItemFk; - - SELECT itemFk INTO vItemFk - FROM vn.buy b - WHERE b.id = vItemFk; - - IF (SELECT COUNT(*) FROM vn.shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN - - INSERT IGNORE INTO vn.parking(`code`) VALUES(vShelvingFk); - INSERT INTO vn.shelving(`code`, parkingFk) - SELECT vShelvingFk, id - FROM vn.parking - WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci; - - END IF; - - IF (SELECT COUNT(*) FROM vn.itemShelving - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk - AND itemFk = vItemFk - AND packing = vPacking) = 1 THEN - - UPDATE vn.itemShelving - SET visible = visible+vQuantity, - created = vCreated - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk - AND itemFk = vItemFk - AND packing = vPacking; - - ELSE - CALL cache.last_buy_refresh(FALSE); - INSERT INTO itemShelving( itemFk, - shelvingFk, - visible, - created, - `grouping`, - packing, - packagingFk) - SELECT vItemFk, - vShelvingFk, - vQuantity, - vCreated, - IF(vGrouping = 0, IFNULL(b.packing, vPacking), vGrouping) `grouping`, - IF(vPacking = 0, b.packing, vPacking) packing, - IF(vPackagingFk = '', b.packagingFk, vPackagingFk) packaging - FROM vn.item i - LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk - LEFT JOIN vn.buy b ON b.id = lb.buy_id - WHERE i.id = vItemFk; - END IF; - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelvingMatch.sql b/db/routines/vn/procedures/itemShelvingMatch.sql index 9a10c2b87..850c7907b 100644 --- a/db/routines/vn/procedures/itemShelvingMatch.sql +++ b/db/routines/vn/procedures/itemShelvingMatch.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingMatch`(vEntryFk INT, vAllTravel BOOLEAN, vFromTimed DATETIME, vToTimed DATETIME) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingMatch`(vEntryFk INT, vAllTravel BOOLEAN, vFromTimed DATETIME, vToTimed DATETIME) BEGIN DECLARE vTravelFk INT; diff --git a/db/routines/vn/procedures/itemShelvingPlacementSupplyAdd.sql b/db/routines/vn/procedures/itemShelvingPlacementSupplyAdd.sql deleted file mode 100644 index c3fc59624..000000000 --- a/db/routines/vn/procedures/itemShelvingPlacementSupplyAdd.sql +++ /dev/null @@ -1,20 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingPlacementSupplyAdd`(vItemShelvingFk INT, vItemPlacementSupplyFk INT, vQuantity INT) -BEGIN - - INSERT INTO vn.itemShelvingPlacementSupply( itemShelvingFk, - itemPlacementSupplyFk, - quantity, - userFk) - VALUES (vItemShelvingFk, - vItemPlacementSupplyFk, - vQuantity, - getUser()); - - UPDATE vn.itemShelving - SET visible = visible - vQuantity - WHERE id = vItemShelvingFk; - - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelvingProblem.sql b/db/routines/vn/procedures/itemShelvingProblem.sql index aed7572ee..06c7a376c 100644 --- a/db/routines/vn/procedures/itemShelvingProblem.sql +++ b/db/routines/vn/procedures/itemShelvingProblem.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingProblem`(vSectorFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingProblem`(vSectorFk INT) BEGIN DECLARE vVisibleCache INT; @@ -38,7 +38,7 @@ BEGIN AND IFNULL(sub3.transit,0) < s.quantity AND s.isPicked = FALSE AND s.reserved = FALSE - AND t.shipped BETWEEN util.VN_CURDATE() AND MIDNIGHT(util.VN_CURDATE()) + AND t.shipped BETWEEN util.VN_CURDATE() AND util.midnight() AND tst.isPreviousPreparable = TRUE AND t.warehouseFk = vWarehouseFk AND iss.sectorFk = vSectorFk diff --git a/db/routines/vn/procedures/itemShelvingRadar.sql b/db/routines/vn/procedures/itemShelvingRadar.sql index 7875c4791..4bdd0873e 100644 --- a/db/routines/vn/procedures/itemShelvingRadar.sql +++ b/db/routines/vn/procedures/itemShelvingRadar.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingRadar`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingRadar`( vSectorFk INT ) BEGIN @@ -49,7 +49,7 @@ BEGIN ish.isChecked, sub.isAllChecked FROM itemShelvingStock iss - JOIN itemShelving ish ON ish.shelvingFk = iss.shelvingFk + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk LEFT JOIN ( SELECT itemFk, IF( diff --git a/db/routines/vn/procedures/itemShelvingRadar_Entry.sql b/db/routines/vn/procedures/itemShelvingRadar_Entry.sql index c0b4fcda2..637b8f77f 100644 --- a/db/routines/vn/procedures/itemShelvingRadar_Entry.sql +++ b/db/routines/vn/procedures/itemShelvingRadar_Entry.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingRadar_Entry`(vEntryFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingRadar_Entry`(vEntryFk INT) BEGIN DECLARE vWarehouseFk INT DEFAULT 1; diff --git a/db/routines/vn/procedures/itemShelvingRadar_Entry_State_beta.sql b/db/routines/vn/procedures/itemShelvingRadar_Entry_State_beta.sql index c8b5d4bb4..3a8a3d297 100644 --- a/db/routines/vn/procedures/itemShelvingRadar_Entry_State_beta.sql +++ b/db/routines/vn/procedures/itemShelvingRadar_Entry_State_beta.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingRadar_Entry_State_beta`(vEntryFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingRadar_Entry_State_beta`(vEntryFk INT) BEGIN DECLARE vWarehouseFk INT DEFAULT 1; diff --git a/db/routines/vn/procedures/itemShelvingSale_Add.sql b/db/routines/vn/procedures/itemShelvingSale_Add.sql index 80eb4efca..c00f25150 100644 --- a/db/routines/vn/procedures/itemShelvingSale_Add.sql +++ b/db/routines/vn/procedures/itemShelvingSale_Add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_Add`(vItemShelvingFk INT, vSaleFk INT, vQuantity INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_Add`(vItemShelvingFk INT, vSaleFk INT, vQuantity INT) BEGIN /** * Añade línea a itemShelvingSale y regulariza el carro @@ -18,7 +18,8 @@ BEGIN getUser()); UPDATE itemShelving - SET visible = visible - vQuantity + SET visible = visible - vQuantity, + available = available - vQuantity WHERE id = vItemShelvingFk; UPDATE vn.saleTracking diff --git a/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql b/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql new file mode 100644 index 000000000..bb915b99a --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql @@ -0,0 +1,51 @@ + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addByCollection`( + vCollectionFk INT(11) +) +BEGIN +/** + * Reserva cantidades con ubicaciones para el contenido de una colección + * + * @param vCollectionFk Identificador de collection + */ + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vSaleFk INT; + DECLARE vSales CURSOR FOR + WITH sales AS ( + SELECT s.id saleFk, s.quantity, SUM(IFNULL(iss.quantity, 0)) quantityReserved + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id + WHERE tc.collectionFk = vCollectionFk + GROUP BY s.id + HAVING quantity <> quantityReserved + ), trackedSales AS ( + SELECT sa.saleFk + FROM sales sa + JOIN vn.saleTracking st ON st.saleFk = sa.saleFk + JOIN vn.`state` s ON s.id = st.stateFk + WHERE st.isChecked + AND s.`code` IN ('PREVIOUS_PREPARATION', 'OK PREVIOUS', 'OK STOWAWAY') + GROUP BY sa.saleFk + ) SELECT s.saleFk + FROM sales s + LEFT JOIN trackedSales ts ON ts.saleFk = s.saleFk + WHERE ts.saleFk IS NULL; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vSales; + l: LOOP + SET vDone = FALSE; + FETCH vSales INTO vSaleFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL itemShelvingSale_addBySale(vSaleFk, NULL); + END LOOP; + CLOSE vSales; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql new file mode 100644 index 000000000..6625e89b8 --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql @@ -0,0 +1,128 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addBySale`( + vSaleFk INT, + vSectorFk INT +) +proc: BEGIN +/** + * Reserva una línea de venta en la ubicación más óptima + * + * @param vSaleFk Id de sale + * @param vItemShelvingSaleFk Id de reserva + * @param vSectorFk Id del sector del operator + */ + DECLARE vLastPickingOrder INT; + DECLARE vDone INT DEFAULT FALSE; + DECLARE vItemShelvingFk INT; + DECLARE vAvailable INT; + DECLARE vReservedQuantity INT; + DECLARE vOutStanding INT; + DECLARE vUserFk INT; + DECLARE vTotalReservedQuantity INT; + DECLARE vSaleQuantity INT; + + DECLARE vItemShelvingAvailable CURSOR FOR + SELECT ish.id itemShelvingFk, + ish.available + FROM sale s + JOIN itemShelving ish ON ish.itemFk = s.itemFk + JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN parking p ON p.id = sh.parkingFk + JOIN sector sc ON sc.id = p.sectorFk + JOIN productionConfig pc + WHERE s.id = vSaleFk + AND NOT sc.isHideForPickers + AND (sc.id = vSectorFk OR vSectorFk IS NULL) + ORDER BY s.id, + p.pickingOrder >= vLastPickingOrder, + sh.priority DESC, + ish.available >= s.quantity DESC, + s.quantity MOD ish.grouping = 0 DESC, + ish.grouping DESC, + IF(pc.orderMode = 'Location', p.pickingOrder, ish.created); + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + SELECT id INTO vSaleFk + FROM sale + WHERE id = vSaleFk + FOR UPDATE; + + SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)), s.quantity + INTO vLastPickingOrder, vOutStanding, vSaleQuantity + FROM sale s + LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id + LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + LEFT JOIN shelving sh ON sh.code = ish.shelvingFk + LEFT JOIN parking p ON p.id = sh.parkingFk + WHERE s.id = vSaleFk; + + IF vOutStanding <= 0 THEN + COMMIT; + LEAVE proc; + END IF; + + SELECT getUser() INTO vUserFk; + + OPEN vItemShelvingAvailable; + l: LOOP + SET vDone = FALSE; + FETCH vItemShelvingAvailable INTO vItemShelvingFk, vAvailable; + + IF vOutStanding <= 0 OR vDone THEN + SELECT SUM(IFNULL(quantity, 0)) + INTO vTotalReservedQuantity + FROM itemShelvingSale + WHERE saleFk = vSaleFk; + + IF vTotalReservedQuantity <> vSaleQuantity THEN + CALL util.debugAdd('itemShelvingSale_addBySale', + CONCAT(vSaleFk, ' - ', vSaleQuantity,' - ', vTotalReservedQuantity,'-', vOutStanding,'-', account.myUser_getId())); + + UPDATE sale + SET quantity = vTotalReservedQuantity + WHERE id = vSaleFk; + END IF; + LEAVE l; + END IF; + + SELECT id INTO vItemShelvingFk + FROM itemShelving + WHERE id = vItemShelvingFk + FOR UPDATE; + + SELECT LEAST(vOutStanding, vAvailable) INTO vReservedQuantity; + SET vOutStanding = vOutStanding - vReservedQuantity; + + IF vReservedQuantity > 0 THEN + CALL util.debugAdd('itemShelvingSale_addBySale_reservedQuantity', + CONCAT(vSaleFk, ' - ', vReservedQuantity, ' - ', vOutStanding, account.myUser_getId())); + INSERT INTO itemShelvingSale( + itemShelvingFk, + saleFk, + quantity, + userFk, + isPicked) + SELECT vItemShelvingFk, + vSaleFk, + vReservedQuantity, + vUserFk, + FALSE; + + UPDATE itemShelving + SET available = available - vReservedQuantity + WHERE id = vItemShelvingFk; + + END IF; + END LOOP; + CLOSE vItemShelvingAvailable; + COMMIT; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySaleGroup.sql b/db/routines/vn/procedures/itemShelvingSale_addBySaleGroup.sql new file mode 100644 index 000000000..08d09c63e --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_addBySaleGroup.sql @@ -0,0 +1,46 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addBySaleGroup`( + vSaleGroupFk INT(11) +) +BEGIN +/** + * Reserva cantidades con ubicaciones para el contenido de una preparación previa + * a través del saleGroup + * + * @param vSaleGroupFk Identificador de saleGroup + */ + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vSaleFk INT; + DECLARE vSectorFk INT; + DECLARE vSales CURSOR FOR + SELECT s.id + FROM saleGroupDetail sgd + JOIN sale s ON sgd.saleFk = s.id + JOIN saleTracking str ON str.saleFk = s.id + JOIN `state` st ON st.id = str.stateFk + AND st.code = 'PREVIOUS_PREPARATION' + LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id + WHERE sgd.saleGroupFk = vSaleGroupFk + AND str.workerFk = account.myUser_getId() + AND iss.id IS NULL; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + SELECT sectorFk INTO vSectorFk + FROM operator + WHERE workerFk = account.myUser_getId(); + + OPEN vSales; + l: LOOP + SET vDone = FALSE; + FETCH vSales INTO vSaleFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk); + END LOOP; + CLOSE vSales; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql b/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql new file mode 100644 index 000000000..24bb94b7e --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql @@ -0,0 +1,48 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE + `vn`.`itemShelvingSale_addBySectorCollection`(vSectorCollectionFk INT(11)) +BEGIN +/** + * Reserva cantidades con ubicaciones para el contenido de una preparación previa + * de la cual ya tiene generada la asociación del saleGroup con sectorCollection + * + * @param vSectorCollectionFk Identificador de sectorCollection + */ + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vSaleFk INT; + DECLARE vSectorFk INT; + DECLARE vSales CURSOR FOR + SELECT DISTINCT s.id + FROM sectorCollectionSaleGroup sc + JOIN saleGroupDetail sg ON sg.saleGroupFk = sc.saleGroupFk + JOIN sale s ON sg.saleFk = s.id + JOIN saleTracking str ON str.saleFk = s.id + JOIN `state` st ON st.id = str.stateFk + AND st.code = 'PREVIOUS_PREPARATION' + LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id + WHERE sc.sectorCollectionFk = vSectorCollectionFk + AND str.workerFk = account.myUser_getId() + AND iss.id IS NULL; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + SELECT sectorFk INTO vSectorFk + FROM operator + WHERE workerFk = account.myUser_getId(); + + CALL util.debugAdd('itemShelvingSale_addBySectorCollection',CONCAT(vSectorCollectionFk,' - ', account.myUser_getId())); + + OPEN vSales; + l: LOOP + SET vDone = FALSE; + FETCH vSales INTO vSaleFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk); + END LOOP; + CLOSE vSales; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingSale_deleteAdded.sql b/db/routines/vn/procedures/itemShelvingSale_deleteAdded.sql new file mode 100644 index 000000000..9b15e82d1 --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_deleteAdded.sql @@ -0,0 +1,49 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_deleteAdded`( + vSelf INT(11) +) +proc: BEGIN +/** + * Borra una reservea devolviendo la cantidad al itemShelving + * + * @param vSelf Identificador del itemShelvingSale + */ + DECLARE vSaleFk INT; + DECLARE vHasSalesPicked BOOL; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + SELECT iss.saleFk INTO vSaleFk + FROM itemShelvingSale iss + JOIN sale s ON s.id = iss.saleFk + WHERE iss.id = vSelf AND s.isAdded + FOR UPDATE; + + IF vSaleFk IS NULL THEN + CALL util.throw('The sale can not be deleted'); + END IF; + + SELECT COUNT(*) INTO vHasSalesPicked + FROM itemShelvingSale + WHERE saleFk = vSaleFk AND isPicked; + + IF vHasSalesPicked THEN + CALL util.throw('A sale with picked sales cannot be deleted'); + END IF; + + UPDATE itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + SET ish.available = ish.available + iss.quantity + WHERE iss.saleFk = vSaleFk; + + DELETE FROM sale WHERE id = vSaleFk; + + COMMIT; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingSale_doReserve.sql b/db/routines/vn/procedures/itemShelvingSale_doReserve.sql new file mode 100644 index 000000000..bbb060934 --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_doReserve.sql @@ -0,0 +1,54 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_doReserve`() +proc: BEGIN +/** + * Genera reservas de la tabla vn.itemShelvingSaleReserve + */ + DECLARE vDone BOOL; + DECLARE vSaleFk INT; + DECLARE vSectorFk INT; + + DECLARE vSales CURSOR FOR + SELECT DISTINCT saleFk, sectorFk FROM tSale; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION + BEGIN + DO RELEASE_LOCK('vn.itemShelvingSale_doReserve'); + ROLLBACK; + RESIGNAL; + END; + + IF !GET_LOCK('vn.itemShelvingSale_doReserve', 0) THEN + LEAVE proc; + END IF; + + CREATE OR REPLACE TEMPORARY TABLE tSale + ENGINE = MEMORY + SELECT id, saleFk, sectorFk FROM itemShelvingSaleReserve; + + OPEN vSales; + + myLoop: LOOP + SET vDone = FALSE; + FETCH vSales INTO vSaleFk, vSectorFk; + + IF vDone THEN + LEAVE myLoop; + END IF; + + CALL itemShelvingSale_addBySale (vSaleFk, vSectorFk); + END LOOP; + + CLOSE vSales; + + DELETE iss FROM itemShelvingSaleReserve iss + JOIN tSale s ON s.id = iss.id AND s.sectorFk = iss.sectorFk; + + DROP TEMPORARY TABLE tSale; + + DO RELEASE_LOCK('vn.itemShelvingSale_doReserve'); +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingSale_reallocate.sql b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql new file mode 100644 index 000000000..3302b908c --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql @@ -0,0 +1,55 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reallocate`( + vItemShelvingFk INT(10), + vItemFk INT(10), + vSectorFk INT +) +BEGIN +/** + * Elimina reservas de un itemShelving e intenta reservar en otra ubicación + * + * @param vItemShelvingFk Id itemShelving + * @param vItemFk Id del artículo + * @param vSectorFk Id del sector + */ + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + UPDATE itemShelving + SET visible = 0, + available = 0 + WHERE id = vItemShelvingFk + AND itemFk = vItemFk; + + SELECT iss.id + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND ish.itemFk = vItemFk + AND NOT iss.isPicked + FOR UPDATE; + + INSERT INTO itemShelvingSaleReserve (saleFk, sectorFk) + SELECT DISTINCT iss.saleFk, vSectorFk + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND ish.itemFk = vItemFk + AND NOT iss.isPicked; + + DELETE iss + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND ish.itemFk = vItemFk + AND NOT iss.isPicked; + COMMIT; + + CALL itemShelvingSale_doReserve(); +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingSale_reserve.sql b/db/routines/vn/procedures/itemShelvingSale_reserve.sql deleted file mode 100644 index afe65bd78..000000000 --- a/db/routines/vn/procedures/itemShelvingSale_reserve.sql +++ /dev/null @@ -1,92 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reserve`() -BEGIN -/** - * Reserva cantidades con ubicaciones para un conjunto de sales del mismo - * almacen. - * - * @table tmp.sale(saleFk, userFk) - */ - DECLARE vCalcFk INT; - DECLARE vWarehouseFk INT; - DECLARE vCurrentYear INT DEFAULT YEAR(util.VN_NOW()); - DECLARE vLastPickingOrder INT; - - SELECT t.warehouseFk, MAX(p.pickingOrder) - INTO vWarehouseFk, vLastPickingOrder - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN tmp.sale ts ON ts.saleFk = s.id - LEFT JOIN itemShelvingSale iss ON iss.saleFk = ts.saleFk - LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - LEFT JOIN shelving sh ON sh.code = ish.shelvingFk - LEFT JOIN parking p ON p.id = sh.parkingFk - WHERE t.warehouseFk IS NOT NULL; - - IF vWarehouseFk IS NULL THEN - CALL util.throw('Warehouse not set'); - END IF; - - CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk); - - SET @outstanding = 0; - SET @oldsaleFk = 0; - - CREATE OR REPLACE TEMPORARY TABLE tSalePlacementQuantity - (INDEX(saleFk)) - ENGINE = MEMORY - SELECT saleFk, userFk, quantityToReserve, itemShelvingFk - FROM( SELECT saleFk, - sub.userFk, - itemShelvingFk , - IF(saleFk <> @oldsaleFk, @outstanding := quantity, @outstanding), - @qtr := LEAST(@outstanding, available) quantityToReserve, - @outStanding := @outStanding - @qtr, - @oldsaleFk := saleFk - FROM( - SELECT ts.saleFk, - ts.userFk, - s.quantity, - ish.id itemShelvingFk, - ish.visible - IFNULL(ishr.reservedQuantity, 0) available - FROM tmp.sale ts - JOIN sale s ON s.id = ts.saleFk - JOIN itemShelving ish ON ish.itemFk = s.itemFk - LEFT JOIN ( - SELECT itemShelvingFk, SUM(quantity) reservedQuantity - FROM itemShelvingSale - WHERE NOT isPicked - GROUP BY itemShelvingFk) ishr ON ishr.itemShelvingFk = ish.id - JOIN shelving sh ON sh.code = ish.shelvingFk - JOIN parking p ON p.id = sh.parkingFk - JOIN sector sc ON sc.id = p.sectorFk - JOIN warehouse w ON w.id = sc.warehouseFk - JOIN productionConfig pc - WHERE w.id = vWarehouseFk - AND NOT sc.isHideForPickers - ORDER BY - s.id, - p.pickingOrder >= vLastPickingOrder, - sh.priority DESC, - ish.visible >= s.quantity DESC, - s.quantity MOD ish.grouping = 0 DESC, - ish.grouping DESC, - IF(pc.orderMode = 'Location', p.pickingOrder, ish.created) - )sub - )sub2 - WHERE quantityToReserve > 0; - - INSERT INTO itemShelvingSale( - itemShelvingFk, - saleFk, - quantity, - userFk) - SELECT itemShelvingFk, - saleFk, - quantityToReserve, - IFNULL(userFk, getUser()) - FROM tSalePlacementQuantity spl; - - DROP TEMPORARY TABLE tmp.sale; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelvingSale_reserveByCollection.sql b/db/routines/vn/procedures/itemShelvingSale_reserveByCollection.sql deleted file mode 100644 index 9a97130dd..000000000 --- a/db/routines/vn/procedures/itemShelvingSale_reserveByCollection.sql +++ /dev/null @@ -1,29 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reserveByCollection`( - vCollectionFk INT(11) -) -BEGIN -/** - * Reserva cantidades con ubicaciones para el contenido de una colección - * - * @param vCollectionFk Identificador de collection - */ - CREATE OR REPLACE TEMPORARY TABLE tmp.sale - (INDEX(saleFk)) - ENGINE = MEMORY - SELECT s.id saleFk, NULL userFk - FROM ticketCollection tc - JOIN sale s ON s.ticketFk = tc.ticketFk - LEFT JOIN ( - SELECT DISTINCT saleFk - FROM saleTracking st - JOIN state s ON s.id = st.stateFk - WHERE st.isChecked - AND s.semaphore = 1)st ON st.saleFk = s.id - WHERE tc.collectionFk = vCollectionFk - AND st.saleFk IS NULL - AND NOT s.isPicked; - - CALL itemShelvingSale_reserve(); -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelvingSale_reserveBySale.sql b/db/routines/vn/procedures/itemShelvingSale_reserveBySale.sql deleted file mode 100644 index fb245062e..000000000 --- a/db/routines/vn/procedures/itemShelvingSale_reserveBySale.sql +++ /dev/null @@ -1,21 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reserveBySale`( - vSelf INT , - vQuantity INT, - vUserFk INT -) -BEGIN -/** - * Reserva cantida y ubicación para una saleFk - * - * @param vSelf Identificador de la venta - * @param vQuantity Cantidad a reservar - * @param vUserFk Id de usuario que realiza la reserva - */ - CREATE OR REPLACE TEMPORARY TABLE tmp.sale - ENGINE = MEMORY - SELECT vSelf saleFk, vUserFk userFk; - - CALL itemShelvingSale_reserve(); -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelvingSale_setPicked.sql b/db/routines/vn/procedures/itemShelvingSale_setPicked.sql new file mode 100644 index 000000000..993ff96f0 --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_setPicked.sql @@ -0,0 +1,34 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setPicked`( + vSaleGroupFk INT(10) +) +BEGIN +/** + * Gestiona la reserva de un vn.saleGroup actualizando vn.itemShelvingSale.isPicked + * y cambiando el estado de la vn.sale + * + * @param vSaleGroupFk Id saleGroupFk + */ + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + IF NOT (SELECT COUNT(*) FROM saleGroup WHERE id = vSaleGroupFk) THEN + CALL util.throw('Sale group not exists'); + END IF; + + START TRANSACTION; + + UPDATE itemShelvingSale iss + JOIN sale s ON s.id = iss.saleFk + JOIN saleGroupDetail sg ON sg.saleFk = s.id + SET iss.isPicked = TRUE + WHERE sg.saleGroupFk = vSaleGroupFk; + + CALL saleTracking_addPreparedSaleGroup(vSaleGroupFk); + + COMMIT; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql index b792534fb..cde1b6872 100644 --- a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql +++ b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql @@ -1,118 +1,111 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setQuantity`( - vItemShelvingSaleFk INT(10), - vQuantity DECIMAL(10,0), - vIsItemShelvingSaleEmpty BOOLEAN -) -BEGIN -/** - * Gestiona la reserva de un itemShelvingFk, actualizando isPicked y quantity - * en vn.itemShelvingSale y vn.sale.isPicked en caso necesario. - * Si la reserva de la ubicación es fallida, se regulariza la situación - * - * @param vItemShelvingSaleFk Id itemShelvingSaleFK - * @param vQuantity Cantidad real que se ha cogido de la ubicación - * @param vIsItemShelvingSaleEmpty determina si ka ubicación itemShelvingSale se ha - * quedado vacio tras el movimiento - */ - DECLARE vSaleFk INT; - DECLARE vCursorSaleFk INT; - DECLARE vItemShelvingFk INT; - DECLARE vReservedQuantity INT; - DECLARE vRemainingQuantity INT; - DECLARE vItemFk INT; - DECLARE vUserFk INT; - DECLARE vDone BOOLEAN DEFAULT FALSE; - DECLARE vSales CURSOR FOR - SELECT iss.saleFk, iss.userFk - FROM itemShelvingSale iss - JOIN sale s ON s.id = iss.saleFk - WHERE iss.id = vItemShelvingSaleFk - AND s.itemFk = vItemFk - AND NOT iss.isPicked; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - IF (SELECT isPicked FROM itemShelvingSale WHERE id = vItemShelvingSaleFk) THEN - CALL util.throw('Booking completed'); - END IF; - - SELECT s.itemFk, iss.saleFk, iss.itemShelvingFk - INTO vItemFk, vSaleFk, vItemShelvingFk - FROM itemShelvingSale iss - JOIN sale s ON s.id = iss.saleFk - WHERE iss.id = vItemShelvingSaleFk - AND NOT iss.isPicked; - - UPDATE itemShelvingSale - SET isPicked = TRUE, - quantity = vQuantity - WHERE id = vItemShelvingSaleFk; - - UPDATE itemShelving - SET visible = IF(vIsItemShelvingSaleEmpty, 0, GREATEST(0,visible - vQuantity)) - WHERE id = vItemShelvingFk; - - IF vIsItemShelvingSaleEmpty THEN - OPEN vSales; -l: LOOP - SET vDone = FALSE; - FETCH vSales INTO vCursorSaleFk, vUserFk; - IF vDone THEN - LEAVE l; - END IF; - - CREATE OR REPLACE TEMPORARY TABLE tmp.sale - (INDEX(saleFk, userFk)) - ENGINE = MEMORY - SELECT vCursorSaleFk, vUserFk; - - CALL itemShelvingSale_reserveWhitUser(); - DROP TEMPORARY TABLE tmp.sale; - - END LOOP; - CLOSE vSales; - - DELETE iss - FROM itemShelvingSale iss - JOIN sale s ON s.id = iss.saleFk - WHERE iss.id = vItemShelvingSaleFk - AND s.itemFk = vItemFk - AND NOT iss.isPicked; - END IF; - - SELECT SUM(quantity) INTO vRemainingQuantity - FROM itemShelvingSale - WHERE saleFk = vSaleFk - AND NOT isPicked; - - IF vRemainingQuantity THEN - CALL itemShelvingSale_reserveBySale (vSaleFk, vRemainingQuantity, NULL); - - SELECT SUM(quantity) INTO vRemainingQuantity - FROM itemShelvingSale - WHERE saleFk = vSaleFk - AND NOT isPicked; - - IF NOT vRemainingQuantity <=> 0 THEN - SELECT SUM(iss.quantity) - INTO vReservedQuantity - FROM itemShelvingSale iss - WHERE iss.saleFk = vSaleFk; - - CALL saleTracking_new( - vSaleFk, - TRUE, - vReservedQuantity, - `account`.`myUser_getId`(), - NULL, - 'PREPARED', - TRUE); - - UPDATE sale s - SET s.quantity = vReservedQuantity - WHERE s.id = vSaleFk ; - END IF; - END IF; -END$$ -DELIMITER ; +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setQuantity`( + vItemShelvingSaleFk INT(10), + vQuantity DECIMAL(10,0), + vIsItemShelvingSaleEmpty BOOLEAN, + vSectorFk INT +) +BEGIN +/** + * Gestiona la reserva de un itemShelvingFk, actualizando isPicked y quantity + * en itemShelvingSale y sale.isPicked en caso necesario. + * Si la reserva de la ubicación es fallida, se regulariza la situación + * + * @param vItemShelvingSaleFk Id itemShelvingSaleFK + * @param vQuantity Cantidad real que se ha cogido de la ubicación + * @param vIsItemShelvingSaleEmpty determina si la ubicación itemShelvingSale se ha + * quedado vacio tras el movimiento + * @param vSectorFk Id del sector + */ + DECLARE vSaleFk INT; + DECLARE vItemShelvingFk INT; + DECLARE vReservedQuantity INT; + DECLARE vRemainingQuantity INT; + DECLARE vItemFk INT; + DECLARE vTotalQuantity INT; + DECLARE vStateCode VARCHAR(45); + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + IF vQuantity > vReservedQuantity + OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty) + OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN + CALL util.throw('The quantity cannot be different from the reserved'); + END IF; + + IF (SELECT isPicked FROM itemShelvingSale WHERE id = vItemShelvingSaleFk) THEN + CALL util.throw('Reservation completed'); + END IF; + + SELECT s.itemFk, + iss.saleFk, + iss.itemShelvingFk, + SUM(IFNULL(iss.quantity,0)), + IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED') + INTO vItemFk, + vSaleFk, + vItemShelvingFk, + vReservedQuantity, + vStateCode + FROM itemShelvingSale iss + JOIN sale s ON s.id = iss.saleFk + LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = iss.saleFk + WHERE iss.id = vItemShelvingSaleFk + AND NOT iss.isPicked; + + IF vQuantity > vReservedQuantity + OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty) + OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN + CALL util.throw('The quantity cannot be different from the reserved'); + END IF; + + START TRANSACTION; + + UPDATE itemShelvingSale + SET isPicked = TRUE, + quantity = vQuantity + WHERE id = vItemShelvingSaleFk; + + SELECT id INTO vItemShelvingFk + FROM itemShelving + WHERE id = vItemShelvingFk + FOR UPDATE; + + UPDATE itemShelving + SET visible = GREATEST(0, visible - vQuantity) + WHERE id = vItemShelvingFk; + + SELECT SUM(IF(isPicked OR id = vItemShelvingSaleFk, 0, quantity)), SUM(quantity) + INTO vRemainingQuantity, vTotalQuantity + FROM itemShelvingSale + WHERE saleFk = vSaleFk; + + IF vRemainingQuantity = 0 AND NOT vIsItemShelvingSaleEmpty THEN + CALL saleTracking_new( + vSaleFk, + TRUE, + vTotalQuantity, + `account`.`myUser_getId`(), + NULL, + vStateCode, + TRUE); + + UPDATE sale s + SET s.quantity = vTotalQuantity, + isPicked = TRUE + WHERE s.id = vSaleFk; + END IF; + + COMMIT; + + IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN + INSERT INTO itemShelvingSaleReserve (saleFk, sectorFk) + SELECT vSaleFk, vSectorFk; + CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk, vSectorFk); + END IF; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingSale_unpicked.sql b/db/routines/vn/procedures/itemShelvingSale_unpicked.sql new file mode 100644 index 000000000..3b636a7b4 --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_unpicked.sql @@ -0,0 +1,60 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_unpicked`( + vSelf INT(11) +) +BEGIN +/** + * Desmarca una línea que ya estaba sacada, devolviendo la cantidad al itemShelving + * + * @param vSelf Identificador del itemShelvingSale + */ + DECLARE vSaleFk INT; + DECLARE vReservedQuantity INT; + DECLARE vIsSaleGroup BOOL; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + IF (SELECT NOT isPicked FROM itemShelvingSale WHERE id = vSelf) THEN + CALL util.throw('Reserva no completada'); + END IF; + + SELECT ish.saleFk, ish.quantity, IF(sg.id, TRUE, FALSE) + INTO vSaleFk, vReservedQuantity, vIsSaleGroup + FROM itemShelvingSale ish + LEFT JOIN saleGroupDetail sg ON sg.saleFk = ish.saleFk + WHERE ish.id = vSelf; + + /*IF vIsSaleGroup THEN + CALL util.throw('Can not unpicked a sale group'); + END IF;*/ + + START TRANSACTION; + + UPDATE itemShelvingSale + SET isPicked = FALSE + WHERE id = vSelf; + + UPDATE sale s + JOIN itemShelvingSale ish ON ish.saleFk = s.id + SET s.isPicked = FALSE + WHERE ish.id = vSelf; + + UPDATE itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + SET ish.visible = ish.visible + iss.quantity + WHERE iss.id = vSelf; + + CALL saleTracking_new( + vSaleFk, + FALSE, + vReservedQuantity, + `account`.`myUser_getId`(), + NULL, + 'ON_PREPARATION', + TRUE); + COMMIT; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingTransfer.sql b/db/routines/vn/procedures/itemShelvingTransfer.sql deleted file mode 100644 index 326f8108b..000000000 --- a/db/routines/vn/procedures/itemShelvingTransfer.sql +++ /dev/null @@ -1,45 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingTransfer`(vItemShelvingFk INT, vShelvingFk VARCHAR(3)) -BEGIN -/** - * Transfiere producto de una ubicación a otra, fusionando si coincide el - * packing y la fecha. - * - * @param vItemShelvingFk Identificador de itemShelving - * @param vShelvingFk Identificador de shelving - */ - DECLARE vNewItemShelvingFk INT DEFAULT 0; - - SELECT MAX(ish.id) - INTO vNewItemShelvingFk - FROM itemShelving ish - JOIN ( - SELECT - itemFk, - packing, - created - FROM itemShelving - WHERE id = vItemShelvingFk - ) ish2 - ON ish2.itemFk = ish.itemFk - AND ish2.packing = ish.packing - AND date(ish2.created) = date(ish.created) - WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci; - - IF vNewItemShelvingFk THEN - UPDATE itemShelving ish - JOIN itemShelving ish2 ON ish2.id = vItemShelvingFk - SET ish.visible = ish.visible + ish2.visible - WHERE ish.id = vNewItemShelvingFk; - - DELETE FROM itemShelving - WHERE id = vItemShelvingFk; - ELSE - UPDATE itemShelving - SET shelvingFk = vShelvingFk - WHERE id = vItemShelvingFk; - END IF; - - SELECT true; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelving_add.sql b/db/routines/vn/procedures/itemShelving_add.sql index d3e0f6a90..92d1609e4 100644 --- a/db/routines/vn/procedures/itemShelving_add.sql +++ b/db/routines/vn/procedures/itemShelving_add.sql @@ -1,8 +1,14 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_add`( + vShelvingFk VARCHAR(8), + vBarcode VARCHAR(22), + vQuantity INT, + vPackagingFk VARCHAR(10), + vGrouping INT, + vPacking INT, + vWarehouseFk INT +) BEGIN - - /** * Añade registro o lo actualiza si ya existe. * @@ -15,11 +21,18 @@ BEGIN * @param vWarehouseFk indica el sector * **/ - DECLARE vItemFk INT; + DECLARE vBuyFk INT; + + SELECT id INTO vBuyFk + FROM buy WHERE id = vBarcode; SELECT barcodeToItem(vBarcode) INTO vItemFk; + IF vBuyFk IS NULL THEN + CALL util.throw('The buy is required'); + END IF; + IF vPacking IS NULL THEN SET vPacking = itemPacking(vBarcode, vWarehouseFk); @@ -29,31 +42,33 @@ BEGIN IF (SELECT COUNT(*) FROM itemShelving WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk - AND packing = vPacking) = 1 THEN + AND packing = vPacking + AND buyFk = vBuyFk) THEN UPDATE itemShelving - SET visible = visible+vQuantity + SET visible = visible + vQuantity, + available = available + vQuantity WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking; ELSE - CALL cache.last_buy_refresh(FALSE); - INSERT INTO itemShelving( itemFk, - shelvingFk, - visible, - grouping, - packing, - packagingFk) - SELECT vItemFk, - vShelvingFk, - vQuantity, - IFNULL(vGrouping, b.grouping), - IFNULL(vPacking, b.packing), - IFNULL(vPackagingFk, b.packagingFk) - FROM item i - LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk - LEFT JOIN buy b ON b.id = lb.buy_id - WHERE i.id = vItemFk; - END IF; + INSERT INTO itemShelving( + itemFk, + shelvingFk, + visible, + grouping, + packing, + packagingFk, + buyFk) + SELECT vItemFk, + vShelvingFk, + vQuantity, + IFNULL(vGrouping, b.grouping), + IFNULL(vPacking, b.packing), + IFNULL(vPackagingFk, b.packagingFk), + id + FROM buy b + WHERE id = vBuyFk; + END IF; END$$ -DELIMITER ; +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelving_addByClaim.sql b/db/routines/vn/procedures/itemShelving_addByClaim.sql index 851162952..5e7cdf3fc 100644 --- a/db/routines/vn/procedures/itemShelving_addByClaim.sql +++ b/db/routines/vn/procedures/itemShelving_addByClaim.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_addByClaim`(vClaimFk INT, vShelvingFk VARCHAR(3)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addByClaim`(vClaimFk INT, vShelvingFk VARCHAR(3)) BEGIN /** * Insert items of claim into itemShelving. @@ -15,7 +15,7 @@ BEGIN JOIN ticket t ON t.id = c.ticketFk WHERE c.id = vClaimFk; - CALL buyUltimate (vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(NULL, vWarehouseFk, util.VN_CURDATE()); INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible) SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible diff --git a/db/routines/vn/procedures/itemShelving_addList.sql b/db/routines/vn/procedures/itemShelving_addList.sql index 130007de5..ade92b9fd 100644 --- a/db/routines/vn/procedures/itemShelving_addList.sql +++ b/db/routines/vn/procedures/itemShelving_addList.sql @@ -1,16 +1,22 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_addList`(vShelvingFk VARCHAR(3), vList TEXT, vIsChecking BOOL, vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addList`( + vShelvingFk VARCHAR(3), + vList TEXT, + vIsChecking BOOL, + vWarehouseFk INT +) BEGIN -/* Recorre cada elemento en la colección vList. +/** + * Recorre cada elemento en la colección vList. * Si el parámetro isChecking = FALSE, llama a itemShelving_add. * * Cuando es TRUE sólo inserta los elementos de la colección que no están ya en - * ese shelving, actualizando los valores del campo vn.itemShelving.isChecked + * ese shelving, actualizando los valores del campo itemShelving.isChecked * - * param vShelvingFk Identificador de vn.shelving - * param vList JSON array con esta estructura: '[value1, value2, ...]' - * param vIsChecking Define si hay que añadir o comprobar los items - * param vWarehouseFk Identificador de vn.warehouse + * @param vShelvingFk Identificador de shelving + * @param vList JSON array con esta estructura: '[value1, value2, ...]' + * @param vIsChecking Define si hay que añadir o comprobar los items + * @param vWarehouseFk Identificador de warehouse */ DECLARE vListLength INT DEFAULT JSON_LENGTH(vList); DECLARE vCounter INT DEFAULT 0; @@ -20,26 +26,27 @@ BEGIN DECLARE vIsChecked BOOL; WHILE vCounter < vListLength DO - SET vPath = CONCAT('$[',vCounter,']'); - SET vBarcode = JSON_EXTRACT(vList,vPath); + SET vPath = CONCAT('$[', vCounter, ']'); + SET vBarcode = JSON_EXTRACT(vList, vPath); SET vIsChecked = NULL; IF vIsChecking THEN SELECT barcodeToItem(vBarcode) INTO vItemFk; - SELECT COUNT(*) INTO vIsChecked - FROM vn.itemShelving + SELECT IF(COUNT(*), TRUE, FALSE) INTO vIsChecked + FROM itemShelving WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk; END IF; - IF NOT (vIsChecking AND vIsChecked) THEN - CALL vn.itemShelving_add(vShelvingFk, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk); + IF NOT vIsChecking OR NOT vIsChecked THEN + CALL itemShelving_add(vShelvingFk, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk); END IF; - UPDATE vn.itemShelving + UPDATE itemShelving SET isChecked = vIsChecked WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk - AND itemFk = vItemFk AND isChecked IS NULL; + AND itemFk = vItemFk + AND isChecked IS NULL; SET vCounter = vCounter + 1; END WHILE; diff --git a/db/routines/vn/procedures/itemShelving_filterBuyer.sql b/db/routines/vn/procedures/itemShelving_filterBuyer.sql index 7112aa48e..0d67a5f46 100644 --- a/db/routines/vn/procedures/itemShelving_filterBuyer.sql +++ b/db/routines/vn/procedures/itemShelving_filterBuyer.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_filterBuyer`(vBuyerFk INT, vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_filterBuyer`(vBuyerFk INT, vWarehouseFk INT) proc:BEGIN /** * Lista de articulos filtrados por comprador @@ -21,7 +21,8 @@ proc:BEGIN sub.downstairs, sub.visible, CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) nicho, - sub.name itemColour + sub.name itemColour, + CAST(sub2.pendiente AS DECIMAL(10,0)) pendingAmount FROM (SELECT iss.itemFk, CONCAT(i.longName, ' ', IFNULL(i.size, ''),' ', IFNULL(i.subName, '') ) longName, '' size, @@ -58,7 +59,8 @@ proc:BEGIN 0, v.visible, v.visible nicho, - ik.name itemColour + ik.name itemColour, + CAST(sub5.pendiente AS DECIMAL(10,0)) pendingAmount FROM cache.visible v JOIN item i ON i.id = v.item_id LEFT JOIN ink ik ON ik.id = i.inkFk diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql index 1be762f09..606bb8bd9 100644 --- a/db/routines/vn/procedures/itemShelving_get.sql +++ b/db/routines/vn/procedures/itemShelving_get.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_get`(IN vSelf VARCHAR(8)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_get`(IN vSelf VARCHAR(8)) BEGIN /** * Lista artículos de itemshelving @@ -16,7 +16,8 @@ BEGIN ish.id, s.priority, ish.isChecked, - ic.url + ic.url, + ish.available FROM itemShelving ish JOIN item i ON i.id = ish.itemFk JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci diff --git a/db/routines/vn/procedures/itemShelving_getAlternatives.sql b/db/routines/vn/procedures/itemShelving_getAlternatives.sql index de30d46ac..89176c4f5 100644 --- a/db/routines/vn/procedures/itemShelving_getAlternatives.sql +++ b/db/routines/vn/procedures/itemShelving_getAlternatives.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_getAlternatives`(vShelvingFk VARCHAR(10)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getAlternatives`(vShelvingFk VARCHAR(10)) BEGIN /** * Devuelve un listado de posibles ubicaciones alternativas a ubicar los item de la matricula diff --git a/db/routines/vn/procedures/itemShelving_getInfo.sql b/db/routines/vn/procedures/itemShelving_getInfo.sql index a5749bd26..f02100e8b 100644 --- a/db/routines/vn/procedures/itemShelving_getInfo.sql +++ b/db/routines/vn/procedures/itemShelving_getInfo.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_getInfo`(vItemFk VARCHAR(22)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getInfo`(vItemFk VARCHAR(22)) BEGIN /** * Muestra información realtiva a la ubicación de un item diff --git a/db/routines/vn/procedures/itemShelving_getItemDetails.sql b/db/routines/vn/procedures/itemShelving_getItemDetails.sql index c01bc348c..4e641ca72 100644 --- a/db/routines/vn/procedures/itemShelving_getItemDetails.sql +++ b/db/routines/vn/procedures/itemShelving_getItemDetails.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_getItemDetails`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getItemDetails`( vBarcodeItem INT, vShelvingFK VARCHAR(10) ) @@ -23,7 +23,7 @@ BEGIN FROM operator WHERE workerFk = account.myUser_getId(); - CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(vBarcodeItem, vWarehouseFk, util.VN_CURDATE()); SELECT buyFk INTO vBuyFk FROM tmp.buyUltimate diff --git a/db/routines/vn/procedures/itemShelving_getSaleDate.sql b/db/routines/vn/procedures/itemShelving_getSaleDate.sql index a9f9466cf..d8ab6ed0c 100644 --- a/db/routines/vn/procedures/itemShelving_getSaleDate.sql +++ b/db/routines/vn/procedures/itemShelving_getSaleDate.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_getSaleDate`(vShelvingFk VARCHAR(3)) +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getSaleDate`(vShelvingFk VARCHAR(3)) BEGIN /* Devuelve la mínima fecha en que se necesita cada producto en esa matrícula. @@ -161,5 +161,5 @@ BEGIN DROP TEMPORARY TABLE tmp.tStockByDay, tmp.tItems; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelving_inventory.sql b/db/routines/vn/procedures/itemShelving_inventory.sql index 73e438fbb..b57df02e0 100644 --- a/db/routines/vn/procedures/itemShelving_inventory.sql +++ b/db/routines/vn/procedures/itemShelving_inventory.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_inventory`(vParkingFromFk VARCHAR(8), vParkingToFk VARCHAR(8)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_inventory`(vParkingFromFk VARCHAR(8), vParkingToFk VARCHAR(8)) BEGIN /** * Devuelve un listado de ubicaciones a revisar @@ -59,5 +59,7 @@ BEGIN WHERE p.pickingOrder BETWEEN vPickingOrderFrom AND vPickingOrderTo AND p.sectorFk = vSectorFk ORDER BY p.pickingOrder; + + DROP TEMPORARY TABLE tmp.stockMisfit; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelving_selfConsumption.sql b/db/routines/vn/procedures/itemShelving_selfConsumption.sql index c974d9903..083d8d74c 100644 --- a/db/routines/vn/procedures/itemShelving_selfConsumption.sql +++ b/db/routines/vn/procedures/itemShelving_selfConsumption.sql @@ -1,17 +1,17 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_selfConsumption`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_selfConsumption`( vShelvingFk VARCHAR(10) COLLATE utf8_general_ci, vItemFk INT, vQuantity INT ) BEGIN /** - * Leave the indicated amount on the shelf + * Leave the indicated amount on the shelve * and create a ticket with the difference. * - * @param vShelvingFk id of the shelf where the item is located. + * @param vShelvingFk id of the shelve where the item is located. * @param vItemFk article of which the self-consumption ticket is to be created. - * @param vQuantity amount that will stay on the shelf + * @param vQuantity amount that will stay on the shelve */ DECLARE vVisible INT; DECLARE vClientFk INT; @@ -80,7 +80,8 @@ BEGIN WHERE id = vItemFk; UPDATE itemShelving - SET visible = IF(id = vItemShelvingFk, vQuantity, 0) + SET visible = IF(id = vItemShelvingFk, vQuantity, 0), + available = IF(id = vItemShelvingFk, vQuantity, 0) WHERE shelvingFk = vShelvingFk AND itemFk = vItemFk; diff --git a/db/routines/vn/procedures/itemShelving_transfer.sql b/db/routines/vn/procedures/itemShelving_transfer.sql new file mode 100644 index 000000000..95d70227f --- /dev/null +++ b/db/routines/vn/procedures/itemShelving_transfer.sql @@ -0,0 +1,53 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_transfer`( + vItemShelvingFk INT, + vShelvingFk VARCHAR(10) +) +BEGIN +/** + * Transfiere producto de una ubicación a otra + * fusionando si coincide el packing y la fecha. + * + * @param vItemShelvingFk Identificador de itemShelving + * @param vShelvingFk Identificador de shelving + */ + DECLARE vNewItemShelvingFk INT; + + SELECT MAX(ish.id) INTO vNewItemShelvingFk + FROM itemShelving ish + JOIN ( + SELECT itemFk, + packing, + created, + buyFk + FROM itemShelving + WHERE id = vItemShelvingFk + ) ish2 ON ish2.itemFk = ish.itemFk + AND ish2.packing = ish.packing + AND DATE(ish2.created) = DATE(ish.created) + AND ish2.buyFk = ish.buyFk + WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci; + + IF vNewItemShelvingFk THEN + UPDATE itemShelving ish + JOIN itemShelving ish2 ON ish2.id = vItemShelvingFk + SET ish.visible = ish.visible + ish2.visible, + ish.available = ish.available + ish2.available + WHERE ish.id = vNewItemShelvingFk; + + DELETE FROM itemShelving + WHERE id = vItemShelvingFk; + ELSE + IF (SELECT EXISTS(SELECT id FROM shelving + WHERE code = vShelvingFk COLLATE utf8_unicode_ci)) THEN + + UPDATE itemShelving + SET shelvingFk = vShelvingFk + WHERE id = vItemShelvingFk; + ELSE + CALL util.throw('The shelving not exists'); + END IF; + END IF; + SELECT TRUE; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelving_update.sql b/db/routines/vn/procedures/itemShelving_update.sql index 079add704..28dfc7c12 100644 --- a/db/routines/vn/procedures/itemShelving_update.sql +++ b/db/routines/vn/procedures/itemShelving_update.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_update`(vVisible INT, vPacking INT, vShelf INT ,vGrouping INT ) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_update`(vVisible INT, vPacking INT, vShelf INT ,vGrouping INT ) BEGIN /** * Actualiza itemShelving. diff --git a/db/routines/vn/procedures/itemTagMake.sql b/db/routines/vn/procedures/itemTagMake.sql index 6d34ecb78..79120a6c0 100644 --- a/db/routines/vn/procedures/itemTagMake.sql +++ b/db/routines/vn/procedures/itemTagMake.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemTagMake`(vItemFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemTagMake`(vItemFk INT) BEGIN /* * Crea los tags usando la tabla plantilla itemTag diff --git a/db/routines/vn/procedures/itemTagReorder.sql b/db/routines/vn/procedures/itemTagReorder.sql index bba3cfe03..6902b1987 100644 --- a/db/routines/vn/procedures/itemTagReorder.sql +++ b/db/routines/vn/procedures/itemTagReorder.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemTagReorder`(itemTypeFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemTagReorder`(itemTypeFk INT) BEGIN SET @isTriggerDisabled = TRUE; diff --git a/db/routines/vn/procedures/itemTagReorderByName.sql b/db/routines/vn/procedures/itemTagReorderByName.sql index 89dc92740..743667912 100644 --- a/db/routines/vn/procedures/itemTagReorderByName.sql +++ b/db/routines/vn/procedures/itemTagReorderByName.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemTagReorderByName`(vName VARCHAR(255)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemTagReorderByName`(vName VARCHAR(255)) BEGIN SET @isTriggerDisabled = TRUE; diff --git a/db/routines/vn/procedures/itemTag_replace.sql b/db/routines/vn/procedures/itemTag_replace.sql index b32285072..2db6ef524 100644 --- a/db/routines/vn/procedures/itemTag_replace.sql +++ b/db/routines/vn/procedures/itemTag_replace.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemTag_replace`(vItemFromFk INT, vItemToFk INT, vPicture VARCHAR(100)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemTag_replace`(vItemFromFk INT, vItemToFk INT, vPicture VARCHAR(100)) BEGIN /* Reemplaza los tags de un artículo por los de otro, así como su imagen diff --git a/db/routines/vn/procedures/itemTopSeller.sql b/db/routines/vn/procedures/itemTopSeller.sql index f42cf67cf..beccc6765 100644 --- a/db/routines/vn/procedures/itemTopSeller.sql +++ b/db/routines/vn/procedures/itemTopSeller.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemTopSeller`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemTopSeller`() BEGIN DECLARE vCategoryFk INTEGER; DECLARE vDone INT DEFAULT FALSE; diff --git a/db/routines/vn/procedures/itemUpdateTag.sql b/db/routines/vn/procedures/itemUpdateTag.sql index 59529e2b0..2c41ff63d 100644 --- a/db/routines/vn/procedures/itemUpdateTag.sql +++ b/db/routines/vn/procedures/itemUpdateTag.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemUpdateTag`(IN vItem BIGINT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemUpdateTag`(IN vItem BIGINT) BEGIN diff --git a/db/routines/vn/procedures/item_GetVisible.sql b/db/routines/vn/procedures/item_GetVisible.sql deleted file mode 100644 index ca5e43107..000000000 --- a/db/routines/vn/procedures/item_GetVisible.sql +++ /dev/null @@ -1,43 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_GetVisible`(vWarehouse SMALLINT, vItem INT) -BEGIN - DECLARE vTomorrow DATETIME DEFAULT TIMESTAMPADD(DAY, 1, util.VN_CURDATE()); - - INSERT INTO tmp.itemVisible (item_id, visible) - SELECT item_id, SUM(amount) amount - FROM ( - SELECT i.itemFk AS item_id, quantity AS amount - FROM itemTicketOut i - LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk - JOIN state s ON s.id = ts.stateFk - LEFT JOIN (SELECT DISTINCT saleFk - FROM saleTracking st - JOIN state s ON s.id = st.stateFk - WHERE st.created > util.VN_CURDATE() - AND (s.isPicked OR st.isChecked) - ) stPrevious ON `stPrevious`.`saleFk` = i.saleFk - WHERE i.warehouseFk = vWarehouse - AND (vItem IS NULL OR i.itemFk = vItem) - AND (s.isPicked OR i.reserved OR stPrevious.saleFk ) - AND i.shipped >= util.VN_CURDATE() AND i.shipped < vTomorrow - UNION ALL - SELECT iei.itemFk, quantity - FROM itemEntryIn iei - WHERE (iei.isReceived != FALSE /*OR ip.modificationDate > util.VN_CURDATE()*/) - AND iei.landed >= util.VN_CURDATE() AND iei.landed < vTomorrow - AND iei.warehouseInFk = vWarehouse - AND (vItem IS NULL OR iei.itemFk = vItem) - AND iei.isVirtualStock is FALSE - UNION ALL - SELECT itemFk, quantity - FROM itemEntryOut - WHERE isDelivered != FALSE - AND shipped >= util.VN_CURDATE() AND shipped < vTomorrow - AND warehouseOutFk = vWarehouse - AND (vItem IS NULL OR itemFk = vItem) - ) t - GROUP BY item_id - ON DUPLICATE KEY UPDATE - visible = IFNULL(stock,0) + VALUES(visible); -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/item_calcVisible.sql b/db/routines/vn/procedures/item_calcVisible.sql new file mode 100644 index 000000000..814d3add3 --- /dev/null +++ b/db/routines/vn/procedures/item_calcVisible.sql @@ -0,0 +1,62 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_calcVisible`( + vSelf INT, + vWarehouseFk INT +) +BEGIN +/** + * Calcula el visible de un artículo o de todos. + * + * @param vWarehouse Warehouse id + * @param vSelf Item id + * @param tmp.itemVisible(item_id, stock, visible) + */ + DECLARE vDated DATE DEFAULT util.VN_CURDATE(); + DECLARE vTomorrow DATETIME DEFAULT util.tomorrow(); + + INSERT INTO tmp.itemVisible(item_id, visible) + SELECT itemFk, SUM(quantity) + FROM ( + SELECT i.itemFk, i.quantity + FROM itemTicketOut i + LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk + JOIN `state` s ON s.id = ts.stateFk + JOIN warehouse w ON w.id = i.warehouseFk + LEFT JOIN ( + SELECT DISTINCT st.saleFk + FROM saleTracking st + JOIN state s ON s.id = st.stateFk + WHERE st.created > vDated + AND (s.isPicked OR st.isChecked) + ) stPrevious ON `stPrevious`.`saleFk` = i.saleFk + WHERE (vWarehouseFk IS NULL OR i.warehouseFk = vWarehouseFk) + AND (vSelf IS NULL OR i.itemFk = vSelf) + AND (s.isPicked OR i.reserved OR stPrevious.saleFk) + AND i.shipped >= vDated AND i.shipped < vTomorrow + AND w.isComparative + UNION ALL + SELECT iei.itemFk, iei.quantity + FROM itemEntryIn iei + JOIN warehouse w ON w.id = iei.warehouseInFk + WHERE iei.isReceived + AND iei.landed >= vDated AND iei.landed < vTomorrow + AND (vWarehouseFk IS NULL OR iei.warehouseInFk = vWarehouseFk) + AND (vSelf IS NULL OR iei.itemFk = vSelf) + AND NOT iei.isVirtualStock + AND w.isComparative + UNION ALL + SELECT ieo.itemFk, ieo.quantity + FROM itemEntryOut ieo + JOIN warehouse w ON w.id = ieo.warehouseOutFk + WHERE ieo.isDelivered + AND ieo.shipped >= vDated + AND ieo.shipped < vTomorrow + AND (vWarehouseFk IS NULL OR ieo.warehouseOutFk = vWarehouseFk) + AND (vSelf IS NULL OR ieo.itemFk = vSelf) + AND w.isComparative + ) t + GROUP BY itemFk + ON DUPLICATE KEY UPDATE + visible = IFNULL(stock, 0) + VALUES(visible); +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/stockTraslation.sql b/db/routines/vn/procedures/item_calculateStock.sql similarity index 66% rename from db/routines/vn/procedures/stockTraslation.sql rename to db/routines/vn/procedures/item_calculateStock.sql index c681112f1..976ac10e4 100644 --- a/db/routines/vn/procedures/stockTraslation.sql +++ b/db/routines/vn/procedures/item_calculateStock.sql @@ -1,15 +1,13 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`stockTraslation`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_calculateStock`( vDated DATE ) BEGIN /** - * Calcula el stock del almacén de subasta desde FechaInventario hasta vDated - * sin tener en cuenta las salidas del mismo dia vDated - * para ver el transporte a reservar + * Calculate the stock of the auction warehouse from the inventory date to vDated * - * @param vDated Fecha hasta la cual calcula el stock - * @return tmp.item + * @param vDated Date to calculate the stock. + * @return tmp.item, tmp.buyUltimate */ DECLARE vAuctionWarehouseFk INT; @@ -36,6 +34,6 @@ BEGIN WHERE warehouse_id = vAuctionWarehouseFk ON DUPLICATE KEY UPDATE quantity = tmp.item.quantity + VALUES(quantity); - CALL buyUltimate(vAuctionWarehouseFk, vDated); + CALL buy_getUltimate(NULL, vAuctionWarehouseFk, vDated); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/item_cleanFloramondo.sql b/db/routines/vn/procedures/item_cleanFloramondo.sql index 080c61b5b..849cfe93d 100644 --- a/db/routines/vn/procedures/item_cleanFloramondo.sql +++ b/db/routines/vn/procedures/item_cleanFloramondo.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_cleanFloramondo`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_cleanFloramondo`() BEGIN /** * Elimina todos los items repetidos de floramondo diff --git a/db/routines/vn/procedures/item_comparative.sql b/db/routines/vn/procedures/item_comparative.sql index d429cf009..298272708 100644 --- a/db/routines/vn/procedures/item_comparative.sql +++ b/db/routines/vn/procedures/item_comparative.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_comparative`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_comparative`( vDate DATETIME, vDayRange TINYINT, vWarehouseFk TINYINT, @@ -10,19 +10,20 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_comparative`( ) proc: BEGIN /** - * Genera una tabla de comparativa de artículos por itemType/comprador/fecha. - * Los datos se calculan en función de los parámetros proporcionados. + * Generates a comparison table of items by itemType/buyer/date. + * The data is calculated based on the provided parameters. * - * @param vDate La fecha para la cual se generará la comparativa. - * @param vDayRange El rango de días a considerar para la comparativa. - * @param vWarehouseFk El identificador del almacén para filtrar los artículos. - * @param vAvailableSince La fecha de disponibilidad desde la cual se consideran los artículos disponibles. - * @param vBuyerFk El identificador del comprador para filtrar los artículos. - * @param vIsFloramondo Indica si se deben incluir solo los artículos de Floramondo (opcional). - * @param vCountryFk El identificador del país. - * @param tmp.comparativeFilterType(filterFk INT ,itemTypeFk INT) + * @param vDate The date for which the comparison will be generated. + * @param vDayRange The range of days to consider for the comparison. + * @param vWarehouseFk The warehouse identifier to filter the items. + * @param vAvailableSince The availability date from which the items are considered available. + * @param vBuyerFk The buyer identifier to filter the items. + * @param vIsFloramondo Indicates whether only Floramondo items should be included (optional). + * @param vCountryFk The country identifier. + * @param tmp.comparativeFilterType(filterFk INT, itemTypeFk INT) * @return tmp.comparative */ + DECLARE vDayRangeStart DATE; DECLARE vDayRangeEnd DATE; DECLARE w1, w2, w3, w4, w5, w6, w7 INT; diff --git a/db/routines/vn/procedures/item_deactivateUnused.sql b/db/routines/vn/procedures/item_deactivateUnused.sql index 68a6b4978..cf8f22500 100644 --- a/db/routines/vn/procedures/item_deactivateUnused.sql +++ b/db/routines/vn/procedures/item_deactivateUnused.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_deactivateUnused`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_deactivateUnused`() BEGIN /** * Cambia a false el campo isActive de la tabla vn.item para todos aquellos diff --git a/db/routines/vn/procedures/item_devalueA2.sql b/db/routines/vn/procedures/item_devalueA2.sql index c9f716d8f..d0178f6a7 100644 --- a/db/routines/vn/procedures/item_devalueA2.sql +++ b/db/routines/vn/procedures/item_devalueA2.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_devalueA2`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_devalueA2`( vSelf INT, vShelvingFK VARCHAR(10), vBuyingValue DECIMAL(10,4), @@ -42,7 +42,7 @@ BEGIN END IF; SELECT warehouseFk INTO vWarehouseFk - FROM userConfig + FROM userMultiConfig WHERE userFk = account.myUser_getId(); IF NOT vWarehouseFk OR vWarehouseFk IS NULL THEN @@ -93,7 +93,7 @@ BEGIN ORDER BY created DESC LIMIT 1; - CALL buyUltimate(vWarehouseFk, vCurdate); + CALL buy_getUltimate(vSelf, vWarehouseFk, vCurdate); SELECT b.entryFk, bu.buyFk,IFNULL(b.buyingValue, 0) INTO vLastEntryFk, vLastBuyFk, vBuyingValueOriginal FROM tmp.buyUltimate bu @@ -303,7 +303,8 @@ BEGIN WHERE id = vTargetItemShelvingFk; ELSE UPDATE itemShelving - SET visible = vCurrentVisible - vQuantity + SET visible = vCurrentVisible - vQuantity, + available = GREATEST(0, available - vQuantity) WHERE id = vTargetItemShelvingFk; END IF; diff --git a/db/routines/vn/procedures/item_getAtp.sql b/db/routines/vn/procedures/item_getAtp.sql index bbf13d396..3e90a7f58 100644 --- a/db/routines/vn/procedures/item_getAtp.sql +++ b/db/routines/vn/procedures/item_getAtp.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getAtp`(vDated DATE) +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getAtp`(vDated DATE) BEGIN /** * Calcula el valor mínimo acumulado para cada artículo ordenado por fecha y @@ -44,5 +44,5 @@ BEGIN GROUP BY itemFk, wareHouseFk; DROP TEMPORARY TABLE tItemOrdered; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql index a4942af6f..4aa589d19 100644 --- a/db/routines/vn/procedures/item_getBalance.sql +++ b/db/routines/vn/procedures/item_getBalance.sql @@ -1,95 +1,85 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getBalance`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getBalance`( vItemFk INT, vWarehouseFk INT, - vDate DATETIME + vDated DATETIME ) BEGIN /** - * @vItemFk item a buscar - * @vWarehouseFk almacen donde buscar - * @vDate Si la fecha es null, muestra el histórico desde el inventario. - * Si la fecha no es null, muestra histórico desde la fecha de vDate. + * Calcula el balance de un artículo. + * + * @vItemFk Id de artículo + * @vWarehouseFk Id de almacén + * @vDated Fecha a calcular, si es NULL muestra el histórico desde el inventario */ - DECLARE vDateInventory DATETIME; + DECLARE vDateInventory DATETIME + DEFAULT ( + SELECT IF(vDated, uc.mockUtcTime, c.inventoried) + FROM config c + JOIN util.config uc + ); + DECLARE vSupplierInventoryFk INT + DEFAULT (SELECT supplierFk FROM inventoryConfig); - IF vDate IS NULL THEN - SELECT inventoried INTO vDateInventory - FROM config; - ELSE - SELECT mockUtcTime INTO vDateInventory - FROM util.config; + IF NOT vSupplierInventoryFk OR NOT vDateInventory THEN + CALL util.throw('Config variables are not set'); END IF; - CREATE OR REPLACE TEMPORARY TABLE tItemDiary( - shipped DATE, - `in` INT(11), - `out` INT(11), - alertLevel INT(11), - stateName VARCHAR(20), - `name` VARCHAR(50), - reference VARCHAR(50), - origin INT(11), - clientFk INT(11), - isPicked INT(11), - isTicket TINYINT(1), - lineFk INT(11), - `order` TINYINT(3) UNSIGNED, - clientType VARCHAR(20), - claimFk INT(10) UNSIGNED, - inventorySupplierFk INT(10) - ); - - INSERT INTO tItemDiary + CREATE OR REPLACE TEMPORARY TABLE tItemDiary + ENGINE = MEMORY WITH entriesIn AS ( - SELECT tr.landed shipped, + SELECT 'entry' originType, + e.id originId, + tr.landed shipped, b.quantity `in`, NULL `out`, st.alertLevel , st.name stateName, - s.name `name`, e.invoiceNumber reference, - e.id origin, - s.id clientFk, + 'supplier' entityType, + s.id entityId, + s.name entityName, IF(st.`code` = 'DELIVERED', TRUE, FALSE) isPicked, FALSE isTicket, b.id lineFk, NULL `order`, NULL clientType, NULL claimFk, - ec.inventorySupplierFk + vSupplierInventoryFk inventorySupplierFk FROM vn.buy b JOIN vn.entry e ON e.id = b.entryFk JOIN vn.travel tr ON tr.id = e.travelFk JOIN vn.supplier s ON s.id = e.supplierFk - JOIN vn.state st ON st.`code` = IF( tr.landed < util.VN_CURDATE() + JOIN vn.state st ON st.`code` = IF(tr.landed < util.VN_CURDATE() OR (util.VN_CURDATE() AND tr.isReceived), 'DELIVERED', 'FREE') - JOIN vn.entryConfig ec WHERE tr.landed >= vDateInventory - AND vWarehouseFk = tr.warehouseInFk - AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL) + AND tr.warehouseInFk = vWarehouseFk + AND (s.id <> vSupplierInventoryFk OR vDated IS NULL) AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable AND NOT e.isRaid - ), entriesOut AS ( - SELECT tr.shipped, + ), + entriesOut AS ( + SELECT 'entry', + e.id originType, + tr.shipped, NULL, b.quantity, st.alertLevel, st.name stateName, - s.name , e.invoiceNumber, - e.id entryFk, - s.id supplierFk, + 'supplier' entityType, + s.id entityId, + s.name, IF(st.`code` = 'DELIVERED' , TRUE, FALSE), FALSE isTicket, b.id, NULL `order`, NULL clientType, NULL claimFk, - ec.inventorySupplierFk + vSupplierInventoryFk FROM vn.buy b JOIN vn.entry e ON e.id = b.entryFk JOIN vn.travel tr ON tr.id = e.travelFk @@ -99,86 +89,108 @@ BEGIN OR (tr.shipped = util.VN_CURDATE() AND tr.isReceived), 'DELIVERED', 'FREE') - JOIN vn.entryConfig ec WHERE tr.shipped >= vDateInventory - AND vWarehouseFk = tr.warehouseOutFk - AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL) + AND tr.warehouseOutFk = vWarehouseFk + AND (s.id <> vSupplierInventoryFk OR vDated IS NULL) AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable AND NOT w.isFeedStock AND NOT e.isRaid - ), sales AS ( - SELECT DATE(t.shipped) shipped, - s.quantity, - st2.alertLevel, - st2.name, - t.nickname, - t.refFk, - t.id ticketFk, - t.clientFk, - s.id saleFk, - st.`order`, - c.typeFk, - cb.claimFk - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id - LEFT JOIN vn.state st ON st.`code` = ts.`code` - JOIN vn.client c ON c.id = t.clientFk - JOIN vn.state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(), - 'DELIVERED', - IF (t.shipped > util.dayEnd(util.VN_CURDATE()), - 'FREE', - IFNULL(ts.code, 'FREE'))) - LEFT JOIN vn.claimBeginning cb ON s.id = cb.saleFk - WHERE t.shipped >= vDateInventory - AND s.itemFk = vItemFk - AND vWarehouseFk = t.warehouseFk - ),sale AS ( - SELECT s.shipped, + ), + sales AS ( + WITH itemSales AS ( + SELECT DATE(t.shipped) shipped, + s.quantity, + st2.alertLevel, + st2.name, + t.refFk, + t.id ticketFk, + 'client' entityType, + t.clientFk entityId, + t.nickname, + s.id saleFk, + st.`order`, + c.typeFk, + cb.claimFk + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id + LEFT JOIN vn.state st ON st.code = ts.code + JOIN vn.client c ON c.id = t.clientFk + JOIN vn.state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(), + 'DELIVERED', + IF (t.shipped > util.dayEnd(util.VN_CURDATE()), + 'FREE', + IFNULL(st.code, 'FREE'))) + LEFT JOIN vn.claimBeginning cb ON cb.saleFk = s.id + WHERE t.shipped >= vDateInventory + AND s.itemFk = vItemFk + AND t.warehouseFk = vWarehouseFk + ) + SELECT 'ticket', + s.ticketFk, + s.shipped, NULL `in`, s.quantity, s.alertLevel, s.name, - s.nickname, s.refFk, - s.ticketFk, - s.clientFk, - IF(stk.saleFk, TRUE, NULL), + s.entityType, + s.entityId, + s.nickname, + IF(stk.saleFk, TRUE, FALSE), TRUE, s.saleFk, s.`order`, s.typeFk, s.claimFk, NULL - FROM sales s + FROM itemSales s LEFT JOIN vn.state stPrep ON stPrep.`code` = 'PREPARED' LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.saleFk AND stk.stateFk = stPrep.id GROUP BY s.saleFk - ) SELECT shipped, - `in`, - `out`, - alertLevel, - stateName, - `name`, - reference, - origin, - clientFk, - isPicked, - isTicket, - lineFk, - `order`, - clientType, - claimFk, - inventorySupplierFk - FROM entriesIn + ), + orders AS ( + SELECT 'order' originType, + o.id originId, + r.shipment, + NULL 'in', + r.amount, + NULL alertLevel, + NULL stateName, + NULL invoiceNumber, + 'client' entityType, + c.id, + c.name, + FALSE, + FALSE isTicket, + NULL buyFk, + NULL 'order', + c.typeFk, + NULL claimFk, + NULL + FROM hedera.orderRow r + JOIN hedera.`order` o ON o.id = r.orderFk + JOIN vn.client c ON c.id = o.customer_id + WHERE r.shipment >= vDateInventory + AND r.warehouseFk = vWarehouseFk + AND r.created >= ( + SELECT SUBTIME(util.VN_NOW(), reserveTime) + FROM hedera.orderConfig + ) + AND NOT o.confirmed + AND r.itemFk = vItemFk + ) + SELECT * FROM entriesIn UNION ALL SELECT * FROM entriesOut UNION ALL - SELECT * FROM sale + SELECT * FROM sales + UNION ALL + SELECT * FROM orders ORDER BY shipped, - (inventorySupplierFk = clientFk) DESC, + (inventorySupplierFk = entityId) DESC, alertLevel DESC, isTicket, `order` DESC, @@ -186,19 +198,20 @@ BEGIN `in` DESC, `out` DESC; - IF vDate IS NULL THEN - + IF vDated IS NULL THEN SET @a := 0; SET @currentLineFk := 0; SET @shipped := ''; - SELECT DATE(@shipped:= t.shipped) shipped, + SELECT t.originType, + t.originId, + DATE(@shipped:= t.shipped) shipped, t.alertLevel, t.stateName, - t.origin, t.reference, - t.clientFk, - t.name, + t.entityType, + t.entityId, + t.entityName, t.`in` invalue, t.`out`, @a := @a + IFNULL(t.`in`, 0) - IFNULL(t.`out`, 0) balance, @@ -214,37 +227,41 @@ BEGIN t.`order` FROM tItemDiary t LEFT JOIN alertLevel a ON a.id = t.alertLevel; - ELSE SELECT IFNULL(SUM(IFNULL(`in`, 0)) - SUM(IFNULL(`out`, 0)), 0) INTO @a FROM tItemDiary - WHERE shipped < vDate; + WHERE shipped < vDated; - SELECT vDate shipped, - 0 alertLevel, - 0 stateName, - 0 origin, - '' reference, - 0 clientFk, - 'Inventario calculado', + SELECT NULL originType, + NULL originId, + vDated shipped, + NULL alertLevel, + NULL stateName, + NULL reference, + NULL entityType, + NULL entityId, + 'Inventario calculado' entityName, @a invalue, NULL `out`, @a balance, - 0 lastPreparedLineFk, - 0 isTicket, - 0 lineFk, - 0 isPicked, - 0 clientType, - 0 claimFk, + NULL lastPreparedLineFk, + NULL isTicket, + NULL lineFk, + NULL isPicked, + NULL clientType, + NULL claimFk, NULL `order` UNION ALL - SELECT shipped, + SELECT originType, + originId, + shipped, alertlevel, stateName, - origin, - reference, - clientFk, - name, `in`, + reference, + entityType, + entityId, + entityName, + `in`, `out`, @a := @a + IFNULL(`in`, 0) - IFNULL(`out`, 0), 0, @@ -255,7 +272,7 @@ BEGIN claimFk, `order` FROM tItemDiary - WHERE shipped >= vDate; + WHERE shipped >= vDated; END IF; DROP TEMPORARY TABLE tItemDiary; diff --git a/db/routines/vn/procedures/item_getInfo.sql b/db/routines/vn/procedures/item_getInfo.sql index 50ab880a0..341142892 100644 --- a/db/routines/vn/procedures/item_getInfo.sql +++ b/db/routines/vn/procedures/item_getInfo.sql @@ -1,5 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getInfo`(IN `vBarcode` VARCHAR(22), IN `vWarehouseFk` INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getInfo`( + `vBarcode` VARCHAR(22), + `vWarehouseFk` INT +) BEGIN /** * Devuelve información relativa al item correspondiente del vBarcode pasado @@ -11,12 +14,14 @@ BEGIN DECLARE vCacheAvailableFk INT; DECLARE vVisibleItemShelving INT; DECLARE vItemFk INT; + DECLARE vDated DATE; + + SELECT barcodeToItem(vBarcode), util.VN_CURDATE() INTO vItemFk, vDated; CALL cache.visible_refresh(vCacheVisibleFk, FALSE, vWarehouseFk); - CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE()); - CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); - - SELECT barcodeToItem(vBarcode) INTO vItemFk; + CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, vDated); + CALL buy_getUltimate(vItemFk, vWarehouseFk, vDated); + SELECT SUM(visible) INTO vVisibleItemShelving FROM itemShelvingStock WHERE itemFk = vItemFk diff --git a/db/routines/vn/procedures/item_getLack.sql b/db/routines/vn/procedures/item_getLack.sql index e0531e2ac..45a6a6260 100644 --- a/db/routines/vn/procedures/item_getLack.sql +++ b/db/routines/vn/procedures/item_getLack.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getLack`(IN vForce BOOLEAN, IN vDays INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getLack`(IN vForce BOOLEAN, IN vDays INT) BEGIN /** * Calcula una tabla con el máximo negativo visible para cada producto y almacen diff --git a/db/routines/vn/procedures/item_getMinETD.sql b/db/routines/vn/procedures/item_getMinETD.sql index 3876587fe..62710231b 100644 --- a/db/routines/vn/procedures/item_getMinETD.sql +++ b/db/routines/vn/procedures/item_getMinETD.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getMinETD`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getMinETD`() BEGIN /* Devuelve una tabla temporal con la primera ETD, para todos los artículos con salida hoy. diff --git a/db/routines/vn/procedures/item_getMinacum.sql b/db/routines/vn/procedures/item_getMinacum.sql index ed987637c..85474fc3f 100644 --- a/db/routines/vn/procedures/item_getMinacum.sql +++ b/db/routines/vn/procedures/item_getMinacum.sql @@ -1,36 +1,40 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getMinacum`(IN vWarehouseFk TINYINT, IN vDatedFrom DATETIME, IN vRange INT, IN vItemFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getMinacum`( + vWarehouseFk TINYINT, + vDated DATE, + vRange INT, + vItemFk INT +) BEGIN /** - * Cálculo del mínimo acumulado, para un item/almacén especificado, en caso de - * NULL para todo. + * Cálculo del mínimo acumulado, para un item/almacén + * especificado, en caso de NULL para todos. * - * @param vWarehouseFk -> warehouseFk - * @param vDatedFrom -> fecha inicio - * @param vRange -> número de días a considerar - * @param vItemFk -> Identificador de item + * @param vWarehouseFk Id warehouse + * @param vDated Fecha inicio + * @param vRange Número de días a considerar + * @param vItemFk Id de artículo * @return tmp.itemMinacum */ - DECLARE vDatedTo DATETIME; + DECLARE vDatedTo DATETIME DEFAULT util.dayEnd(vDated + INTERVAL vRange DAY); - SET vDatedFrom = TIMESTAMP(DATE(vDatedFrom), '00:00:00'); - SET vDatedTo = TIMESTAMP(TIMESTAMPADD(DAY, vRange, vDatedFrom), '23:59:59'); - - DROP TEMPORARY TABLE IF EXISTS tmp.itemCalc; - CREATE TEMPORARY TABLE tmp.itemCalc + CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc (INDEX (itemFk, warehouseFk)) + ENGINE = MEMORY SELECT sub.itemFk, sub.dated, CAST(SUM(sub.quantity) AS SIGNED) quantity, sub.warehouseFk - FROM (SELECT s.itemFk, + FROM ( + SELECT s.itemFk, DATE(t.shipped) dated, -s.quantity quantity, t.warehouseFk FROM sale s JOIN ticket t ON t.id = s.ticketFk - WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo - AND s.quantity != 0 + WHERE t.shipped BETWEEN vDated AND vDatedTo + AND t.warehouseFk + AND s.quantity <> 0 AND (vItemFk IS NULL OR s.itemFk = vItemFk) AND (vWarehouseFk IS NULL OR t.warehouseFk = vWarehouseFk) UNION ALL @@ -40,11 +44,11 @@ BEGIN t.warehouseInFk FROM buy b JOIN entry e ON e.id = b.entryFk - LEFT JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vDatedFrom AND vDatedTo + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vDated AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND !e.isExcludedFromAvailable - AND b.quantity != 0 + AND NOT e.isExcludedFromAvailable + AND b.quantity <> 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) UNION ALL SELECT b.itemFk, @@ -53,27 +57,46 @@ BEGIN t.warehouseOutFk FROM buy b JOIN entry e ON e.id = b.entryFk - LEFT JOIN travel t ON t.id = e.travelFk - WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo + JOIN travel t ON t.id = e.travelFk + WHERE t.shipped BETWEEN vDated AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk) - AND !e.isExcludedFromAvailable - AND b.quantity != 0 + AND NOT e.isExcludedFromAvailable + AND b.quantity <> 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) - AND !e.isRaid + AND NOT e.isRaid + UNION ALL + SELECT r.itemFk, + r.shipment, + -r.amount, + r.warehouseFk + FROM hedera.orderRow r + JOIN hedera.`order` o ON o.id = r.orderFk + JOIN client c ON c.id = o.customer_id + WHERE r.shipment BETWEEN vDated AND vDatedTo + AND (vWarehouseFk IS NULL OR r.warehouseFk = vWarehouseFk) + AND r.created >= ( + SELECT util.VN_NOW() - INTERVAL TIME_TO_SEC(reserveTime) SECOND + FROM hedera.orderConfig + ) + AND NOT o.confirmed + AND (vItemFk IS NULL OR r.itemFk = vItemFk) + AND r.amount <> 0 ) sub GROUP BY sub.itemFk, sub.warehouseFk, sub.dated; - CALL item_getAtp(vDatedFrom); - DROP TEMPORARY TABLE tmp.itemCalc; + CALL item_getAtp(vDated); - DROP TEMPORARY TABLE IF EXISTS tmp.itemMinacum; - CREATE TEMPORARY TABLE tmp.itemMinacum + CREATE OR REPLACE TEMPORARY TABLE tmp.itemMinacum (INDEX(itemFk)) ENGINE = MEMORY - SELECT i.itemFk, - i.warehouseFk, - i.quantity amount - FROM tmp.itemAtp i - HAVING amount != 0; + SELECT itemFk, + warehouseFk, + quantity amount + FROM tmp.itemAtp + WHERE quantity <> 0; + + DROP TEMPORARY TABLE + tmp.itemAtp, + tmp.itemCalc; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index 762c25342..537f53848 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -1,28 +1,29 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getSimilar`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getSimilar`( vSelf INT, vWarehouseFk INT, vDated DATE, - vShowType BOOL + vShowType BOOL, + vDaysInForward INT ) BEGIN /** -* Propone articulos disponibles ordenados, con la cantidad -* de veces usado y segun sus caracteristicas. -* -* @param vSelf Id de artículo -* @param vWarehouseFk Id de almacen -* @param vDated Fecha -* @param vShowType Mostrar tipos -*/ - DECLARE vCalcFk INT; + * Propone articulos ordenados, con la cantidad + * de veces usado y segun sus caracteristicas. + * + * @param vSelf Id de artículo + * @param vWarehouseFk Id de almacen + * @param vDated Fecha + * @param vShowType Mostrar tipos + * @param vDaysInForward Días de alcance para las ventas (https://redmine.verdnatura.es/issues/7956#note-4) + */ + DECLARE vAvailableCalcFk INT; + DECLARE vVisibleCalcFk INT; DECLARE vTypeFk INT; DECLARE vPriority INT DEFAULT 1; - CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated); - - -- Añadido temporalmente para que no se cuelgue la db - SET vShowType = TRUE; + CALL cache.available_refresh(vAvailableCalcFk, FALSE, vWarehouseFk, vDated); + CALL cache.visible_refresh(vVisibleCalcFk, FALSE, vWarehouseFk); WITH itemTags AS ( SELECT i.id, @@ -44,6 +45,7 @@ BEGIN WHERE i.id = vSelf ) SELECT i.id itemFk, + NULL advanceable, -- https://redmine.verdnatura.es/issues/7956#note-4 i.longName, i.subName, i.tag5, @@ -64,22 +66,22 @@ BEGIN WHEN b.groupingMode = 'grouping' THEN b.grouping WHEN b.groupingMode = 'packing' THEN b.packing ELSE 1 - END AS minQuantity, - iss.visible located, + END minQuantity, + v.visible located, b.price2 FROM vn.item i JOIN cache.available a ON a.item_id = i.id - AND a.calc_id = vCalcFk + AND a.calc_id = vAvailableCalcFk + LEFT JOIN cache.visible v ON v.item_id = i.id + AND v.calc_id = vVisibleCalcFk + LEFT JOIN cache.last_buy lb ON lb.item_id = i.id + AND lb.warehouse_id = vWarehouseFk LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id AND ip.itemFk = vSelf LEFT JOIN vn.itemTag it ON it.itemFk = i.id AND it.priority = vPriority LEFT JOIN vn.tag t ON t.id = it.tagFk - LEFT JOIN cache.last_buy lb ON lb.item_id = i.id - AND lb.warehouse_id = vWarehouseFk LEFT JOIN vn.buy b ON b.id = lb.buy_id - LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = i.id - AND iss.warehouseFk = vWarehouseFk JOIN itemTags its WHERE a.available > 0 AND (i.typeFk = its.typeFk OR NOT vShowType) diff --git a/db/routines/vn/procedures/item_getStock.sql b/db/routines/vn/procedures/item_getStock.sql index c7df75ef2..8c0eea251 100644 --- a/db/routines/vn/procedures/item_getStock.sql +++ b/db/routines/vn/procedures/item_getStock.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getStock`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getStock`( vWarehouseFk SMALLINT, vDated DATE, vItemFk INT diff --git a/db/routines/vn/procedures/item_multipleBuy.sql b/db/routines/vn/procedures/item_multipleBuy.sql index ba49f8d36..50a535620 100644 --- a/db/routines/vn/procedures/item_multipleBuy.sql +++ b/db/routines/vn/procedures/item_multipleBuy.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_multipleBuy`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_multipleBuy`( vDate DATETIME, vWarehouseFk INT ) @@ -13,7 +13,7 @@ BEGIN */ ALTER TABLE tmp.itemInventory ADD IF NOT EXISTS buy_id INT; - CALL buyUltimate(vWarehouseFk, vDate); + CALL buy_getUltimate (NULL, vWarehouseFk, vDate); CREATE OR REPLACE TEMPORARY TABLE tmp (KEY (itemFk)) diff --git a/db/routines/vn/procedures/item_multipleBuyByDate.sql b/db/routines/vn/procedures/item_multipleBuyByDate.sql index d508afca4..115202895 100644 --- a/db/routines/vn/procedures/item_multipleBuyByDate.sql +++ b/db/routines/vn/procedures/item_multipleBuyByDate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_multipleBuyByDate`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_multipleBuyByDate`( vDated DATETIME, vWarehouseFk TINYINT(3) ) diff --git a/db/routines/vn/procedures/item_refreshFromTags.sql b/db/routines/vn/procedures/item_refreshFromTags.sql index 398c01d8e..704224993 100644 --- a/db/routines/vn/procedures/item_refreshFromTags.sql +++ b/db/routines/vn/procedures/item_refreshFromTags.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_refreshFromTags`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_refreshFromTags`(vSelf INT) BEGIN /** * Updates item attributes with its corresponding tags. @@ -46,12 +46,18 @@ BEGIN i.tag8 = JSON_VALUE(vTags, '$.8'), i.tag9 = JSON_VALUE(vTags, '$.9'), i.tag10 = JSON_VALUE(vTags, '$.10'), + i.tag11 = JSON_VALUE(vTags, '$.11'), + i.tag12 = JSON_VALUE(vTags, '$.12'), + i.tag13 = JSON_VALUE(vTags, '$.13'), i.value5 = JSON_VALUE(vValues, '$.5'), i.value6 = JSON_VALUE(vValues, '$.6'), i.value7 = JSON_VALUE(vValues, '$.7'), i.value8 = JSON_VALUE(vValues, '$.8'), i.value9 = JSON_VALUE(vValues, '$.9'), i.value10 = JSON_VALUE(vValues, '$.10'), + i.value11 = JSON_VALUE(vValues, '$.11'), + i.value12 = JSON_VALUE(vValues, '$.12'), + i.value13 = JSON_VALUE(vValues, '$.13'), i.producerFk = p.id, i.inkFk = k.id, i.originFk = IFNULL(o.id, i.originFk) diff --git a/db/routines/vn/procedures/item_refreshTags.sql b/db/routines/vn/procedures/item_refreshTags.sql index 84ace0883..188242866 100644 --- a/db/routines/vn/procedures/item_refreshTags.sql +++ b/db/routines/vn/procedures/item_refreshTags.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_refreshTags`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_refreshTags`() BEGIN /** * Update item table, tag "cache" fields diff --git a/db/routines/vn/procedures/item_saveReference.sql b/db/routines/vn/procedures/item_saveReference.sql index 52416b637..4a4a5d1d7 100644 --- a/db/routines/vn/procedures/item_saveReference.sql +++ b/db/routines/vn/procedures/item_saveReference.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_saveReference`(vBarcode VARCHAR(22), vReference VARCHAR(150)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_saveReference`(vBarcode VARCHAR(22), vReference VARCHAR(150)) BEGIN /** diff --git a/db/routines/vn/procedures/item_setGeneric.sql b/db/routines/vn/procedures/item_setGeneric.sql index 9a78b1349..6f6600759 100644 --- a/db/routines/vn/procedures/item_setGeneric.sql +++ b/db/routines/vn/procedures/item_setGeneric.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_setGeneric`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_setGeneric`(vSelf INT) BEGIN /** * Asigna el código genérico a un item, salvo que sea un código de item genérico. diff --git a/db/routines/vn/procedures/item_setVisibleDiscard.sql b/db/routines/vn/procedures/item_setVisibleDiscard.sql index 0a6c54971..976cb5014 100644 --- a/db/routines/vn/procedures/item_setVisibleDiscard.sql +++ b/db/routines/vn/procedures/item_setVisibleDiscard.sql @@ -1,12 +1,13 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_setVisibleDiscard`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_setVisibleDiscard`( vItemFk INT, vWarehouseFk INT, vQuantity INT, vAddressFk INT) BEGIN /** - * Procedimiento para dar dar de baja/alta un item, si vAddressFk es NULL se entiende que se da de alta y se toma el addressFk de la configuración + * Procedimiento para dar dar de baja/alta un item, si vAdressFk es NULL + * se entiende que se da de alta y se toma el addressFk de la configuración * * @param vItemFk Identificador del ítem * @param vWarehouseFk id del warehouse diff --git a/db/routines/vn/procedures/item_updatePackingType.sql b/db/routines/vn/procedures/item_updatePackingType.sql index 12a5e687b..021bab11c 100644 --- a/db/routines/vn/procedures/item_updatePackingType.sql +++ b/db/routines/vn/procedures/item_updatePackingType.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_updatePackingType`(vItem INT, vItemPackingTypeFk VARCHAR(1)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_updatePackingType`(vItem INT, vItemPackingTypeFk VARCHAR(1)) BEGIN /** * Update the packing type of an item diff --git a/db/routines/vn/procedures/item_ValuateInventory.sql b/db/routines/vn/procedures/item_valuateInventory.sql similarity index 67% rename from db/routines/vn/procedures/item_ValuateInventory.sql rename to db/routines/vn/procedures/item_valuateInventory.sql index bfd96fa82..5642ba812 100644 --- a/db/routines/vn/procedures/item_ValuateInventory.sql +++ b/db/routines/vn/procedures/item_valuateInventory.sql @@ -1,5 +1,9 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_ValuateInventory`(vDated DATE, vIsDetailed BOOLEAN) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_valuateInventory`( + vDated DATE, + vItemTypeFk INT, + vItemCategoryFk INT +) BEGIN DECLARE vInventoried DATE; DECLARE vHasNotInventory BOOLEAN DEFAULT FALSE; @@ -15,8 +19,7 @@ BEGIN SELECT tr.landed INTO vInventoried FROM travel tr JOIN `entry` e ON e.travelFk = tr.id - JOIN entryConfig ec - WHERE landed <= vDateDayEnd + WHERE tr.landed <= vDateDayEnd AND e.supplierFk = vInventorySupplierFk ORDER BY tr.landed DESC LIMIT 1; @@ -27,8 +30,7 @@ BEGIN SELECT landed INTO vInventoryClone FROM travel tr JOIN `entry` e ON e.travelFk = tr.id - JOIN entryConfig ec - WHERE landed >= vDated + WHERE tr.landed >= vDated AND e.supplierFk = vInventorySupplierFk ORDER BY landed ASC LIMIT 1; @@ -38,13 +40,14 @@ BEGIN END IF; CREATE OR REPLACE TEMPORARY TABLE tInventory( - warehouseFk SMALLINT, - itemFk BIGINT, - quantity INT, - cost DOUBLE DEFAULT 0, - total DOUBLE DEFAULT 0, - warehouseInventory VARCHAR(20), - PRIMARY KEY (warehouseInventory, itemFk) USING HASH + warehouseFk SMALLINT, + itemFk BIGINT, + quantity INT, + volume DECIMAL(10,2), + cost DOUBLE DEFAULT 0, + total DOUBLE DEFAULT 0, + warehouseInventory VARCHAR(20), + PRIMARY KEY (warehouseInventory, itemFk) USING HASH ) ENGINE = MEMORY; @@ -60,12 +63,14 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN itemType t ON t.id = i.typeFk - JOIN warehouse w ON w.id = warehouseInFk - JOIN entryConfig ec - WHERE landed = vDateDayEnd + JOIN itemCategory ic ON ic.id = t.categoryFk + JOIN warehouse w ON w.id = tr.warehouseInFk + WHERE tr.landed = vDateDayEnd AND e.supplierFk = vInventorySupplierFk AND w.valuatedInventory AND t.isInventory + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) GROUP BY tr.warehouseInFk, b.itemFk; ELSE INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) @@ -78,12 +83,14 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN itemType t ON t.id = i.typeFk - JOIN warehouse w ON w.id = warehouseInFk - JOIN entryConfig ec - WHERE landed = vInventoried + JOIN itemCategory ic ON ic.id = t.categoryFk + JOIN warehouse w ON w.id = tr.warehouseInFk + WHERE tr.landed = vInventoried AND e.supplierFk = vInventorySupplierFk AND w.valuatedInventory AND t.isInventory + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) GROUP BY tr.warehouseInFk, b.itemFk; END IF; @@ -98,14 +105,16 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN itemType t ON t.id = i.typeFk + JOIN itemCategory ic ON ic.id = t.categoryFk JOIN warehouse w ON w.id = tr.warehouseInFk - JOIN entryConfig ec WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE) AND NOT e.isRaid AND w.valuatedInventory AND t.isInventory AND e.supplierFk <> vInventorySupplierFk + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity * IF(vHasNotInventory, -1, 1)); -- Descontamos las salidas @@ -119,11 +128,14 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN itemType t ON t.id = i.typeFk + JOIN itemCategory ic ON ic.id = t.categoryFk JOIN warehouse w ON w.id = tr.warehouseOutFk WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd AND NOT e.isRaid AND w.valuatedInventory AND t.isInventory + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity * IF(vHasNotInventory,1,-1)); -- Descontamos las lineas de venta @@ -137,10 +149,13 @@ BEGIN JOIN `client` c ON c.id = t.clientFk JOIN item i ON i.id = s.itemFk JOIN itemType it ON it.id = i.typeFk + JOIN itemCategory ic ON ic.id = it.categoryFk JOIN warehouse w ON w.id = t.warehouseFk WHERE t.shipped BETWEEN vInventoried AND vDateDayEnd AND w.valuatedInventory AND it.isInventory + AND (it.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 1, -1); -- Volver a poner lo que esta aun en las estanterias @@ -155,11 +170,14 @@ BEGIN JOIN `client` c ON c.id = t.clientFk JOIN item i ON i.id = s.itemFk JOIN itemType it ON it.id = i.typeFk + JOIN itemCategory ic ON ic.id = it.categoryFk JOIN warehouse w ON w.id = t.warehouseFk WHERE t.shipped BETWEEN vDated AND vDateDayEnd AND NOT (s.isPicked OR t.isLabeled) AND w.valuatedInventory AND it.isInventory + AND (it.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 0, 1); END IF; @@ -174,6 +192,7 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN itemType t ON t.id = i.typeFk + JOIN itemCategory ic ON ic.id = t.categoryFk JOIN warehouse wIn ON wIn.id = tr.warehouseInFk JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk WHERE vDated >= tr.shipped AND vDated < tr.landed @@ -181,54 +200,42 @@ BEGIN AND wIn.valuatedInventory AND t.isInventory AND e.isConfirmed + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity); - CALL vn.buyUltimate(NULL, vDateDayEnd); + CALL buy_getUltimate (NULL, NULL, vDateDayEnd); + + DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity; UPDATE tInventory i JOIN tmp.buyUltimate bu ON i.warehouseFk = bu.warehouseFk AND i.itemFk = bu.itemFk JOIN buy b ON b.id = bu.buyFk - SET total = i.quantity * (IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0)), - cost = IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0) - WHERE i.quantity; + LEFT JOIN itemCost ic ON ic.itemFk = i.itemFk + AND ic.warehouseFk = i.warehouseFk + SET i.total = i.quantity * (IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0)), + i.cost = IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0), + i.volume = i.quantity * ic.cm3delivery / 1000000; - DELETE FROM tInventory - WHERE quantity IS NULL OR NOT quantity; - - IF vIsDetailed THEN - SELECT ti.warehouseFk, - i.id itemFk, - i.longName, - i.size, - ti.quantity, - tp.name Tipo, - ic.name Reino, - ti.cost, - CAST(ti.total AS DECIMAL(10, 2)) total, - ti.warehouseInventory almacen - FROM tInventory ti - JOIN warehouse w ON w.id = warehouseFk - JOIN item i ON i.id = ti.itemFk - JOIN itemType tp ON tp.id = i.typeFk - JOIN itemCategory ic ON ic.id = tp.categoryFk - WHERE w.valuatedInventory - AND ti.total > 0 - ORDER BY ti.total DESC; - ELSE - SELECT i.warehouseInventory Almacen, - ic.name Reino, - CAST(i.total AS DECIMAL(10, 2)) Euros, - w.code Comprador, - it.id - FROM tInventory i - JOIN warehouse wh ON wh.id = warehouseFk - JOIN item it ON it.id = i.itemFk - JOIN itemType itp ON itp.id = it.typeFk - LEFT JOIN worker w ON w.id = itp.workerFk - JOIN itemCategory ic ON ic.id = itp.categoryFk - WHERE wh.valuatedInventory - AND i.total > 0; - END IF; + SELECT ti.warehouseFk, + i.id, + i.longName, + i.size, + ti.quantity, + ti.volume, + tp.name itemTypeName, + ic.name itemCategoryName, + ti.cost, + ti.total, + ti.warehouseInventory, + ic.display + FROM tInventory ti + JOIN warehouse w ON w.id = warehouseFk + JOIN item i ON i.id = ti.itemFk + JOIN itemType tp ON tp.id = i.typeFk + JOIN itemCategory ic ON ic.id = tp.categoryFk + WHERE w.valuatedInventory + AND ti.total > 0; DROP TEMPORARY TABLE tmp.buyUltimate, diff --git a/db/routines/vn/procedures/item_zoneClosure.sql b/db/routines/vn/procedures/item_zoneClosure.sql index c555e5df2..6b33f1b0a 100644 --- a/db/routines/vn/procedures/item_zoneClosure.sql +++ b/db/routines/vn/procedures/item_zoneClosure.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_zoneClosure`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_zoneClosure`() BEGIN /* Devuelve una tabla temporal con la hora minima de un ticket sino tiene el de la zoneClosure y diff --git a/db/routines/vn/procedures/ledger_doCompensation.sql b/db/routines/vn/procedures/ledger_doCompensation.sql index 80475ac08..c2149a1f1 100644 --- a/db/routines/vn/procedures/ledger_doCompensation.sql +++ b/db/routines/vn/procedures/ledger_doCompensation.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_doCompensation`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ledger_doCompensation`( vDated DATE, vCompensationAccount VARCHAR(10), vBankFk VARCHAR(10), @@ -28,7 +28,7 @@ BEGIN DECLARE vIsOriginalAClient BOOL; DECLARE vPayMethodCompensation INT; - CALL ledger_next(YEAR(vDated), vNewBookEntry); + CALL ledger_nextTx(YEAR(vDated), vNewBookEntry); SELECT COUNT(id) INTO vIsOriginalAClient FROM client diff --git a/db/routines/vn/procedures/ledger_next.sql b/db/routines/vn/procedures/ledger_next.sql index 5cde90def..34fbb1cdc 100644 --- a/db/routines/vn/procedures/ledger_next.sql +++ b/db/routines/vn/procedures/ledger_next.sql @@ -1,13 +1,35 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ledger_next`( IN vFiscalYear INT, - OUT vNewBookEntry INT + OUT vLastBookEntry INT ) +/** + * Devuelve un número de asiento válido, según el contador de asientos + * tabla vn.ledgerConfig, si no existe lo inicializa a 1 + * No inicia transacción, para transaccionar usar vn.ledger_nextTx + * + * @param vFiscalYear Id del año contable + * @return vLastBookEntry Id del asiento + */ BEGIN - UPDATE ledgerCompany - SET bookEntry = LAST_INSERT_ID(bookEntry + 1) - WHERE fiscalYear = vFiscalYear; + IF vFiscalYear IS NULL THEN + CALL util.throw('Fiscal year is required'); + END IF; - SET vNewBookEntry = LAST_INSERT_ID(); + SELECT bookEntry + 1 INTO vLastBookEntry + FROM ledgerCompany + WHERE fiscalYear = vFiscalYear + FOR UPDATE; + + IF vLastBookEntry IS NULL THEN + INSERT INTO ledgerCompany + SET fiscalYear = vFiscalYear, + bookEntry = 1; + SET vLastBookEntry = 1; + END IF; + + UPDATE ledgerCompany + SET bookEntry = vLastBookEntry + WHERE fiscalYear = vFiscalYear; END$$ -DELIMITER ; +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ledger_nextTx.sql b/db/routines/vn/procedures/ledger_nextTx.sql new file mode 100644 index 000000000..0a32861a3 --- /dev/null +++ b/db/routines/vn/procedures/ledger_nextTx.sql @@ -0,0 +1,30 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ledger_nextTx`( + IN vFiscalYear INT, + OUT vLastBookEntry INT +) +/** + * Devuelve un número de asiento válido, según el contador de asientos + * tabla vn.ledgerConfig, si no existe lo inicializa a 1 + * Lo hace transaccionando el proceso + * + * @param vFiscalYear Id del año contable + * @return vLastBookEntry Id del asiento + */ +BEGIN + DECLARE vIsRequiredTx BOOL DEFAULT NOT @@in_transaction; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + CALL util.tx_rollback(vIsRequiredTx); + RESIGNAL; + END; + + IF vFiscalYear IS NULL THEN + CALL util.throw('Fiscal year is required'); + END IF; + + CALL util.tx_start(vIsRequiredTx); + CALL ledger_next(vFiscalYear, vLastBookEntry); + CALL util.tx_commit(vIsRequiredTx); +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/logShow.sql b/db/routines/vn/procedures/logShow.sql index 836d3b0c4..0aad86095 100644 --- a/db/routines/vn/procedures/logShow.sql +++ b/db/routines/vn/procedures/logShow.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`logShow`(vOriginFk INT, vEntity VARCHAR(45)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`logShow`(vOriginFk INT, vEntity VARCHAR(45)) BEGIN /** * Muestra las acciones realizadas por el usuario diff --git a/db/routines/vn/procedures/lungSize_generator.sql b/db/routines/vn/procedures/lungSize_generator.sql index e13e83650..e3f2009e1 100644 --- a/db/routines/vn/procedures/lungSize_generator.sql +++ b/db/routines/vn/procedures/lungSize_generator.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`lungSize_generator`(vDate DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`lungSize_generator`(vDate DATE) BEGIN SET @buildingOrder := 0; diff --git a/db/routines/vn/procedures/machineWorker_add.sql b/db/routines/vn/procedures/machineWorker_add.sql index b2a7c7e19..41000f556 100644 --- a/db/routines/vn/procedures/machineWorker_add.sql +++ b/db/routines/vn/procedures/machineWorker_add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`machineWorker_add`(vPlate VARCHAR(10), vWorkerFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`machineWorker_add`(vPlate VARCHAR(10), vWorkerFk INT) BEGIN /** diff --git a/db/routines/vn/procedures/machineWorker_getHistorical.sql b/db/routines/vn/procedures/machineWorker_getHistorical.sql index 47fcec5b6..67b1971a2 100644 --- a/db/routines/vn/procedures/machineWorker_getHistorical.sql +++ b/db/routines/vn/procedures/machineWorker_getHistorical.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`machineWorker_getHistorical`(vPlate VARCHAR(20), vWorkerFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`machineWorker_getHistorical`(vPlate VARCHAR(20), vWorkerFk INT) BEGIN /** * Obtiene historial de la matrícula vPlate que el trabajador vWorkerFk escanea, diff --git a/db/routines/vn/procedures/machineWorker_update.sql b/db/routines/vn/procedures/machineWorker_update.sql index 064aa8931..f1a6e40b5 100644 --- a/db/routines/vn/procedures/machineWorker_update.sql +++ b/db/routines/vn/procedures/machineWorker_update.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`machineWorker_update`(vPlate VARCHAR(10), vWorkerFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`machineWorker_update`(vPlate VARCHAR(10), vWorkerFk INT) BEGIN /** diff --git a/db/routines/vn/procedures/machine_getWorkerPlate.sql b/db/routines/vn/procedures/machine_getWorkerPlate.sql index 4a50e0334..cbb71c4cf 100644 --- a/db/routines/vn/procedures/machine_getWorkerPlate.sql +++ b/db/routines/vn/procedures/machine_getWorkerPlate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`machine_getWorkerPlate`(vWorkerFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`machine_getWorkerPlate`(vWorkerFk INT) BEGIN /** * Selecciona la matrícula del vehículo del workerfk diff --git a/db/routines/vn/procedures/mail_insert.sql b/db/routines/vn/procedures/mail_insert.sql index 5c5c2e9fd..8af84e145 100644 --- a/db/routines/vn/procedures/mail_insert.sql +++ b/db/routines/vn/procedures/mail_insert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`mail_insert`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`mail_insert`( vReceiver VARCHAR(255), vReplyTo VARCHAR(50), vSubject VARCHAR(100), diff --git a/db/routines/vn/procedures/makeNewItem.sql b/db/routines/vn/procedures/makeNewItem.sql index 5995f43b7..6e5c5b244 100644 --- a/db/routines/vn/procedures/makeNewItem.sql +++ b/db/routines/vn/procedures/makeNewItem.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`makeNewItem`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`makeNewItem`() BEGIN DECLARE newItemFk INT; diff --git a/db/routines/vn/procedures/makePCSGraf.sql b/db/routines/vn/procedures/makePCSGraf.sql index 31b4a42e7..7fbef5ec0 100644 --- a/db/routines/vn/procedures/makePCSGraf.sql +++ b/db/routines/vn/procedures/makePCSGraf.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`makePCSGraf`(vDated DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`makePCSGraf`(vDated DATE) BEGIN diff --git a/db/routines/vn/procedures/manaSpellersRequery.sql b/db/routines/vn/procedures/manaSpellersRequery.sql index 30b91b4f1..4bb64d454 100644 --- a/db/routines/vn/procedures/manaSpellersRequery.sql +++ b/db/routines/vn/procedures/manaSpellersRequery.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`manaSpellersRequery`(vWorkerFk INTEGER) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`manaSpellersRequery`(vWorkerFk INTEGER) `whole_proc`: BEGIN /** diff --git a/db/routines/vn/procedures/multipleInventory.sql b/db/routines/vn/procedures/multipleInventory.sql index 2a28aa9a0..c051706b7 100644 --- a/db/routines/vn/procedures/multipleInventory.sql +++ b/db/routines/vn/procedures/multipleInventory.sql @@ -1,15 +1,16 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventory`( +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`multipleInventory`( vDate DATE, vWarehouseFk TINYINT, vMaxDays TINYINT -) +) proc: BEGIN DECLARE vDateTomorrow DATE DEFAULT vDate + INTERVAL 1 DAY; DECLARE vDateFrom DATE DEFAULT vDate; DECLARE vDateTo DATETIME; DECLARE vDateToTomorrow DATETIME; DECLARE vDefaultDayRange INT; + DECLARE vCalcFk INT; IF vDate < util.VN_CURDATE() THEN LEAVE proc; @@ -36,9 +37,11 @@ proc: BEGIN ADD `life` TINYINT NOT NULL DEFAULT '0'; -- Calculo del inventario - UPDATE tmp.itemInventory ai - JOIN ( - SELECT itemFk Id_Article, SUM(quantity) Subtotal + CREATE OR REPLACE TEMPORARY TABLE tItemInventoryCalc + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT itemFk, + SUM(quantity) quantity FROM ( SELECT s.itemFk, - s.quantity quantity FROM sale s @@ -69,56 +72,26 @@ proc: BEGIN AND w.isComparative AND NOT e.isExcludedFromAvailable AND NOT e.isRaid - ) sub2 - GROUP BY itemFk - ) sub ON ai.id = sub.Id_Article - SET ai.inventory = sub.Subtotal, - ai.visible = sub.Subtotal, - ai.avalaible = sub.Subtotal, - ai.sd = sub.Subtotal; + ) sub + GROUP BY itemFk; -- Cálculo del visible - UPDATE tmp.itemInventory ai - JOIN ( - SELECT itemFk Id_Article, SUM(quantity) Subtotal - FROM ( - SELECT s.itemFk, s.quantity - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - JOIN warehouse w ON w.id = t.warehouseFk - WHERE t.shipped >= vDate - AND t.shipped < vDateTomorrow - AND (NOT isPicked AND NOT t.isLabeled AND t.refFk IS NULL) - AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk - AND w.isComparative - UNION ALL - SELECT b.itemFk, - b.quantity - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseInFk - WHERE t.landed = vDate - AND NOT t.isReceived - AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid - AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk - AND w.isComparative - UNION ALL - SELECT b.itemFk, b.quantity - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseOutFk - WHERE t.shipped = vDate - AND NOT t.isReceived - AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid - AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk - AND w.isComparative - ) sub2 - GROUP BY itemFk - ) sub ON ai.id = sub.Id_Article - SET ai.visible = ai.visible + sub.Subtotal; + CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk); + + CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc + (PRIMARY KEY (item_id)) + ENGINE = MEMORY + SELECT item_id, visible + FROM cache.visible + WHERE calc_id = vCalcFk; + + UPDATE tmp.itemInventory it + LEFT JOIN tItemInventoryCalc iic ON iic.itemFk = it.id + LEFT JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id + SET it.inventory = iic.quantity, + it.visible = ivc.visible, + it.avalaible = iic.quantity, + it.sd = iic.quantity; -- Calculo del disponible CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc @@ -166,29 +139,35 @@ proc: BEGIN CALL item_getAtp(vDate); CALL travel_upcomingArrivals(vWarehouseFk, vDate); - UPDATE tmp.itemInventory ai - JOIN ( - SELECT it.itemFk, - SUM(it.quantity) quantity, - im.quantity minQuantity - FROM tmp.itemCalc it - JOIN tmp.itemAtp im ON im.itemFk = it.itemFk - JOIN item i ON i.id = it.itemFk - LEFT JOIN origin o ON o.id = i.originFk - LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk - WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL, - t.landing, - vDateToTomorrow) - GROUP BY it.itemFk - ) sub ON sub.itemFk = ai.id - SET ai.avalaible = IF(sub.minQuantity > 0, - ai.avalaible, - ai.avalaible + sub.minQuantity), - ai.sd = ai.inventory + sub.quantity; + CREATE OR REPLACE TEMPORARY TABLE tItemAvailableCalc + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT it.itemFk, + SUM(it.quantity) quantity, + im.quantity minQuantity + FROM tmp.itemCalc it + JOIN tmp.itemAtp im ON im.itemFk = it.itemFk + JOIN item i ON i.id = it.itemFk + LEFT JOIN origin o ON o.id = i.originFk + LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk + WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL, + t.landing, + vDateToTomorrow) + GROUP BY it.itemFk; + + UPDATE tmp.itemInventory it + JOIN tItemAvailableCalc iac ON iac.itemFk = it.id + SET it.avalaible = IF(iac.minQuantity > 0, + it.avalaible, + it.avalaible + iac.minQuantity), + it.sd = it.inventory + iac.quantity; DROP TEMPORARY TABLE tmp.itemTravel, tmp.itemCalc, - tmp.itemAtp; -END$$ -DELIMITER ; + tmp.itemAtp, + tItemInventoryCalc, + tItemVisibleCalc, + tItemAvailableCalc; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/mysqlConnectionsSorter_kill.sql b/db/routines/vn/procedures/mysqlConnectionsSorter_kill.sql index 129b356f2..0dbe34bdd 100644 --- a/db/routines/vn/procedures/mysqlConnectionsSorter_kill.sql +++ b/db/routines/vn/procedures/mysqlConnectionsSorter_kill.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`mysqlConnectionsSorter_kill`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`mysqlConnectionsSorter_kill`() BEGIN /** diff --git a/db/routines/vn/procedures/mysqlPreparedCount_check.sql b/db/routines/vn/procedures/mysqlPreparedCount_check.sql index b0c78946d..c388036a5 100644 --- a/db/routines/vn/procedures/mysqlPreparedCount_check.sql +++ b/db/routines/vn/procedures/mysqlPreparedCount_check.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`mysqlPreparedCount_check`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`mysqlPreparedCount_check`() BEGIN DECLARE vPreparedCount INTEGER; diff --git a/db/routines/vn/procedures/nextShelvingCodeMake.sql b/db/routines/vn/procedures/nextShelvingCodeMake.sql index d76d6276b..5fc90beac 100644 --- a/db/routines/vn/procedures/nextShelvingCodeMake.sql +++ b/db/routines/vn/procedures/nextShelvingCodeMake.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`nextShelvingCodeMake`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`nextShelvingCodeMake`() BEGIN DECLARE newShelving VARCHAR(3); diff --git a/db/routines/vn/procedures/observationAdd.sql b/db/routines/vn/procedures/observationAdd.sql index 960cf0bfe..98935436c 100644 --- a/db/routines/vn/procedures/observationAdd.sql +++ b/db/routines/vn/procedures/observationAdd.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`observationAdd`(vOriginFk INT, vTableCode VARCHAR(45), vDescription TEXT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`observationAdd`(vOriginFk INT, vTableCode VARCHAR(45), vDescription TEXT) BEGIN /** * Guarda las observaciones realizadas por el usuario diff --git a/db/routines/vn/procedures/orderCreate.sql b/db/routines/vn/procedures/orderCreate.sql index 8f732dad6..87f98673b 100644 --- a/db/routines/vn/procedures/orderCreate.sql +++ b/db/routines/vn/procedures/orderCreate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`orderCreate`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`orderCreate`( vLanded DATE, vAgencyMode INT, vAddress INT, diff --git a/db/routines/vn/procedures/orderDelete.sql b/db/routines/vn/procedures/orderDelete.sql index 4264191da..95f800395 100644 --- a/db/routines/vn/procedures/orderDelete.sql +++ b/db/routines/vn/procedures/orderDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`orderDelete`(IN vId INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`orderDelete`(IN vId INT) BEGIN DELETE FROM hedera.`order` where id = vId; diff --git a/db/routines/vn/procedures/orderListCreate.sql b/db/routines/vn/procedures/orderListCreate.sql index 12396ea90..aa7d1284d 100644 --- a/db/routines/vn/procedures/orderListCreate.sql +++ b/db/routines/vn/procedures/orderListCreate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`orderListCreate`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`orderListCreate`( vLanded DATE, vAgencyMode INT, vAddress INT, diff --git a/db/routines/vn/procedures/orderListVolume.sql b/db/routines/vn/procedures/orderListVolume.sql index 6eb641f83..946f20d95 100644 --- a/db/routines/vn/procedures/orderListVolume.sql +++ b/db/routines/vn/procedures/orderListVolume.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`orderListVolume`(IN vOrderId INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`orderListVolume`(IN vOrderId INT) BEGIN SELECT diff --git a/db/routines/vn/procedures/packingListSwitch.sql b/db/routines/vn/procedures/packingListSwitch.sql index 0883a7b6d..47009b007 100644 --- a/db/routines/vn/procedures/packingListSwitch.sql +++ b/db/routines/vn/procedures/packingListSwitch.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`packingListSwitch`(saleFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`packingListSwitch`(saleFk INT) BEGIN DECLARE valueFk INT; diff --git a/db/routines/vn/procedures/packingSite_startCollection.sql b/db/routines/vn/procedures/packingSite_startCollection.sql index 53edd89f1..6c613f5db 100644 --- a/db/routines/vn/procedures/packingSite_startCollection.sql +++ b/db/routines/vn/procedures/packingSite_startCollection.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`packingSite_startCollection`(vSelf INT, vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`packingSite_startCollection`(vSelf INT, vTicketFk INT) proc: BEGIN /** * @param vSelf packingSite id diff --git a/db/routines/vn/procedures/parking_add.sql b/db/routines/vn/procedures/parking_add.sql index 17772424e..38d974eb0 100644 --- a/db/routines/vn/procedures/parking_add.sql +++ b/db/routines/vn/procedures/parking_add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`parking_add`(vFromColumn INT, vToColumn INT, vFromRow INT, vToRow INT, vSectorFk INT, vIsLetterMode BOOLEAN) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`parking_add`(vFromColumn INT, vToColumn INT, vFromRow INT, vToRow INT, vSectorFk INT, vIsLetterMode BOOLEAN) BEGIN DECLARE vColumn INT; diff --git a/db/routines/vn/procedures/parking_algemesi.sql b/db/routines/vn/procedures/parking_algemesi.sql index 6ea13193d..b9087f57a 100644 --- a/db/routines/vn/procedures/parking_algemesi.sql +++ b/db/routines/vn/procedures/parking_algemesi.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`parking_algemesi`(vFromRow INT, vToRow INT, vSectorFk INT, vLetter VARCHAR(1), vPickingOrder INT, vTrolleysByLine INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`parking_algemesi`(vFromRow INT, vToRow INT, vSectorFk INT, vLetter VARCHAR(1), vPickingOrder INT, vTrolleysByLine INT) BEGIN DECLARE vRow INT; diff --git a/db/routines/vn/procedures/parking_new.sql b/db/routines/vn/procedures/parking_new.sql index 327e3a4b0..ba7101828 100644 --- a/db/routines/vn/procedures/parking_new.sql +++ b/db/routines/vn/procedures/parking_new.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`parking_new`(vStart INT, vEnd INT, vSectorFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`parking_new`(vStart INT, vEnd INT, vSectorFk INT) BEGIN DECLARE vRow INT; diff --git a/db/routines/vn/procedures/parking_setOrder.sql b/db/routines/vn/procedures/parking_setOrder.sql index 241f855f7..26c601abd 100644 --- a/db/routines/vn/procedures/parking_setOrder.sql +++ b/db/routines/vn/procedures/parking_setOrder.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`parking_setOrder`(vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`parking_setOrder`(vWarehouseFk INT) BEGIN /* diff --git a/db/routines/vn/procedures/payment_add.sql b/db/routines/vn/procedures/payment_add.sql index 061a75848..769b72241 100644 --- a/db/routines/vn/procedures/payment_add.sql +++ b/db/routines/vn/procedures/payment_add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`payment_add`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`payment_add`( vDated DATE, vSupplierFk INT, vAmount DOUBLE, diff --git a/db/routines/vn/procedures/prepareClientList.sql b/db/routines/vn/procedures/prepareClientList.sql index 486152fd6..d4576999c 100644 --- a/db/routines/vn/procedures/prepareClientList.sql +++ b/db/routines/vn/procedures/prepareClientList.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`prepareClientList`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`prepareClientList`() BEGIN /* diff --git a/db/routines/vn/procedures/prepareTicketList.sql b/db/routines/vn/procedures/prepareTicketList.sql index f0f47f9a2..7c44bb994 100644 --- a/db/routines/vn/procedures/prepareTicketList.sql +++ b/db/routines/vn/procedures/prepareTicketList.sql @@ -1,19 +1,21 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`prepareTicketList`(vStartingDate DATETIME, vEndingDate DATETIME) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`prepareTicketList`(vStartingDate DATETIME, vEndingDate DATETIME) BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.productionTicket; CREATE TEMPORARY TABLE tmp.productionTicket (PRIMARY KEY (ticketFk)) ENGINE = MEMORY SELECT t.id ticketFk, t.clientFk - FROM vn.ticket t - LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id - JOIN vn.client c ON c.id = t.clientFk + FROM ticket t + JOIN alertLevel al ON al.code = 'DELIVERED' + LEFT JOIN ticketState ts ON ts.ticketFk = t.id + JOIN client c ON c.id = t.clientFk + WHERE c.typeFk IN ('normal','handMaking','internalUse') AND ( t.shipped BETWEEN util.VN_CURDATE() AND vEndingDate OR ( - ts.alertLevel < 3 + ts.alertLevel < al.id AND t.shipped >= vStartingDate AND t.shipped < util.VN_CURDATE() ) diff --git a/db/routines/vn/procedures/previousSticker_get.sql b/db/routines/vn/procedures/previousSticker_get.sql index 05f7de250..ad3dbd1c4 100644 --- a/db/routines/vn/procedures/previousSticker_get.sql +++ b/db/routines/vn/procedures/previousSticker_get.sql @@ -1,58 +1,64 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`previousSticker_get`(vSaleGroupFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`previousSticker_get`( + vSaleGroupFk INT +) BEGIN /** * Devuelve los campos a imprimir en una etiqueta de preparación previa. - * Actualiza el valor de vn.saleGroup.parkingFk en el caso de que exista un + * Actualiza el valor de saleGroup.parkingFk en el caso de que exista un * saleGroup del mismo ticket con parking, del mismo sector, para que todos se * pongan juntos. * - * @param vSaleGroupFk Identificador de vn.saleGroup + * @param vSaleGroupFk Identificador de saleGroup */ DECLARE vTicketFk INT; DECLARE vParkingFk INT; DECLARE vSectorFk INT; + DECLARE vTicketLines INT; - SELECT s.ticketFk - INTO vTicketFk - FROM vn.saleGroupDetail sgd - JOIN vn.sale s ON s.id = sgd.saleFk - WHERE sgd.saleGroupFk = vSaleGroupFk - LIMIT 1; + WITH ticketData AS( + SELECT DISTINCT s.ticketFk + FROM vn.saleGroupDetail sgd + JOIN vn.sale s ON s.id = sgd.saleFk + WHERE sgd.saleGroupFk = vSaleGroupFk + ) + SELECT COUNT(*), s.ticketFk INTO vTicketLines, vTicketFk + FROM vn.sale s + JOIN ticketData td ON td.ticketFk = s.ticketFk; SELECT sg.parkingFk, sc.sectorFk INTO vParkingFk, vSectorFk - FROM vn.saleGroup sg - JOIN vn.sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sg.id - JOIN vn.sectorCollection sc ON sc.id = scsg.sectorCollectionFk - JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = sg.id - JOIN vn.sale s ON s.id = sgd.saleFk + FROM saleGroup sg + JOIN sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sg.id + JOIN sectorCollection sc ON sc.id = scsg.sectorCollectionFk + JOIN saleGroupDetail sgd ON sgd.saleGroupFk = sg.id + JOIN sale s ON s.id = sgd.saleFk WHERE s.ticketFk = vTicketFk AND sg.parkingFk IS NOT NULL LIMIT 1; - UPDATE vn.saleGroup sg + UPDATE saleGroup sg SET sg.parkingFk = vParkingFk WHERE sg.id = vSaleGroupFk AND sg.sectorFk = vSectorFk; SELECT sgd.saleGroupFk, t.id ticketFk, - p.code as location, - t.observations, + COUNT(*) previousLines, IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) shippingHour, IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) shippingMinute , IFNULL(MAX(i.itemPackingTypeFk),'H') itemPackingTypeFk , - count(*) items, + vTicketLines ticketLines, + p.code `location`, sc.description sector - FROM vn.sale s - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id - JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk - JOIN vn.sector sc ON sc.id = sg.sectorFk - JOIN vn.ticket t ON t.id = s.ticketFk - LEFT JOIN vn.parking p ON p.id = sg.parkingFk - LEFT JOIN vn.`zone` z ON z.id = t.zoneFk + FROM sale s + JOIN item i ON i.id = s.itemFk + JOIN saleGroupDetail sgd ON sgd.saleFk = s.id + JOIN saleGroup sg ON sg.id = sgd.saleGroupFk + JOIN sector sc ON sc.id = sg.sectorFk + JOIN ticket t ON t.id = s.ticketFk + LEFT JOIN parking p ON p.id = sg.parkingFk + LEFT JOIN `zone` z ON z.id = t.zoneFk WHERE sgd.saleGroupFk = vSaleGroupFk; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/printer_checkSector.sql b/db/routines/vn/procedures/printer_checkSector.sql index 40728a81a..bb8ad9d85 100644 --- a/db/routines/vn/procedures/printer_checkSector.sql +++ b/db/routines/vn/procedures/printer_checkSector.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`printer_checkSector`(vLabelerFk tinyint(3) unsigned, vSector INT(11)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`printer_checkSector`(vLabelerFk tinyint(3) unsigned, vSector INT(11)) BEGIN /** * Comprueba si la impresora pertenece al sector diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql index b42645d1e..1d206e20d 100644 --- a/db/routines/vn/procedures/productionControl.sql +++ b/db/routines/vn/procedures/productionControl.sql @@ -1,6 +1,6 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`productionControl`( - vWarehouseFk INT, +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`productionControl`( + vWarehouseFk INT, vScopeDays INT ) proc: BEGIN @@ -15,13 +15,11 @@ proc: BEGIN DECLARE vEndingDate DATETIME; DECLARE vIsTodayRelative BOOLEAN; - SELECT util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, maxProductionScopeDays) DAY - INTO vEndingDate - FROM productionConfig; - - SELECT isTodayRelative INTO vIsTodayRelative - FROM worker - WHERE id = getUser(); -- Cambiar por account.myUser_getId(), falta dar permisos + SELECT w.isTodayRelative, util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, pc.maxProductionScopeDays) DAY + INTO vIsTodayRelative,vEndingDate + FROM worker w + JOIN productionConfig pc + WHERE w.id = account.myUser_getId(); CALL prepareTicketList(util.yesterday(), vEndingDate); @@ -31,7 +29,8 @@ proc: BEGIN CALL prepareClientList(); CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems - (INDEX (ticketFk)) ENGINE = MEMORY + (INDEX (ticketFk)) + ENGINE = MEMORY SELECT tt.ticketFk, tt.clientFk, t.warehouseFk, t.shipped FROM tmp.productionTicket tt JOIN ticket t ON t.id = tt.ticketFk; @@ -67,7 +66,7 @@ proc: BEGIN wk.code salesPersonCode, p.id provinceFk, tls.productionOrder, - IFNULL(tls.alertLevel, 0) alertLevel, + IFNULL(tls.alertLevel, al.id) alertLevel, t.isBoxed palletized, IF(rm.isPickingAllowed, rm.bufferFk, NULL) ubicacion, tlu.lastUpdated, @@ -81,6 +80,7 @@ proc: BEGIN rm.bufferFk FROM tmp.productionTicket tt JOIN ticket t ON tt.ticketFk = t.id + JOIN alertLevel al ON al.code = 'FREE' LEFT JOIN ticketStateToday tst ON tst.ticketFk = t.id LEFT JOIN `state` st ON st.id = tst.state LEFT JOIN client c ON c.id = t.clientFk @@ -101,7 +101,7 @@ proc: BEGIN LEFT JOIN parking pk ON pk.id = tp.parkingFk WHERE t.warehouseFk = vWarehouseFk AND dm.code IN ('AGENCY', 'DELIVERY', 'PICKUP'); - + UPDATE tmp.productionBuffer pb JOIN ( SELECT pb.ticketFk, GROUP_CONCAT(p.code) previaParking @@ -109,12 +109,12 @@ proc: BEGIN JOIN sale s ON s.ticketFk = pb.ticketFk JOIN saleGroupDetail sgd ON sgd.saleFk = s.id JOIN saleGroup sg ON sg.id = sgd.saleGroupFk - JOIN parking p ON p.id = sg.parkingFk + JOIN parking p ON p.id = sg.parkingFk GROUP BY pb.ticketFk ) t ON t.ticketFk = pb.ticketFk SET pb.previaParking = t.previaParking; - -- Problemas por ticket + -- Problemas por ticket ALTER TABLE tmp.productionBuffer CHANGE COLUMN `problem` `problem` VARCHAR(255), ADD COLUMN `collectionH` INT, @@ -145,13 +145,19 @@ proc: BEGIN -- Líneas y volumen por ticket UPDATE tmp.productionBuffer pb JOIN ( - SELECT tt.ticketFk, - COUNT(*) `lines`, - SUM(sv.volume) m3, - IFNULL(SUM(IF(sv.isPicked, sv.volume, 0)) / SUM(sv.volume), 0) rate - FROM tmp.productionTicket tt - JOIN saleVolume sv ON sv.ticketFk = tt.ticketFk - GROUP BY tt.ticketFk + SELECT tt.ticketFk, + COUNT(*) `lines`, + SUM(s.quantity * ic.cm3delivery / 1000000) m3, + IFNULL(SUM(IF(s.isPicked, + (s.quantity * ic.cm3delivery / 1000000), + 0)) / SUM(s.quantity * ic.cm3delivery / 1000000), + 0) rate + FROM tmp.productionTicket tt + JOIN sale s ON s.ticketFk = tt.ticketFk + AND s.quantity > 0 + JOIN itemCost ic ON ic.itemFk = s.itemFk + AND ic.warehouseFk = vWarehouseFk + GROUP BY tt.ticketFk ) m ON m.ticketFk = pb.ticketFk SET pb.`lines` = m.`lines`, pb.m3 = m.m3, @@ -161,27 +167,30 @@ proc: BEGIN WHERE NOT `lines`; -- Lineas por linea de encajado + CREATE OR REPLACE TEMPORARY TABLE tItemPackingType + (PRIMARY KEY(ticketFk)) + ENGINE = MEMORY + SELECT ticketFk, + SUM(sub.H) H, + SUM(sub.V) V, + SUM(sub.N) N + FROM ( + SELECT t.ticketFk, + SUM(i.itemPackingTypeFk = 'H') H, + SUM(i.itemPackingTypeFk = 'V') V, + SUM(i.itemPackingTypeFk IS NULL) N + FROM tmp.productionTicket t + JOIN sale s ON s.ticketFk = t.ticketFk + JOIN item i ON i.id = s.itemFk + GROUP BY t.ticketFk, i.itemPackingTypeFk + ) sub + GROUP BY ticketFk; + UPDATE tmp.productionBuffer pb - JOIN ( - SELECT ticketFk, - SUM(sub.H) H, - SUM(sub.V) V, - SUM(sub.N) N - FROM ( - SELECT t.ticketFk, - SUM(i.itemPackingTypeFk = 'H') H, - SUM(i.itemPackingTypeFk = 'V') V, - SUM(i.itemPackingTypeFk IS NULL) N - FROM tmp.productionTicket t - JOIN sale s ON s.ticketFk = t.ticketFk - JOIN item i ON i.id = s.itemFk - GROUP BY t.ticketFk, i.itemPackingTypeFk - ) sub - GROUP BY ticketFk - ) sub2 ON sub2.ticketFk = pb.ticketFk - SET pb.H = sub2.H, - pb.V = sub2.V, - pb.N = sub2.N; + JOIN tItemPackingType ti ON ti.ticketFk = pb.ticketFk + SET pb.H = ti.H, + pb.V = ti.V, + pb.N = ti.N; -- Colecciones segun tipo de encajado UPDATE tmp.productionBuffer pb @@ -200,8 +209,6 @@ proc: BEGIN salesInParkingCount INT DEFAULT 0) ENGINE = MEMORY; - -- Insertamos todos los tickets que tienen productos parkineados - -- en sectores de previa, segun el sector CREATE OR REPLACE TEMPORARY TABLE tItemShelvingStock (PRIMARY KEY(itemFk, sectorFk)) ENGINE = MEMORY @@ -218,6 +225,8 @@ proc: BEGIN AND ish.visible GROUP BY ish.itemFk, p.sectorFk; + CREATE INDEX idxItem ON tItemShelvingStock (itemFk); + INSERT INTO tmp.ticketWithPrevia(ticketFk, salesCount) SELECT pb.ticketFk, COUNT(DISTINCT s.id) FROM tmp.productionBuffer pb @@ -232,7 +241,6 @@ proc: BEGIN AND s.quantity > 0 GROUP BY pb.ticketFk; - -- Se calcula la cantidad de productos que estan ya preparados porque su saleGroup está aparcado UPDATE tmp.ticketWithPrevia twp JOIN ( SELECT pb.ticketFk, COUNT(DISTINCT s.id) salesInParkingCount @@ -246,18 +254,33 @@ proc: BEGIN ) sub ON twp.ticketFk = sub.ticketFk SET twp.salesInParkingCount = sub.salesInParkingCount; - -- Marcamos como pendientes aquellos que no coinciden las cantidades UPDATE tmp.productionBuffer pb JOIN tmp.ticketWithPrevia twp ON twp.ticketFk = pb.ticketFk SET pb.previousWithoutParking = TRUE WHERE twp.salesCount > twp.salesInParkingCount; + -- hasPlantTray + ALTER TABLE tmp.productionBuffer + ADD hasPlantTray BOOL DEFAULT FALSE; + + UPDATE tmp.productionBuffer pb + JOIN sale s ON s.ticketFk = pb.ticketFk + JOIN item i ON i.id = s.itemFk + JOIN cache.last_buy lb ON lb.warehouse_id = vWarehouseFk + AND lb.item_id = s.itemFk + JOIN buy b ON b.id = lb.buy_id + JOIN packaging p ON p.id = b.packagingFk + SET pb.hasPlantTray = TRUE + WHERE p.isPlantTray + AND s.quantity >= b.packing + AND pb.isOwn; + DROP TEMPORARY TABLE tmp.productionTicket, tmp.ticket, - tmp.risk, tmp.ticket_problems, tmp.ticketWithPrevia, - tItemShelvingStock; + tItemShelvingStock, + tItemPackingType; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/productionError_add.sql b/db/routines/vn/procedures/productionError_add.sql index e29accac9..e86b5ff0d 100644 --- a/db/routines/vn/procedures/productionError_add.sql +++ b/db/routines/vn/procedures/productionError_add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`productionError_add`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`productionError_add`() BEGIN DECLARE vDatedFrom DATETIME; DECLARE vDatedTo DATETIME; diff --git a/db/routines/vn/procedures/productionError_addCheckerPackager.sql b/db/routines/vn/procedures/productionError_addCheckerPackager.sql index dd75f797b..7968aec38 100644 --- a/db/routines/vn/procedures/productionError_addCheckerPackager.sql +++ b/db/routines/vn/procedures/productionError_addCheckerPackager.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`productionError_addCheckerPackager`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`productionError_addCheckerPackager`( vDatedFrom DATETIME, vDatedTo DATETIME, vRol VARCHAR(50)) diff --git a/db/routines/vn/procedures/productionSectorList.sql b/db/routines/vn/procedures/productionSectorList.sql index 5447f10d0..ed6eff147 100644 --- a/db/routines/vn/procedures/productionSectorList.sql +++ b/db/routines/vn/procedures/productionSectorList.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`productionSectorList`(vSectorFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`productionSectorList`(vSectorFk INT) BEGIN /** * Devuelve el listado de sale que se puede preparar en previa para ese sector @@ -55,7 +55,6 @@ BEGIN i.itemPackingTypeFk, isa.`size`, isa.Estado, - isa.sectorProdPriority, isa.available, isa.sectorFk, isa.matricula, @@ -104,5 +103,6 @@ BEGIN ) sub; DROP TEMPORARY TABLE tmp.whiteTicket; DROP TEMPORARY TABLE tmp.sectorTypeTicket; + DROP TEMPORARY TABLE tmp.productionBuffer; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/queueMember_updateQueue.sql b/db/routines/vn/procedures/queueMember_updateQueue.sql new file mode 100644 index 000000000..5af44da4f --- /dev/null +++ b/db/routines/vn/procedures/queueMember_updateQueue.sql @@ -0,0 +1,29 @@ +DELIMITER $$ + +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`queueMember_updateQueue`( + vBusinessFk INT +) +BEGIN + /** + * Elimina la entrada de la cola anterior y luego inserta la nueva para un trabajador. + * + * @param vBusinessFk ID del negocio + */ + DECLARE vNewQueue VARCHAR(10); + DECLARE vExtension VARCHAR(10); + DECLARE exit handler FOR SQLEXCEPTION + + SELECT d.pbxQueue, s.extension + INTO vNewQueue, vExtension + FROM business b + JOIN department d ON d.id = b.departmentFk + JOIN pbx.sip s ON s.user_id = b.workerFk + WHERE b.id = vBusinessFk; + + DELETE FROM pbx.queueMember + WHERE extension = vExtension COLLATE utf8_general_ci; + + INSERT IGNORE INTO pbx.queueMember (queue, extension) + VALUES (vNewQueue, vExtension); +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/raidUpdate.sql b/db/routines/vn/procedures/raidUpdate.sql index 703c14e5c..71352868e 100644 --- a/db/routines/vn/procedures/raidUpdate.sql +++ b/db/routines/vn/procedures/raidUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`raidUpdate`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`raidUpdate`() BEGIN /** * Actualiza el travel de las entradas de redadas diff --git a/db/routines/vn/procedures/rangeDateInfo.sql b/db/routines/vn/procedures/rangeDateInfo.sql index 502248686..a748680b0 100644 --- a/db/routines/vn/procedures/rangeDateInfo.sql +++ b/db/routines/vn/procedures/rangeDateInfo.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`rangeDateInfo`(vStarted DATE, vEnded DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`rangeDateInfo`(vStarted DATE, vEnded DATE) BEGIN /** * Crea una tabla temporal con las fechas diff --git a/db/routines/vn/procedures/rateView.sql b/db/routines/vn/procedures/rateView.sql index d840aa9d5..a92c2bd5b 100644 --- a/db/routines/vn/procedures/rateView.sql +++ b/db/routines/vn/procedures/rateView.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`rateView`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`rateView`() BEGIN /** * Muestra información sobre tasas de cambio de Dolares diff --git a/db/routines/vn/procedures/rate_getPrices.sql b/db/routines/vn/procedures/rate_getPrices.sql index c82ad918e..9674dbacf 100644 --- a/db/routines/vn/procedures/rate_getPrices.sql +++ b/db/routines/vn/procedures/rate_getPrices.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`rate_getPrices`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`rate_getPrices`( vDated DATE, vWarehouseFk INT ) diff --git a/db/routines/vn/procedures/recipe_Plaster.sql b/db/routines/vn/procedures/recipe_Plaster.sql index 18fdf55c8..c77c03ef2 100644 --- a/db/routines/vn/procedures/recipe_Plaster.sql +++ b/db/routines/vn/procedures/recipe_Plaster.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`recipe_Plaster`(vItemFk INT, vTicketFk INT, vQuantity INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`recipe_Plaster`(vItemFk INT, vTicketFk INT, vQuantity INT) BEGIN DECLARE vLastCost DECIMAL(10,2); diff --git a/db/routines/vn/procedures/remittance_calc.sql b/db/routines/vn/procedures/remittance_calc.sql index ed0a18662..ee0a65fcd 100644 --- a/db/routines/vn/procedures/remittance_calc.sql +++ b/db/routines/vn/procedures/remittance_calc.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`remittance_calc`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`remittance_calc`( vDated DATE ) BEGIN diff --git a/db/routines/vn/procedures/reportLabelCollection_get.sql b/db/routines/vn/procedures/reportLabelCollection_get.sql index e7f8f2bc3..fc6faf471 100644 --- a/db/routines/vn/procedures/reportLabelCollection_get.sql +++ b/db/routines/vn/procedures/reportLabelCollection_get.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`reportLabelCollection_get`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`reportLabelCollection_get`( vParam INT, vLabelCount INT ) @@ -47,7 +47,7 @@ BEGIN LEFT JOIN ticketTrolley tt ON tt.ticket = t.id LEFT JOIN zone zo ON t.zoneFk = zo.id LEFT JOIN routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN roadmapStop rs ON rs.id = rm.expeditionTruckFk + LEFT JOIN roadmapStop rs ON rs.id = rm.roadmapStopFk WHERE IF(vIsCollection, tc.collectionFk = vParam, tc.ticketFk = vParam) GROUP BY t.id ORDER BY cc.code; diff --git a/db/routines/vn/procedures/report_print.sql b/db/routines/vn/procedures/report_print.sql index 5d399dedf..a5e08538e 100644 --- a/db/routines/vn/procedures/report_print.sql +++ b/db/routines/vn/procedures/report_print.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`report_print`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`report_print`( vReportName VARCHAR(100), vPrinterFk INT, vUserFk INT, diff --git a/db/routines/vn/procedures/routeGuessPriority.sql b/db/routines/vn/procedures/routeGuessPriority.sql index 7208fcbcf..b5445bc50 100644 --- a/db/routines/vn/procedures/routeGuessPriority.sql +++ b/db/routines/vn/procedures/routeGuessPriority.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`routeGuessPriority`(IN vRuta INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`routeGuessPriority`(IN vRuta INT) BEGIN /* Usa los valores del ultimo año para adivinar el orden de los tickets en la ruta * vRuta id ruta diff --git a/db/routines/vn/procedures/routeInfo.sql b/db/routines/vn/procedures/routeInfo.sql index 1f25b1429..bcfba3f51 100644 --- a/db/routines/vn/procedures/routeInfo.sql +++ b/db/routines/vn/procedures/routeInfo.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`routeInfo`(vRouteFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`routeInfo`(vRouteFk INT) BEGIN DECLARE vPackages INT; diff --git a/db/routines/vn/procedures/routeMonitor_calculate.sql b/db/routines/vn/procedures/routeMonitor_calculate.sql index 04a31a161..c9a7a9ccf 100644 --- a/db/routines/vn/procedures/routeMonitor_calculate.sql +++ b/db/routines/vn/procedures/routeMonitor_calculate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`routeMonitor_calculate`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`routeMonitor_calculate`( vDate DATE, vDaysAgo INT ) @@ -106,7 +106,7 @@ BEGIN SET rm.m3boxes = sub.m3boxes; UPDATE routesMonitor rm - JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk + JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk SET rm.etd = rs.eta; DROP TEMPORARY TABLE tmp.routesMonitor; diff --git a/db/routines/vn/procedures/routeSetOk.sql b/db/routines/vn/procedures/routeSetOk.sql index 86b32fe7b..bd77c7c14 100644 --- a/db/routines/vn/procedures/routeSetOk.sql +++ b/db/routines/vn/procedures/routeSetOk.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`routeSetOk`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`routeSetOk`( vRouteFk INT) BEGIN diff --git a/db/routines/vn/procedures/routeUpdateM3.sql b/db/routines/vn/procedures/routeUpdateM3.sql index 7dbf5a194..a3f78bfa3 100644 --- a/db/routines/vn/procedures/routeUpdateM3.sql +++ b/db/routines/vn/procedures/routeUpdateM3.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`routeUpdateM3`(vRoute INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`routeUpdateM3`(vRoute INT) BEGIN /** * @deprecated Use vn.route_updateM3() diff --git a/db/routines/vn/procedures/route_calcCommission.sql b/db/routines/vn/procedures/route_calcCommission.sql index 63f702bee..7c911a5e2 100644 --- a/db/routines/vn/procedures/route_calcCommission.sql +++ b/db/routines/vn/procedures/route_calcCommission.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`route_calcCommission`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`route_calcCommission`( vSelf INT ) BEGIN diff --git a/db/routines/vn/procedures/route_doRecalc.sql b/db/routines/vn/procedures/route_doRecalc.sql index 365796f7e..03faa8df1 100644 --- a/db/routines/vn/procedures/route_doRecalc.sql +++ b/db/routines/vn/procedures/route_doRecalc.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`route_doRecalc`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`route_doRecalc`() proc: BEGIN /** * Recalculates modified route. diff --git a/db/routines/vn/procedures/route_getTickets.sql b/db/routines/vn/procedures/route_getTickets.sql index 55b08208f..136c8f520 100644 --- a/db/routines/vn/procedures/route_getTickets.sql +++ b/db/routines/vn/procedures/route_getTickets.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`route_getTickets`(vRouteFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`route_getTickets`(vRouteFk INT) BEGIN /** * Pasado un RouteFk devuelve la información diff --git a/db/routines/vn/procedures/route_updateM3.sql b/db/routines/vn/procedures/route_updateM3.sql index 92d26b753..f6842bf1d 100644 --- a/db/routines/vn/procedures/route_updateM3.sql +++ b/db/routines/vn/procedures/route_updateM3.sql @@ -1,14 +1,18 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`route_updateM3`(vRoute INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`route_updateM3`( + vSelf INT +) BEGIN +/** + * Actualiza el volumen de la ruta. + * + * @param vSelf Id ruta + */ + DECLARE vVolume DECIMAL(10,1) + DEFAULT (SELECT SUM(volume) FROM saleVolume WHERE routeFk = vSelf); - UPDATE vn.route r - LEFT JOIN ( - SELECT routeFk, SUM(volume) AS m3 - FROM saleVolume - WHERE routeFk = vRoute - ) v ON v.routeFk = r.id - SET r.m3 = IFNULL(v.m3,0) - WHERE r.id =vRoute; + UPDATE `route` + SET m3 = IFNULL(vVolume, 0) + WHERE id = vSelf; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/saleBuy_Add.sql b/db/routines/vn/procedures/saleBuy_Add.sql index 2f689ad2a..7ad1f051d 100644 --- a/db/routines/vn/procedures/saleBuy_Add.sql +++ b/db/routines/vn/procedures/saleBuy_Add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`saleBuy_Add`(vSaleFk INT, vBuyFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleBuy_Add`(vSaleFk INT, vBuyFk INT) BEGIN /* Añade un registro a la tabla saleBuy en el caso de que sea posible mantener la trazabilidad diff --git a/db/routines/vn/procedures/saleGroup_add.sql b/db/routines/vn/procedures/saleGroup_add.sql index 63e3bdedd..2057c4ac8 100644 --- a/db/routines/vn/procedures/saleGroup_add.sql +++ b/db/routines/vn/procedures/saleGroup_add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`saleGroup_add`(vSectorFk INT,vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleGroup_add`(vSectorFk INT,vTicketFk INT) BEGIN /** * Añade un nuevo registro a la tabla y devuelve su id. diff --git a/db/routines/vn/procedures/saleGroup_setParking.sql b/db/routines/vn/procedures/saleGroup_setParking.sql index 4872f74c6..889583c82 100644 --- a/db/routines/vn/procedures/saleGroup_setParking.sql +++ b/db/routines/vn/procedures/saleGroup_setParking.sql @@ -1,17 +1,20 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`saleGroup_setParking`(IN `vSaleGroupFk` VARCHAR(8), IN `vParkingFk` INT) -proc: BEGIN +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleGroup_setParking`( + vSaleGroupFk VARCHAR(8), + vParkingFk INT +) +BEGIN /** - * Aparca una preparación previa en un parking + * Aparca una preparación previa en un parking. * * @param vSaleGroupFk id de la preparación previa * @param vParkingFk id del parking */ - UPDATE vn.saleGroup sg + UPDATE saleGroup sg SET sg.parkingFk = vParkingFk - WHERE sg.id = vSaleGroupFk - AND sg.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); + WHERE sg.id = vSaleGroupFk + AND sg.created >= util.VN_CURDATE() - INTERVAL 1 WEEK; - CALL vn.ticket_setNextState(vn.ticket_get(vSaleGroupFk)); + CALL ticket_setNextState(ticket_get(vSaleGroupFk)); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/saleMistake_Add.sql b/db/routines/vn/procedures/saleMistake_Add.sql index cc174993e..93db28bb9 100644 --- a/db/routines/vn/procedures/saleMistake_Add.sql +++ b/db/routines/vn/procedures/saleMistake_Add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`saleMistake_Add`(vSaleFk INT, vUserFk INT, vTypeFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleMistake_Add`(vSaleFk INT, vUserFk INT, vTypeFk INT) BEGIN INSERT INTO vn.saleMistake(saleFk, userFk, typeFk) diff --git a/db/routines/vn/procedures/salePreparingList.sql b/db/routines/vn/procedures/salePreparingList.sql index ae3a267f3..9964c3e87 100644 --- a/db/routines/vn/procedures/salePreparingList.sql +++ b/db/routines/vn/procedures/salePreparingList.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`salePreparingList`(IN vTicketFk BIGINT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`salePreparingList`(IN vTicketFk BIGINT) BEGIN /** * Devuelve un listado con las lineas de vn.sale y los distintos estados de prepacion diff --git a/db/routines/vn/procedures/saleSplit.sql b/db/routines/vn/procedures/saleSplit.sql index dab78d811..6fa4d48b3 100644 --- a/db/routines/vn/procedures/saleSplit.sql +++ b/db/routines/vn/procedures/saleSplit.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`saleSplit`(vSaleFk INT, vQuantity INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleSplit`(vSaleFk INT, vQuantity INT) BEGIN diff --git a/db/routines/vn/procedures/saleTracking_add.sql b/db/routines/vn/procedures/saleTracking_add.sql index dc347b0e3..6b7fa5ed3 100644 --- a/db/routines/vn/procedures/saleTracking_add.sql +++ b/db/routines/vn/procedures/saleTracking_add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`saleTracking_add`(vSaleGroupFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleTracking_add`(vSaleGroupFk INT) BEGIN /** Inserta en vn.saleTracking las lineas de una previa * diff --git a/db/routines/vn/procedures/saleTracking_addPreparedSaleGroup.sql b/db/routines/vn/procedures/saleTracking_addPreparedSaleGroup.sql index b9475433c..8c5d336ab 100644 --- a/db/routines/vn/procedures/saleTracking_addPreparedSaleGroup.sql +++ b/db/routines/vn/procedures/saleTracking_addPreparedSaleGroup.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`saleTracking_addPreparedSaleGroup`(vSaleGroupFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleTracking_addPreparedSaleGroup`(vSaleGroupFk INT) BEGIN /** * Inserta lineas de vn.saleTracking para un saleGroup (previa) que escanea un sacador diff --git a/db/routines/vn/procedures/saleTracking_addPrevOK.sql b/db/routines/vn/procedures/saleTracking_addPrevOK.sql index 84cea965f..34d1cfac8 100644 --- a/db/routines/vn/procedures/saleTracking_addPrevOK.sql +++ b/db/routines/vn/procedures/saleTracking_addPrevOK.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`saleTracking_addPrevOK`(vSectorCollectionFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleTracking_addPrevOK`(vSectorCollectionFk INT) BEGIN /** * Inserta los registros de la colección de sector con el estado PREVIA OK diff --git a/db/routines/vn/procedures/saleTracking_del.sql b/db/routines/vn/procedures/saleTracking_del.sql index 263bd68a1..3c8282b1e 100644 --- a/db/routines/vn/procedures/saleTracking_del.sql +++ b/db/routines/vn/procedures/saleTracking_del.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`saleTracking_del`(vSaleFk INT, vState VARCHAR(50)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleTracking_del`(vSaleFk INT, vState VARCHAR(50)) BEGIN DELETE FROM itemShelvingSale diff --git a/db/routines/vn/procedures/saleTracking_new.sql b/db/routines/vn/procedures/saleTracking_new.sql index 5982f8df0..f43ba53fa 100644 --- a/db/routines/vn/procedures/saleTracking_new.sql +++ b/db/routines/vn/procedures/saleTracking_new.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`saleTracking_new`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleTracking_new`( vSaleFK INT, vIsChecked BOOLEAN, vOriginalQuantity INT, diff --git a/db/routines/vn/procedures/saleTracking_updateIsChecked.sql b/db/routines/vn/procedures/saleTracking_updateIsChecked.sql index 57d8df701..0d4d27f73 100644 --- a/db/routines/vn/procedures/saleTracking_updateIsChecked.sql +++ b/db/routines/vn/procedures/saleTracking_updateIsChecked.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`saleTracking_updateIsChecked`(vSaleFK INT, vIsChecked BOOL, vIsScanned BOOL) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleTracking_updateIsChecked`(vSaleFK INT, vIsChecked BOOL, vIsScanned BOOL) BEGIN /** diff --git a/db/routines/vn/procedures/sale_PriceFix.sql b/db/routines/vn/procedures/sale_PriceFix.sql index 8ffa77070..bdd7ad77f 100644 --- a/db/routines/vn/procedures/sale_PriceFix.sql +++ b/db/routines/vn/procedures/sale_PriceFix.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_PriceFix`(vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sale_PriceFix`(vTicketFk INT) BEGIN DELETE sc.* @@ -8,7 +8,7 @@ BEGIN JOIN vn.component c ON c.id = sc.componentFk JOIN vn.componentType ct ON ct.id = c.typeFk WHERE s.ticketFk = vTicketFk - AND ct.`type` = 'otros'; + AND ct.code = 'other'; UPDATE vn.sale s JOIN ( diff --git a/db/routines/vn/procedures/sale_boxPickingPrint.sql b/db/routines/vn/procedures/sale_boxPickingPrint.sql index dbb3b6c14..6bb954a78 100644 --- a/db/routines/vn/procedures/sale_boxPickingPrint.sql +++ b/db/routines/vn/procedures/sale_boxPickingPrint.sql @@ -1,6 +1,6 @@ DELIMITER $$ $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE vn.sale_boxPickingPrint( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE vn.sale_boxPickingPrint( IN vPrinterFk INT, IN vSaleFk INT, IN vPacking INT, @@ -160,7 +160,10 @@ w1: WHILE vQuantity >= vPacking DO UPDATE sale SET quantity = quantity - vPacking WHERE id = vSaleFk; - UPDATE itemShelving SET visible = visible - vPacking WHERE id = vItemShelvingFk; + UPDATE itemShelving + SET visible = visible - vPacking, + available = available - vPacking + WHERE id = vItemShelvingFk; SET vNewSaleFk = NULL; diff --git a/db/routines/vn/procedures/sale_calculateComponent.sql b/db/routines/vn/procedures/sale_calculateComponent.sql index 63786c75c..4264603cd 100644 --- a/db/routines/vn/procedures/sale_calculateComponent.sql +++ b/db/routines/vn/procedures/sale_calculateComponent.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_calculateComponent`(vSelf INT, vOption VARCHAR(25)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sale_calculateComponent`(vSelf INT, vOption VARCHAR(25)) proc: BEGIN /** * Crea tabla temporal para vn.sale_recalcComponent() para recalcular los componentes diff --git a/db/routines/vn/procedures/sale_getBoxPickingList.sql b/db/routines/vn/procedures/sale_getBoxPickingList.sql index 7466eb9be..f343ab375 100644 --- a/db/routines/vn/procedures/sale_getBoxPickingList.sql +++ b/db/routines/vn/procedures/sale_getBoxPickingList.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_getBoxPickingList`(vSectorFk INT, vDated DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sale_getBoxPickingList`(vSectorFk INT, vDated DATE) BEGIN /** * Returns a suitable boxPicking sales list @@ -19,21 +19,20 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.sale (saleFk INT PRIMARY KEY) - SELECT - s.ticketFk, - s.id saleFk, - s.itemFk, - s.concept, - s.quantity, - MAKETIME(pb.HH,pb.mm,0) etd, - pb.routeFk, - FLOOR(s.quantity / IF(i.isBoxPickingMode, ish.packing, i.packingOut)) stickers, - IF(i.isBoxPickingMode, ish.packing, i.packingOut) packing, - b.packagingFk + SELECT s.ticketFk, + s.id saleFk, + s.itemFk, + s.concept, + s.quantity, + MAKETIME(pb.HH,pb.mm,0) etd, + pb.routeFk, + FLOOR(s.quantity / IF(i.isBoxPickingMode, ish.packing, i.packingOut)) stickers, + IF(i.isBoxPickingMode, ish.packing, i.packingOut) packing, + IF(pa.isPackageReturnable, pc.defaultBigPackageFk, b.packagingFk) packagingFk FROM sale s JOIN item i ON i.id = s.itemFk JOIN itemShelving ish ON ish.itemFk = s.itemFk - LEFT JOIN ( SELECT iss.itemShelvingFk, + LEFT JOIN ( SELECT iss.itemShelvingFk, s.itemFk, SUM(iss.quantity) reserve FROM itemShelvingSale iss @@ -52,6 +51,8 @@ BEGIN LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk LEFT JOIN buy b ON b.id = lb.buy_id + LEFT JOIN packaging pa ON pa.id = b.packagingFk + JOIN packagingConfig pc WHERE IF(i.isBoxPickingMode, ish.packing, i.packingOut) <= LEAST(s.quantity, ish.visible - IFNULL(tISS.reserve,0)) AND NOT pb.problem diff --git a/db/routines/vn/procedures/sale_getFromTicketOrCollection.sql b/db/routines/vn/procedures/sale_getFromTicketOrCollection.sql index 5308bdd28..b395d5bc4 100644 --- a/db/routines/vn/procedures/sale_getFromTicketOrCollection.sql +++ b/db/routines/vn/procedures/sale_getFromTicketOrCollection.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_getFromTicketOrCollection`(vParam INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sale_getFromTicketOrCollection`(vParam INT) BEGIN /** * Visualizar lineas de la tabla sale a través del parámetro vParam que puede diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 98926b28b..b50b4784d 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -1,40 +1,34 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_getProblems`(IN vIsTodayRelative tinyint(1)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sale_getProblems`( + vIsTodayRelative tinyint(1) +) BEGIN /** * Calcula los problemas de cada venta para un conjunto de tickets. * * @param vIsTodayRelative Indica si se calcula el disponible como si todo saliera hoy - * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular + * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Tickets a calcular * @return tmp.sale_problems */ - DECLARE vWarehouseFk INT; + DECLARE vWarehouseFk INT; DECLARE vDate DATE; - DECLARE vAvailableCache INT; + DECLARE vAvailableCache INT; DECLARE vVisibleCache INT; DECLARE vDone BOOL; - DECLARE vComponentCount INT; - - DECLARE vCursor CURSOR FOR - SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, util.VN_CURDATE(), DATE(tt.shipped)) - FROM tmp.sale_getProblems tt - WHERE DATE(tt.shipped) BETWEEN util.VN_CURDATE() - AND util.VN_CURDATE() + INTERVAL IF(vIsTodayRelative, 9.9, 1.9) DAY; + DECLARE vCursor CURSOR FOR + SELECT DISTINCT warehouseFk, IF(vIsTodayRelative, util.VN_CURDATE(), DATE(shipped)) + FROM tmp.sale_getProblems + WHERE shipped BETWEEN util.VN_CURDATE() + AND util.dayEnd(util.VN_CURDATE() + INTERVAL IF(vIsTodayRelative, 9.9, 1.9) DAY); DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DELETE tt.* - FROM tmp.sale_getProblems tt - JOIN ticketObservation tto ON tto.ticketFk = tt.ticketFk - JOIN observationType ot ON ot.id = tto.observationTypeFk - WHERE ot.code = 'administrative' - AND tto.description = 'Miriam'; - CREATE OR REPLACE TEMPORARY TABLE tmp.sale_problems ( ticketFk INT(11), saleFk INT(11), isFreezed INTEGER(1) DEFAULT 0, risk DECIMAL(10,1) DEFAULT 0, + hasRisk TINYINT(1) DEFAULT 0, hasHighRisk TINYINT(1) DEFAULT 0, hasTicketRequest INTEGER(1) DEFAULT 0, itemShortage VARCHAR(255), @@ -46,104 +40,45 @@ BEGIN isTooLittle BOOL DEFAULT FALSE, isVip BOOL DEFAULT FALSE, PRIMARY KEY (ticketFk, saleFk) - ) ENGINE = MEMORY; + ); -- No memory - CREATE OR REPLACE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (ticketFk)) - ENGINE = MEMORY - SELECT ticketFk, clientFk - FROM tmp.sale_getProblems; + INSERT INTO tmp.sale_problems(ticketFk, + saleFk, + isFreezed, + risk, + hasRisk, + hasHighRisk, + hasTicketRequest, + isTaxDataChecked, + hasComponentLack, + isTooLittle) + SELECT sgp.ticketFk, + s.id, + IF(FIND_IN_SET('isFreezed', t.problem), TRUE, FALSE) isFreezed, + t.risk, + IF(FIND_IN_SET('hasRisk', t.problem), TRUE, FALSE) hasRisk, + IF(FIND_IN_SET('hasHighRisk', t.problem), TRUE, FALSE) hasHighRisk, + IF(FIND_IN_SET('hasTicketRequest', t.problem), TRUE, FALSE) hasTicketRequest, + IF(FIND_IN_SET('isTaxDataChecked', t.problem), FALSE, TRUE) isTaxDataChecked, + IF(FIND_IN_SET('hasComponentLack', s.problem), TRUE, FALSE) hasComponentLack, + IF(FIND_IN_SET('isTooLittle', t.problem) + AND util.VN_NOW() < (util.VN_CURDATE() + INTERVAL HOUR(zc.`hour`) HOUR) + INTERVAL MINUTE(zc.`hour`) MINUTE, + TRUE, FALSE) isTooLittle + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk + LEFT JOIN sale s ON s.ticketFk = t.id + LEFT JOIN item i ON i.id = s.itemFk + LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk + AND zc.dated = util.VN_CURDATE() + WHERE s.problem <> '' OR t.problem <> '' OR t.risk + GROUP BY t.id, s.id; - SELECT COUNT(*) INTO vComponentCount - FROM component - WHERE isRequired; - - -- Too Little - INSERT INTO tmp.sale_problems(ticketFk, isTooLittle) - SELECT tp.ticketFk, TRUE - FROM tmp.sale_getProblems tp - JOIN ticket t ON t.id = tp.ticketFk - JOIN ( - SELECT t.addressFk, SUM(sv.litros) litros, t.totalWithoutVat - FROM tmp.ticket_list tl - JOIN saleVolume sv ON sv.ticketFk = tl.ticketFk - JOIN ticket t ON t.id = tl.ticketFk - JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk - AND zc.dated = util.VN_CURDATE() - JOIN agencyMode am ON am.id = t.agencyModeFk - JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk - WHERE util.VN_NOW() < (util.VN_CURDATE() + INTERVAL HOUR(zc.`hour`) HOUR) + INTERVAL MINUTE(zc.`hour`) MINUTE - AND dm.code IN ('AGENCY','DELIVERY','PICKUP') - AND t.shipped BETWEEN util.VN_CURDATE() AND util.midnight() - GROUP BY t.addressFk - ) sub ON sub.addressFk = t.addressFk - JOIN volumeConfig vc - WHERE sub.litros < vc.minTicketVolume - AND sub.totalWithoutVat < vc.minTicketValue; - - -- VIP INSERT INTO tmp.sale_problems(ticketFk, isVip) - SELECT DISTINCT tl.ticketFk, TRUE - FROM tmp.ticket_list tl - JOIN client c ON c.id = tl.clientFk + SELECT sgp.ticketFk, TRUE + FROM tmp.sale_getProblems sgp + JOIN client c ON c.id = sgp.clientFk WHERE c.businessTypeFk = 'VIP' - ON DUPLICATE KEY UPDATE isVip = TRUE; - - -- Faltan componentes - INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk) - SELECT ticketFk, (vComponentCount > nComp) hasComponentLack, saleFk - FROM ( - SELECT COUNT(s.id) nComp, tl.ticketFk, s.id saleFk - FROM tmp.ticket_list tl - JOIN vn.sale s ON s.ticketFk = tl.ticketFk - LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id - LEFT JOIN vn.component c ON c.id = sc.componentFk AND c.isRequired - JOIN vn.ticket t ON t.id = tl.ticketFk - JOIN vn.agencyMode am ON am.id = t.agencyModeFk - JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk - WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP') - AND s.quantity > 0 - GROUP BY s.id - ) sub - HAVING hasComponentLack; - - -- Cliente congelado - INSERT INTO tmp.sale_problems(ticketFk, isFreezed) - SELECT DISTINCT tl.ticketFk, TRUE - FROM tmp.ticket_list tl - JOIN client c ON c.id = tl.clientFk - WHERE c.isFreezed - ON DUPLICATE KEY UPDATE isFreezed = c.isFreezed; - - -- Credit exceeded - CREATE OR REPLACE TEMPORARY TABLE tmp.clientGetDebt - (PRIMARY KEY (clientFk)) - ENGINE = MEMORY - SELECT DISTINCT clientFk - FROM tmp.ticket_list; - - CALL client_getDebt(util.VN_CURDATE()); - - INSERT INTO tmp.sale_problems(ticketFk, risk, hasHighRisk) - SELECT DISTINCT tl.ticketFk, r.risk, ((r.risk - cc.riskTolerance) > c.credit + 10) - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk - JOIN agencyMode a ON t.agencyModeFk = a.id - JOIN tmp.risk r ON r.clientFk = t.clientFk - JOIN client c ON c.id = t.clientFk - JOIN clientConfig cc - WHERE r.risk > c.credit + 10 - AND NOT a.isRiskFree - ON DUPLICATE KEY UPDATE - risk = r.risk, hasHighRisk = ((r.risk - cc.riskTolerance) > c.credit + 10); - - -- Antiguo COD 100, son peticiones de compra sin terminar - INSERT INTO tmp.sale_problems(ticketFk, hasTicketRequest) - SELECT DISTINCT tl.ticketFk, TRUE - FROM tmp.ticket_list tl - JOIN ticketRequest tr ON tr.ticketFk = tl.ticketFk - WHERE tr.isOK IS NULL - ON DUPLICATE KEY UPDATE hasTicketRequest = TRUE; + ON DUPLICATE KEY UPDATE isVIP = TRUE; CREATE OR REPLACE TEMPORARY TABLE tItemShelvingStock_byWarehouse (INDEX (itemFk, warehouseFk)) @@ -155,10 +90,9 @@ BEGIN JOIN shelving sh ON sh.code = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk JOIN sector s ON s.id = p.sectorFk - GROUP BY ish.itemFk, - s.warehouseFk; + GROUP BY ish.itemFk, s.warehouseFk; - -- Disponible, Faltas, Inventario y Retrasos + -- Disponible, faltas, inventario y retrasos OPEN vCursor; l: LOOP SET vDone = FALSE; @@ -177,14 +111,14 @@ BEGIN INSERT INTO tmp.sale_problems(ticketFk, itemShortage, saleFk) SELECT ticketFk, problem, saleFk FROM ( - SELECT tl.ticketFk, - LEFT(CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')),250) problem, - s.id AS saleFk - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk + SELECT sgp.ticketFk, + LEFT(CONCAT('F: ', GROUP_CONCAT(i.id, ' ', i.longName, ' ')), 250) problem, + s.id saleFk + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk - JOIN itemType it on it.id = i.typeFk + JOIN itemType it ON it.id = i.typeFk JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.visible v ON v.item_id = i.id AND v.calc_id = vVisibleCache @@ -192,8 +126,8 @@ BEGIN AND av.calc_id = vAvailableCache LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk - WHERE IFNULL(v.visible,0) < s.quantity - AND IFNULL(av.available ,0) < s.quantity + WHERE IFNULL(v.visible, 0) < s.quantity + AND IFNULL(av.available, 0) < s.quantity AND IFNULL(issw.visible, 0) < s.quantity AND NOT s.isPicked AND NOT s.reserved @@ -202,27 +136,27 @@ BEGIN AND NOT i.generic AND util.VN_CURDATE() = vDate AND t.warehouseFk = vWarehouseFk - GROUP BY tl.ticketFk) sub + GROUP BY sgp.ticketFk) sub ON DUPLICATE KEY UPDATE itemShortage = sub.problem, saleFk = sub.saleFk; -- Inventario: Visible suficiente, pero ubicado menor a la cantidad vendida INSERT INTO tmp.sale_problems(ticketFk, itemLost, saleFk) SELECT ticketFk, problem, saleFk FROM ( - SELECT tl.ticketFk, + SELECT sgp.ticketFk, LEFT(GROUP_CONCAT('I: ', i.id, ' ', i.longName, ' '), 250) problem, s.id saleFk - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk - JOIN itemType it on it.id = i.typeFk + JOIN itemType it ON it.id = i.typeFk JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk - WHERE IFNULL(v.visible,0) >= s.quantity + WHERE IFNULL(v.visible, 0) >= s.quantity AND IFNULL(issw.visible, 0) < s.quantity AND s.quantity > 0 AND NOT s.isPicked @@ -232,22 +166,22 @@ BEGIN AND NOT i.generic AND util.VN_CURDATE() = vDate AND t.warehouseFk = vWarehouseFk - GROUP BY tl.ticketFk + GROUP BY sgp.ticketFk ) sub - ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; + ON DUPLICATE KEY UPDATE itemLost = sub.problem, saleFk = sub.saleFk; -- Retraso: Disponible suficiente, pero no visible ni ubicado INSERT INTO tmp.sale_problems(ticketFk, itemDelay, saleFk) SELECT ticketFk, problem, saleFk FROM ( - SELECT tl.ticketFk, + SELECT sgp.ticketFk, LEFT(GROUP_CONCAT('R: ', i.id, ' ', i.longName, ' '), 250) problem, s.id saleFk - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk - JOIN itemType it on it.id = i.typeFk + JOIN itemType it ON it.id = i.typeFk JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache @@ -266,43 +200,34 @@ BEGIN AND NOT i.generic AND util.VN_CURDATE() = vDate AND t.warehouseFk = vWarehouseFk - GROUP BY tl.ticketFk + GROUP BY sgp.ticketFk ) sub ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; - -- Redondeo: Cantidad pedida incorrecta en al grouping de la última compra - CALL buyUltimate(vWarehouseFk, vDate); + -- Redondeo: cantidad incorrecta con respecto al grouping + CALL buy_getUltimate(NULL, vWarehouseFk, vDate); INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) SELECT ticketFk, problem, saleFk FROM ( - SELECT tl.ticketFk, - s.id saleFk , - LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,''), ' '), 250) problem, - MOD(s.quantity, b.`grouping`) hasRounding - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk + SELECT sgp.ticketFk, + s.id saleFk, + LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250) problem + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk AND t.warehouseFk = vWarehouseFk - JOIN sale s ON s.ticketFk = tl.ticketFk + JOIN sale s ON s.ticketFk = sgp.ticketFk JOIN item i ON i.id = s.itemFk JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk JOIN buy b ON b.id = bu.buyFk - GROUP BY tl.ticketFk - HAVING hasRounding - ) sub + WHERE MOD(s.quantity, b.`grouping`) + GROUP BY sgp.ticketFk + )sub ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk; + + DROP TEMPORARY TABLE tmp.buyUltimate; END LOOP; CLOSE vCursor; - - INSERT INTO tmp.sale_problems(ticketFk, isTaxDataChecked) - SELECT DISTINCT tl.ticketFk, FALSE - FROM tmp.ticket_list tl - JOIN client c ON c.id = tl.clientFk - WHERE NOT c.isTaxDataChecked - ON DUPLICATE KEY UPDATE isTaxDataChecked = FALSE; - DROP TEMPORARY TABLE - tmp.clientGetDebt, - tmp.ticket_list, - tItemShelvingStock_byWarehouse; + DROP TEMPORARY TABLE tItemShelvingStock_byWarehouse; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/sale_getProblemsByTicket.sql b/db/routines/vn/procedures/sale_getProblemsByTicket.sql index b4aaad7de..ff419989d 100644 --- a/db/routines/vn/procedures/sale_getProblemsByTicket.sql +++ b/db/routines/vn/procedures/sale_getProblemsByTicket.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_getProblemsByTicket`(IN vTicketFk INT, IN vIsTodayRelative TINYINT(1)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sale_getProblemsByTicket`(IN vTicketFk INT, IN vIsTodayRelative TINYINT(1)) BEGIN /** * Calcula los problemas de cada venta @@ -7,8 +7,7 @@ BEGIN * * @return Problems result */ - DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems; - CREATE TEMPORARY TABLE tmp.sale_getProblems + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems (INDEX (ticketFk)) ENGINE = MEMORY SELECT t.id ticketFk, t.clientFk, t.warehouseFk, t.shipped diff --git a/db/routines/vn/procedures/sale_recalcComponent.sql b/db/routines/vn/procedures/sale_recalcComponent.sql index 54297571a..19fadd0b9 100644 --- a/db/routines/vn/procedures/sale_recalcComponent.sql +++ b/db/routines/vn/procedures/sale_recalcComponent.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_recalcComponent`(vOption VARCHAR(25)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sale_recalcComponent`(vOption VARCHAR(25)) proc: BEGIN /** * Este procedimiento recalcula los componentes de un conjunto de sales, @@ -78,7 +78,7 @@ proc: BEGIN DROP TEMPORARY TABLE tmp.zoneGetLanded; -- rellena la tabla buyUltimate con la ultima compra - CALL buyUltimate (vWarehouseFk, vShipped); + CALL buy_getUltimate(NULL, vWarehouseFk, vShipped); CREATE OR REPLACE TEMPORARY TABLE tmp.sale (PRIMARY KEY (saleFk)) ENGINE = MEMORY diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index a4aefc088..a61d260cc 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_replaceItem`(vSaleFk INT, vNewItemFk INT, vQuantity INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sale_replaceItem`(vSaleFk INT, vNewItemFk INT, vQuantity INT) BEGIN /** * Añade un nuevo articulo para sustituir a otro, y actualiza la memoria de sustituciones. @@ -53,7 +53,7 @@ BEGIN JOIN ticket t ON t.id = s.ticketFk WHERE s.id = vSaleFk; - CALL buyUltimate(vWarehouseFk, vDate); + CALL buy_getUltimate(vNewItemFk, vWarehouseFk, vDate); SELECT `grouping`, groupingMode, packing INTO vGrouping,vGroupingMode,vPacking @@ -61,6 +61,8 @@ BEGIN JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk; + DROP TEMPORARY TABLE tmp.buyUltimate; + IF vGroupingMode = 'packing' AND vPacking > 0 THEN SET vRoundQuantity = vPacking; END IF; diff --git a/db/routines/vn/procedures/sale_setProblem.sql b/db/routines/vn/procedures/sale_setProblem.sql index 20319cc3f..333590658 100644 --- a/db/routines/vn/procedures/sale_setProblem.sql +++ b/db/routines/vn/procedures/sale_setProblem.sql @@ -1,18 +1,41 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblem`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sale_setProblem`( vProblemCode VARCHAR(25) ) BEGIN /** * Update column sale.problem with a problem code + * * @param vProblemCode Code to set or unset - * @table tmp.sale(saleFk, hasProblem) + * @table tmp.sale(saleFk, hasProblem, isProblemCalcNeeded) */ - UPDATE sale s - JOIN tmp.sale ts ON ts.saleFk = s.id - SET s.problem = CONCAT( - IF(ts.hasProblem, - CONCAT(s.problem, ',', vProblemCode), - REPLACE(s.problem, vProblemCode , ''))); + DECLARE vSaleFk INT; + DECLARE vHasProblem INT; + DECLARE vIsProblemCalcNeeded BOOL; + DECLARE vDone BOOL; + DECLARE vSaleList CURSOR FOR + SELECT saleFk, hasProblem, isProblemCalcNeeded + FROM tmp.sale; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vSaleList; + l: LOOP + SET vDone = FALSE; + FETCH vSaleList INTO vSaleFk, vHasProblem, vIsProblemCalcNeeded; + + IF vDone THEN + LEAVE l; + END IF; + + UPDATE sale + SET problem = IF (vIsProblemCalcNeeded, + CONCAT( + IF(vHasProblem, + CONCAT(problem, ',', vProblemCode), + REPLACE(problem, vProblemCode , ''))), + NULL) + WHERE id = vSaleFk; + END LOOP; + CLOSE vSaleList; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/sale_setProblemComponentLack.sql b/db/routines/vn/procedures/sale_setProblemComponentLack.sql index 363663a00..ad14d97d4 100644 --- a/db/routines/vn/procedures/sale_setProblemComponentLack.sql +++ b/db/routines/vn/procedures/sale_setProblemComponentLack.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblemComponentLack`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sale_setProblemComponentLack`( vSelf INT ) BEGIN @@ -10,9 +10,13 @@ BEGIN * @param vSelf Id del sale */ CREATE OR REPLACE TEMPORARY TABLE tmp.sale - (INDEX(saleFk)) + (INDEX(saleFk, isProblemCalcNeeded)) ENGINE = MEMORY - SELECT vSelf saleFk, sale_hasComponentLack(vSelf) hasProblem; + SELECT vSelf saleFk, + sale_hasComponentLack(vSelf) hasProblem, + (ticket_isProblemCalcNeeded(ticketFk) AND quantity > 0) isProblemCalcNeeded + FROM sale + WHERE id = vSelf; CALL sale_setProblem('hasComponentLack'); diff --git a/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql b/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql index 895598e84..fc432f8b3 100644 --- a/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql +++ b/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblemComponentLackByComponent`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sale_setProblemComponentLackByComponent`( vComponentFk INT ) BEGIN @@ -10,14 +10,19 @@ BEGIN * @param vComponentFk Id component */ CREATE OR REPLACE TEMPORARY TABLE tmp.sale - (INDEX(saleFk)) + (INDEX(saleFk, isProblemCalcNeeded)) ENGINE = MEMORY - SELECT s.id saleFk, sale_hasComponentLack(s.id) hasProblem - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - WHERE t.shipped >= util.midnight() - AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk); + SELECT saleFk, + sale_hasComponentLack(saleFk) hasProblem, + (ticket_isProblemCalcNeeded(ticketFk) AND quantity > 0) isProblemCalcNeeded + FROM ( + SELECT s.id saleFk, s.ticketFk, s.quantity + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + WHERE t.shipped >= util.VN_CURDATE() + AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk) + GROUP BY s.id) sub; CALL sale_setProblem('hasComponentLack'); diff --git a/db/routines/vn/procedures/sale_setProblemRounding.sql b/db/routines/vn/procedures/sale_setProblemRounding.sql deleted file mode 100644 index 366fbf8fd..000000000 --- a/db/routines/vn/procedures/sale_setProblemRounding.sql +++ /dev/null @@ -1,34 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblemRounding`( - vSelf INT -) -BEGIN -/** - * Update the rounding problem for a sales line - * @param vSelf Id sale - */ - DECLARE vItemFk INT; - DECLARE vWarehouseFk INT; - DECLARE vShipped DATE; - DECLARE vQuantity INT; - - SELECT s.itemFk, t.warehouseFk, t.shipped, s.quantity - INTO vItemFk, vWarehouseFk, vShipped, vQuantity - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - WHERE s.id = vSelf; - - CALL buyUltimate(vWarehouseFk, vShipped); - - CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - SELECT vSelf saleFk, MOD(vQuantity, bu.`grouping`) hasProblem - FROM tmp.buyUltimate bu - JOIN buy b ON b.id = bu.buyFk - WHERE bu.itemFk = vItemFk; - - CALL sale_setProblem('hasRounding'); - - DROP TEMPORARY TABLE tmp.ticket; - DROP TEMPORARY TABLE tmp.buyUltimate; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/sales_merge.sql b/db/routines/vn/procedures/sales_merge.sql deleted file mode 100644 index a91268c2f..000000000 --- a/db/routines/vn/procedures/sales_merge.sql +++ /dev/null @@ -1,39 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sales_merge`(vTicketFk INT) -BEGIN - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - CREATE OR REPLACE TEMPORARY TABLE tSalesToPreserve - SELECT s.id, s.itemFk, SUM(s.quantity) newQuantity - FROM sale s - JOIN item i ON i.id = s.itemFk - JOIN itemType it ON it.id = i.typeFk - WHERE s.ticketFk = vTicketFk - AND it.isMergeable - GROUP BY s.itemFk, s.price, s.discount; - - START TRANSACTION; - - UPDATE sale s - JOIN tSalesToPreserve stp ON stp.id = s.id - SET quantity = newQuantity - WHERE s.ticketFk = vTicketFk; - - DELETE s.* - FROM sale s - LEFT JOIN tSalesToPreserve stp ON stp.id = s.id - JOIN item i ON i.id = s.itemFk - JOIN itemType it ON it.id = i.typeFk - WHERE s.ticketFk = vTicketFk - AND stp.id IS NULL - AND it.isMergeable; - - COMMIT; - - DROP TEMPORARY TABLE tSalesToPreserve; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/sales_mergeByCollection.sql b/db/routines/vn/procedures/sales_mergeByCollection.sql index 4c0693753..279f9593f 100644 --- a/db/routines/vn/procedures/sales_mergeByCollection.sql +++ b/db/routines/vn/procedures/sales_mergeByCollection.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sales_mergeByCollection`(vCollectionFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sales_mergeByCollection`(vCollectionFk INT) BEGIN DECLARE vDone BOOL; @@ -26,7 +26,7 @@ BEGIN LEAVE myLoop; END IF; - CALL vn.sales_merge(vTicketFk); + CALL ticket_mergeSales(vTicketFk); END LOOP; diff --git a/db/routines/vn/procedures/sectorCollectionSaleGroup_add.sql b/db/routines/vn/procedures/sectorCollectionSaleGroup_add.sql index 5ffb30635..9ca1227c1 100644 --- a/db/routines/vn/procedures/sectorCollectionSaleGroup_add.sql +++ b/db/routines/vn/procedures/sectorCollectionSaleGroup_add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sectorCollectionSaleGroup_add`(vSaleGroupFk INT, vSectorCollectionFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sectorCollectionSaleGroup_add`(vSaleGroupFk INT, vSectorCollectionFk INT) BEGIN /** * Inserta un nuevo registro en vn.sectorCollectionSaleGroup diff --git a/db/routines/vn/procedures/sectorCollection_get.sql b/db/routines/vn/procedures/sectorCollection_get.sql index e518e05f8..97a44b150 100644 --- a/db/routines/vn/procedures/sectorCollection_get.sql +++ b/db/routines/vn/procedures/sectorCollection_get.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sectorCollection_get`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sectorCollection_get`() BEGIN /** * Devuelve las colecciones del sector que corresponden al usuario conectado, y que estan incompletas diff --git a/db/routines/vn/procedures/sectorCollection_getMyPartial.sql b/db/routines/vn/procedures/sectorCollection_getMyPartial.sql new file mode 100644 index 000000000..e02455235 --- /dev/null +++ b/db/routines/vn/procedures/sectorCollection_getMyPartial.sql @@ -0,0 +1,18 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sectorCollection_getMyPartial`() +BEGIN +/** + * Devuelve las colecciones del sector que corresponden al usuario conectado, y que estan incompletas + * + */ + SELECT DISTINCT sc.id collectionFk, sc.created + FROM vn.sectorCollection sc + LEFT JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id + LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk + LEFT JOIN vn.sale sl ON sl.id = sgd.saleFk + LEFT JOIN itemShelvingSale iss ON iss.saleFk = sl.id + WHERE sc.userFk = account.myUser_getId() + AND (scsg.sectorCollectionFk IS NULL OR NOT iss.isPicked) + AND sc.created > util.VN_CURDATE() - INTERVAL 1 DAY; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/sectorCollection_getSale.sql b/db/routines/vn/procedures/sectorCollection_getSale.sql index e1636895b..b3b1f0f3f 100644 --- a/db/routines/vn/procedures/sectorCollection_getSale.sql +++ b/db/routines/vn/procedures/sectorCollection_getSale.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sectorCollection_getSale`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sectorCollection_getSale`(vSelf INT) BEGIN /** * Devuelve las lineas de venta correspondientes a esa coleccion de sector diff --git a/db/routines/vn/procedures/sectorCollection_hasSalesReserved.sql b/db/routines/vn/procedures/sectorCollection_hasSalesReserved.sql new file mode 100644 index 000000000..6d0fb8f23 --- /dev/null +++ b/db/routines/vn/procedures/sectorCollection_hasSalesReserved.sql @@ -0,0 +1,25 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION vn.sectorCollection_hasSalesReserved(vSelf INT) RETURNS tinyint(1) +DETERMINISTIC +BEGIN +/** + * Devuelve si sectorCollection tiene reservas + * @param vSelf Id de sectorCollection + * + * returns BOOLEAN + */ + DECLARE vHasSalesReserved BOOLEAN; + + SELECT DISTINCT COUNT(*) INTO vHasSalesReserved + FROM sectorCollection sc + JOIN sectorCollectionSaleGroup scsg ON sc.id = scsg.sectorCollectionFk + JOIN saleGroup sg ON sg.id = scsg.saleGroupFk + JOIN saleGroupDetail sgd ON sgd.saleGroupFk = sg.id + JOIN sale s ON s.id = sgd.saleFk + JOIN itemShelvingSale iss ON iss.saleFk = s.id + JOIN saleTracking st ON st.saleFk = s.id + WHERE sc.id = vSelf; + + RETURN vHasSalesReserved; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/sectorCollection_new.sql b/db/routines/vn/procedures/sectorCollection_new.sql index fae8eba31..3f0112015 100644 --- a/db/routines/vn/procedures/sectorCollection_new.sql +++ b/db/routines/vn/procedures/sectorCollection_new.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sectorCollection_new`(vSectorFk INT) +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sectorCollection_new`(vSectorFk INT) BEGIN /** * Inserta una nueva colección, si el usuario no tiene ninguna vacia. @@ -24,5 +24,5 @@ BEGIN INSERT INTO vn.sectorCollection(userFk, sectorFk) VALUES(vUserFk, vSectorFk); END IF; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/sectorProductivity_add.sql b/db/routines/vn/procedures/sectorProductivity_add.sql index be75c842d..8b520e692 100644 --- a/db/routines/vn/procedures/sectorProductivity_add.sql +++ b/db/routines/vn/procedures/sectorProductivity_add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sectorProductivity_add`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sectorProductivity_add`() BEGIN DECLARE vDatedFrom DATETIME; DECLARE vDatedTo DATETIME; diff --git a/db/routines/vn/procedures/sector_getWarehouse.sql b/db/routines/vn/procedures/sector_getWarehouse.sql index fe363f39f..5a9f1ee5f 100644 --- a/db/routines/vn/procedures/sector_getWarehouse.sql +++ b/db/routines/vn/procedures/sector_getWarehouse.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sector_getWarehouse`(vSectorFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sector_getWarehouse`(vSectorFk INT) BEGIN SELECT s.warehouseFk diff --git a/db/routines/vn/procedures/setParking.sql b/db/routines/vn/procedures/setParking.sql index 97a40bbe0..96b459031 100644 --- a/db/routines/vn/procedures/setParking.sql +++ b/db/routines/vn/procedures/setParking.sql @@ -1,6 +1,9 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`setParking`(IN `vParam` VARCHAR(8), IN `vParkingCode` VARCHAR(8)) -proc: BEGIN +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`setParking`( + vParam VARCHAR(8), + vParkingCode VARCHAR(8) +) +BEGIN /** * Aparca una colección, un ticket, un saleGroup o un shelving en un parking * @@ -8,54 +11,31 @@ proc: BEGIN * @param vParkingCode código del parking */ DECLARE vParkingFk INT; - DECLARE vIsSaleGroup BOOL; - DECLARE vIsTicket BOOL; - DECLARE vIsCollection BOOL; + DECLARE vLastWeek DATE; - SET vParkingCode = replace(vParkingCode,' ',''); + SET vParkingCode = REPLACE(vParkingCode, ' ', ''); SELECT id INTO vParkingFk - FROM vn.parking + FROM parking WHERE code = vParkingCode COLLATE utf8_unicode_ci; IF vParkingFk IS NULL THEN CALL util.throw('parkingNotExist'); - LEAVE proc; END IF; - -- Se comprueba si es una preparación previa - SELECT COUNT(*) INTO vIsSaleGroup - FROM vn.saleGroup sg - WHERE sg.id = vParam; + SET vLastWeek = util.VN_CURDATE() - INTERVAL 1 WEEK; - IF vIsSaleGroup THEN - CALL vn.saleGroup_setParking(vParam, vParkingFk); - LEAVE proc; + -- Comprobamos si es una prep. previa, ticket, colección o shelving + IF (SELECT TRUE FROM saleGroup WHERE id = vParam) THEN + CALL saleGroup_setParking(vParam, vParkingFk); + ELSEIF (SELECT TRUE FROM ticket WHERE id = vParam AND shipped >= vLastWeek) THEN + CALL ticket_setParking(vParam, vParkingFk); + ELSEIF (SELECT TRUE FROM `collection` WHERE id = vParam AND created >= vLastWeek) THEN + CALL collection_setParking(vParam, vParkingFk); + ELSEIF (SELECT TRUE FROM shelving WHERE code = vParam COLLATE utf8_unicode_ci) THEN + CALL shelving_setParking(vParam, vParkingFk); + ELSE + CALL util.throw('paramNotExist'); END IF; - - -- Se comprueba si es un ticket - SELECT COUNT(*) INTO vIsTicket - FROM vn.ticket t - WHERE t.id = vParam - AND t.shipped >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); - - IF vIsTicket THEN - CALL vn.ticket_setParking(vParam, vParkingFk); - LEAVE proc; - END IF; - - -- Se comprueba si es una coleccion de tickets - SELECT COUNT(*) INTO vIsCollection - FROM vn.collection c - WHERE c.id = vParam - AND c.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); - - IF vIsCollection THEN - CALL vn.collection_setParking(vParam, vParkingFk); - LEAVE proc; - END IF; - - -- Por descarte, se considera una matrícula - CALL vn.shelving_setParking(vParam, vParkingFk); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/shelvingChange.sql b/db/routines/vn/procedures/shelvingChange.sql index fde38212c..2e7e92082 100644 --- a/db/routines/vn/procedures/shelvingChange.sql +++ b/db/routines/vn/procedures/shelvingChange.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`shelvingChange`(IN `vShelvingO` VARCHAR(8), IN `vShelvingD` VARCHAR(8)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingChange`(IN `vShelvingO` VARCHAR(8), IN `vShelvingD` VARCHAR(8)) BEGIN UPDATE vn.itemShelving diff --git a/db/routines/vn/procedures/shelvingLog_get.sql b/db/routines/vn/procedures/shelvingLog_get.sql index d48e38d03..d72d6cf8b 100644 --- a/db/routines/vn/procedures/shelvingLog_get.sql +++ b/db/routines/vn/procedures/shelvingLog_get.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`shelvingLog_get`(shelvingFk VARCHAR(10)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingLog_get`(shelvingFk VARCHAR(10)) BEGIN /* Lista el log de un carro diff --git a/db/routines/vn/procedures/shelvingParking_get.sql b/db/routines/vn/procedures/shelvingParking_get.sql index 0131db7d2..a9ed9f74a 100644 --- a/db/routines/vn/procedures/shelvingParking_get.sql +++ b/db/routines/vn/procedures/shelvingParking_get.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`shelvingParking_get`(vShelvingFk VARCHAR(10), vWarehouseFk INT, vDayRange INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingParking_get`(vShelvingFk VARCHAR(10), vWarehouseFk INT, vDayRange INT) BEGIN diff --git a/db/routines/vn/procedures/shelvingPriority_update.sql b/db/routines/vn/procedures/shelvingPriority_update.sql index 317f17333..87019e9cf 100644 --- a/db/routines/vn/procedures/shelvingPriority_update.sql +++ b/db/routines/vn/procedures/shelvingPriority_update.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`shelvingPriority_update`(priority INT,vShelvingFk VARCHAR(10)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingPriority_update`(priority INT,vShelvingFk VARCHAR(10)) BEGIN UPDATE vn.shelving SET priority = priority WHERE code=vShelvingFk COLLATE utf8_unicode_ci; diff --git a/db/routines/vn/procedures/shelving_clean.sql b/db/routines/vn/procedures/shelving_clean.sql index f9248a0d7..0b29968bc 100644 --- a/db/routines/vn/procedures/shelving_clean.sql +++ b/db/routines/vn/procedures/shelving_clean.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`shelving_clean`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelving_clean`() BEGIN DELETE FROM shelving @@ -25,8 +25,9 @@ UPDATE shelving sh AND ( sh.parked IS NULL OR - sh.parked < TIMESTAMPADD(MONTH,-1,util.VN_CURDATE()) - ) + sh.parked < util.VN_CURDATE() - INTERVAL 2 WEEK + ) + AND IF(code REGEXP '^[A-Za-z]{2}[0-9]', LEFT (code, 2) NOT IN ( SELECT DISTINCT LEFT(its.shelvingFk, 2) FROM itemShelving its diff --git a/db/routines/vn/procedures/shelving_getSpam.sql b/db/routines/vn/procedures/shelving_getSpam.sql index 2895470ad..cef407285 100644 --- a/db/routines/vn/procedures/shelving_getSpam.sql +++ b/db/routines/vn/procedures/shelving_getSpam.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`shelving_getSpam`(vDated DATE, vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelving_getSpam`(vDated DATE, vWarehouseFk INT) BEGIN /** * Devuelve las matrículas con productos que no son necesarios para la venta diff --git a/db/routines/vn/procedures/shelving_setParking.sql b/db/routines/vn/procedures/shelving_setParking.sql index 0ff07ef5d..f9acad74d 100644 --- a/db/routines/vn/procedures/shelving_setParking.sql +++ b/db/routines/vn/procedures/shelving_setParking.sql @@ -1,20 +1,23 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`shelving_setParking`(IN `vShelvingCode` VARCHAR(8), IN `vParkingFk` INT) -proc: BEGIN +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelving_setParking`( + `vShelvingCode` VARCHAR(8), + `vParkingFk` INT +) +BEGIN /** * Aparca una matrícula en un parking * * @param vShelvingCode code de la matrícula * @param vParkingFk id del parking */ - INSERT INTO vn.shelvingLog (originFk, userFk, action , description,changedModel,changedModelId) + INSERT INTO shelvingLog (originFk, userFk, action , description,changedModel,changedModelId) SELECT s.id, account.myUser_getId(), 'update', CONCAT("Cambio parking ",vShelvingCode," de ", p.code," a ", pNew.code),'Shelving',s.id FROM parking p JOIN shelving s ON s.parkingFk = p.id JOIN parking pNew ON pNew.id = vParkingFk WHERE s.code = vShelvingCode COLLATE utf8_unicode_ci; - UPDATE vn.shelving + UPDATE shelving SET parkingFk = vParkingFk, parked = util.VN_NOW(), isPrinted = TRUE diff --git a/db/routines/vn/procedures/sleep_X_min.sql b/db/routines/vn/procedures/sleep_X_min.sql index 39102b57d..507432390 100644 --- a/db/routines/vn/procedures/sleep_X_min.sql +++ b/db/routines/vn/procedures/sleep_X_min.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sleep_X_min`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sleep_X_min`() BEGIN # Ernesto. 4.8.2020 # Para su uso en las tareas ejecutadas a las 2AM (visibles con: SELECT * FROM bs.nightTask order by started asc;) diff --git a/db/routines/vn/procedures/stockBought_calculate.sql b/db/routines/vn/procedures/stockBought_calculate.sql new file mode 100644 index 000000000..8b2a32e5d --- /dev/null +++ b/db/routines/vn/procedures/stockBought_calculate.sql @@ -0,0 +1,62 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`stockBought_calculate`( + vDated DATE +) +proc: BEGIN +/** + * Calculate the stock of the auction warehouse from the inventory date to vDated + * without taking into account the outputs of the same day vDated + * + * @param vDated Date to calculate the stock. + */ + IF vDated < util.VN_CURDATE() THEN + LEAVE proc; + END IF; + + CREATE OR REPLACE TEMPORARY TABLE tStockBought + SELECT workerFk, reserve + FROM stockBought + WHERE dated = vDated + AND reserve; + + DELETE FROM stockBought WHERE dated = vDated; + + CALL item_calculateStock(vDated); + + INSERT INTO stockBought(workerFk, bought, dated) + SELECT it.workerFk, + ROUND(SUM( + (ti.quantity / b.packing) * + buy_getVolume(b.id) + ) / vc.palletM3 / 1000000, 1) bought, + vDated + FROM itemType it + JOIN item i ON i.typeFk = it.id + LEFT JOIN tmp.item ti ON ti.itemFk = i.id + JOIN itemCategory ic ON ic.id = it.categoryFk + JOIN warehouse wh ON wh.code = 'VNH' + JOIN tmp.buyUltimate bu ON bu.itemFk = i.id + AND bu.warehouseFk = wh.id + JOIN buy b ON b.id = bu.buyFk + JOIN volumeConfig vc + WHERE ic.display + GROUP BY it.workerFk + HAVING bought; + + UPDATE stockBought s + JOIN tStockBought ts ON ts.workerFk = s.workerFk + SET s.reserve = ts.reserve + WHERE s.dated = vDated; + + INSERT INTO stockBought (workerFk, reserve, dated) + SELECT ts.workerFk, ts.reserve, vDated + FROM tStockBought ts + WHERE ts.workerFk NOT IN ( + SELECT workerFk + FROM stockBought + WHERE dated = vDated + ); + + DROP TEMPORARY TABLE tStockBought, tmp.item, tmp.buyUltimate; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/stockBuyedByWorker.sql b/db/routines/vn/procedures/stockBuyedByWorker.sql deleted file mode 100644 index 730612db8..000000000 --- a/db/routines/vn/procedures/stockBuyedByWorker.sql +++ /dev/null @@ -1,74 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`stockBuyedByWorker`( - vDated DATE, - vWorker INT -) -BEGIN -/** - * Inserta el volumen de compra de un comprador - * en stockBuyed de acuerdo con la fecha. - * - * @param vDated Fecha de compra - * @param vWorker Id de trabajador - */ - CREATE OR REPLACE TEMPORARY TABLE tStockBuyed - (INDEX (userFk)) - ENGINE = MEMORY - SELECT requested, reserved, userFk - FROM stockBuyed - WHERE dated = vDated - AND userFk = vWorker; - - DELETE FROM stockBuyed - WHERE dated = vDated - AND userFk = vWorker; - - CALL stockTraslation(vDated); - - INSERT INTO stockBuyed(userFk, buyed, `dated`, reserved, requested, description) - SELECT it.workerFk, - SUM((ti.quantity / b.packing) * buy_getVolume(b.id)) / vc.palletM3 / 1000000, - vDated, - sb.reserved, - sb.requested, - u.name - FROM itemType it - JOIN item i ON i.typeFk = it.id - LEFT JOIN tmp.item ti ON ti.itemFk = i.id - JOIN itemCategory ic ON ic.id = it.categoryFk - JOIN warehouse wh ON wh.code = 'VNH' - JOIN tmp.buyUltimate bu ON bu.itemFk = i.id - AND bu.warehouseFk = wh.id - JOIN buy b ON b.id = bu.buyFk - JOIN volumeConfig vc - JOIN account.`user` u ON u.id = it.workerFk - LEFT JOIN tStockBuyed sb ON sb.userFk = it.workerFk - WHERE ic.display - AND it.workerFk = vWorker; - - SELECT b.entryFk Id_Entrada, - i.id Id_Article, - i.name Article, - ti.quantity Cantidad, - (ac.conversionCoefficient * (ti.quantity / b.packing) * buy_getVolume(b.id)) - / (vc.trolleyM3 * 1000000) buyed, - b.packagingFk id_cubo, - b.packing - FROM tmp.item ti - JOIN item i ON i.id = ti.itemFk - JOIN itemType it ON i.typeFk = it.id - JOIN itemCategory ic ON ic.id = it.categoryFk - JOIN worker w ON w.id = it.workerFk - JOIN auctionConfig ac - JOIN tmp.buyUltimate bu ON bu.itemFk = i.id - AND bu.warehouseFk = ac.warehouseFk - JOIN buy b ON b.id = bu.buyFk - JOIN volumeConfig vc - WHERE ic.display - AND w.id = vWorker; - - DROP TEMPORARY TABLE tmp.buyUltimate, - tmp.item, - tStockBuyed; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/stockBuyed_add.sql b/db/routines/vn/procedures/stockBuyed_add.sql deleted file mode 100644 index 1fff1484c..000000000 --- a/db/routines/vn/procedures/stockBuyed_add.sql +++ /dev/null @@ -1,70 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`stockBuyed_add`( - vDated DATE -) -BEGIN -/** - * Inserta el volumen de compra por comprador - * en stockBuyed de acuerdo con la fecha. - * - * @param vDated Fecha de compra - */ - CREATE OR REPLACE TEMPORARY TABLE tStockBuyed - (INDEX (userFk)) - ENGINE = MEMORY - SELECT requested, reserved, userFk - FROM stockBuyed - WHERE dated = vDated; - - DELETE FROM stockBuyed WHERE dated = vDated; - - CALL stockTraslation(vDated); - - INSERT INTO stockBuyed(userFk, buyed, `dated`, description) - SELECT it.workerFk, - SUM((ti.quantity / b.packing) * buy_getVolume(b.id)) / vc.palletM3 / 1000000, - vDated, - u.name - FROM itemType it - JOIN item i ON i.typeFk = it.id - LEFT JOIN tmp.item ti ON ti.itemFk = i.id - JOIN itemCategory ic ON ic.id = it.categoryFk - JOIN warehouse wh ON wh.code = 'VNH' - JOIN tmp.buyUltimate bu ON bu.itemFk = i.id AND bu.warehouseFk = wh.id - JOIN buy b ON b.id = bu.buyFk - JOIN volumeConfig vc - JOIN account.`user` u ON u.id = it.workerFk - JOIN workerDepartment wd ON wd.workerFk = u.id - JOIN department d ON d.id = wd.departmentFk - WHERE ic.display - AND d.code IN ('shopping', 'logistic', 'franceTeam') - GROUP BY it.workerFk; - - INSERT INTO stockBuyed(buyed, dated, description) - SELECT SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000), - vDated, - IF(c.code = 'ES', p.name, c.name) destiny - FROM itemTicketOut ito - JOIN ticket t ON t.id = ito.ticketFk - JOIN `address` a ON a.id = t.addressFk - JOIN province p ON p.id = a.provinceFk - JOIN country c ON c.id = p.countryFk - JOIN warehouse wh ON wh.id = t.warehouseFk - JOIN itemCost ic ON ic.itemFk = ito.itemFk - AND ic.warehouseFk = t.warehouseFk - JOIN volumeConfig vc - WHERE ito.shipped BETWEEN vDated AND util.dayend(vDated) - AND wh.code = 'VNH' - GROUP BY destiny; - - UPDATE stockBuyed s - JOIN tStockBuyed ts ON ts.userFk = s.userFk - SET s.requested = ts.requested, - s.reserved = ts.reserved - WHERE s.dated = vDated; - - DROP TEMPORARY TABLE tmp.buyUltimate, - tmp.item, - tStockBuyed; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/subordinateGetList.sql b/db/routines/vn/procedures/subordinateGetList.sql index 0431afaa4..9eeddef94 100644 --- a/db/routines/vn/procedures/subordinateGetList.sql +++ b/db/routines/vn/procedures/subordinateGetList.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`subordinateGetList`(vBossFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`subordinateGetList`(vBossFk INT) BEGIN -- deprecated usar vn.worker_GetHierarch diff --git a/db/routines/vn/procedures/supplierExpenses.sql b/db/routines/vn/procedures/supplierExpenses.sql index 11ebbd603..a219ee9e9 100644 --- a/db/routines/vn/procedures/supplierExpenses.sql +++ b/db/routines/vn/procedures/supplierExpenses.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`supplierExpenses`(vEnded DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`supplierExpenses`(vEnded DATE) BEGIN DROP TEMPORARY TABLE IF EXISTS openingBalance; diff --git a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql index a3401843a..6700a4932 100644 --- a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql +++ b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql @@ -1,14 +1,14 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`supplierPackaging_ReportSource`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`supplierPackaging_ReportSource`( vFromDated DATE, vSupplierFk INT ) BEGIN /** -* Selecciona los embalajes de un proveedor a partir de una fecha +* Create a report with packaging balance * -* @param vFromDated Fecha de la que partir -* @param vSupplierFk Id del proveedor +* @param vFromDated Starting date +* @param vSupplierFk Supplier ID */ SET @vBalance = 0; SET @vItemFk = NULL; @@ -22,7 +22,7 @@ BEGIN landed, `in`, `out`, - warehouse, + sref, buyingValue, IF ( NOT (@vItemFk <=> sub.itemFk), @@ -31,19 +31,20 @@ BEGIN ) balance, @vItemFk := sub.itemFk previousItemFk FROM ( - SELECT supplierFk, - itemFk, - longName, - supplier, - CONCAT('E',entryFk) entryFk, - landed, - `in`, - `out`, - warehouse, - buyingValue - FROM supplierPackaging - WHERE supplierFk = vSupplierFk - AND landed >= vFromDated + SELECT sp.supplierFk, + sp.itemFk, + sp.longName, + sp.supplier, + CONCAT('E',sp.entryFk) entryFk, + sp.landed, + sp.`in`, + sp.`out`, + e.invoiceNumber sref, + sp.buyingValue + FROM supplierPackaging sp + JOIN entry e ON e.id = sp.entryFk + WHERE sp.supplierFk = vSupplierFk + AND sp.landed >= vFromDated UNION ALL SELECT vSupplierFk, itemFk, @@ -68,7 +69,7 @@ BEGIN DATE(t.shipped), -LEAST(s.quantity,0) `in`, GREATEST(s.quantity,0) `out`, - t.warehouseFk, + t.cmrFk, s.price * (100 - s.discount) / 100 FROM sale s JOIN item i ON i.id = s.itemFk @@ -99,6 +100,7 @@ BEGIN WHERE su.id = vSupplierFk AND t.shipped < vFromDated AND p.isPackageReturnable + AND NOT t.isDeleted GROUP BY s.itemFk UNION ALL SELECT vSupplierFk, @@ -109,7 +111,7 @@ BEGIN DATE(t.shipped), -LEAST(tp.quantity,0) `in`, GREATEST(tp.quantity,0) `out`, - t.warehouseFk, + t.cmrFk, 0 FROM ticketPackaging tp JOIN packaging p ON p.id = tp.packagingFk @@ -138,8 +140,9 @@ BEGIN JOIN client c ON c.id = t.clientFk JOIN supplier su ON su.nif = c.fi WHERE su.id = vSupplierFk - AND t.shipped >= vFromDated + AND t.shipped < vFromDated AND p.isPackageReturnable + AND NOT t.isDeleted GROUP BY p.itemFk ORDER BY itemFk, landed, entryFk ) sub @@ -153,7 +156,7 @@ BEGIN landed, CAST(`in` AS DECIMAL(10,0)) `in`, CAST(`out` AS DECIMAL(10,0)) `out`, - warehouse, + sref, buyingValue, balance FROM tSupplierPackaging diff --git a/db/routines/vn/procedures/supplier_checkBalance.sql b/db/routines/vn/procedures/supplier_checkBalance.sql index 04c513927..5e5cd5aed 100644 --- a/db/routines/vn/procedures/supplier_checkBalance.sql +++ b/db/routines/vn/procedures/supplier_checkBalance.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`supplier_checkBalance`(IN vDateTo DATETIME, IN vIsConciliated BOOL) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`supplier_checkBalance`(IN vDateTo DATETIME, IN vIsConciliated BOOL) BEGIN /** * Compara los datos de nuestros proveedores con diff --git a/db/routines/vn/procedures/supplier_checkIsActive.sql b/db/routines/vn/procedures/supplier_checkIsActive.sql index 9dcb6452a..75118d03a 100644 --- a/db/routines/vn/procedures/supplier_checkIsActive.sql +++ b/db/routines/vn/procedures/supplier_checkIsActive.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`supplier_checkIsActive`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`supplier_checkIsActive`(vSelf INT) BEGIN /** * Comprueba si un proveedor esta activo. diff --git a/db/routines/vn/procedures/supplier_disablePayMethodChecked.sql b/db/routines/vn/procedures/supplier_disablePayMethodChecked.sql index d486f6e86..02cbbcb8f 100644 --- a/db/routines/vn/procedures/supplier_disablePayMethodChecked.sql +++ b/db/routines/vn/procedures/supplier_disablePayMethodChecked.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`supplier_disablePayMethodChecked`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`supplier_disablePayMethodChecked`() BEGIN /* diff --git a/db/routines/vn/procedures/supplier_statement.sql b/db/routines/vn/procedures/supplier_statement.sql deleted file mode 100644 index a03a7770c..000000000 --- a/db/routines/vn/procedures/supplier_statement.sql +++ /dev/null @@ -1,139 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`supplier_statement`( - vSupplierFk INT, - vCurrencyFk INT, - vCompanyFk INT, - vOrderBy VARCHAR(15), - vIsConciliated BOOL -) -BEGIN -/** - * Crea un estado de cuenta de proveedores calculando - * los saldos en euros y en la moneda especificada. - * - * @param vSupplierFk Id del proveedor - * @param vCurrencyFk Id de la moneda - * @param vCompanyFk Id de la empresa - * @param vOrderBy Criterio de ordenación - * @param vIsConciliated Indica si está conciliado o no - * @return tmp.supplierStatement - */ - SET @euroBalance:= 0; - SET @currencyBalance:= 0; - - CREATE OR REPLACE TEMPORARY TABLE tmp.supplierStatement - ENGINE = MEMORY - SELECT *, - @euroBalance:= ROUND( - @euroBalance + IFNULL(paymentEuros, 0) - - IFNULL(invoiceEuros, 0), 2 - ) euroBalance, - @currencyBalance:= ROUND( - @currencyBalance + IFNULL(paymentCurrency, 0) - - IFNULL(invoiceCurrency, 0), 2 - ) currencyBalance - FROM ( - SELECT * FROM - ( - SELECT NULL bankFk, - ii.companyFk, - ii.serial, - ii.id, - CASE - WHEN vOrderBy = 'issued' THEN ii.issued - WHEN vOrderBy = 'bookEntried' THEN ii.bookEntried - WHEN vOrderBy = 'booked' THEN ii.booked - WHEN vOrderBy = 'dueDate' THEN iid.dueDated - END dated, - CONCAT('S/Fra ', ii.supplierRef) sref, - IF(ii.currencyFk > 1, - ROUND(SUM(iid.foreignValue) / SUM(iid.amount), 3), - NULL - ) changeValue, - CAST(SUM(iid.amount) AS DECIMAL(10,2)) invoiceEuros, - CAST(SUM(iid.foreignValue) AS DECIMAL(10,2)) invoiceCurrency, - NULL paymentEuros, - NULL paymentCurrency, - ii.currencyFk, - ii.isBooked, - c.code, - 'invoiceIn' statementType - FROM invoiceIn ii - JOIN invoiceInDueDay iid ON iid.invoiceInFk = ii.id - JOIN currency c ON c.id = ii.currencyFk - WHERE ii.issued > '2014-12-31' - AND ii.supplierFk = vSupplierFk - AND vCurrencyFk IN (ii.currencyFk, 0) - AND vCompanyFk IN (ii.companyFk, 0) - AND (vIsConciliated = ii.isBooked OR NOT vIsConciliated) - GROUP BY iid.id - UNION ALL - SELECT p.bankFk, - p.companyFk, - NULL, - p.id, - CASE - WHEN vOrderBy = 'issued' THEN p.received - WHEN vOrderBy = 'bookEntried' THEN p.received - WHEN vOrderBy = 'booked' THEN p.received - WHEN vOrderBy = 'dueDate' THEN p.dueDated - END, - CONCAT(IFNULL(pm.name, ''), - IF(pn.concept <> '', - CONCAT(' : ', pn.concept), - '') - ), - IF(p.currencyFk > 1, p.divisa / p.amount, NULL), - NULL, - NULL, - p.amount, - p.divisa, - p.currencyFk, - p.isConciliated, - c.code, - 'payment' - FROM payment p - LEFT JOIN currency c ON c.id = p.currencyFk - LEFT JOIN accounting a ON a.id = p.bankFk - LEFT JOIN payMethod pm ON pm.id = p.payMethodFk - LEFT JOIN promissoryNote pn ON pn.paymentFk = p.id - WHERE p.received > '2014-12-31' - AND p.supplierFk = vSupplierFk - AND vCurrencyFk IN (p.currencyFk, 0) - AND vCompanyFk IN (p.companyFk, 0) - AND (vIsConciliated = p.isConciliated OR NOT vIsConciliated) - UNION ALL - SELECT NULL, - companyFk, - NULL, - se.id, - CASE - WHEN vOrderBy = 'issued' THEN se.dated - WHEN vOrderBy = 'bookEntried' THEN se.dated - WHEN vOrderBy = 'booked' THEN se.dated - WHEN vOrderBy = 'dueDate' THEN se.dueDated - END, - se.description, - 1, - amount, - NULL, - NULL, - NULL, - currencyFk, - isConciliated, - c.`code`, - 'expense' - FROM supplierExpense se - JOIN currency c ON c.id = se.currencyFk - WHERE se.supplierFk = vSupplierFk - AND vCurrencyFk IN (se.currencyFk,0) - AND vCompanyFk IN (se.companyFk,0) - AND (vIsConciliated = se.isConciliated OR NOT vIsConciliated) - ) sub - ORDER BY (dated IS NULL AND NOT isBooked), - dated, - IF(vOrderBy = 'dueDate', id, NULL) - LIMIT 10000000000000000000 - ) t; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/supplier_statementWithEntries.sql b/db/routines/vn/procedures/supplier_statementWithEntries.sql new file mode 100644 index 000000000..c0014f8e5 --- /dev/null +++ b/db/routines/vn/procedures/supplier_statementWithEntries.sql @@ -0,0 +1,166 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE vn.supplier_statementWithEntries( + vSupplierFk INT, + vCurrencyFk INT, + vCompanyFk INT, + vOrderBy VARCHAR(15), + vIsConciliated BOOL, + vHasEntries BOOL +) +BEGIN +/** +* Creates a supplier statement, calculating balances in euros and the specified currency. +* +* @param vSupplierFk Supplier ID +* @param vCurrencyFk Currency ID +* @param vCompanyFk Company ID +* @param vOrderBy Order by criteria +* @param vIsConciliated Indicates whether it is reconciled or not +* @param vHasEntries Indicates if future entries must be shown +* @return tmp.supplierStatement +*/ + DECLARE vBalanceStartingDate DATETIME; + + SET @euroBalance:= 0; + SET @currencyBalance:= 0; + + SELECT balanceStartingDate + INTO vBalanceStartingDate + FROM invoiceInConfig; + + CREATE OR REPLACE TEMPORARY TABLE tmp.supplierStatement + ENGINE = MEMORY + SELECT *, + @euroBalance:= ROUND( + @euroBalance + IFNULL(paymentEuros, 0) - + IFNULL(invoiceEuros, 0), 2 + ) euroBalance, + @currencyBalance:= ROUND( + @currencyBalance + IFNULL(paymentCurrency, 0) - + IFNULL(invoiceCurrency, 0), 2 + ) currencyBalance + FROM ( + SELECT NULL bankFk, + ii.companyFk, + ii.serial, + ii.id, + CASE + WHEN vOrderBy = 'issued' THEN ii.issued + WHEN vOrderBy = 'bookEntried' THEN ii.bookEntried + WHEN vOrderBy = 'booked' THEN ii.booked + WHEN vOrderBy = 'dueDate' THEN iid.dueDated + END dated, + CONCAT('S/Fra ', ii.supplierRef) sref, + IF(ii.currencyFk > 1, + ROUND(SUM(iid.foreignValue) / SUM(iid.amount), 3), + NULL + ) changeValue, + CAST(SUM(iid.amount) AS DECIMAL(10,2)) invoiceEuros, + CAST(SUM(iid.foreignValue) AS DECIMAL(10,2)) invoiceCurrency, + NULL paymentEuros, + NULL paymentCurrency, + ii.currencyFk, + ii.isBooked, + c.code, + 'invoiceIn' statementType + FROM invoiceIn ii + LEFT JOIN invoiceInDueDay iid ON iid.invoiceInFk = ii.id + JOIN currency c ON c.id = ii.currencyFk + WHERE ii.issued >= vBalanceStartingDate + AND ii.supplierFk = vSupplierFk + AND vCurrencyFk IN (ii.currencyFk, 0) + AND vCompanyFk IN (ii.companyFk, 0) + AND (vIsConciliated = ii.isBooked OR NOT vIsConciliated) + GROUP BY iid.id, ii.id + UNION ALL + SELECT p.bankFk, + p.companyFk, + NULL, + p.id, + CASE + WHEN vOrderBy = 'issued' THEN p.received + WHEN vOrderBy = 'bookEntried' THEN p.received + WHEN vOrderBy = 'booked' THEN p.received + WHEN vOrderBy = 'dueDate' THEN p.dueDated + END, + CONCAT(IFNULL(pm.name, ''), + IF(pn.concept <> '', + CONCAT(' : ', pn.concept), + '') + ), + IF(p.currencyFk > 1, p.divisa / p.amount, NULL), + NULL, + NULL, + p.amount, + p.divisa, + p.currencyFk, + p.isConciliated, + c.code, + 'payment' + FROM payment p + LEFT JOIN currency c ON c.id = p.currencyFk + LEFT JOIN accounting a ON a.id = p.bankFk + LEFT JOIN payMethod pm ON pm.id = p.payMethodFk + LEFT JOIN promissoryNote pn ON pn.paymentFk = p.id + WHERE p.received >= vBalanceStartingDate + AND p.supplierFk = vSupplierFk + AND vCurrencyFk IN (p.currencyFk, 0) + AND vCompanyFk IN (p.companyFk, 0) + AND (vIsConciliated = p.isConciliated OR NOT vIsConciliated) + UNION ALL + SELECT NULL, + companyFk, + NULL, + se.id, + CASE + WHEN vOrderBy = 'issued' THEN se.dated + WHEN vOrderBy = 'bookEntried' THEN se.dated + WHEN vOrderBy = 'booked' THEN se.dated + WHEN vOrderBy = 'dueDate' THEN se.dueDated + END, + se.description, + 1, + amount, + NULL, + NULL, + NULL, + currencyFk, + isConciliated, + c.`code`, + 'expense' + FROM supplierExpense se + JOIN currency c ON c.id = se.currencyFk + WHERE se.supplierFk = vSupplierFk + AND vCurrencyFk IN (se.currencyFk,0) + AND vCompanyFk IN (se.companyFk,0) + AND (vIsConciliated = se.isConciliated OR NOT vIsConciliated) + UNION ALL + SELECT NULL bankFk, + e.companyFk, + 'E' serial, + e.invoiceNumber id, + tr.landed dated, + CONCAT('Ent. ',e.id) sref, + 1 / ((e.commission/100)+1) changeValue, + e.invoiceAmount * (1 + (e.commission/100)), + e.invoiceAmount, + NULL, + NULL, + e.currencyFk, + FALSE isBooked, + c.code, + 'order' + FROM entry e + JOIN travel tr ON tr.id = e.travelFk + JOIN currency c ON c.id = e.currencyFk + WHERE e.supplierFk = vSupplierFk + AND tr.landed >= CURDATE() + AND e.invoiceInFk IS NULL + AND vHasEntries + ORDER BY (dated IS NULL AND NOT isBooked), + dated, + IF(vOrderBy = 'dueDate', id, NULL) + LIMIT 10000000000000000000 + ) t; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/ticketBoxesView.sql b/db/routines/vn/procedures/ticketBoxesView.sql index d5fcef226..4f62a3d6c 100644 --- a/db/routines/vn/procedures/ticketBoxesView.sql +++ b/db/routines/vn/procedures/ticketBoxesView.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketBoxesView`(IN vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketBoxesView`(IN vTicketFk INT) BEGIN SELECT s.id, diff --git a/db/routines/vn/procedures/ticketBuiltTime.sql b/db/routines/vn/procedures/ticketBuiltTime.sql index 936e872ab..0e1938681 100644 --- a/db/routines/vn/procedures/ticketBuiltTime.sql +++ b/db/routines/vn/procedures/ticketBuiltTime.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketBuiltTime`(vDate DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketBuiltTime`(vDate DATE) BEGIN DECLARE vDateStart DATETIME DEFAULT DATE(vDate); diff --git a/db/routines/vn/procedures/ticketCalculateClon.sql b/db/routines/vn/procedures/ticketCalculateClon.sql index a56491590..872efee10 100644 --- a/db/routines/vn/procedures/ticketCalculateClon.sql +++ b/db/routines/vn/procedures/ticketCalculateClon.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketCalculateClon`(IN vTicketNew INT, vTicketOld INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketCalculateClon`(IN vTicketNew INT, vTicketOld INT) BEGIN /* * Recalcula los componentes un ticket clonado, diff --git a/db/routines/vn/procedures/ticketCalculateFromType.sql b/db/routines/vn/procedures/ticketCalculateFromType.sql index 63f4b8941..54d180abd 100644 --- a/db/routines/vn/procedures/ticketCalculateFromType.sql +++ b/db/routines/vn/procedures/ticketCalculateFromType.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketCalculateFromType`( vLanded DATE, +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketCalculateFromType`( vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vTypeFk INT) diff --git a/db/routines/vn/procedures/ticketCalculatePurge.sql b/db/routines/vn/procedures/ticketCalculatePurge.sql index 86e3b0d1b..da126281f 100644 --- a/db/routines/vn/procedures/ticketCalculatePurge.sql +++ b/db/routines/vn/procedures/ticketCalculatePurge.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketCalculatePurge`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketCalculatePurge`() BEGIN DROP TEMPORARY TABLE tmp.ticketCalculateItem, diff --git a/db/routines/vn/procedures/ticketClon.sql b/db/routines/vn/procedures/ticketClon.sql index 9144ac709..9d7d1c5b3 100644 --- a/db/routines/vn/procedures/ticketClon.sql +++ b/db/routines/vn/procedures/ticketClon.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketClon`(vTicketFk INT, vNewShipped DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketClon`(vTicketFk INT, vNewShipped DATE) BEGIN DECLARE vNewTicketFk INT; diff --git a/db/routines/vn/procedures/ticketClon_OneYear.sql b/db/routines/vn/procedures/ticketClon_OneYear.sql index b0c08dec8..31f896a22 100644 --- a/db/routines/vn/procedures/ticketClon_OneYear.sql +++ b/db/routines/vn/procedures/ticketClon_OneYear.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketClon_OneYear`(vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketClon_OneYear`(vTicketFk INT) BEGIN DECLARE vShipped DATE; diff --git a/db/routines/vn/procedures/ticketCollection_get.sql b/db/routines/vn/procedures/ticketCollection_get.sql index 357471fee..6af94fbf2 100644 --- a/db/routines/vn/procedures/ticketCollection_get.sql +++ b/db/routines/vn/procedures/ticketCollection_get.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketCollection_get`(vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketCollection_get`(vTicketFk INT) BEGIN SELECT tc.collectionFk diff --git a/db/routines/vn/procedures/ticketCollection_setUsedShelves.sql b/db/routines/vn/procedures/ticketCollection_setUsedShelves.sql index c69575ba7..8851fcafb 100644 --- a/db/routines/vn/procedures/ticketCollection_setUsedShelves.sql +++ b/db/routines/vn/procedures/ticketCollection_setUsedShelves.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketCollection_setUsedShelves`(vTicketFk INT, vUsedShelves INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketCollection_setUsedShelves`(vTicketFk INT, vUsedShelves INT) BEGIN /* diff --git a/db/routines/vn/procedures/ticketComponentUpdate.sql b/db/routines/vn/procedures/ticketComponentUpdate.sql index bdb3bf6cb..373bf8fbc 100644 --- a/db/routines/vn/procedures/ticketComponentUpdate.sql +++ b/db/routines/vn/procedures/ticketComponentUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketComponentUpdate`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketComponentUpdate`( vTicketFk INT, vClientFk INT, vAgencyModeFk INT, diff --git a/db/routines/vn/procedures/ticketComponentUpdateSale.sql b/db/routines/vn/procedures/ticketComponentUpdateSale.sql index d002655d1..26ede95c2 100644 --- a/db/routines/vn/procedures/ticketComponentUpdateSale.sql +++ b/db/routines/vn/procedures/ticketComponentUpdateSale.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketComponentUpdateSale`(vCode VARCHAR(25)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketComponentUpdateSale`(vCode VARCHAR(25)) BEGIN /** * A partir de la tabla tmp.sale, crea los Movimientos_componentes diff --git a/db/routines/vn/procedures/ticketDown_PrintableSelection.sql b/db/routines/vn/procedures/ticketDown_PrintableSelection.sql index 45002dd1f..082a890a6 100644 --- a/db/routines/vn/procedures/ticketDown_PrintableSelection.sql +++ b/db/routines/vn/procedures/ticketDown_PrintableSelection.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketDown_PrintableSelection`(vSectorFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketDown_PrintableSelection`(vSectorFk INT) BEGIN UPDATE vn.ticketDown td diff --git a/db/routines/vn/procedures/ticketGetTaxAdd.sql b/db/routines/vn/procedures/ticketGetTaxAdd.sql index 55f587d9d..b977ae042 100644 --- a/db/routines/vn/procedures/ticketGetTaxAdd.sql +++ b/db/routines/vn/procedures/ticketGetTaxAdd.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketGetTaxAdd`(vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketGetTaxAdd`(vTicketFk INT) BEGIN /** * Añade un ticket a la tabla tmp.ticket para calcular diff --git a/db/routines/vn/procedures/ticketGetTax_new.sql b/db/routines/vn/procedures/ticketGetTax_new.sql index f7c5891cc..b7df8a766 100644 --- a/db/routines/vn/procedures/ticketGetTax_new.sql +++ b/db/routines/vn/procedures/ticketGetTax_new.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketGetTax_new`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketGetTax_new`() READS SQL DATA BEGIN /** diff --git a/db/routines/vn/procedures/ticketGetTotal.sql b/db/routines/vn/procedures/ticketGetTotal.sql index b77f261b0..02c824009 100644 --- a/db/routines/vn/procedures/ticketGetTotal.sql +++ b/db/routines/vn/procedures/ticketGetTotal.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketGetTotal`(vTaxArea VARCHAR(25)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketGetTotal`(vTaxArea VARCHAR(25)) BEGIN /** * Calcula el total con IVA para un conjunto de tickets. diff --git a/db/routines/vn/procedures/ticketGetVisibleAvailable.sql b/db/routines/vn/procedures/ticketGetVisibleAvailable.sql index 07dfa69e5..01010f548 100644 --- a/db/routines/vn/procedures/ticketGetVisibleAvailable.sql +++ b/db/routines/vn/procedures/ticketGetVisibleAvailable.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketGetVisibleAvailable`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketGetVisibleAvailable`( vTicket INT) BEGIN DECLARE vVisibleCalc INT; @@ -7,13 +7,16 @@ BEGIN DECLARE vShipped DATE; DECLARE vWarehouse TINYINT; DECLARE vAlertLevel INT; + DECLARE vAlertLevelFree INT; - SELECT t.warehouseFk, t.shipped, ts.alertLevel INTO vWarehouse, vShipped, vAlertLevel + SELECT t.warehouseFk, t.shipped, ts.alertLevel, al.id + INTO vWarehouse, vShipped, vAlertLevel, vAlertLevelFree FROM ticket t + JOIN alertLevel al ON al.code = 'FREE' LEFT JOIN ticketState ts ON ts.ticketFk = vTicket WHERE t.id = vTicket; - IF vAlertLevel IS NULL OR vAlertLevel = 0 THEN + IF vAlertLevel IS NULL OR vAlertLevel = vAlertLevelFree THEN IF vShipped >= util.VN_CURDATE() THEN CALL cache.available_refresh(vAvailableCalc, FALSE, vWarehouse, vShipped); END IF; diff --git a/db/routines/vn/procedures/ticketMissed_List.sql b/db/routines/vn/procedures/ticketMissed_List.sql deleted file mode 100644 index 6b0f66e6a..000000000 --- a/db/routines/vn/procedures/ticketMissed_List.sql +++ /dev/null @@ -1,49 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketMissed_List`(vTicketFk INT) -BEGIN - - DECLARE vParkingFk INT; - DECLARE vParked DATETIME; - DECLARE vLevel INT; - DECLARE vCollectionFk INT; - - SELECT IFNULL(`level`,0), IFNULL(collectionFk,0) - INTO vLevel, vCollectionFk - FROM vn.ticketCollection - WHERE ticketFk = vTicketFk - LIMIT 1; - - SELECT created, parkingFk - INTO vParked, vParkingFk - FROM vn.ticketParking - WHERE ticketFk = vTicketFk; - - SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia - FROM vn.ticketParking tp - JOIN vn.parking p ON p.id = tp.parkingFk - JOIN vn.sector sc ON sc.id = p.sectorFk - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk - JOIN vn.ticketStateToday tst ON tst.ticketFk = tp.ticketFk - JOIN vn.ticket t ON t.id = tp.ticketFk - JOIN vn.zone z ON z.id = t.zoneFk - JOIN vn.agencyMode am ON am.id = z.agencyModeFk - JOIN vn.state s ON s.id = tst.state - WHERE (s.alertLevel < 2 - AND tp.parkingFk = vParkingFk - AND sc.isPackagingArea - AND ( - ( - ( IFNULL(tc.collectionFk,-1) != IFNULL(@vCollectionFk,0) AND tp.created < vParked ) - OR - ( tc.collectionFk = vCollectionFk AND LEFT(tc.level,1) < LEFT(vLevel,1) ) - ) - )) -- Etiquetas que no se han escaneado y ya estamos con una posterior - OR - (s.alertLevel > 1 - AND tp.parkingFk = vParkingFk - AND sc.isPackagingArea - AND tp.created < vParked - AND t.packages <=> 0); - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/ticketNotInvoicedByClient.sql b/db/routines/vn/procedures/ticketNotInvoicedByClient.sql index cb177b6d0..7933fda80 100644 --- a/db/routines/vn/procedures/ticketNotInvoicedByClient.sql +++ b/db/routines/vn/procedures/ticketNotInvoicedByClient.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketNotInvoicedByClient`(vClientFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketNotInvoicedByClient`(vClientFk INT) BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket; diff --git a/db/routines/vn/procedures/ticketObservation_addNewBorn.sql b/db/routines/vn/procedures/ticketObservation_addNewBorn.sql index f70a11a48..3e04c8c4e 100644 --- a/db/routines/vn/procedures/ticketObservation_addNewBorn.sql +++ b/db/routines/vn/procedures/ticketObservation_addNewBorn.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketObservation_addNewBorn`(vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketObservation_addNewBorn`(vTicketFk INT) BEGIN /** diff --git a/db/routines/vn/procedures/ticketPackaging_add.sql b/db/routines/vn/procedures/ticketPackaging_add.sql index f96068b56..ed791a5f2 100644 --- a/db/routines/vn/procedures/ticketPackaging_add.sql +++ b/db/routines/vn/procedures/ticketPackaging_add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketPackaging_add`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketPackaging_add`( vClientFk INT, vDated DATE, vCompanyFk INT, diff --git a/db/routines/vn/procedures/ticketParking_findSkipped.sql b/db/routines/vn/procedures/ticketParking_findSkipped.sql index b00006ffe..14ab28a15 100644 --- a/db/routines/vn/procedures/ticketParking_findSkipped.sql +++ b/db/routines/vn/procedures/ticketParking_findSkipped.sql @@ -1,64 +1,66 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketParking_findSkipped`(vTicketFk INT, vItemPackingTypeFk VARCHAR(1)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketParking_findSkipped`(vTicketFk INT, vItemPackingTypeFk VARCHAR(1)) BEGIN - + /** * Averigua los tickets que se han saltado por un error en el proceso encajado * @param vTicketFk Ticket * @param vItemPackingTypeFk Modo de encajado * @return un select con los tickets afectados - */ + */ DECLARE vParkingFk INT; DECLARE vParked DATETIME; DECLARE vLevel INT; DECLARE vWagon INT; DECLARE vCollectionFk INT; - - SELECT IFNULL(`level`,0), IFNULL(`wagon`,0),IFNULL(collectionFk,0) + + SELECT IFNULL(`level`,0), IFNULL(`wagon`,0),IFNULL(collectionFk,0) INTO vLevel, vWagon, vCollectionFk FROM vn.ticketCollection tc JOIN vn.collection c ON c.id = tc.collectionFk AND c.itemPackingTypeFk = vItemPackingTypeFk WHERE ticketFk = vTicketFk ORDER BY c.id DESC LIMIT 1; - - SELECT created, parkingFk + + SELECT created, parkingFk INTO vParked, vParkingFk FROM vn.ticketParking tp - JOIN vn.parking p ON p.id = tp.parkingFk - JOIN vn.sector s ON s.id = p.sectorFk + JOIN vn.parking p ON p.id = tp.parkingFk + JOIN vn.sector s ON s.id = p.sectorFk WHERE ticketFk = vTicketFk AND s.itemPackingTypeFk = vItemPackingTypeFk AND s.isPackagingArea ; - + SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' ', tc.wagon, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia FROM vn.ticketParking tp - JOIN vn.parking p ON p.id = tp.parkingFk - JOIN vn.sector sc ON sc.id = p.sectorFk - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk - JOIN vn.ticketStateToday tst ON tst.ticketFk = tp.ticketFk - JOIN vn.ticket t ON t.id = tp.ticketFk - JOIN vn.zone z ON z.id = t.zoneFk - JOIN vn.agencyMode am ON am.id = z.agencyModeFk - JOIN vn.state s ON s.id = tst.state - WHERE (s.alertLevel < 2 + JOIN vn.parking p ON p.id = tp.parkingFk + JOIN vn.sector sc ON sc.id = p.sectorFk + LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk + JOIN vn.ticketStateToday tst ON tst.ticketFk = tp.ticketFk + JOIN vn.ticket t ON t.id = tp.ticketFk + JOIN vn.zone z ON z.id = t.zoneFk + JOIN vn.agencyMode am ON am.id = z.agencyModeFk + JOIN vn.state s ON s.id = tst.state + JOIN vn.alertLevel alPacked ON alPacked.code = 'PACKED' + JOIN vn.alertLevel alOnPreparation ON alOnPreparation.code = 'ON_PREPARATION' + WHERE (s.alertLevel < alPacked.id AND tp.parkingFk = vParkingFk AND sc.isPackagingArea AND ( ( IFNULL(tc.collectionFk,-1) != IFNULL(@vCollectionFk,0) AND tp.created < vParked ) OR - ( tc.collectionFk = vCollectionFk + ( tc.collectionFk = vCollectionFk AND (LEFT(tc.wagon,1) < LEFT(vWagon,1) - OR (LEFT(tc.wagon,1) = LEFT(vWagon,1) AND LEFT(tc.level,1) < LEFT(vLevel,1))) + OR (LEFT(tc.wagon,1) = LEFT(vWagon,1) AND LEFT(tc.level,1) < LEFT(vLevel,1))) ) ) ) -- Etiquetas que no se han escaneado y ya estamos con una posterior OR - (s.alertLevel > 1 + (s.alertLevel > alOnPreparation.id AND tp.parkingFk = vParkingFk AND sc.isPackagingArea - AND tp.created < vParked + AND tp.created < vParked AND t.packages <=> 0); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticketRefund_beforeUpsert.sql b/db/routines/vn/procedures/ticketRefund_beforeUpsert.sql deleted file mode 100644 index 5a0e99318..000000000 --- a/db/routines/vn/procedures/ticketRefund_beforeUpsert.sql +++ /dev/null @@ -1,18 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketRefund_beforeUpsert`(vRefundTicketFk INT, vOriginalTicketFk INT) -BEGIN - DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE; - - IF vRefundTicketFk = vOriginalTicketFk THEN - CALL util.throw('Original ticket and refund ticket has same id'); - END IF; - - SELECT COUNT(*) INTO vAlreadyExists - FROM ticketRefund - WHERE refundTicketFk = vOriginalTicketFk; - - IF vAlreadyExists > 0 THEN - CALL util.throw('This ticket is already a refund'); - END IF; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/ticketRefund_upsert.sql b/db/routines/vn/procedures/ticketRefund_upsert.sql new file mode 100644 index 000000000..fb22e6e8c --- /dev/null +++ b/db/routines/vn/procedures/ticketRefund_upsert.sql @@ -0,0 +1,25 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketRefund_upsert`( + vRefundTicketFk INT, + vOriginalTicketFk INT +) + READS SQL DATA +BEGIN +/** + * Common code for ticketRefund triggers + * + * @param vRefundTicketFk + * @param vOriginalTicketFk + */ + DECLARE vIsDeleted BOOL; + + SELECT COUNT(*) INTO vIsDeleted + FROM ticket + WHERE id IN (vRefundTicketFk, vOriginalTicketFk) + AND isDeleted; + + IF vIsDeleted THEN + CALL util.throw('The refund ticket cannot be deleted tickets'); + END IF; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/ticketStateToday_setState.sql b/db/routines/vn/procedures/ticketStateToday_setState.sql index 73a92bbb5..8802c3d08 100644 --- a/db/routines/vn/procedures/ticketStateToday_setState.sql +++ b/db/routines/vn/procedures/ticketStateToday_setState.sql @@ -1,26 +1,29 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketStateToday_setState`(vTicketFk INT, vStateCode VARCHAR(45)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketStateToday_setState`(vTicketFk INT, vStateCode VARCHAR(45)) BEGIN - + /* Modifica el estado de un ticket de hoy - * + * * @param vTicketFk el id del ticket * @param vStateCode estado a modificar del ticket - * + * */ - + DECLARE vAlertLevel INT; - - SELECT s.alertLevel INTO vAlertLevel - FROM state s - JOIN ticketStateToday tst ON tst.state = s.id + DECLARE vAlertLevelPacked INT; + + SELECT s.alertLevel, al.id + INTO vAlertLevel, vAlertLevelPacked + FROM state s + JOIN ticketStateToday tst ON tst.state = s.id + JOIN alertLevel al ON al.code = 'PACKED' WHERE tst.ticketFk = vTicketFk LIMIT 1; - - IF vAlertLevel < 2 THEN - + + IF vAlertLevel < vAlertLevelPacked THEN + CALL vn.ticket_setState(vTicketFk, vStateCode); - + END IF; END$$ diff --git a/db/routines/vn/procedures/ticketStateUpdate.sql b/db/routines/vn/procedures/ticketStateUpdate.sql deleted file mode 100644 index 4e19b7eb4..000000000 --- a/db/routines/vn/procedures/ticketStateUpdate.sql +++ /dev/null @@ -1,26 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketStateUpdate`(vTicketFk INT, vStateCode VARCHAR(45)) -BEGIN - - /* - * @deprecated:utilizar ticket_setState - */ - - DECLARE vAlertLevel INT; - - SELECT s.alertLevel INTO vAlertLevel - FROM vn.state s - JOIN vn.ticketState ts ON ts.stateFk = s.id - WHERE ts.ticketFk = vTicketFk; - - IF !(vStateCode = 'ON_CHECKING' AND vAlertLevel > 1) THEN - - INSERT INTO ticketTracking(stateFk, ticketFk, userFk) - SELECT id, vTicketFk, account.myUser_getId() - FROM vn.state - WHERE `code` = vStateCode collate utf8_unicode_ci; - - END IF; - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/ticketToInvoiceByAddress.sql b/db/routines/vn/procedures/ticketToInvoiceByAddress.sql index ad51c761a..5e554d358 100644 --- a/db/routines/vn/procedures/ticketToInvoiceByAddress.sql +++ b/db/routines/vn/procedures/ticketToInvoiceByAddress.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketToInvoiceByAddress`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketToInvoiceByAddress`( vStarted DATE, vEnded DATETIME, vAddress INT, diff --git a/db/routines/vn/procedures/ticketToInvoiceByDate.sql b/db/routines/vn/procedures/ticketToInvoiceByDate.sql index 8937ab7ae..52e418ee3 100644 --- a/db/routines/vn/procedures/ticketToInvoiceByDate.sql +++ b/db/routines/vn/procedures/ticketToInvoiceByDate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketToInvoiceByDate`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketToInvoiceByDate`( vStarted DATE, vEnded DATETIME, vClient INT, diff --git a/db/routines/vn/procedures/ticketToInvoiceByRef.sql b/db/routines/vn/procedures/ticketToInvoiceByRef.sql index 4f5c23ba2..390340143 100644 --- a/db/routines/vn/procedures/ticketToInvoiceByRef.sql +++ b/db/routines/vn/procedures/ticketToInvoiceByRef.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketToInvoiceByRef`(IN vInvoiceRef VARCHAR(15)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketToInvoiceByRef`(IN vInvoiceRef VARCHAR(15)) BEGIN /* Para tickets ya facturados, vuelve a repetir el proceso de facturación. diff --git a/db/routines/vn/procedures/ticket_Clone.sql b/db/routines/vn/procedures/ticket_Clone.sql index 7670e832e..f97655007 100644 --- a/db/routines/vn/procedures/ticket_Clone.sql +++ b/db/routines/vn/procedures/ticket_Clone.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_Clone`(vOriginalTicket INT, OUT vNewTicket INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_Clone`(vOriginalTicket INT, OUT vNewTicket INT) BEGIN /** * Clona el contenido de un ticket en otro @@ -9,6 +9,11 @@ BEGIN */ DECLARE vStateFk INT; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + RESIGNAL; + END; + INSERT INTO ticket ( clientFk, shipped, diff --git a/db/routines/vn/procedures/ticket_DelayTruck.sql b/db/routines/vn/procedures/ticket_DelayTruck.sql index 7a3170d68..ebd0e5baf 100644 --- a/db/routines/vn/procedures/ticket_DelayTruck.sql +++ b/db/routines/vn/procedures/ticket_DelayTruck.sql @@ -1,22 +1,23 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_DelayTruck`(vWarehouserFk INT, vHour INT, vMinute INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_DelayTruck`(vWarehouserFk INT, vHour INT, vMinute INT) BEGIN DECLARE done INT DEFAULT FALSE; DECLARE vTicketFk INT; - DECLARE cur1 CURSOR FOR SELECT ticketFk FROM tmp.ticket; + DECLARE cur1 CURSOR FOR SELECT ticketFk FROM tTicket; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; CALL vn.productionControl(vWarehouserFk,0) ; - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - CREATE TEMPORARY TABLE tmp.ticket + DROP TEMPORARY TABLE IF EXISTS tTicket; + CREATE TEMPORARY TABLE tTicket SELECT ticketFk FROM tmp.productionBuffer + JOIN alertLevel al ON al.code = 'FREE' WHERE shipped = util.VN_CURDATE() AND problem LIKE '%I:%' AND (HH <= vHour OR HH = vHour AND mm < vMinute) - AND alertLevel = 0; + AND alertLevel = al.id; OPEN cur1; @@ -30,5 +31,6 @@ BEGIN END LOOP; CLOSE cur1; + DROP TEMPORARY TABLE tTicket, tmp.productionBuffer; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_DelayTruckSplit.sql b/db/routines/vn/procedures/ticket_DelayTruckSplit.sql index c7de6a984..1dc45d065 100644 --- a/db/routines/vn/procedures/ticket_DelayTruckSplit.sql +++ b/db/routines/vn/procedures/ticket_DelayTruckSplit.sql @@ -1,5 +1,7 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_DelayTruckSplit`(vTicketFk INT) +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_DelayTruckSplit`( + vTicketFk INT +) BEGIN /** * Splita las lineas de ticket que no estan ubicadas @@ -50,8 +52,8 @@ BEGIN SET s.ticketFk = vNewTicketFk; END IF; - CALL ticketStateUpdate(vNewTicketFk, 'FIXING'); + CALL ticket_setState(vNewTicketFk, 'FIXING'); DROP TEMPORARY TABLE tmp.SalesToSplit; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_WeightDeclaration.sql b/db/routines/vn/procedures/ticket_WeightDeclaration.sql index e50290dd8..9105cfc61 100644 --- a/db/routines/vn/procedures/ticket_WeightDeclaration.sql +++ b/db/routines/vn/procedures/ticket_WeightDeclaration.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_WeightDeclaration`(vClientFk INT, vDated DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_WeightDeclaration`(vClientFk INT, vDated DATE) BEGIN DECLARE vTheorycalWeight DECIMAL(10,2); diff --git a/db/routines/vn/procedures/ticket_add.sql b/db/routines/vn/procedures/ticket_add.sql index 5c3c28081..03ad7246b 100644 --- a/db/routines/vn/procedures/ticket_add.sql +++ b/db/routines/vn/procedures/ticket_add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_add`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_add`( vClientId INT ,vShipped DATE ,vWarehouseFk INT @@ -65,6 +65,8 @@ BEGIN IF (vZoneFk IS NULL OR vZoneFk = 0) AND vIsRequiredZone THEN CALL util.throw ('NOT_ZONE_WITH_THIS_PARAMETERS'); END IF; + + DROP TEMPORARY TABLE tmp.zoneGetShipped; END IF; INSERT INTO ticket ( diff --git a/db/routines/vn/procedures/ticket_administrativeCopy.sql b/db/routines/vn/procedures/ticket_administrativeCopy.sql index f240a5fe0..7e8c436a8 100644 --- a/db/routines/vn/procedures/ticket_administrativeCopy.sql +++ b/db/routines/vn/procedures/ticket_administrativeCopy.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_administrativeCopy`(vOriginalTicket INT, OUT vNewTicket INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_administrativeCopy`(vOriginalTicket INT, OUT vNewTicket INT) BEGIN INSERT INTO vn.ticket(clientFk, addressFk, shipped, warehouseFk, companyFk, landed) diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index d1ca7b5e2..57c3f4235 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) BEGIN /** * Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar. @@ -19,8 +19,7 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) - SELECT - origin.ticketFk futureId, + SELECT origin.ticketFk futureId, dest.ticketFk id, dest.state, origin.futureState, @@ -51,48 +50,48 @@ BEGIN origin.warehouseFk futureWarehouseFk, origin.companyFk futureCompanyFk, IFNULL(dest.nickname, origin.nickname) nickname, - dest.landed + dest.landed, + dest.preparation FROM ( - SELECT - s.ticketFk, - c.salesPersonFk workerFk, - t.shipped, - t.totalWithVat, - st.name futureState, - am.name futureAgency, - count(s.id) futureLines, - GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, - CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, - SUM(s.quantity <= (IFNULL(il.stock,0) + IFNULL(im.amount, 0))) hasStock, - z.id futureZoneFk, - z.name futureZoneName, - st.classColor, - t.clientFk, - t.nickname, - t.addressFk, - t.warehouseFk, - t.companyFk, - t.agencyModeFk - FROM ticket t - JOIN client c ON c.id = t.clientFk - JOIN sale s ON s.ticketFk = t.id - JOIN saleVolume sv ON sv.saleFk = s.id - JOIN item i ON i.id = s.itemFk - JOIN ticketState ts ON ts.ticketFk = t.id - JOIN state st ON st.id = ts.stateFk - JOIN agencyMode am ON t.agencyModeFk = am.id - JOIN zone z ON t.zoneFk = z.id - LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk - LEFT JOIN tmp.itemMinacum im ON im.itemFk = i.id - AND im.warehouseFk = vWarehouseFk - LEFT JOIN tmp.itemList il ON il.itemFk = i.id - WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) - AND t.warehouseFk = vWarehouseFk - GROUP BY t.id + SELECT s.ticketFk, + c.salesPersonFk workerFk, + t.shipped, + t.totalWithVat, + st.name futureState, + am.name futureAgency, + count(s.id) futureLines, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, + CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, + SUM(s.quantity <= (IFNULL(il.stock,0) + IFNULL(im.amount, 0))) hasStock, + z.id futureZoneFk, + z.name futureZoneName, + st.classColor, + t.clientFk, + t.nickname, + t.addressFk, + t.warehouseFk, + t.companyFk, + t.agencyModeFk + FROM ticket t + JOIN client c ON c.id = t.clientFk + JOIN sale s ON s.ticketFk = t.id + JOIN saleVolume sv ON sv.saleFk = s.id + JOIN item i ON i.id = s.itemFk + JOIN ticketState ts ON ts.ticketFk = t.id + JOIN `state` st ON st.id = ts.stateFk + JOIN agencyMode am ON t.agencyModeFk = am.id + JOIN `zone` z ON t.zoneFk = z.id + LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk + LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN tmp.itemMinacum im ON im.itemFk = i.id + AND im.warehouseFk = vWarehouseFk + LEFT JOIN tmp.itemList il ON il.itemFk = i.id + WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) + AND t.warehouseFk = vWarehouseFk + GROUP BY t.id ) origin LEFT JOIN ( - SELECT - t.id ticketFk, + SELECT t.id ticketFk, st.name state, GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, t.shipped, @@ -108,18 +107,25 @@ BEGIN t.warehouseFk, t.companyFk, t.landed, - t.agencyModeFk + t.agencyModeFk, + SEC_TO_TIME( + COALESCE(HOUR(t.shipped), HOUR(zc.hour), HOUR(z.hour)) * 3600 + + COALESCE(MINUTE(t.shipped), MINUTE(zc.hour), MINUTE(z.hour)) * 60 + ) preparation FROM ticket t JOIN sale s ON s.ticketFk = t.id JOIN saleVolume sv ON sv.saleFk = s.id JOIN item i ON i.id = s.itemFk JOIN ticketState ts ON ts.ticketFk = t.id - JOIN state st ON st.id = ts.stateFk + JOIN `state` st ON st.id = ts.stateFk JOIN agencyMode am ON t.agencyModeFk = am.id LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN `zone` z ON z.id = t.zoneFk + LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk + JOIN ticketCanAdvanceConfig tc WHERE t.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) AND t.warehouseFk = vWarehouseFk - AND st.order <= 5 + AND st.order <= tc.destinationOrder GROUP BY t.id ) dest ON dest.addressFk = origin.addressFk WHERE origin.hasStock; diff --git a/db/routines/vn/procedures/ticket_canMerge.sql b/db/routines/vn/procedures/ticket_canMerge.sql index c3f211027..ce90551db 100644 --- a/db/routines/vn/procedures/ticket_canMerge.sql +++ b/db/routines/vn/procedures/ticket_canMerge.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canMerge`(vDated DATE, vScopeDays INT, vLitersMax INT, vLinesMax INT, vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_canMerge`(vDated DATE, vScopeDays INT, vLitersMax INT, vLinesMax INT, vWarehouseFk INT) BEGIN /** * Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro diff --git a/db/routines/vn/procedures/ticket_canbePostponed.sql b/db/routines/vn/procedures/ticket_canbePostponed.sql index 442059b99..1f3c43057 100644 --- a/db/routines/vn/procedures/ticket_canbePostponed.sql +++ b/db/routines/vn/procedures/ticket_canbePostponed.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canbePostponed`(vOriginDated DATE, vFutureDated DATE, vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_canbePostponed`(vOriginDated DATE, vFutureDated DATE, vWarehouseFk INT) BEGIN /** * Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro @@ -21,6 +21,7 @@ BEGIN t.clientFk, t.warehouseFk, ts.alertLevel, + sub2.alertLevel futureAlertLevel, t.shipped, t.totalWithVat, sub2.shipped futureShipped, @@ -47,6 +48,7 @@ BEGIN t.addressFk, t.id, t.shipped, + ts.alertLevel, st.name state, st.code, st.classColor, diff --git a/db/routines/vn/procedures/ticket_checkNoComponents.sql b/db/routines/vn/procedures/ticket_checkNoComponents.sql index 28fe333f0..aa2947763 100644 --- a/db/routines/vn/procedures/ticket_checkNoComponents.sql +++ b/db/routines/vn/procedures/ticket_checkNoComponents.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_checkNoComponents`(vShippedFrom DATETIME, vShippedTo DATETIME) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_checkNoComponents`(vShippedFrom DATETIME, vShippedTo DATETIME) BEGIN /** @@ -20,7 +20,8 @@ BEGIN JOIN itemCategory ic ON ic.id = tp.categoryFk JOIN saleComponent sc ON sc.saleFk = s.id JOIN component c ON c.id = sc.componentFk - JOIN componentType ct ON ct.id = c.typeFk AND ct.id = 1 + JOIN componentType ct ON ct.id = c.typeFk + AND ct.code = 'cost' WHERE t.shipped BETWEEN vShippedFrom AND vShippedTo AND ic.merchandise; diff --git a/db/routines/vn/procedures/ticket_cloneAll.sql b/db/routines/vn/procedures/ticket_cloneAll.sql index 4b3401ed7..30f0431f7 100644 --- a/db/routines/vn/procedures/ticket_cloneAll.sql +++ b/db/routines/vn/procedures/ticket_cloneAll.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_cloneAll`(vTicketFk INT, vNewShipped DATE, vWithWarehouse BOOLEAN, OUT vNewTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_cloneAll`(vTicketFk INT, vNewShipped DATE, vWithWarehouse BOOLEAN, OUT vNewTicketFk INT) BEGIN DECLARE vDone BOOLEAN DEFAULT FALSE; diff --git a/db/routines/vn/procedures/ticket_cloneWeekly.sql b/db/routines/vn/procedures/ticket_cloneWeekly.sql index 6bceb2fdf..bfea00f31 100644 --- a/db/routines/vn/procedures/ticket_cloneWeekly.sql +++ b/db/routines/vn/procedures/ticket_cloneWeekly.sql @@ -1,7 +1,9 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_cloneWeekly`(vDateFrom DATE, vDateTo DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_cloneWeekly`( + vDateFrom DATE, + vDateTo DATE +) BEGIN - DECLARE vIsDone BOOL; DECLARE vLanding DATE; DECLARE vShipment DATE; DECLARE vWarehouseFk INT; @@ -12,42 +14,50 @@ BEGIN DECLARE vAgencyModeFk INT; DECLARE vNewTicket INT; DECLARE vYear INT; - DECLARE vSalesPersonFK INT; - DECLARE vItemPicker INT; + DECLARE vObservationSalesPersonFk INT + DEFAULT (SELECT id FROM observationType WHERE code = 'salesPerson'); + DECLARE vObservationItemPickerFk INT + DEFAULT (SELECT id FROM observationType WHERE code = 'itemPicker'); + DECLARE vEmail VARCHAR(255); + DECLARE vIsDuplicateMail BOOL; + DECLARE vSubject VARCHAR(100); + DECLARE vMessage TEXT; + DECLARE vDone BOOL; - DECLARE rsTicket CURSOR FOR - SELECT tt.ticketFk, - t.clientFk, - t.warehouseFk, - t.companyFk, - t.addressFk, - tt.agencyModeFk, - ti.dated - FROM ticketWeekly tt - JOIN ticket t ON tt.ticketFk = t.id - JOIN tmp.time ti - WHERE WEEKDAY(ti.dated) = tt.weekDay; + DECLARE vTickets CURSOR FOR + SELECT tt.ticketFk, + t.clientFk, + t.warehouseFk, + t.companyFk, + t.addressFk, + tt.agencyModeFk, + ti.dated + FROM ticketWeekly tt + JOIN ticket t ON tt.ticketFk = t.id + JOIN tmp.time ti + WHERE WEEKDAY(ti.dated) = tt.weekDay; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE; - - CALL `util`.`time_generate`(vDateFrom,vDateTo); - - OPEN rsTicket; - myLoop: LOOP - BEGIN - DECLARE vSalesPersonEmail VARCHAR(150); - DECLARE vIsDuplicateMail BOOL; - DECLARE vSubject VARCHAR(150); - DECLARE vMessage TEXT; - - SET vIsDone = FALSE; - FETCH rsTicket INTO vTicketFk,vClientFk, vWarehouseFk, vCompanyFk, vAddressFk, vAgencyModeFk,vShipment; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - IF vIsDone THEN - LEAVE myLoop; + CALL `util`.`time_generate`(vDateFrom, vDateTo); + + OPEN vTickets; + l: LOOP + SET vDone = FALSE; + FETCH vTickets INTO + vTicketFk, + vClientFk, + vWarehouseFk, + vCompanyFk, + vAddressFk, + vAgencyModeFk, + vShipment; + + IF vDone THEN + LEAVE l; END IF; - -- busca si el ticket ya ha sido clonado + -- Busca si el ticket ya ha sido clonado IF EXISTS (SELECT TRUE FROM ticket tOrig JOIN sale saleOrig ON tOrig.id = saleOrig.ticketFk JOIN saleCloned sc ON sc.saleOriginalFk = saleOrig.id @@ -57,7 +67,7 @@ BEGIN AND tClon.isDeleted = FALSE AND DATE(tClon.shipped) = vShipment) THEN - ITERATE myLoop; + ITERATE l; END IF; IF vAgencyModeFk IS NULL THEN @@ -67,7 +77,7 @@ BEGIN AND isDefaultAddress; END IF; - CALL zone_getLanded(vShipment, vAddressFk, vAgencyModeFk, vWarehouseFk,FALSE); + CALL zone_getLanded(vShipment, vAddressFk, vAgencyModeFk, vWarehouseFk, FALSE); SET vLanding = NULL; SELECT landed INTO vLanding FROM tmp.zoneGetLanded LIMIT 1; @@ -88,18 +98,24 @@ BEGIN SET clonedFrom = vTicketFk WHERE id = vNewTicket; - INSERT INTO sale (ticketFk, itemFk, concept, quantity, price, - discount, priceFixed, isPriceFixed) + INSERT INTO sale (ticketFk, + itemFk, + concept, + quantity, + price, + discount, + priceFixed, + isPriceFixed) SELECT vNewTicket, - saleOrig.itemFk, - saleOrig.concept, - saleOrig.quantity, - saleOrig.price, - saleOrig.discount, - saleOrig.priceFixed, - saleOrig.isPriceFixed - FROM sale saleOrig - WHERE saleOrig.ticketFk = vTicketFk; + itemFk, + concept, + quantity, + price, + discount, + priceFixed, + isPriceFixed + FROM sale + WHERE ticketFk = vTicketFk; INSERT IGNORE INTO saleCloned(saleOriginalFk, saleClonedFk) SELECT saleOriginal.id, saleClon.id @@ -123,28 +139,20 @@ BEGIN ,attenderFk, ticketFk) SELECT description, - ordered, - shipped, - quantity, - price, - itemFk, - clientFk, - response, - total, - buyed, - requesterFk, - attenderFk, - vNewTicket + ordered, + shipped, + quantity, + price, + itemFk, + clientFk, + response, + total, + buyed, + requesterFk, + attenderFk, + vNewTicket FROM ticketRequest - WHERE ticketFk =vTicketFk; - - SELECT id INTO vSalesPersonFK - FROM observationType - WHERE code = 'salesPerson'; - - SELECT id INTO vItemPicker - FROM observationType - WHERE code = 'itemPicker'; + WHERE ticketFk = vTicketFk; INSERT INTO ticketObservation( ticketFk, @@ -152,7 +160,7 @@ BEGIN description) VALUES( vNewTicket, - vSalesPersonFK, + vObservationSalesPersonFk, CONCAT('turno desde ticket: ',vTicketFk)) ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' '); @@ -162,16 +170,17 @@ BEGIN description) VALUES( vNewTicket, - vItemPicker, + vObservationItemPickerFk, 'ATENCION: Contiene lineas de TURNO') ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' '); - IF (vLanding IS NULL) THEN - - SELECT e.email INTO vSalesPersonEmail + IF vLanding IS NULL THEN + SELECT IFNULL(d.notificationEmail, e.email) INTO vEmail FROM client c JOIN account.emailUser e ON e.userFk = c.salesPersonFk + LEFT JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk + LEFT JOIN department d ON d.id = wd.departmentFk WHERE c.id = vClientFk; SET vSubject = CONCAT('Turnos - No se ha podido clonar correctamente el ticket ', @@ -183,20 +192,21 @@ BEGIN SELECT COUNT(*) INTO vIsDuplicateMail FROM mail - WHERE receiver = vSalesPersonEmail + WHERE receiver = vEmail AND subject = vSubject; IF NOT vIsDuplicateMail THEN - CALL mail_insert(vSalesPersonEmail, NULL, vSubject, vMessage); + CALL mail_insert(vEmail, NULL, vSubject, vMessage); END IF; - CALL ticketStateUpdate (vNewTicket, 'FIXING'); + CALL ticket_setState(vNewTicket, 'FIXING'); ELSE CALL ticketCalculateClon(vNewTicket, vTicketFk); END IF; - - END; END LOOP; - CLOSE rsTicket; - DROP TEMPORARY TABLE IF EXISTS tmp.time; + CLOSE vTickets; + + DROP TEMPORARY TABLE IF EXISTS + tmp.time, + tmp.zoneGetLanded; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_close.sql b/db/routines/vn/procedures/ticket_close.sql index 47d748ddf..0da001ffa 100644 --- a/db/routines/vn/procedures/ticket_close.sql +++ b/db/routines/vn/procedures/ticket_close.sql @@ -1,8 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_close`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_close`() BEGIN /** - * Realiza el cierre de todos los + * Realiza el cierre de todos los * tickets de la tabla tmp.ticket_close. * * @table tmp.ticket_close(ticketFk) Identificadores de los tickets a cerrar @@ -17,10 +17,11 @@ BEGIN DECLARE vHasDailyInvoice BOOL; DECLARE vWithPackage BOOL; DECLARE vHasToInvoice BOOL; + DECLARE vSerial VARCHAR(2); DECLARE cur CURSOR FOR SELECT ticketFk FROM tmp.ticket_close; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN RESIGNAL; @@ -30,7 +31,7 @@ BEGIN proc: LOOP SET vDone = FALSE; - + FETCH cur INTO vCurTicketFk; IF vDone THEN @@ -44,15 +45,15 @@ BEGIN t.shipped, IFNULL(a.hasDailyInvoice, co.hasDailyInvoice), w.isManaged, - c.hasToInvoice + c.hasToInvoice INTO vClientFk, vIsTaxDataChecked, - vCompanyFk, + vCompanyFk, vShipped, vHasDailyInvoice, vWithPackage, - vHasToInvoice - FROM ticket t + vHasToInvoice + FROM ticket t JOIN `client` c ON c.id = t.clientFk JOIN province p ON p.id = c.provinceFk LEFT JOIN autonomy a ON a.id = p.autonomyFk @@ -62,33 +63,40 @@ BEGIN INSERT INTO ticketPackaging (ticketFk, packagingFk, quantity) (SELECT vCurTicketFk, p.id, COUNT(*) - FROM expedition e + FROM expedition e JOIN packaging p ON p.id = e.packagingFk + JOIN ticket t ON t.id = e.ticketFk + LEFT JOIN agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk WHERE e.ticketFk = vCurTicketFk AND p.isPackageReturnable AND vWithPackage + AND NOT dm.`code`= 'PICKUP' GROUP BY p.itemFk); -- No retornables o no catalogados - INSERT INTO sale (itemFk, ticketFk, concept, quantity, price, isPriceFixed) + INSERT INTO sale (itemFk, ticketFk, concept, quantity, price, isPriceFixed) (SELECT e.freightItemFk, vCurTicketFk, i.name, COUNT(*) AS amount, getSpecialPrice(e.freightItemFk, vClientFk), 1 - FROM expedition e + FROM expedition e JOIN item i ON i.id = e.freightItemFk LEFT JOIN packaging p ON p.itemFk = i.id WHERE e.ticketFk = vCurTicketFk AND IFNULL(p.isPackageReturnable, 0) = 0 AND getSpecialPrice(e.freightItemFk, vClientFk) > 0 GROUP BY e.freightItemFk); - - IF(vHasDailyInvoice) AND vHasToInvoice THEN - -- Facturacion rapida + IF(vHasDailyInvoice) AND vHasToInvoice THEN + SELECT invoiceSerial(vClientFk, vCompanyFk, 'quick') INTO vSerial; + IF vSerial IS NULL THEN + CALL util.throw('Cannot booking without a serial'); + END IF; + CALL ticket_setState(vCurTicketFk, 'DELIVERED'); - -- Facturar si está contabilizado + IF vIsTaxDataChecked THEN CALL invoiceOut_newFromClient( - vClientFk, - (SELECT invoiceSerial(vClientFk, vCompanyFk, 'M')), - vShipped, - vCompanyFk, + vClientFk, + vSerial, + vShipped, + vCompanyFk, NULL, NULL, vNewInvoiceId); diff --git a/db/routines/vn/procedures/ticket_closeByTicket.sql b/db/routines/vn/procedures/ticket_closeByTicket.sql index 837b809a2..bd0b5b102 100644 --- a/db/routines/vn/procedures/ticket_closeByTicket.sql +++ b/db/routines/vn/procedures/ticket_closeByTicket.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_closeByTicket`(IN vTicketFk int) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_closeByTicket`(IN vTicketFk int) BEGIN /** * Inserta el ticket en la tabla temporal diff --git a/db/routines/vn/procedures/ticket_componentMakeUpdate.sql b/db/routines/vn/procedures/ticket_componentMakeUpdate.sql index 4b0a5bdbc..fa6b79068 100644 --- a/db/routines/vn/procedures/ticket_componentMakeUpdate.sql +++ b/db/routines/vn/procedures/ticket_componentMakeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_componentMakeUpdate`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_componentMakeUpdate`( vTicketFk INT, vClientFk INT, vNickname VARCHAR(50), diff --git a/db/routines/vn/procedures/ticket_componentPreview.sql b/db/routines/vn/procedures/ticket_componentPreview.sql index 729e3a743..25bdd5ded 100644 --- a/db/routines/vn/procedures/ticket_componentPreview.sql +++ b/db/routines/vn/procedures/ticket_componentPreview.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_componentPreview`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_componentPreview`( vTicketFk INT, vLanded DATE, vAddressFk INT, @@ -56,13 +56,12 @@ BEGIN FROM zone WHERE id = vZoneFk; - CALL buyUltimate(vWarehouseFk, vShipped); + CALL buy_getUltimate(NULL, vWarehouseFk, vShipped); DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY ( - SELECT - vWarehouseFk AS warehouseFk, - NULL AS available, + SELECT vWarehouseFk warehouseFk, + NULL available, s.itemFk, bu.buyFk, vZoneFk zoneFk diff --git a/db/routines/vn/procedures/ticket_doCmr.sql b/db/routines/vn/procedures/ticket_doCmr.sql index 2da8464b4..ba64944f8 100644 --- a/db/routines/vn/procedures/ticket_doCmr.sql +++ b/db/routines/vn/procedures/ticket_doCmr.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doCmr`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_doCmr`(vSelf INT) BEGIN /** * Crea u actualiza la información del CMR asociado con @@ -18,7 +18,7 @@ BEGIN com.id companyFk, a.id addressFk, c2.defaultAddressFk, - su.id supplierFk, + IFNULL(sat.supplierFk, su.id) supplierFk, t.landed FROM ticket t JOIN ticketState ts ON ts.ticketFk = t.id @@ -28,15 +28,18 @@ BEGIN JOIN `address` a ON a.id = t.addressFk JOIN province p ON p.id = a.provinceFk JOIN country co ON co.id = p.countryFk - JOIN agencyMode am ON am.id = t.agencyModeFk JOIN warehouse w ON w.id = t.warehouseFk JOIN company com ON com.id = t.companyFk JOIN client c2 ON c2.id = com.clientFk - JOIN supplierAccount sa ON sa.id = com.supplierAccountFk + JOIN supplierAccount sa ON sa.id = com.supplierAccountFk JOIN supplier su ON su.id = sa.supplierFk LEFT JOIN route r ON r.id = t.routeFk LEFT JOIN worker wo ON wo.id = r.workerFk LEFT JOIN vehicle v ON v.id = r.vehicleFk + LEFT JOIN agencyMode am ON am.id = r.agencyModeFk + LEFT JOIN agency ag ON ag.id = am.agencyFk + LEFT JOIN supplierAgencyTerm sat ON sat.agencyFk = ag.id + AND wo.isFreelance WHERE al.code IN ('PACKED', 'DELIVERED') AND co.code <> 'ES' AND am.name <> 'ABONO' diff --git a/db/routines/vn/procedures/ticket_getFromFloramondo.sql b/db/routines/vn/procedures/ticket_getFromFloramondo.sql index 4d83d6dda..05c625653 100644 --- a/db/routines/vn/procedures/ticket_getFromFloramondo.sql +++ b/db/routines/vn/procedures/ticket_getFromFloramondo.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getFromFloramondo`(vDateFrom DATE, vDateTo DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_getFromFloramondo`(vDateFrom DATE, vDateTo DATE) BEGIN /** * Genera una tabla con la lista de tickets de Floramondo @@ -66,7 +66,7 @@ BEGIN JOIN vn.componentType ct ON ct.id = c.typeFk JOIN vn.sale s ON s.id = sc.saleFk JOIN tmp.ticket t ON t.ticketFk = s.ticketFk - WHERE ct.code = 'FREIGHT' + WHERE ct.code = 'freight' GROUP BY t.ticketFk) sb ON sb.ticketFk = tf.ticketFk SET tf.freight = sb.freight; @@ -88,7 +88,7 @@ BEGIN -- Margin UPDATE tmp.ticketFloramondo tf - JOIN (SELECT SUM(IF(ct.code = 'COST',sc.value, 0)) cost, + JOIN (SELECT SUM(IF(ct.code = 'cost',sc.value, 0)) cost, SUM(IF(ct.isMargin, sc.value, 0)) margin, t.ticketFk FROM vn.saleComponent sc diff --git a/db/routines/vn/procedures/ticket_getMovable.sql b/db/routines/vn/procedures/ticket_getMovable.sql index 512151bd4..cf56316f1 100644 --- a/db/routines/vn/procedures/ticket_getMovable.sql +++ b/db/routines/vn/procedures/ticket_getMovable.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getMovable`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_getMovable`( vTicketFk INT, vNewShipped DATETIME, vWarehouseFk INT diff --git a/db/routines/vn/procedures/ticket_getProblems.sql b/db/routines/vn/procedures/ticket_getProblems.sql index 521e4cf2f..1851bce47 100644 --- a/db/routines/vn/procedures/ticket_getProblems.sql +++ b/db/routines/vn/procedures/ticket_getProblems.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getProblems`(IN vIsTodayRelative tinyint(1)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_getProblems`( + vIsTodayRelative tinyint(1) +) BEGIN /** * Calcula los problemas para un conjunto de tickets. @@ -16,6 +18,7 @@ BEGIN SELECT ticketFk, MAX(isFreezed) isFreezed, MAX(risk) risk, + MAX(hasRisk) hasRisk, MAX(hasHighRisk) hasHighRisk, MAX(hasTicketRequest) hasTicketRequest, MAX(itemShortage) itemShortage, @@ -30,19 +33,19 @@ BEGIN FROM tmp.sale_problems GROUP BY ticketFk; - UPDATE tmp.ticket_problems tp - SET tp.totalProblems = ( - (tp.isFreezed) + - IF(tp.risk,TRUE, FALSE) + - (tp.hasTicketRequest) + - (tp.isTaxDataChecked = 0) + - (tp.hasComponentLack) + - (tp.itemDelay) + - (tp.isTooLittle) + - (tp.itemLost) + - (tp.hasRounding) + - (tp.itemShortage) + - (tp.isVip) + UPDATE tmp.ticket_problems + SET totalProblems = ( + (isFreezed) + + (hasHighRisk) + + (hasTicketRequest) + + (!isTaxDataChecked) + + (hasComponentLack) + + (itemDelay IS NOT NULL) + + (isTooLittle) + + (itemLost IS NOT NULL) + + (hasRounding IS NOT NULL) + + (itemShortage IS NOT NULL) + + (isVip) ); DROP TEMPORARY TABLE tmp.sale_problems; diff --git a/db/routines/vn/procedures/ticket_getSplitList.sql b/db/routines/vn/procedures/ticket_getSplitList.sql index 10488d596..988bc2931 100644 --- a/db/routines/vn/procedures/ticket_getSplitList.sql +++ b/db/routines/vn/procedures/ticket_getSplitList.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getSplitList`(vDated DATE, vHour TIME, vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_getSplitList`(vDated DATE, vHour TIME, vWarehouseFk INT) BEGIN /** * Devuelve un listado con los tickets posibles para splitar HOY. diff --git a/db/routines/vn/procedures/ticket_getTax.sql b/db/routines/vn/procedures/ticket_getTax.sql index b9f5c14e3..947c45806 100644 --- a/db/routines/vn/procedures/ticket_getTax.sql +++ b/db/routines/vn/procedures/ticket_getTax.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getTax`(IN vTaxArea VARCHAR(25)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_getTax`(IN vTaxArea VARCHAR(25)) BEGIN /** * Calcula la base imponible, el IVA y el recargo de equivalencia para diff --git a/db/routines/vn/procedures/ticket_getWarnings.sql b/db/routines/vn/procedures/ticket_getWarnings.sql index 0bda30446..d817a92bb 100644 --- a/db/routines/vn/procedures/ticket_getWarnings.sql +++ b/db/routines/vn/procedures/ticket_getWarnings.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getWarnings`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_getWarnings`() BEGIN /** * Calcula las adventencias para un conjunto de tickets. diff --git a/db/routines/vn/procedures/ticket_getWithParameters.sql b/db/routines/vn/procedures/ticket_getWithParameters.sql index 2d3d09311..02a6d8a1d 100644 --- a/db/routines/vn/procedures/ticket_getWithParameters.sql +++ b/db/routines/vn/procedures/ticket_getWithParameters.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getWithParameters`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_getWithParameters`( vClientFk INT, vWarehouseFk INT, vShipped DATE, diff --git a/db/routines/vn/procedures/ticket_insertZone.sql b/db/routines/vn/procedures/ticket_insertZone.sql index ee6eabdec..600bf80ee 100644 --- a/db/routines/vn/procedures/ticket_insertZone.sql +++ b/db/routines/vn/procedures/ticket_insertZone.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_insertZone`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_insertZone`() BEGIN DECLARE vDone INT DEFAULT 0; DECLARE vFechedTicket INT; diff --git a/db/routines/vn/procedures/ticket_mergeSales.sql b/db/routines/vn/procedures/ticket_mergeSales.sql new file mode 100644 index 000000000..8ef5f6d90 --- /dev/null +++ b/db/routines/vn/procedures/ticket_mergeSales.sql @@ -0,0 +1,54 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_mergeSales`( + vSelf INT +) +BEGIN +/** + * Para un ticket se agrupa las diferentes líneas de venta de un mismo artículo en una sola + * siempre y cuando tengan el mismo precio y dto. + * + * @param vSelf Id de ticket + */ + DECLARE vHasSalesToMerge BOOL; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + SELECT id INTO vSelf + FROM ticket + WHERE id = vSelf FOR UPDATE; + + CREATE OR REPLACE TEMPORARY TABLE tSalesToPreserve + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT s.id, s.itemFk, SUM(s.quantity) newQuantity + FROM sale s + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + WHERE s.ticketFk = vSelf + AND it.isMergeable + GROUP BY s.itemFk, s.price, s.discount + HAVING COUNT(*) > 1; + + SELECT COUNT(*) INTO vHasSalesToMerge FROM tSalesToPreserve; + + IF vHasSalesToMerge THEN + UPDATE sale s + JOIN tSalesToPreserve stp ON stp.id = s.id + SET s.quantity = newQuantity; + + DELETE s + FROM sale s + JOIN tSalesToPreserve stp ON stp.itemFk = s.itemFk + WHERE s.ticketFk = vSelf + AND s.id <> stp.id; + END IF; + + COMMIT; + DROP TEMPORARY TABLE tSalesToPreserve; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_priceDifference.sql b/db/routines/vn/procedures/ticket_priceDifference.sql index 4ef168840..5e36be8a0 100644 --- a/db/routines/vn/procedures/ticket_priceDifference.sql +++ b/db/routines/vn/procedures/ticket_priceDifference.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_priceDifference`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_priceDifference`( vTicketFk INT, vLanded DATE, vAddressFk INT, diff --git a/db/routines/vn/procedures/ticket_printLabelPrevious.sql b/db/routines/vn/procedures/ticket_printLabelPrevious.sql index cba42ff3e..e40e125b5 100644 --- a/db/routines/vn/procedures/ticket_printLabelPrevious.sql +++ b/db/routines/vn/procedures/ticket_printLabelPrevious.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_printLabelPrevious`(vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_printLabelPrevious`(vTicketFk INT) BEGIN /** * Calls the report_print procedure and passes it diff --git a/db/routines/vn/procedures/ticket_recalc.sql b/db/routines/vn/procedures/ticket_recalc.sql index 50065d03a..ee408a8ca 100644 --- a/db/routines/vn/procedures/ticket_recalc.sql +++ b/db/routines/vn/procedures/ticket_recalc.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_recalc`(vSelf INT, vTaxArea VARCHAR(25)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_recalc`(vSelf INT, vTaxArea VARCHAR(25)) proc:BEGIN /** * Calcula y guarda el total con/sin IVA en un ticket. diff --git a/db/routines/vn/procedures/ticket_recalcByScope.sql b/db/routines/vn/procedures/ticket_recalcByScope.sql index 41105fe23..42652272c 100644 --- a/db/routines/vn/procedures/ticket_recalcByScope.sql +++ b/db/routines/vn/procedures/ticket_recalcByScope.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_recalcByScope`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_recalcByScope`( vScope VARCHAR(255), vId INT ) @@ -14,16 +14,28 @@ BEGIN 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)); + SELECT DISTINCT t.id + FROM ticket t + LEFT JOIN tItems ti ON ti.id = t.id + WHERE t.refFk IS NULL + AND ((vScope = 'client' AND t.clientFk = vId) + OR (vScope = 'address' AND t.addressFk = vId) + OR (vScope = 'item' AND ti.id) + ); - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + CREATE OR REPLACE TEMPORARY TABLE tItems + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT DISTINCT t.id + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN itemTaxCountry itc ON itc.itemFk = s.itemFk + WHERE t.refFk IS NULL + AND (vScope = 'item' AND itc.itemFk = vId); OPEN cTickets; - myLoop: LOOP SET vDone = FALSE; FETCH cTickets INTO vTicketFk; @@ -34,7 +46,8 @@ BEGIN CALL ticket_recalc(vTicketFk, NULL); END LOOP; - CLOSE cTickets; + + DROP TEMPORARY TABLE tItems; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_recalcComponents.sql b/db/routines/vn/procedures/ticket_recalcComponents.sql index 0282c0e42..86a40a4eb 100644 --- a/db/routines/vn/procedures/ticket_recalcComponents.sql +++ b/db/routines/vn/procedures/ticket_recalcComponents.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_recalcComponents`(vSelf INT, vOption VARCHAR(25)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_recalcComponents`(vSelf INT, vOption VARCHAR(25)) proc: BEGIN /** diff --git a/db/routines/vn/procedures/ticket_setNextState.sql b/db/routines/vn/procedures/ticket_setNextState.sql index d13cd53f0..164bf34e4 100644 --- a/db/routines/vn/procedures/ticket_setNextState.sql +++ b/db/routines/vn/procedures/ticket_setNextState.sql @@ -1,14 +1,21 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setNextState`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setNextState`( + vSelf INT +) BEGIN /** - * Cambia el estado del ticket al siguiente estado según la tabla state + * Cambia el estado del ticket al siguiente estado según la tabla state. * - * @param vSelf id dle ticket + * @param vSelf Id ticket */ DECLARE vStateFk INT; DECLARE vNewStateFk INT; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + RESIGNAL; + END; + SELECT stateFk INTO vStateFk FROM ticketState WHERE ticketFk = vSelf; @@ -17,6 +24,10 @@ BEGIN FROM state WHERE id = vStateFk; + IF vNewStateFk IS NULL THEN + CALL util.throw('The ticket not have next state'); + END IF; + INSERT INTO ticketTracking(stateFk, ticketFk, userFk) VALUES (vNewStateFk, vSelf, account.myUser_getId()); END$$ diff --git a/db/routines/vn/procedures/ticket_setParking.sql b/db/routines/vn/procedures/ticket_setParking.sql index 54c64daea..acc9a2aee 100644 --- a/db/routines/vn/procedures/ticket_setParking.sql +++ b/db/routines/vn/procedures/ticket_setParking.sql @@ -1,11 +1,14 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setParking`(IN `vTicketFk` VARCHAR(8), IN `vParkingFk` INT) -proc: BEGIN +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setParking`( + vSelf INT, + vParkingFk INT +) +BEGIN /** - * Aparca un ticket en un parking + * Aparca un ticket en un parking. * - * @param vTicketFk id del ticket - * @param vParkingFk id del parking + * @param vSelf Id ticket + * @param vParkingFk Id parking */ DECLARE vDone INT DEFAULT FALSE; DECLARE vCollectionTicketFk INT; @@ -14,7 +17,7 @@ proc: BEGIN FROM ticket t LEFT JOIN ticketCollection tc1 ON tc1.ticketFk = t.id LEFT JOIN ticketCollection tc2 ON tc2.collectionFk = tc1.collectionFk - WHERE t.id = vTicketFk; + WHERE t.id = vSelf; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -23,7 +26,7 @@ proc: BEGIN FROM ticket t LEFT JOIN ticketCollection tc1 ON tc1.ticketFk = t.id LEFT JOIN ticketCollection tc2 ON tc2.collectionFk = tc1.collectionFk - WHERE t.id = vTicketFk + WHERE t.id = vSelf ON DUPLICATE KEY UPDATE parkingFk = vParkingFk; OPEN vCursor; diff --git a/db/routines/vn/procedures/ticket_setPreviousState.sql b/db/routines/vn/procedures/ticket_setPreviousState.sql index c03d41b09..aaf482c30 100644 --- a/db/routines/vn/procedures/ticket_setPreviousState.sql +++ b/db/routines/vn/procedures/ticket_setPreviousState.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setPreviousState`(vTicketFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setPreviousState`(vTicketFk INT) BEGIN DECLARE vControlFk INT; diff --git a/db/routines/vn/procedures/ticket_setProblem.sql b/db/routines/vn/procedures/ticket_setProblem.sql index bab8f1f52..bf305f2f0 100644 --- a/db/routines/vn/procedures/ticket_setProblem.sql +++ b/db/routines/vn/procedures/ticket_setProblem.sql @@ -1,19 +1,41 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblem`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setProblem`( vProblemCode VARCHAR(25) ) BEGIN /** - * Update column ticket.problem with a problem code + * Update column ticket.problem with a problem code and SET NULL when + * the problem is not requiered * * @param vProblemCode Code to set or unset - * @table tmp.ticket(ticketFk, hasProblem) + * @table tmp.ticket(ticketFk, hasProblem, isProblemCalcNeeded) */ - UPDATE ticket t - JOIN tmp.ticket tt ON tt.ticketFk = t.id - SET t.problem = CONCAT( - IF(tt.hasProblem, - CONCAT(problem, ',', vProblemCode), - REPLACE(problem, vProblemCode , ''))); + DECLARE vTicketFk INT; + DECLARE vHasProblem INT; + DECLARE vIsProblemCalcNeeded BOOL; + DECLARE vDone BOOL; + DECLARE vTicketList CURSOR FOR + SELECT ticketFk, hasProblem, isProblemCalcNeeded + FROM tmp.ticket; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vTicketList; + l: LOOP + SET vDone = FALSE; + FETCH vTicketList INTO vTicketFk, vHasProblem, vIsProblemCalcNeeded; + + IF vDone THEN + LEAVE l; + END IF; + + UPDATE ticket + SET problem = IF(vIsProblemCalcNeeded, + CONCAT(IF(vHasProblem, + CONCAT(problem, ',', vProblemCode), + REPLACE(problem, vProblemCode , ''))), + NULL) + WHERE id = vTicketFk; + END LOOP; + CLOSE vTicketList; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setProblemFreeze.sql b/db/routines/vn/procedures/ticket_setProblemFreeze.sql index bdb32b3fe..622894dfa 100644 --- a/db/routines/vn/procedures/ticket_setProblemFreeze.sql +++ b/db/routines/vn/procedures/ticket_setProblemFreeze.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemFreeze`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setProblemFreeze`( vClientFk INT ) BEGIN @@ -9,11 +9,13 @@ BEGIN * @param vClientFk Id Cliente, if NULL all clients */ CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - (INDEX(ticketFk)) + (INDEX(ticketFk, isProblemCalcNeeded)) ENGINE = MEMORY - SELECT t.id ticketFk, FALSE hasProblem + SELECT t.id ticketFk, + FALSE hasProblem, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded FROM ticket t - WHERE t.shipped >= util.midnight() + WHERE t.shipped >= util.VN_CURDATE() AND (vClientFk IS NULL OR t.clientFk = vClientFk); UPDATE tmp.ticket t @@ -21,8 +23,8 @@ BEGIN JOIN client c ON c.id = ti.clientFk SET t.hasProblem = TRUE WHERE c.isFreezed; - - CALL ticket_setProblem('hasTicketRequest'); + + CALL ticket_setProblem('isFreezed'); DROP TEMPORARY TABLE tmp.ticket; END$$ diff --git a/db/routines/vn/procedures/ticket_setProblemRequest.sql b/db/routines/vn/procedures/ticket_setProblemRequest.sql index a5dc31472..f84847b65 100644 --- a/db/routines/vn/procedures/ticket_setProblemRequest.sql +++ b/db/routines/vn/procedures/ticket_setProblemRequest.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRequest`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setProblemRequest`( vSelf INT ) BEGIN @@ -9,11 +9,13 @@ BEGIN * @param vSelf Id ticket, if NULL ALL tickets */ CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - (INDEX(ticketFk)) + (INDEX(ticketFk, isProblemCalcNeeded)) ENGINE = MEMORY - SELECT t.id ticketFk, FALSE hasProblem + SELECT t.id ticketFk, + FALSE hasProblem, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded FROM ticket t - WHERE t.shipped >= util.midnight() + WHERE t.shipped >= util.VN_CURDATE() AND (vSelf IS NULL OR t.id = vSelf); UPDATE tmp.ticket t diff --git a/db/routines/vn/procedures/ticket_setProblemRisk.sql b/db/routines/vn/procedures/ticket_setProblemRisk.sql index 7c499f5ba..60a188d3e 100644 --- a/db/routines/vn/procedures/ticket_setProblemRisk.sql +++ b/db/routines/vn/procedures/ticket_setProblemRisk.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRisk`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setProblemRisk`( vSelf INT ) BEGIN @@ -10,21 +10,30 @@ BEGIN */ DECLARE vHasRisk BOOL; DECLARE vHasHighRisk BOOL; + DECLARE vIsProblemCalcNeeded BOOL; - SELECT t.risk > (c.credit + 10), ((t.risk - cc.riskTolerance) > (c.credit + 10)) - INTO vHasRisk, vHasHighRisk + SELECT t.risk > (c.credit + 10), + (t.risk - cc.riskTolerance) > (c.credit + 10), + ticket_isProblemCalcNeeded(t.id) + INTO vHasRisk, vHasHighRisk, vIsProblemCalcNeeded FROM client c JOIN ticket t ON t.clientFk = c.id JOIN clientConfig cc WHERE t.id = vSelf; CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - SELECT vSelf ticketFk, vRisk hasProblem; + ENGINE = MEMORY + SELECT vSelf ticketFk, + vHasRisk hasProblem, + vIsProblemCalcNeeded isProblemCalcNeeded; CALL ticket_setProblem('hasRisk'); CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - SELECT vSelf ticketFk, vHasHighRisk hasProblem; + ENGINE = MEMORY + SELECT vSelf ticketFk, + vHasHighRisk hasProblem, + vIsProblemCalcNeeded isProblemCalcNeeded; CALL ticket_setProblem('hasHighRisk'); diff --git a/db/routines/vn/procedures/ticket_setProblemRiskByClient.sql b/db/routines/vn/procedures/ticket_setProblemRiskByClient.sql new file mode 100644 index 000000000..1652fd29e --- /dev/null +++ b/db/routines/vn/procedures/ticket_setProblemRiskByClient.sql @@ -0,0 +1,35 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setProblemRiskByClient`( + vClientFk INT +) +BEGIN +/** + * Updates future ticket risk for a client. + * + * @param vClientFk Id client + */ + DECLARE vDone INT DEFAULT FALSE; + DECLARE vTicketFk INT; + DECLARE vTickets CURSOR FOR + SELECT id + FROM ticket + WHERE clientFk = vClientFk + AND shipped >= util.VN_CURDATE() + AND refFk IS NULL; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vTickets; + l: LOOP + SET vDone = FALSE; + FETCH vTickets INTO vTicketFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL vn.ticket_setProblemRisk(vTicketFk); + END LOOP; + CLOSE vTickets; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setProblemRounding.sql b/db/routines/vn/procedures/ticket_setProblemRounding.sql deleted file mode 100644 index 272a48151..000000000 --- a/db/routines/vn/procedures/ticket_setProblemRounding.sql +++ /dev/null @@ -1,34 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRounding`( - vSelf INT -) -BEGIN -/** - * Update the rounding problem for the sales lines of a ticket - * - * @param vSelf Id de ticket - */ - DECLARE vWarehouseFk INT; - DECLARE vDated DATE; - - SELECT warehouseFk, shipped - INTO vWarehouseFk, vDated - FROM ticket - WHERE id = vSelf; - - CALL buyUltimate(vWarehouseFk, vDated); - - CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - SELECT s.id saleFk , MOD(s.quantity, b.`grouping`) hasProblem - FROM ticket t - JOIN sale s ON s.ticketFk = tl.ticketFk - JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk - JOIN buy b ON b.id = bu.buyFk - WHERE t.id = vSelf; - - CALL sale_setProblem('hasRounding'); - - DROP TEMPORARY TABLE tmp.ticket; - DROP TEMPORARY TABLE tmp.buyUltimate; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setProblemTaxDataChecked.sql b/db/routines/vn/procedures/ticket_setProblemTaxDataChecked.sql index b6c2d8533..f5c9a88b6 100644 --- a/db/routines/vn/procedures/ticket_setProblemTaxDataChecked.sql +++ b/db/routines/vn/procedures/ticket_setProblemTaxDataChecked.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setProblemTaxDataChecked`(vClientFk INT) BEGIN /** @@ -9,12 +9,14 @@ BEGIN * @param vClientFk Id cliente, if NULL all clients */ CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - (INDEX(ticketFk)) + (INDEX(ticketFk, isProblemCalcNeeded)) ENGINE = MEMORY - SELECT t.id ticketFk, IF(c.isTaxDataChecked, FALSE, TRUE) hasProblem + SELECT t.id ticketFk, + IF(c.isTaxDataChecked, FALSE, TRUE) hasProblem, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded FROM ticket t JOIN client c ON c.id = t.clientFk - WHERE t.shipped >= util.midnight() + WHERE t.shipped >= util.VN_CURDATE() AND (c.id = vClientFk OR vClientFk IS NULL); CALL ticket_setProblem('isTaxDataChecked'); diff --git a/db/routines/vn/procedures/ticket_setProblemTooLittle.sql b/db/routines/vn/procedures/ticket_setProblemTooLittle.sql index 98a0787af..233b3d6df 100644 --- a/db/routines/vn/procedures/ticket_setProblemTooLittle.sql +++ b/db/routines/vn/procedures/ticket_setProblemTooLittle.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemTooLittle`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setProblemTooLittle`( vSelf INT ) BEGIN @@ -8,11 +8,25 @@ BEGIN * * @param vSelf Id del ticket */ + DECLARE vTicketIsTooLittle BOOL; + + SELECT ticket_isTooLittle(vSelf) INTO vTicketIsTooLittle; + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - (INDEX(ticketFk)) + (INDEX(ticketFk, isProblemCalcNeeded)) ENGINE = MEMORY - SELECT vSelf ticketFk, ticket_isTooLittle(vSelf) hasProblem; - + WITH ticketData AS ( + SELECT addressFk, DATE(shipped) dated + FROM vn.ticket + WHERE id = vSelf + ) + SELECT t.id ticketFk, + vTicketIsTooLittle hasProblem, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded + FROM vn.ticket t + JOIN ticketData td ON td.addressFk = t.addressFk + WHERE t.shipped BETWEEN td.dated AND util.dayEnd(td.dated); + CALL ticket_setProblem('isTooLittle'); DROP TEMPORARY TABLE tmp.ticket; diff --git a/db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql b/db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql index 9a7852ac5..acbfd22e9 100644 --- a/db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql +++ b/db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemTooLittleItemCost`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setProblemTooLittleItemCost`( vItemFk INT ) BEGIN @@ -10,16 +10,18 @@ BEGIN * @param vItemFk Id del item, NULL ALL items */ CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - (INDEX(ticketFk)) + (INDEX(ticketFk, isProblemCalcNeeded)) ENGINE = MEMORY WITH tickets AS( SELECT t.id ticketFk FROM vn.ticket t - JOIN vn.sale s ON s.ticketFk = t.id - WHERE t.shipped >= util.midnight() + LEFT JOIN vn.sale s ON s.ticketFk = t.id + WHERE t.shipped >= util.VN_CURDATE() AND (s.itemFk = vItemFk OR vItemFk IS NULL) GROUP BY t.id - )SELECT ticketFk, ticket_isTooLittle(ticketFk) hasProblem + )SELECT ticketFk, + ticket_isTooLittle(ticketFk) hasProblem, + ticket_isProblemCalcNeeded(ticketFk) isProblemCalcNeeded FROM tickets; CALL ticket_setProblem('isTooLittle'); diff --git a/db/routines/vn/procedures/ticket_setRisk.sql b/db/routines/vn/procedures/ticket_setRisk.sql index f5e6cb5a0..9c006d1e2 100644 --- a/db/routines/vn/procedures/ticket_setRisk.sql +++ b/db/routines/vn/procedures/ticket_setRisk.sql @@ -1,87 +1,83 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setRisk`( - vClientFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setRisk`( + vClientFk INT +) BEGIN /** - * Update the risk for a client with pending tickets + * Update the risk for a client with pending tickets. * * @param vClientFk Id cliente */ - DECLARE vHasDebt BOOL; - - SELECT COUNT(*) INTO vHasDebt - FROM `client` - WHERE id = vClientFk - AND typeFk = 'normal'; - - IF vHasDebt THEN - + IF (SELECT COUNT(*) FROM client WHERE id = vClientFk AND typeFk = 'normal') THEN CREATE OR REPLACE TEMPORARY TABLE tTicketRisk - (KEY (ticketFk)) + (PRIMARY KEY (ticketFk)) ENGINE = MEMORY - WITH ticket AS( - SELECT id ticketFk, companyFk, DATE(shipped) dated - FROM vn.ticket t - WHERE clientFk = vClientFk - AND refFk IS NULL - AND NOT isDeleted - AND totalWithoutVat <> 0 - ), dated AS( - SELECT t.companyFk, MIN(DATE(t.dated) - INTERVAL cc.riskScope MONTH) started, - MAX(DATE(t.dated)) ended - FROM ticket t - JOIN vn.clientConfig cc - GROUP BY t.companyFk - ), balance AS( - SELECT SUM(amount)amount, companyFk - FROM ( - SELECT amount, companyFk - FROM vn.clientRisk - WHERE clientFk = vClientFk - UNION ALL - SELECT -(SUM(amount) / 100) amount, tm.companyFk - FROM hedera.tpvTransaction t - JOIN hedera.tpvMerchant tm ON t.id = t.merchantFk - WHERE clientFk = vClientFk - AND receiptFk IS NULL - AND status = 'ok' - ) sub - WHERE companyFk + WITH ticket AS ( + SELECT t.id ticketFk, + t.companyFk, + DATE(t.shipped) dated, + t.totalWithVat, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded + FROM vn.ticket t + JOIN vn.clientConfig cc + WHERE t.clientFk = vClientFk + AND t.refFk IS NULL + AND NOT t.isDeleted + AND IFNULL(t.totalWithVat, 0) <> 0 + AND t.shipped > (util.VN_CURDATE() - INTERVAL cc.riskScope MONTH) + ), uninvoiced AS ( + SELECT companyFk, dated, SUM(totalWithVat) amount + FROM ticket + GROUP BY companyFk, dated + ), companies AS ( + SELECT DISTINCT companyFk FROM uninvoiced + ), balance AS ( + SELECT SUM(IFNULL(amount, 0))amount, companyFk + FROM ( + SELECT cr.amount, c.companyFk + FROM companies c + LEFT JOIN vn.clientRisk cr ON cr.companyFk = c.companyFk + AND cr.clientFk = vClientFk + UNION ALL + SELECT -(SUM(t.amount) / 100) amount, c.companyFk + FROM companies c + LEFT JOIN hedera.tpvMerchant tm ON tm.companyFk = c.companyFk + LEFT JOIN hedera.tpvTransaction t ON t.merchantFk = tm.id + AND t.clientFk = vClientFk + AND t.receiptFk IS NULL + AND t.`status` = 'ok' + ) sub + WHERE companyFk GROUP BY companyFk - ), uninvoiced AS( - SELECT t.companyFk, DATE(t.shipped) dated, SUM(IFNULL(t.totalWithVat, 0)) amount - FROM vn.ticket t - JOIN dated d - WHERE t.clientFk = vClientFk - AND t.refFk IS NULL - AND t.shipped BETWEEN d.started AND d.ended - GROUP BY t.companyFk, DATE(t.shipped) - ), receipt AS( - SELECT companyFk,DATE(payed) dated, SUM(amountPaid) amount - FROM vn.receipt - WHERE clientFk = vClientFk - AND payed > util.VN_CURDATE() - GROUP BY companyFk, DATE(payed) - ), risk AS( + ), receipt AS ( + SELECT r.companyFk, DATE(r.payed) dated, SUM(r.amountPaid) amount + FROM vn.receipt r + JOIN companies c ON c.companyFk = r.companyFk + WHERE r.clientFk = vClientFk + AND r.payed > util.VN_CURDATE() + GROUP BY r.companyFk, DATE(r.payed) + ), risk AS ( SELECT b.companyFk, - ui.dated, - SUM(ui.amount) OVER (PARTITION BY b.companyFk ORDER BY ui.dated ) + + ui.dated, + SUM(ui.amount) OVER (PARTITION BY b.companyFk ORDER BY ui.dated) + b.amount + SUM(IFNULL(r.amount, 0)) amount FROM balance b JOIN uninvoiced ui ON ui.companyFk = b.companyFk - LEFT JOIN receipt r ON r.dated > ui.dated AND r.companyFk = ui.companyFk + LEFT JOIN receipt r ON r.dated > ui.dated + AND r.companyFk = ui.companyFk GROUP BY b.companyFk, ui.dated - ) - SELECT ti.ticketFk, r.amount - FROM ticket ti - JOIN risk r ON r.dated = ti.dated AND r.companyFk = ti.companyFk; + ) + SELECT ti.ticketFk, r.amount, ti.isProblemCalcNeeded + FROM ticket ti + JOIN risk r ON r.dated = ti.dated + AND r.companyFk = ti.companyFk; UPDATE ticket t JOIN tTicketRisk tr ON tr.ticketFk = t.id - SET t.risk = tr.amount; + SET t.risk = IF(tr.isProblemCalcNeeded, tr.amount, NULL); DROP TEMPORARY TABLE tTicketRisk; - END IF; + END IF; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setState.sql b/db/routines/vn/procedures/ticket_setState.sql index bde8e0692..f4906fb11 100644 --- a/db/routines/vn/procedures/ticket_setState.sql +++ b/db/routines/vn/procedures/ticket_setState.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setState`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setState`( vSelf INT, vStateCode VARCHAR(255) COLLATE utf8_general_ci ) diff --git a/db/routines/vn/procedures/ticket_setVolume.sql b/db/routines/vn/procedures/ticket_setVolume.sql new file mode 100644 index 000000000..c3cf0d057 --- /dev/null +++ b/db/routines/vn/procedures/ticket_setVolume.sql @@ -0,0 +1,24 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setVolume`( + vSelf INT +) +BEGIN +/** + * Update the volume ticket. + * + * @param vSelf Ticket id + */ + DECLARE vVolume DECIMAL(10,6); + + SELECT SUM(s.quantity * ic.cm3delivery / 1000000) INTO vVolume + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN itemCost ic ON ic.itemFk = s.itemFk + AND ic.warehouseFk = t.warehouseFk + WHERE t.id = vSelf; + + UPDATE ticket + SET volume = vVolume + WHERE id = vSelf; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_setVolumeItemCost.sql b/db/routines/vn/procedures/ticket_setVolumeItemCost.sql new file mode 100644 index 000000000..3c23b7c34 --- /dev/null +++ b/db/routines/vn/procedures/ticket_setVolumeItemCost.sql @@ -0,0 +1,39 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setVolumeItemCost`( + vItemFk INT +) +BEGIN +/** + * Update the volume of tickets containing the item. + * + * @param vItemFk Item id + */ + DECLARE vTicket INT; + DECLARE vDone BOOL; + + DECLARE vTickets CURSOR FOR + SELECT DISTINCT t.id + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN itemCost ic ON ic.itemFk = s.itemFk + AND ic.warehouseFk = t.warehouseFk + WHERE s.itemFk = vItemFk + AND t.shipped >= util.VN_CURDATE() + AND t.refFk IS NULL; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vTickets; + l: LOOP + FETCH vTickets INTO vTicket; + + IF vDone THEN + LEAVE l; + END IF; + + CALL ticket_setVolume(vTicket); + + END LOOP l; + CLOSE vTickets; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_split.sql b/db/routines/vn/procedures/ticket_split.sql index 172f6829a..c16b7d0df 100644 --- a/db/routines/vn/procedures/ticket_split.sql +++ b/db/routines/vn/procedures/ticket_split.sql @@ -1,5 +1,9 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_split`(vTicketFk INT, vTicketFutureFk INT, vDated DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_split`( + vTicketFk INT, + vTicketFutureFk INT, + vDated DATE +) proc:BEGIN /** * Mueve las lineas con problemas a otro ticket existente o a uno nuevo. @@ -17,60 +21,56 @@ proc:BEGIN FROM tmp.salesToSplit WHERE ticketFk = vTicketFk; - SELECT count(*) INTO vTotalLines - FROM vn.sale s + SELECT COUNT(*) INTO vTotalLines + FROM sale s WHERE s.ticketFk = vTicketFk; SET vHasFullProblem = (vTotalLines = vProblemLines); -- Ticket completo IF vHasFullProblem THEN - - UPDATE vn.ticket - SET landed = vDated + INTERVAL 1 DAY, + UPDATE ticket + SET landed = vDated + INTERVAL 1 DAY, shipped = vDated, - nickname = CONCAT('(',DAY(util.VN_CURDATE()),') ', nickname ) + nickname = CONCAT('(',DAY(util.VN_CURDATE()),') ', nickname) WHERE id = vTicketFk; - SELECT "moved" message, NULL ticketFuture; + SELECT 'moved' message, NULL ticketFuture; LEAVE proc; - END IF; -- Ticket a futuro existe IF vTicketFutureFk THEN - - UPDATE vn.sale s - JOIN tmp.salesToSplit ss ON s.id = ss.saleFk + UPDATE sale s + JOIN tmp.salesToSplit ss ON s.id = ss.saleFk SET s.ticketFk = vTicketFutureFk, s.concept = CONCAT('(s) ', s.concept) WHERE ss.ticketFk = vTicketFk; - SELECT "future" message, NULL ticketFuture; + SELECT 'future' message, NULL ticketFuture; LEAVE proc; - END IF; -- Ticket nuevo - CALL vn.ticket_Clone(vTicketFk, vTicketFutureFk); + CALL ticket_Clone(vTicketFk, vTicketFutureFk); - UPDATE vn.ticket t - JOIN vn.productionConfig pc + UPDATE ticket t + JOIN productionConfig pc SET t.routeFk = IF(t.shipped = vDated , t.routeFk, NULL), - t.landed = vDated + INTERVAL 1 DAY, + t.landed = vDated + INTERVAL 1 DAY, t.shipped = vDated, t.agencyModeFk = pc.defautlAgencyMode, t.zoneFk = pc.defaultZone WHERE t.id = vTicketFutureFk; - - UPDATE vn.sale s - JOIN tmp.salesToSplit sts ON sts.saleFk = s.id + + UPDATE sale s + JOIN tmp.salesToSplit sts ON sts.saleFk = s.id SET s.ticketFk = vTicketFutureFk, s.concept = CONCAT('(s) ', s.concept) WHERE sts.ticketFk = vTicketFk; - CALL vn.ticketStateUpdate(vTicketFutureFk, 'FIXING'); + CALL ticket_setState(vTicketFutureFk, 'FIXING'); - SELECT "new" message,vTicketFutureFk ticketFuture; + SELECT 'new' message, vTicketFutureFk ticketFuture; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index d6424efad..9a4bc01eb 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -1,106 +1,89 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_splitItemPackingType`(vTicketFk INT, vOriginalItemPackingTypeFk VARCHAR(1)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_splitItemPackingType`( + vSelf INT, + vOriginalItemPackingTypeFk VARCHAR(1) +) proc:BEGIN /** - * Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado. - * Respeta el id inicial para el tipo propuesto. + * Clona y reparte las líneas de ventas de un ticket en funcion del tipo de empaquetado. + * Respeta el id de ticket original para el tipo de empaquetado propuesto. * - * @param vTicketFk Identificador de vn.ticket - * @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original + * @param vSelf Id ticket + * @param vOriginalItemPackingTypeFk Tipo empaquetado que se mantiene el ticket original * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) */ - DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H'; - DECLARE vNewTicketFk INT; - DECLARE vPackingTypesToSplit INT; DECLARE vDone INT DEFAULT FALSE; + DECLARE vHasItemPackingType BOOL; + DECLARE vItemPackingTypeFk INT; + DECLARE vNewTicketFk INT; - DECLARE cur1 CURSOR FOR - SELECT itemPackingTypeFk - FROM tmp.saleGroup - WHERE itemPackingTypeFk IS NOT NULL - ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC; + DECLARE vItemPackingTypes CURSOR FOR + SELECT DISTINCT itemPackingTypeFk + FROM tSalesToMove; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DELETE FROM vn.sale - WHERE quantity = 0 - AND ticketFk = vTicketFk; + SELECT COUNT(*) INTO vHasItemPackingType + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + WHERE t.id = vSelf + AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk; - DROP TEMPORARY TABLE IF EXISTS tmp.sale; - CREATE TEMPORARY TABLE tmp.sale - (PRIMARY KEY (id)) - SELECT s.id, i.itemPackingTypeFk , IFNULL(sv.litros, 0) litros - FROM vn.sale s - JOIN vn.item i ON i.id = s.itemFk - LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id - WHERE s.ticketFk = vTicketFk; + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT( + ticketFk INT, + itemPackingTypeFk VARCHAR(1) + ) ENGINE=MEMORY + SELECT vSelf ticketFk, vOriginalItemPackingTypeFk itemPackingTypeFk; - DROP TEMPORARY TABLE IF EXISTS tmp.saleGroup; - CREATE TEMPORARY TABLE tmp.saleGroup - SELECT itemPackingTypeFk , sum(litros) AS totalLitros - FROM tmp.sale - GROUP BY itemPackingTypeFk; + IF NOT vHasItemPackingType THEN + LEAVE proc; + END IF; - SELECT COUNT(*) INTO vPackingTypesToSplit - FROM tmp.saleGroup - WHERE itemPackingTypeFk IS NOT NULL; + CREATE OR REPLACE TEMPORARY TABLE tSalesToMove ( + ticketFk INT, + saleFk INT, + itemPackingTypeFk INT + ) ENGINE=MEMORY; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketIPT; - CREATE TEMPORARY TABLE tmp.ticketIPT - (ticketFk INT, - itemPackingTypeFk VARCHAR(1)); + INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk) + SELECT s.id, i.itemPackingTypeFk + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + WHERE t.id = vSelf + AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk; - CASE vPackingTypesToSplit - WHEN 0 THEN - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vTicketFk, vItemPackingTypeFk); - WHEN 1 THEN - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - SELECT vTicketFk, itemPackingTypeFk - FROM tmp.saleGroup - WHERE itemPackingTypeFk IS NOT NULL; - ELSE - OPEN cur1; + OPEN vItemPackingTypes; - FETCH cur1 INTO vItemPackingTypeFk; + l: LOOP + SET vDone = FALSE; + FETCH vItemPackingTypes INTO vItemPackingTypeFk; - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vTicketFk, vItemPackingTypeFk); + IF vDone THEN + LEAVE l; + END IF; - read_loop: LOOP - FETCH cur1 INTO vItemPackingTypeFk; + CALL ticket_Clone(vSelf, vNewTicketFk); - IF vDone THEN - LEAVE read_loop; - END IF; + UPDATE tSalesToMove + SET ticketFk = vNewTicketFk + WHERE itemPackingTypeFk = vItemPackingTypeFk; - CALL vn.ticket_Clone(vTicketFk, vNewTicketFk); + END LOOP; - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vNewTicketFk, vItemPackingTypeFk); - END LOOP; + CLOSE vItemPackingTypes; - CLOSE cur1; + UPDATE sale s + JOIN tSalesToMove stm ON stm.saleFk = s.id + SET s.ticketFk = stm.ticketFk + WHERE stm.ticketFk; - UPDATE vn.sale s - JOIN tmp.sale ts ON ts.id = s.id - JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk - SET s.ticketFk = t.ticketFk; + INSERT INTO tmp.ticketIPT (ticketFk, itemPackingTypeFk) + SELECT ticketFk, itemPackingTypeFk + FROM tSalesToMove + GROUP BY ticketFk; - SELECT itemPackingTypeFk INTO vItemPackingTypeFk - FROM tmp.saleGroup sg - WHERE NOT ISNULL(sg.itemPackingTypeFk) - ORDER BY sg.itemPackingTypeFk - LIMIT 1; - - UPDATE vn.sale s - JOIN tmp.sale ts ON ts.id = s.id - JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk - SET s.ticketFk = t.ticketFk - WHERE ts.itemPackingTypeFk IS NULL; - END CASE; - - DROP TEMPORARY TABLE tmp.sale; - DROP TEMPORARY TABLE tmp.saleGroup; + DROP TEMPORARY TABLE tSalesToMove; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_splitPackingComplete.sql b/db/routines/vn/procedures/ticket_splitPackingComplete.sql index 528e8fbed..cc2e4183d 100644 --- a/db/routines/vn/procedures/ticket_splitPackingComplete.sql +++ b/db/routines/vn/procedures/ticket_splitPackingComplete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_splitPackingComplete`(vTicketFk INT, vSectorFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_splitPackingComplete`(vTicketFk INT, vSectorFk INT) BEGIN DECLARE vNeedToSplit BOOLEAN; diff --git a/db/routines/vn/procedures/timeBusiness_calculate.sql b/db/routines/vn/procedures/timeBusiness_calculate.sql index 3cb734069..448a061ad 100644 --- a/db/routines/vn/procedures/timeBusiness_calculate.sql +++ b/db/routines/vn/procedures/timeBusiness_calculate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeBusiness_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`timeBusiness_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** * Horas que debe trabajar un empleado según contrato y día. diff --git a/db/routines/vn/procedures/timeBusiness_calculateAll.sql b/db/routines/vn/procedures/timeBusiness_calculateAll.sql index 4e0ac7da5..6ba9edbd4 100644 --- a/db/routines/vn/procedures/timeBusiness_calculateAll.sql +++ b/db/routines/vn/procedures/timeBusiness_calculateAll.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeBusiness_calculateAll`(vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`timeBusiness_calculateAll`(vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** diff --git a/db/routines/vn/procedures/timeBusiness_calculateByDepartment.sql b/db/routines/vn/procedures/timeBusiness_calculateByDepartment.sql index 54c587342..8253e322f 100644 --- a/db/routines/vn/procedures/timeBusiness_calculateByDepartment.sql +++ b/db/routines/vn/procedures/timeBusiness_calculateByDepartment.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeBusiness_calculateByDepartment`(vDepartmentFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`timeBusiness_calculateByDepartment`(vDepartmentFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** * @param vDepartmentFk diff --git a/db/routines/vn/procedures/timeBusiness_calculateByUser.sql b/db/routines/vn/procedures/timeBusiness_calculateByUser.sql index a54dfcc2e..800d21c73 100644 --- a/db/routines/vn/procedures/timeBusiness_calculateByUser.sql +++ b/db/routines/vn/procedures/timeBusiness_calculateByUser.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeBusiness_calculateByUser`(vUserFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`timeBusiness_calculateByUser`(vUserFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** diff --git a/db/routines/vn/procedures/timeBusiness_calculateByWorker.sql b/db/routines/vn/procedures/timeBusiness_calculateByWorker.sql index 89a4c0ab0..29a9f8f5c 100644 --- a/db/routines/vn/procedures/timeBusiness_calculateByWorker.sql +++ b/db/routines/vn/procedures/timeBusiness_calculateByWorker.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeBusiness_calculateByWorker`(vWorkerFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`timeBusiness_calculateByWorker`(vWorkerFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** diff --git a/db/routines/vn/procedures/timeControl_calculate.sql b/db/routines/vn/procedures/timeControl_calculate.sql index 258960265..f37e0f521 100644 --- a/db/routines/vn/procedures/timeControl_calculate.sql +++ b/db/routines/vn/procedures/timeControl_calculate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeControl_calculate`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`timeControl_calculate`( vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN diff --git a/db/routines/vn/procedures/timeControl_calculateAll.sql b/db/routines/vn/procedures/timeControl_calculateAll.sql index c6354ad78..ae085a6a6 100644 --- a/db/routines/vn/procedures/timeControl_calculateAll.sql +++ b/db/routines/vn/procedures/timeControl_calculateAll.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeControl_calculateAll`(vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`timeControl_calculateAll`(vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** diff --git a/db/routines/vn/procedures/timeControl_calculateByDepartment.sql b/db/routines/vn/procedures/timeControl_calculateByDepartment.sql index bb9ccec60..bdd096a77 100644 --- a/db/routines/vn/procedures/timeControl_calculateByDepartment.sql +++ b/db/routines/vn/procedures/timeControl_calculateByDepartment.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeControl_calculateByDepartment`(vDepartmentFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`timeControl_calculateByDepartment`(vDepartmentFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** * @param vDepartmentFk diff --git a/db/routines/vn/procedures/timeControl_calculateByUser.sql b/db/routines/vn/procedures/timeControl_calculateByUser.sql index 8e831cb4c..4c123a840 100644 --- a/db/routines/vn/procedures/timeControl_calculateByUser.sql +++ b/db/routines/vn/procedures/timeControl_calculateByUser.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeControl_calculateByUser`(vUserFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`timeControl_calculateByUser`(vUserFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** diff --git a/db/routines/vn/procedures/timeControl_calculateByWorker.sql b/db/routines/vn/procedures/timeControl_calculateByWorker.sql index 98c3dedd2..d4b14efe9 100644 --- a/db/routines/vn/procedures/timeControl_calculateByWorker.sql +++ b/db/routines/vn/procedures/timeControl_calculateByWorker.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeControl_calculateByWorker`(vWorkerFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`timeControl_calculateByWorker`(vWorkerFk INT, vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /** diff --git a/db/routines/vn/procedures/timeControl_getError.sql b/db/routines/vn/procedures/timeControl_getError.sql index 6e5ca02ab..fa6345b9c 100644 --- a/db/routines/vn/procedures/timeControl_getError.sql +++ b/db/routines/vn/procedures/timeControl_getError.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`timeControl_getError`(vDatedFrom DATETIME, vDatedTo DATETIME) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`timeControl_getError`(vDatedFrom DATETIME, vDatedTo DATETIME) BEGIN /* * @param vDatedFrom diff --git a/db/routines/vn/procedures/tpvTransaction_checkStatus.sql b/db/routines/vn/procedures/tpvTransaction_checkStatus.sql index e16c20161..eeea13979 100644 --- a/db/routines/vn/procedures/tpvTransaction_checkStatus.sql +++ b/db/routines/vn/procedures/tpvTransaction_checkStatus.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`tpvTransaction_checkStatus`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`tpvTransaction_checkStatus`() BEGIN /** * diff --git a/db/routines/vn/procedures/travelVolume.sql b/db/routines/vn/procedures/travelVolume.sql index 21eae36ac..2e2cdc83b 100644 --- a/db/routines/vn/procedures/travelVolume.sql +++ b/db/routines/vn/procedures/travelVolume.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travelVolume`(vTravelFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travelVolume`(vTravelFk INT) BEGIN SELECT w1.name AS ORI, diff --git a/db/routines/vn/procedures/travelVolume_get.sql b/db/routines/vn/procedures/travelVolume_get.sql index f9d00aeb4..99c0acbb8 100644 --- a/db/routines/vn/procedures/travelVolume_get.sql +++ b/db/routines/vn/procedures/travelVolume_get.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travelVolume_get`(vFromDated DATE, vToDated DATE, vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travelVolume_get`(vFromDated DATE, vToDated DATE, vWarehouseFk INT) BEGIN SELECT tr.landed Fecha, a.name Agencia, diff --git a/db/routines/vn/procedures/travel_checkDates.sql b/db/routines/vn/procedures/travel_checkDates.sql index 45690fcb4..004fefa64 100644 --- a/db/routines/vn/procedures/travel_checkDates.sql +++ b/db/routines/vn/procedures/travel_checkDates.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_checkDates`(vShipped DATE, vLanded DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_checkDates`(vShipped DATE, vLanded DATE) BEGIN /** * Checks the landing/shipment dates of travel, throws an error diff --git a/db/routines/vn/procedures/travel_checkPackaging.sql b/db/routines/vn/procedures/travel_checkPackaging.sql index 59df1b894..2b67f4d25 100644 --- a/db/routines/vn/procedures/travel_checkPackaging.sql +++ b/db/routines/vn/procedures/travel_checkPackaging.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_checkPackaging`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_checkPackaging`(vSelf INT) BEGIN DECLARE vDone BOOL; DECLARE vEntryFk INT; diff --git a/db/routines/vn/procedures/travel_checkWarehouseIsFeedStock.sql b/db/routines/vn/procedures/travel_checkWarehouseIsFeedStock.sql index ef69d772b..27ca9955f 100644 --- a/db/routines/vn/procedures/travel_checkWarehouseIsFeedStock.sql +++ b/db/routines/vn/procedures/travel_checkWarehouseIsFeedStock.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_checkWarehouseIsFeedStock`(vWarehouseFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_checkWarehouseIsFeedStock`(vWarehouseFk INT) proc: BEGIN /* * Check that the warehouse is not Feed Stock diff --git a/db/routines/vn/procedures/travel_clone.sql b/db/routines/vn/procedures/travel_clone.sql index 96500baa1..74a76d477 100644 --- a/db/routines/vn/procedures/travel_clone.sql +++ b/db/routines/vn/procedures/travel_clone.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_clone`(vSelf INT, vDays INT, OUT vNewTravelFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_clone`(vSelf INT, vDays INT, OUT vNewTravelFk INT) BEGIN /** * Clona un travel el número de dias indicado y devuelve su id. diff --git a/db/routines/vn/procedures/travel_cloneWithEntries.sql b/db/routines/vn/procedures/travel_cloneWithEntries.sql index 7cf9ee5ef..ee26aea32 100644 --- a/db/routines/vn/procedures/travel_cloneWithEntries.sql +++ b/db/routines/vn/procedures/travel_cloneWithEntries.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_cloneWithEntries`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_cloneWithEntries`( IN vTravelFk INT, IN vDateStart DATE, IN vDateEnd DATE, @@ -24,8 +24,8 @@ BEGIN DECLARE vEvaNotes VARCHAR(255); DECLARE vDone BOOL; DECLARE vAuxEntryFk INT; - DECLARE vTx BOOLEAN DEFAULT @@in_transaction; - DECLARE vRsEntry CURSOR FOR + DECLARE vIsRequiredTx BOOLEAN DEFAULT NOT @@in_transaction; + DECLARE vRsEntry CURSOR FOR SELECT e.id FROM entry e JOIN travel t ON t.id = e.travelFk @@ -35,11 +35,11 @@ BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN - CALL util.tx_rollback(vTx); + CALL util.tx_rollback(vIsRequiredTx); RESIGNAL; END; - CALL util.tx_start(vTx); + CALL util.tx_start(vIsRequiredTx); INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk, agencyModeFk, `ref`, isDelivered, isReceived, m3, cargoSupplierFk, kg,clonedFrom) SELECT vDateStart, vDateEnd, vWarehouseInFk, vWarehouseOutFk, vAgencyModeFk, vRef, isDelivered, isReceived, m3,cargoSupplierFk, kg,vTravelFk @@ -76,6 +76,6 @@ BEGIN SET @isModeInventory = FALSE; CLOSE vRsEntry; - CALL util.tx_commit(vTx); + CALL util.tx_commit(vIsRequiredTx); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/travel_getDetailFromContinent.sql b/db/routines/vn/procedures/travel_getDetailFromContinent.sql index e81e648b3..a9ee0b6ca 100644 --- a/db/routines/vn/procedures/travel_getDetailFromContinent.sql +++ b/db/routines/vn/procedures/travel_getDetailFromContinent.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_getDetailFromContinent`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_getDetailFromContinent`( vContinentFk INT ) BEGIN diff --git a/db/routines/vn/procedures/travel_getEntriesMissingPackage.sql b/db/routines/vn/procedures/travel_getEntriesMissingPackage.sql index 35d30e0c4..dc78f964c 100644 --- a/db/routines/vn/procedures/travel_getEntriesMissingPackage.sql +++ b/db/routines/vn/procedures/travel_getEntriesMissingPackage.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_getEntriesMissingPackage`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_getEntriesMissingPackage`(vSelf INT) BEGIN DECLARE vpackageOrPackingNull INT; DECLARE vTravelFk INT; diff --git a/db/routines/vn/procedures/travel_moveRaids.sql b/db/routines/vn/procedures/travel_moveRaids.sql index c7696e829..95e02ec55 100644 --- a/db/routines/vn/procedures/travel_moveRaids.sql +++ b/db/routines/vn/procedures/travel_moveRaids.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_moveRaids`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_moveRaids`() BEGIN /* diff --git a/db/routines/vn/procedures/travel_recalc.sql b/db/routines/vn/procedures/travel_recalc.sql index 46d1cdc4f..9aebeaad8 100644 --- a/db/routines/vn/procedures/travel_recalc.sql +++ b/db/routines/vn/procedures/travel_recalc.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_recalc`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_recalc`(vSelf INT) proc: BEGIN /** * Updates the number of entries assigned to the travel. diff --git a/db/routines/vn/procedures/travel_throwAwb.sql b/db/routines/vn/procedures/travel_throwAwb.sql new file mode 100644 index 000000000..a372e4600 --- /dev/null +++ b/db/routines/vn/procedures/travel_throwAwb.sql @@ -0,0 +1,14 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_throwAwb`(vSelf INT) +BEGIN +/** + * Throws an error if travel does not have a logical AWB + * or there are several AWBs associated with the same DUA + * + * @param vSelf The travel id + */ + IF NOT travel_hasUniqueAwb(vSelf) THEN + CALL util.throw('A different AWB is found in the entries'); + END IF; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/travel_upcomingArrivals.sql b/db/routines/vn/procedures/travel_upcomingArrivals.sql index a2cd3733c..f271f55a0 100644 --- a/db/routines/vn/procedures/travel_upcomingArrivals.sql +++ b/db/routines/vn/procedures/travel_upcomingArrivals.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_upcomingArrivals`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_upcomingArrivals`( vWarehouseFk INT, vDate DATETIME ) diff --git a/db/routines/vn/procedures/travel_updatePacking.sql b/db/routines/vn/procedures/travel_updatePacking.sql index 0f63bbf62..dd73bb199 100644 --- a/db/routines/vn/procedures/travel_updatePacking.sql +++ b/db/routines/vn/procedures/travel_updatePacking.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_updatePacking`(vItemFk INT, vPacking INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_updatePacking`(vItemFk INT, vPacking INT) BEGIN /** * Actualiza packing para los movimientos de almacén de la subasta al almacén central diff --git a/db/routines/vn/procedures/travel_weeklyClone.sql b/db/routines/vn/procedures/travel_weeklyClone.sql index a92916c10..182e824af 100644 --- a/db/routines/vn/procedures/travel_weeklyClone.sql +++ b/db/routines/vn/procedures/travel_weeklyClone.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_weeklyClone`(vSinceWeek INT, vToWeek INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_weeklyClone`(vSinceWeek INT, vToWeek INT) BEGIN /** * Clona los traslados plantilla para las semanas pasadas por parámetros. diff --git a/db/routines/vn/procedures/typeTagMake.sql b/db/routines/vn/procedures/typeTagMake.sql index ddfc7fdb9..168b3f4ef 100644 --- a/db/routines/vn/procedures/typeTagMake.sql +++ b/db/routines/vn/procedures/typeTagMake.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`typeTagMake`(vTypeFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`typeTagMake`(vTypeFk INT) BEGIN /* * Plantilla para modificar reemplazar todos los tags diff --git a/db/routines/vn/procedures/updatePedidosInternos.sql b/db/routines/vn/procedures/updatePedidosInternos.sql index 97b01bf8b..b2bc25cb9 100644 --- a/db/routines/vn/procedures/updatePedidosInternos.sql +++ b/db/routines/vn/procedures/updatePedidosInternos.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`updatePedidosInternos`(vItemFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`updatePedidosInternos`(vItemFk INT) BEGIN UPDATE vn.item SET upToDown = 0 WHERE item.id = vItemFk; diff --git a/db/routines/vn/procedures/vehicle_checkNumberPlate.sql b/db/routines/vn/procedures/vehicle_checkNumberPlate.sql index 8e3f24d76..cbbcbec63 100644 --- a/db/routines/vn/procedures/vehicle_checkNumberPlate.sql +++ b/db/routines/vn/procedures/vehicle_checkNumberPlate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`vehicle_checkNumberPlate`(vNumberPlate VARCHAR(10), vCountryCodeFk VARCHAR(2)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`vehicle_checkNumberPlate`(vNumberPlate VARCHAR(10), vCountryCodeFk VARCHAR(2)) BEGIN /** * Comprueba si la matricula pasada tiene el formato correcto dependiendo del pais del vehiculo diff --git a/db/routines/vn/procedures/vehicle_notifyEvents.sql b/db/routines/vn/procedures/vehicle_notifyEvents.sql index 1a07a96e2..756b20bca 100644 --- a/db/routines/vn/procedures/vehicle_notifyEvents.sql +++ b/db/routines/vn/procedures/vehicle_notifyEvents.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`vehicle_notifyEvents`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`vehicle_notifyEvents`() proc:BEGIN /** * Query the vehicleEvent table to see if there are any events that need to be notified. diff --git a/db/routines/vn/procedures/visible_getMisfit.sql b/db/routines/vn/procedures/visible_getMisfit.sql index 631f0236e..a7abdca9a 100644 --- a/db/routines/vn/procedures/visible_getMisfit.sql +++ b/db/routines/vn/procedures/visible_getMisfit.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`visible_getMisfit`(vSectorFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`visible_getMisfit`(vSectorFk INT) BEGIN /* Devuelve una tabla temporal con los descuadres entre el visible teórico y lo ubicado en la práctica diff --git a/db/routines/vn/procedures/warehouseFitting.sql b/db/routines/vn/procedures/warehouseFitting.sql index 4be35a3ee..10347bebf 100644 --- a/db/routines/vn/procedures/warehouseFitting.sql +++ b/db/routines/vn/procedures/warehouseFitting.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`warehouseFitting`(IN vWhOrigin INT , IN vWhDestiny INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`warehouseFitting`(IN vWhOrigin INT , IN vWhDestiny INT) BEGIN DECLARE vCacheVisibleOriginFk INT; DECLARE vCacheVisibleDestinyFk INT; diff --git a/db/routines/vn/procedures/warehouseFitting_byTravel.sql b/db/routines/vn/procedures/warehouseFitting_byTravel.sql index db67c1599..9e0a7abc0 100644 --- a/db/routines/vn/procedures/warehouseFitting_byTravel.sql +++ b/db/routines/vn/procedures/warehouseFitting_byTravel.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`warehouseFitting_byTravel`(IN vTravelFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`warehouseFitting_byTravel`(IN vTravelFk INT) BEGIN DECLARE vWhOrigin INT; diff --git a/db/routines/vn/procedures/workerCalculateBoss.sql b/db/routines/vn/procedures/workerCalculateBoss.sql index 0fc08ed40..afbf1f89d 100644 --- a/db/routines/vn/procedures/workerCalculateBoss.sql +++ b/db/routines/vn/procedures/workerCalculateBoss.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerCalculateBoss`(vWorker INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerCalculateBoss`(vWorker INT) BEGIN /** * Actualiza la tabla workerBosses diff --git a/db/routines/vn/procedures/workerCalendar_calculateBusiness.sql b/db/routines/vn/procedures/workerCalendar_calculateBusiness.sql index 72b461154..429435e3e 100644 --- a/db/routines/vn/procedures/workerCalendar_calculateBusiness.sql +++ b/db/routines/vn/procedures/workerCalendar_calculateBusiness.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerCalendar_calculateBusiness`(vYear INT, vBusinessFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerCalendar_calculateBusiness`(vYear INT, vBusinessFk INT) BEGIN /** * Calcula los días y horas de vacaciones en función de un contrato y año diff --git a/db/routines/vn/procedures/workerCalendar_calculateYear.sql b/db/routines/vn/procedures/workerCalendar_calculateYear.sql index 9e3baf641..ccda31ce3 100644 --- a/db/routines/vn/procedures/workerCalendar_calculateYear.sql +++ b/db/routines/vn/procedures/workerCalendar_calculateYear.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerCalendar_calculateYear`(vYear INT, vWorkerFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerCalendar_calculateYear`(vYear INT, vWorkerFk INT) BEGIN /** diff --git a/db/routines/vn/procedures/workerCreateExternal.sql b/db/routines/vn/procedures/workerCreateExternal.sql index f8cea70b1..c825e6fc5 100644 --- a/db/routines/vn/procedures/workerCreateExternal.sql +++ b/db/routines/vn/procedures/workerCreateExternal.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerCreateExternal`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerCreateExternal`( vFirstName VARCHAR(50), vSurname1 VARCHAR(50), vSurname2 VARCHAR(50), diff --git a/db/routines/vn/procedures/workerDepartmentByDate.sql b/db/routines/vn/procedures/workerDepartmentByDate.sql index 40a099d64..466fd3ab6 100644 --- a/db/routines/vn/procedures/workerDepartmentByDate.sql +++ b/db/routines/vn/procedures/workerDepartmentByDate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerDepartmentByDate`(vDate DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerDepartmentByDate`(vDate DATE) BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.workerDepartmentByDate; diff --git a/db/routines/vn/procedures/workerDisable.sql b/db/routines/vn/procedures/workerDisable.sql index 04612a6dc..7760d5de0 100644 --- a/db/routines/vn/procedures/workerDisable.sql +++ b/db/routines/vn/procedures/workerDisable.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerDisable`(vUserId int) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerDisable`(vUserId int) mainLabel:BEGIN IF (SELECT COUNT(*) FROM workerDisableExcluded WHERE workerFk = vUserId AND (dated > util.VN_CURDATE() OR dated IS NULL)) > 0 THEN diff --git a/db/routines/vn/procedures/workerDisableAll.sql b/db/routines/vn/procedures/workerDisableAll.sql index e2f7740b2..5c1aed342 100644 --- a/db/routines/vn/procedures/workerDisableAll.sql +++ b/db/routines/vn/procedures/workerDisableAll.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerDisableAll`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerDisableAll`() BEGIN DECLARE done BOOL DEFAULT FALSE; DECLARE vUserFk INT; diff --git a/db/routines/vn/procedures/workerForAllCalculateBoss.sql b/db/routines/vn/procedures/workerForAllCalculateBoss.sql index f3574116e..4db97e017 100644 --- a/db/routines/vn/procedures/workerForAllCalculateBoss.sql +++ b/db/routines/vn/procedures/workerForAllCalculateBoss.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerForAllCalculateBoss`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerForAllCalculateBoss`() BEGIN /** * Actualiza la tabla workerBosses utilizando el procedimiento diff --git a/db/routines/vn/procedures/workerJourney_replace.sql b/db/routines/vn/procedures/workerJourney_replace.sql index 1fcb8c590..7156e8658 100644 --- a/db/routines/vn/procedures/workerJourney_replace.sql +++ b/db/routines/vn/procedures/workerJourney_replace.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerJourney_replace`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerJourney_replace`( vDatedFrom DATE, vDatedTo DATE, vWorkerFk INT) diff --git a/db/routines/vn/procedures/workerMistakeType_get.sql b/db/routines/vn/procedures/workerMistakeType_get.sql index ae81640a1..3429521e5 100644 --- a/db/routines/vn/procedures/workerMistakeType_get.sql +++ b/db/routines/vn/procedures/workerMistakeType_get.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerMistakeType_get`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerMistakeType_get`() BEGIN /** diff --git a/db/routines/vn/procedures/workerMistake_add.sql b/db/routines/vn/procedures/workerMistake_add.sql index c4786090b..3dfc67046 100644 --- a/db/routines/vn/procedures/workerMistake_add.sql +++ b/db/routines/vn/procedures/workerMistake_add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerMistake_add`(vWorkerFk INT, vWorkerMistakeTypeFk VARCHAR(10)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerMistake_add`(vWorkerFk INT, vWorkerMistakeTypeFk VARCHAR(10)) BEGIN /** * Añade error al trabajador diff --git a/db/routines/vn/procedures/workerTimeControlSOWP.sql b/db/routines/vn/procedures/workerTimeControlSOWP.sql index 14959b942..80e57d5c3 100644 --- a/db/routines/vn/procedures/workerTimeControlSOWP.sql +++ b/db/routines/vn/procedures/workerTimeControlSOWP.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControlSOWP`(IN vUserFk INT, IN vDated DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerTimeControlSOWP`(IN vUserFk INT, IN vDated DATE) BEGIN SET @order := 0; diff --git a/db/routines/vn/procedures/workerTimeControl_calculateOddDays.sql b/db/routines/vn/procedures/workerTimeControl_calculateOddDays.sql index 9c1e58608..57fd3e977 100644 --- a/db/routines/vn/procedures/workerTimeControl_calculateOddDays.sql +++ b/db/routines/vn/procedures/workerTimeControl_calculateOddDays.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControl_calculateOddDays`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerTimeControl_calculateOddDays`() BEGIN /** * Calculo de las fichadas impares por empleado y dia. diff --git a/db/routines/vn/procedures/workerTimeControl_check.sql b/db/routines/vn/procedures/workerTimeControl_check.sql index ce0e51490..30cf5c639 100644 --- a/db/routines/vn/procedures/workerTimeControl_check.sql +++ b/db/routines/vn/procedures/workerTimeControl_check.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerTimeControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100)) proc: BEGIN /** * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a workerTimeControlAdd diff --git a/db/routines/vn/procedures/workerTimeControl_checkBreak.sql b/db/routines/vn/procedures/workerTimeControl_checkBreak.sql index 15dd12373..81850df9f 100644 --- a/db/routines/vn/procedures/workerTimeControl_checkBreak.sql +++ b/db/routines/vn/procedures/workerTimeControl_checkBreak.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControl_checkBreak`(vStarted DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerTimeControl_checkBreak`(vStarted DATE) BEGIN /** * Retorna los trabajadores que no han respetado el descanso semanal de 36/72 horas diff --git a/db/routines/vn/procedures/workerTimeControl_clockIn.sql b/db/routines/vn/procedures/workerTimeControl_clockIn.sql index a1ce53bc2..522546918 100644 --- a/db/routines/vn/procedures/workerTimeControl_clockIn.sql +++ b/db/routines/vn/procedures/workerTimeControl_clockIn.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControl_clockIn`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerTimeControl_clockIn`( vWorkerFk INT, vTimed DATETIME, vDirection VARCHAR(10), diff --git a/db/routines/vn/procedures/workerTimeControl_direction.sql b/db/routines/vn/procedures/workerTimeControl_direction.sql index f7a68e1e4..84db396cc 100644 --- a/db/routines/vn/procedures/workerTimeControl_direction.sql +++ b/db/routines/vn/procedures/workerTimeControl_direction.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControl_direction`(vWorkerFk VARCHAR(10), vTimed DATETIME) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerTimeControl_direction`(vWorkerFk VARCHAR(10), vTimed DATETIME) BEGIN /** * Devuelve que direcciones de fichadas son lógicas a partir de la anterior fichada @@ -9,6 +9,8 @@ BEGIN */ DECLARE vLastIn DATETIME ; DECLARE vIsMiddleOdd BOOLEAN ; + DECLARE vMailTo VARCHAR(50) DEFAULT NULL; + DECLARE vUserName VARCHAR(50) DEFAULT NULL; IF (vTimed IS NULL) THEN SET vTimed = util.VN_NOW(); @@ -57,5 +59,18 @@ BEGIN VALUES('in', NULL); END IF; + IF (SELECT option1 IS NULL AND option2 IS NULL FROM tmp.workerTimeControlDirection) THEN + SELECT CONCAT(u.name, '@verdnatura.es'), CONCAT(w.firstName, ' ', w.lastName) + INTO vMailTo, vUserName + FROM account.user u + JOIN worker w ON w.bossFk = u.id + WHERE w.id = vWorkerFk; + + CALL mail_insert( + vMailTo, + vMailTo, + 'Error al fichar', + CONCAT(vUserName, ' tiene problemas para fichar')); + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/workerTimeControl_getClockIn.sql b/db/routines/vn/procedures/workerTimeControl_getClockIn.sql index 11cd23fa5..454cd3c77 100644 --- a/db/routines/vn/procedures/workerTimeControl_getClockIn.sql +++ b/db/routines/vn/procedures/workerTimeControl_getClockIn.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControl_getClockIn`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerTimeControl_getClockIn`( vUserFk INT, vDated DATE) BEGIN diff --git a/db/routines/vn/procedures/workerTimeControl_login.sql b/db/routines/vn/procedures/workerTimeControl_login.sql index c46663e1f..0a138693c 100644 --- a/db/routines/vn/procedures/workerTimeControl_login.sql +++ b/db/routines/vn/procedures/workerTimeControl_login.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControl_login`(vWorkerFk VARCHAR(10)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerTimeControl_login`(vWorkerFk VARCHAR(10)) BEGIN /** * Consulta la información del usuario y los botones que tiene que activar en la tablet tras hacer login diff --git a/db/routines/vn/procedures/workerTimeControl_remove.sql b/db/routines/vn/procedures/workerTimeControl_remove.sql index 7b34cbbeb..b4e55986a 100644 --- a/db/routines/vn/procedures/workerTimeControl_remove.sql +++ b/db/routines/vn/procedures/workerTimeControl_remove.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControl_remove`(IN vUserFk INT, IN vTimed DATETIME) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerTimeControl_remove`(IN vUserFk INT, IN vTimed DATETIME) BEGIN DECLARE vDirectionRemove VARCHAR(6); diff --git a/db/routines/vn/procedures/workerTimeControl_sendMailByDepartment.sql b/db/routines/vn/procedures/workerTimeControl_sendMailByDepartment.sql index 5b276084a..b8af457d0 100644 --- a/db/routines/vn/procedures/workerTimeControl_sendMailByDepartment.sql +++ b/db/routines/vn/procedures/workerTimeControl_sendMailByDepartment.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControl_sendMailByDepartment`(IN vDatedFrom DATETIME, IN vDatedTo DATETIME, IN vWorkerFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerTimeControl_sendMailByDepartment`(IN vDatedFrom DATETIME, IN vDatedTo DATETIME, IN vWorkerFk INT) BEGIN /** * Inserta el registro de horario semanalmente de PRODUCCION, CAMARA, REPARTO, TALLER NATURAL y TALLER ARTIFICIAL en vn.mail. diff --git a/db/routines/vn/procedures/workerTimeControl_sendMailByDepartmentLauncher.sql b/db/routines/vn/procedures/workerTimeControl_sendMailByDepartmentLauncher.sql index 406bb8d8d..e1ccb1c78 100644 --- a/db/routines/vn/procedures/workerTimeControl_sendMailByDepartmentLauncher.sql +++ b/db/routines/vn/procedures/workerTimeControl_sendMailByDepartmentLauncher.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControl_sendMailByDepartmentLauncher`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerTimeControl_sendMailByDepartmentLauncher`() BEGIN DECLARE vDatedFrom, vDatedTo DATETIME; diff --git a/db/routines/vn/procedures/workerTimeControl_weekCheckBreak.sql b/db/routines/vn/procedures/workerTimeControl_weekCheckBreak.sql index 70ef3da07..af87a251e 100644 --- a/db/routines/vn/procedures/workerTimeControl_weekCheckBreak.sql +++ b/db/routines/vn/procedures/workerTimeControl_weekCheckBreak.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerTimeControl_weekCheckBreak`(vStarted DATE, vEnded DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerTimeControl_weekCheckBreak`(vStarted DATE, vEnded DATE) BEGIN /** * Retorna los trabajadores que no han respetado el descanso semanal de 36/72 horas diff --git a/db/routines/vn/procedures/workerWeekControl.sql b/db/routines/vn/procedures/workerWeekControl.sql index 8001d8d3a..186b0a35d 100644 --- a/db/routines/vn/procedures/workerWeekControl.sql +++ b/db/routines/vn/procedures/workerWeekControl.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workerWeekControl`(vUserFk INT, vDated DATE, vTabletFk VARCHAR(100)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workerWeekControl`(vUserFk INT, vDated DATE, vTabletFk VARCHAR(100)) BEGIN /* * Devuelve la cantidad de descansos de 12h y de 36 horas que ha disfrutado el trabajador diff --git a/db/routines/vn/procedures/worker_checkMultipleDevice.sql b/db/routines/vn/procedures/worker_checkMultipleDevice.sql index 00df08d49..71978ca3b 100644 --- a/db/routines/vn/procedures/worker_checkMultipleDevice.sql +++ b/db/routines/vn/procedures/worker_checkMultipleDevice.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`worker_checkMultipleDevice`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`worker_checkMultipleDevice`( vSelf INT ) BEGIN diff --git a/db/routines/vn/procedures/worker_getFromHasMistake.sql b/db/routines/vn/procedures/worker_getFromHasMistake.sql index 052097e79..a65558bbb 100644 --- a/db/routines/vn/procedures/worker_getFromHasMistake.sql +++ b/db/routines/vn/procedures/worker_getFromHasMistake.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`worker_getFromHasMistake`(vDepartmentFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`worker_getFromHasMistake`(vDepartmentFk INT) BEGIN /** diff --git a/db/routines/vn/procedures/worker_getHierarchy.sql b/db/routines/vn/procedures/worker_getHierarchy.sql index de6956898..cbcdd8131 100644 --- a/db/routines/vn/procedures/worker_getHierarchy.sql +++ b/db/routines/vn/procedures/worker_getHierarchy.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`worker_getHierarchy`(vUserFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`worker_getHierarchy`( + vUserFk INT +) BEGIN /** * Retorna una tabla temporal con los trabajadores que tiene @@ -12,15 +14,16 @@ BEGIN (PRIMARY KEY (workerFk)) ENGINE = MEMORY WITH RECURSIVE workerHierarchy AS ( - SELECT id workerFk, bossFk, 0 depth + SELECT id workerFk, bossFk, 0 `depth`, CAST(id AS CHAR(255)) `path` FROM vn.worker WHERE id = vUserFk UNION ALL - SELECT w.id, w.bossFk, wh.depth + 1 + SELECT w.id, w.bossFk, wh.`depth` + 1, CONCAT(wh.`path`, ',', w.id) FROM vn.worker w JOIN workerHierarchy wh ON w.bossFk = wh.workerFk + WHERE NOT FIND_IN_SET(w.id, wh.`path`) ) - SELECT * + SELECT * FROM workerHierarchy ORDER BY depth, workerFk; END$$ diff --git a/db/routines/vn/procedures/worker_getSector.sql b/db/routines/vn/procedures/worker_getSector.sql index 759bb839b..3d636394d 100644 --- a/db/routines/vn/procedures/worker_getSector.sql +++ b/db/routines/vn/procedures/worker_getSector.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`worker_getSector`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`worker_getSector`() BEGIN /** diff --git a/db/routines/vn/procedures/worker_updateBalance.sql b/db/routines/vn/procedures/worker_updateBalance.sql index 17c2fbbe1..96357e4d6 100644 --- a/db/routines/vn/procedures/worker_updateBalance.sql +++ b/db/routines/vn/procedures/worker_updateBalance.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`worker_updateBalance`(vSelf INT(11), vCredit DECIMAL(10,2), vDebit DECIMAL(10,2)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`worker_updateBalance`(vSelf INT(11), vCredit DECIMAL(10,2), vDebit DECIMAL(10,2)) BEGIN /** * Actualiza la columna balance de worker. diff --git a/db/routines/vn/procedures/worker_updateBusiness.sql b/db/routines/vn/procedures/worker_updateBusiness.sql index 76c8c9cbb..43edb0416 100644 --- a/db/routines/vn/procedures/worker_updateBusiness.sql +++ b/db/routines/vn/procedures/worker_updateBusiness.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`worker_updateBusiness`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`worker_updateBusiness`(vSelf INT) BEGIN /** * Activates an account and configures its email settings. @@ -21,6 +21,8 @@ BEGIN SET businessFk = vNewBusinessFk WHERE id = vSelf; + CALL queueMember_updateQueue(vNewBusinessFk); + IF vOldBusinessFk IS NULL THEN CALL account.account_enable(vSelf); diff --git a/db/routines/vn/procedures/worker_updateChangedBusiness.sql b/db/routines/vn/procedures/worker_updateChangedBusiness.sql index 05e68b099..0bb0e5905 100644 --- a/db/routines/vn/procedures/worker_updateChangedBusiness.sql +++ b/db/routines/vn/procedures/worker_updateChangedBusiness.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`worker_updateChangedBusiness`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`worker_updateChangedBusiness`() BEGIN /** * Actualiza el contrato actual de todos los trabajadores cuyo contracto ha diff --git a/db/routines/vn/procedures/workingHours.sql b/db/routines/vn/procedures/workingHours.sql index c08226db7..12b65753f 100644 --- a/db/routines/vn/procedures/workingHours.sql +++ b/db/routines/vn/procedures/workingHours.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workingHours`(username varchar(255), logon boolean) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workingHours`(username varchar(255), logon boolean) BEGIN DECLARE userid int(11); diff --git a/db/routines/vn/procedures/workingHoursTimeIn.sql b/db/routines/vn/procedures/workingHoursTimeIn.sql index 8a4268c54..a8ac07cb4 100644 --- a/db/routines/vn/procedures/workingHoursTimeIn.sql +++ b/db/routines/vn/procedures/workingHoursTimeIn.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workingHoursTimeIn`(vUserId INT(11)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workingHoursTimeIn`(vUserId INT(11)) BEGIN INSERT INTO vn.workingHours (timeIn, userId) VALUES (util.VN_NOW(),vUserId); diff --git a/db/routines/vn/procedures/workingHoursTimeOut.sql b/db/routines/vn/procedures/workingHoursTimeOut.sql index f6ce2886c..d44d99f52 100644 --- a/db/routines/vn/procedures/workingHoursTimeOut.sql +++ b/db/routines/vn/procedures/workingHoursTimeOut.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`workingHoursTimeOut`(vUserId INT(11)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`workingHoursTimeOut`(vUserId INT(11)) BEGIN UPDATE vn.workingHours SET timeOut = util.VN_NOW() diff --git a/db/routines/vn/procedures/wrongEqualizatedClient.sql b/db/routines/vn/procedures/wrongEqualizatedClient.sql index 47a6a608d..75499b6f1 100644 --- a/db/routines/vn/procedures/wrongEqualizatedClient.sql +++ b/db/routines/vn/procedures/wrongEqualizatedClient.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`wrongEqualizatedClient`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`wrongEqualizatedClient`() BEGIN SELECT clientFk, c.name, c.isActive, c.isTaxDataChecked, count(ie) as num FROM vn.client c diff --git a/db/routines/vn/procedures/xdiario_new.sql b/db/routines/vn/procedures/xdiario_new.sql new file mode 100644 index 000000000..1c73c6bda --- /dev/null +++ b/db/routines/vn/procedures/xdiario_new.sql @@ -0,0 +1,64 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`xdiario_new`( + vBookNumber INT, + vDated DATE, + vSubaccount VARCHAR(12), + vAccount VARCHAR(12), + vConcept VARCHAR(25), + vDebit DOUBLE, + vCredit DOUBLE, + vEuro DOUBLE, + vSerie CHAR(1), + vInvoice VARCHAR(8), + vVat DOUBLE, + vRe DOUBLE, + vAux TINYINT, + vCompanyFk INT, + OUT vNewBookNumber INT +) +/** + * Este procedimiento se encarga de la inserción de registros en la tabla XDiario. + * Si el número de asiento (vBookNumber) no está definido, se genera uno nuevo utilizando + * vn.ledger_next. + * + * @param vBookNumber Número de asiento. Si es NULL, se generará uno nuevo. + * @param vDated Fecha utilizada para generar un nuevo número de libro si vBookNumber es NULL. + * @param vSubaccount Subcuenta para la transacción. + * @param vAccount Cuenta para la transacción. + * @param vConcept Concepto de la transacción. + * @param vDebit Monto del débito para la transacción. + * @param vCredit Monto del crédito para la transacción. + * @param vEuro Monto en euros para la transacción. + * @param vSerie Serie para la transacción. + * @param vInvoice Número de factura para la transacción. + * @param vVat Monto del IVA para la transacción. + * @param vRe Monto del RE para la transacción. + * @param vAux Variable auxiliar para la transacción. + * @param vCompanyFk Clave foránea de la compañía para la transacción. + * @return No retorna un valor, pero realiza una inserción en la tabla XDiario. + */ +BEGIN + IF vBookNumber IS NULL THEN + CALL ledger_nextTx(YEAR(vDated), vBookNumber); + END IF; + + INSERT INTO XDiario + SET ASIEN = vBookNumber, + FECHA = vDated, + SUBCTA = vSubaccount, + CONTRA = vAccount, + CONCEPTO = vConcept, + EURODEBE = vDebit, + EUROHABER = vCredit, + BASEEURO = vEuro, + SERIE = vSerie, + FACTURA = vInvoice, + IVA = vVat, + RECEQUIV = vRe, + AUXILIAR = IF(vAux = FALSE, NULL, '*'), + MONEDAUSO = 2, + empresa_id = vCompanyFk; + + SET vNewBookNumber = vBookNumber; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/zoneClosure_recalc.sql b/db/routines/vn/procedures/zoneClosure_recalc.sql index 9e51c007d..b1bc77350 100644 --- a/db/routines/vn/procedures/zoneClosure_recalc.sql +++ b/db/routines/vn/procedures/zoneClosure_recalc.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneClosure_recalc`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zoneClosure_recalc`() proc: BEGIN /** * Recalculates the delivery time (hour) for every zone in days + scope in future diff --git a/db/routines/vn/procedures/zoneGeo_calcTree.sql b/db/routines/vn/procedures/zoneGeo_calcTree.sql index 34e1d8241..0bca0d26f 100644 --- a/db/routines/vn/procedures/zoneGeo_calcTree.sql +++ b/db/routines/vn/procedures/zoneGeo_calcTree.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneGeo_calcTree`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zoneGeo_calcTree`() BEGIN /** * Calculates the #path, #lft, #rgt, #sons and #depth columns of diff --git a/db/routines/vn/procedures/zoneGeo_calcTreeRec.sql b/db/routines/vn/procedures/zoneGeo_calcTreeRec.sql index da499ede3..1994f2f8b 100644 --- a/db/routines/vn/procedures/zoneGeo_calcTreeRec.sql +++ b/db/routines/vn/procedures/zoneGeo_calcTreeRec.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneGeo_calcTreeRec`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zoneGeo_calcTreeRec`( vSelf INT, vPath VARCHAR(255), vDepth INT, diff --git a/db/routines/vn/procedures/zoneGeo_checkName.sql b/db/routines/vn/procedures/zoneGeo_checkName.sql index 5933f4be2..066209ffd 100644 --- a/db/routines/vn/procedures/zoneGeo_checkName.sql +++ b/db/routines/vn/procedures/zoneGeo_checkName.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneGeo_checkName`(vName VARCHAR(255)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zoneGeo_checkName`(vName VARCHAR(255)) BEGIN IF vName = '' THEN SIGNAL SQLSTATE '45000' diff --git a/db/routines/vn/procedures/zoneGeo_delete.sql b/db/routines/vn/procedures/zoneGeo_delete.sql index 5bf0c5120..d6f13171b 100644 --- a/db/routines/vn/procedures/zoneGeo_delete.sql +++ b/db/routines/vn/procedures/zoneGeo_delete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneGeo_delete`(vSelf INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zoneGeo_delete`(vSelf INT) BEGIN /** * Deletes a node from the #zoneGeo table. Also sets a mark diff --git a/db/routines/vn/procedures/zoneGeo_doCalc.sql b/db/routines/vn/procedures/zoneGeo_doCalc.sql index ce32357ec..16f2bd819 100644 --- a/db/routines/vn/procedures/zoneGeo_doCalc.sql +++ b/db/routines/vn/procedures/zoneGeo_doCalc.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneGeo_doCalc`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zoneGeo_doCalc`() proc: BEGIN /** * Recalculates the zones tree. diff --git a/db/routines/vn/procedures/zoneGeo_setParent.sql b/db/routines/vn/procedures/zoneGeo_setParent.sql index 3f8f051a2..ad37d69db 100644 --- a/db/routines/vn/procedures/zoneGeo_setParent.sql +++ b/db/routines/vn/procedures/zoneGeo_setParent.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneGeo_setParent`(vSelf INT, vParentFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zoneGeo_setParent`(vSelf INT, vParentFk INT) BEGIN /** * Updates the parent of a node. Also sets a mark diff --git a/db/routines/vn/procedures/zoneGeo_throwNotEditable.sql b/db/routines/vn/procedures/zoneGeo_throwNotEditable.sql index 0b5c8aecf..2fa6fbf85 100644 --- a/db/routines/vn/procedures/zoneGeo_throwNotEditable.sql +++ b/db/routines/vn/procedures/zoneGeo_throwNotEditable.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneGeo_throwNotEditable`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zoneGeo_throwNotEditable`() BEGIN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Column `geoFk` cannot be modified'; diff --git a/db/routines/vn/procedures/zone_excludeFromGeo.sql b/db/routines/vn/procedures/zone_excludeFromGeo.sql index 6f0556bd7..23a5865fd 100644 --- a/db/routines/vn/procedures/zone_excludeFromGeo.sql +++ b/db/routines/vn/procedures/zone_excludeFromGeo.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_excludeFromGeo`(vZoneGeo INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_excludeFromGeo`(vZoneGeo INT) BEGIN /** * Excluye zonas a partir un geoFk. diff --git a/db/routines/vn/procedures/zone_getAddresses.sql b/db/routines/vn/procedures/zone_getAddresses.sql index ce7b0204e..2e5982c82 100644 --- a/db/routines/vn/procedures/zone_getAddresses.sql +++ b/db/routines/vn/procedures/zone_getAddresses.sql @@ -1,55 +1,57 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getAddresses`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getAddresses`( vSelf INT, - vLanded DATE + vShipped DATE, + vDepartmentFk INT ) BEGIN /** * Devuelve un listado de todos los clientes activos * con consignatarios a los que se les puede - * vender producto para esa zona y no tiene un ticket - * para ese día. + * vender producto para esa zona. * * @param vSelf Id de zona - * @param vDated Fecha de entrega + * @param vShipped Fecha de envio + * @param vDepartmentFk Id de departamento * @return Un select */ CALL zone_getPostalCode(vSelf); - WITH notHasTicket AS ( - SELECT id - FROM vn.client - WHERE id NOT IN ( - SELECT clientFk - FROM vn.ticket - WHERE landed BETWEEN vLanded AND util.dayEnd(vLanded) - ) + WITH clientWithTicket AS ( + SELECT clientFk + FROM vn.ticket + WHERE shipped BETWEEN vShipped AND util.dayEnd(vShipped) ) - SELECT c.id clientFk, - c.name, - c.phone, - bt.description, - c.salesPersonFk, - u.name username, - aai.invoiced, - cnb.lastShipped - FROM vn.client c - JOIN notHasTicket ON notHasTicket.id = c.id - LEFT JOIN account.`user` u ON u.id = c.salesPersonFk - JOIN vn.`address` a ON a.clientFk = c.id - JOIN vn.postCode pc ON pc.code = a.postalCode - JOIN vn.town t ON t.id = pc.townFk AND t.provinceFk = a.provinceFk - JOIN vn.zoneGeo zg ON zg.name = a.postalCode - JOIN tmp.zoneNodes zn ON zn.geoFk = pc.geoFk - LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = c.id - LEFT JOIN vn.annualAverageInvoiced aai ON aai.clientFk = c.id - JOIN vn.clientType ct ON ct.code = c.typeFk - JOIN vn.businessType bt ON bt.code = c.businessTypeFk - WHERE a.isActive - AND c.isActive - AND ct.code = 'normal' - AND bt.code <> 'worker' - GROUP BY c.id; + SELECT c.id, + c.name, + c.phone, + bt.description, + c.salesPersonFk, + u.name username, + aai.invoiced, + cnb.lastShipped, + cwt.clientFk + FROM vn.client c + JOIN vn.worker w ON w.id = c.salesPersonFk + JOIN vn.workerDepartment wd ON wd.workerFk = w.id + JOIN vn.department d ON d.id = wd.departmentFk + LEFT JOIN clientWithTicket cwt ON cwt.clientFk = c.id + LEFT JOIN account.`user` u ON u.id = c.salesPersonFk + JOIN vn.`address` a ON a.clientFk = c.id + JOIN vn.postCode pc ON pc.code = a.postalCode + JOIN vn.town t ON t.id = pc.townFk AND t.provinceFk = a.provinceFk + JOIN vn.zoneGeo zg ON zg.name = a.postalCode + JOIN tmp.zoneNodes zn ON zn.geoFk = pc.geoFk + LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = c.id + LEFT JOIN vn.annualAverageInvoiced aai ON aai.clientFk = c.id + JOIN vn.clientType ct ON ct.code = c.typeFk + JOIN vn.businessType bt ON bt.code = c.businessTypeFk + WHERE a.isActive + AND c.isActive + AND ct.code = 'normal' + AND bt.code <> 'worker' + AND (d.id = vDepartmentFk OR NOT vDepartmentFk) + GROUP BY c.id; DROP TEMPORARY TABLE tmp.zoneNodes; END$$ diff --git a/db/routines/vn/procedures/zone_getAgency.sql b/db/routines/vn/procedures/zone_getAgency.sql index 8b66b110b..8b3540477 100644 --- a/db/routines/vn/procedures/zone_getAgency.sql +++ b/db/routines/vn/procedures/zone_getAgency.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getAgency`(vAddress INT, vLanded DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getAgency`(vAddress INT, vLanded DATE) BEGIN /** * Devuelve el listado de agencias disponibles para la fecha diff --git a/db/routines/vn/procedures/zone_getAvailable.sql b/db/routines/vn/procedures/zone_getAvailable.sql index 4fd3d1b34..5362185e6 100644 --- a/db/routines/vn/procedures/zone_getAvailable.sql +++ b/db/routines/vn/procedures/zone_getAvailable.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getAvailable`(vAddress INT, vLanded DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getAvailable`(vAddress INT, vLanded DATE) BEGIN CALL zone_getFromGeo(address_getGeo(vAddress)); CALL zone_getOptionsForLanding(vLanded, FALSE); diff --git a/db/routines/vn/procedures/zone_getClosed.sql b/db/routines/vn/procedures/zone_getClosed.sql index f48e6ff44..4d22c96bd 100644 --- a/db/routines/vn/procedures/zone_getClosed.sql +++ b/db/routines/vn/procedures/zone_getClosed.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getClosed`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getClosed`() proc:BEGIN /** * Devuelve una tabla con las zonas cerradas para hoy diff --git a/db/routines/vn/procedures/zone_getCollisions.sql b/db/routines/vn/procedures/zone_getCollisions.sql index 023b9aac2..9b57017f7 100644 --- a/db/routines/vn/procedures/zone_getCollisions.sql +++ b/db/routines/vn/procedures/zone_getCollisions.sql @@ -1,6 +1,6 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getCollisions`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getCollisions`() BEGIN /** * Calcula si para un mismo codigo postal y dia @@ -103,6 +103,7 @@ BEGIN DROP TEMPORARY TABLE geoCollision, tmp.zone, - tmp.zoneNodes; + tmp.zoneNodes, + tmp.zoneOption; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/zone_getEvents.sql b/db/routines/vn/procedures/zone_getEvents.sql index 53e065083..ce85d1862 100644 --- a/db/routines/vn/procedures/zone_getEvents.sql +++ b/db/routines/vn/procedures/zone_getEvents.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getEvents`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getEvents`( vGeoFk INT, vAgencyModeFk INT) BEGIN diff --git a/db/routines/vn/procedures/zone_getFromGeo.sql b/db/routines/vn/procedures/zone_getFromGeo.sql index fe6be86a7..6ccb8b570 100644 --- a/db/routines/vn/procedures/zone_getFromGeo.sql +++ b/db/routines/vn/procedures/zone_getFromGeo.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getFromGeo`(vGeoFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getFromGeo`(vGeoFk INT) BEGIN /** * Returns all zones which have the passed geo included. diff --git a/db/routines/vn/procedures/zone_getLanded.sql b/db/routines/vn/procedures/zone_getLanded.sql index b75f409b9..1d6cdcc3f 100644 --- a/db/routines/vn/procedures/zone_getLanded.sql +++ b/db/routines/vn/procedures/zone_getLanded.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getLanded`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT, vShowExpiredZones BOOLEAN) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getLanded`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT, vShowExpiredZones BOOLEAN) BEGIN /** * Devuelve una tabla temporal con el dia de recepcion para vShipped. diff --git a/db/routines/vn/procedures/zone_getLeaves.sql b/db/routines/vn/procedures/zone_getLeaves.sql index d1e66267e..51ab487ed 100644 --- a/db/routines/vn/procedures/zone_getLeaves.sql +++ b/db/routines/vn/procedures/zone_getLeaves.sql @@ -1,10 +1,10 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getLeaves`( +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getLeaves`( vSelf INT, vParentFk INT, vSearch VARCHAR(255), vHasInsert BOOL -) +) BEGIN /** * Devuelve las ubicaciones incluidas en la ruta y que sean hijos de parentFk. @@ -119,5 +119,5 @@ BEGIN END IF; DROP TEMPORARY TABLE tNodes, tZones; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/zone_getOptionsForLanding.sql b/db/routines/vn/procedures/zone_getOptionsForLanding.sql index 1c12e8c88..80ccf7ed1 100644 --- a/db/routines/vn/procedures/zone_getOptionsForLanding.sql +++ b/db/routines/vn/procedures/zone_getOptionsForLanding.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getOptionsForLanding`(vLanded DATE, vShowExpiredZones BOOLEAN) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getOptionsForLanding`(vLanded DATE, vShowExpiredZones BOOLEAN) BEGIN /** * Gets computed options for the passed zones and delivery date. diff --git a/db/routines/vn/procedures/zone_getOptionsForShipment.sql b/db/routines/vn/procedures/zone_getOptionsForShipment.sql index ec7824303..fa48b0b0f 100644 --- a/db/routines/vn/procedures/zone_getOptionsForShipment.sql +++ b/db/routines/vn/procedures/zone_getOptionsForShipment.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getOptionsForShipment`(vShipped DATE, vShowExpiredZones BOOLEAN) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getOptionsForShipment`(vShipped DATE, vShowExpiredZones BOOLEAN) BEGIN /** * Gets computed options for the passed zones and shipping date. diff --git a/db/routines/vn/procedures/zone_getPostalCode.sql b/db/routines/vn/procedures/zone_getPostalCode.sql index 920ad3171..b768b6e12 100644 --- a/db/routines/vn/procedures/zone_getPostalCode.sql +++ b/db/routines/vn/procedures/zone_getPostalCode.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getPostalCode`(vSelf INT) +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getPostalCode`(vSelf INT) BEGIN /** * Devuelve los códigos postales incluidos en una zona @@ -42,5 +42,5 @@ BEGIN DELETE FROM tmp.zoneNodes WHERE sons > 0; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/zone_getShipped.sql b/db/routines/vn/procedures/zone_getShipped.sql index 8d28c9062..924883b72 100644 --- a/db/routines/vn/procedures/zone_getShipped.sql +++ b/db/routines/vn/procedures/zone_getShipped.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getShipped`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vShowExpiredZones BOOLEAN) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getShipped`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vShowExpiredZones BOOLEAN) BEGIN /** * Devuelve la mínima fecha de envío para cada warehouse diff --git a/db/routines/vn/procedures/zone_getState.sql b/db/routines/vn/procedures/zone_getState.sql index aa61d08a2..1678be87d 100644 --- a/db/routines/vn/procedures/zone_getState.sql +++ b/db/routines/vn/procedures/zone_getState.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getState`(vDated DATE) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getState`(vDated DATE) BEGIN /** * Devuelve las zonas y el estado para la fecha solicitada diff --git a/db/routines/vn/procedures/zone_getWarehouse.sql b/db/routines/vn/procedures/zone_getWarehouse.sql index b6915a302..aeeba2867 100644 --- a/db/routines/vn/procedures/zone_getWarehouse.sql +++ b/db/routines/vn/procedures/zone_getWarehouse.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT) BEGIN /** * Devuelve el listado de agencias disponibles para la fecha, diff --git a/db/routines/vn/procedures/zone_upcomingDeliveries.sql b/db/routines/vn/procedures/zone_upcomingDeliveries.sql index 96c4136ae..0c3713175 100644 --- a/db/routines/vn/procedures/zone_upcomingDeliveries.sql +++ b/db/routines/vn/procedures/zone_upcomingDeliveries.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_upcomingDeliveries`() +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_upcomingDeliveries`() BEGIN DECLARE vForwardDays INT; diff --git a/db/routines/vn/triggers/XDiario_beforeInsert.sql b/db/routines/vn/triggers/XDiario_beforeInsert.sql index bc89e221f..81f45ef56 100644 --- a/db/routines/vn/triggers/XDiario_beforeInsert.sql +++ b/db/routines/vn/triggers/XDiario_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`XDiario_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`XDiario_beforeInsert` BEFORE INSERT ON `XDiario` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/XDiario_beforeUpdate.sql b/db/routines/vn/triggers/XDiario_beforeUpdate.sql index 33787c8f1..1653da4a4 100644 --- a/db/routines/vn/triggers/XDiario_beforeUpdate.sql +++ b/db/routines/vn/triggers/XDiario_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`XDiario_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`XDiario_beforeUpdate` BEFORE UPDATE ON `XDiario` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/accountReconciliation_beforeInsert.sql b/db/routines/vn/triggers/accountReconciliation_beforeInsert.sql index 4fedd62b8..f37084329 100644 --- a/db/routines/vn/triggers/accountReconciliation_beforeInsert.sql +++ b/db/routines/vn/triggers/accountReconciliation_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`accountReconciliation_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`accountReconciliation_beforeInsert` BEFORE INSERT ON `accountReconciliation` FOR EACH ROW diff --git a/db/routines/vn/triggers/address_afterDelete.sql b/db/routines/vn/triggers/address_afterDelete.sql index d4195d48d..92326c302 100644 --- a/db/routines/vn/triggers/address_afterDelete.sql +++ b/db/routines/vn/triggers/address_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`address_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`address_afterDelete` AFTER DELETE ON `address` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/address_afterInsert.sql b/db/routines/vn/triggers/address_afterInsert.sql index 318fd3958..e97658311 100644 --- a/db/routines/vn/triggers/address_afterInsert.sql +++ b/db/routines/vn/triggers/address_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`address_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`address_afterInsert` BEFORE INSERT ON `address` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/address_afterUpdate.sql b/db/routines/vn/triggers/address_afterUpdate.sql index ab5e03882..a4e3e51e0 100644 --- a/db/routines/vn/triggers/address_afterUpdate.sql +++ b/db/routines/vn/triggers/address_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`address_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`address_afterUpdate` AFTER UPDATE ON `address` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/address_beforeInsert.sql b/db/routines/vn/triggers/address_beforeInsert.sql index 2ef582499..56ef7aa51 100644 --- a/db/routines/vn/triggers/address_beforeInsert.sql +++ b/db/routines/vn/triggers/address_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`address_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`address_beforeInsert` BEFORE INSERT ON `address` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/address_beforeUpdate.sql b/db/routines/vn/triggers/address_beforeUpdate.sql index 8922105e7..35887912c 100644 --- a/db/routines/vn/triggers/address_beforeUpdate.sql +++ b/db/routines/vn/triggers/address_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`address_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`address_beforeUpdate` BEFORE UPDATE ON `address` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/agency_afterInsert.sql b/db/routines/vn/triggers/agency_afterInsert.sql index 35670538b..85bde9bb5 100644 --- a/db/routines/vn/triggers/agency_afterInsert.sql +++ b/db/routines/vn/triggers/agency_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`agency_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`agency_afterInsert` AFTER INSERT ON `agency` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/agency_beforeInsert.sql b/db/routines/vn/triggers/agency_beforeInsert.sql index 8ff3958e1..b08b7b995 100644 --- a/db/routines/vn/triggers/agency_beforeInsert.sql +++ b/db/routines/vn/triggers/agency_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`agency_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`agency_beforeInsert` BEFORE INSERT ON `agency` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/autonomy_afterDelete.sql b/db/routines/vn/triggers/autonomy_afterDelete.sql index f278ccdea..3ff27c3dd 100644 --- a/db/routines/vn/triggers/autonomy_afterDelete.sql +++ b/db/routines/vn/triggers/autonomy_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`autonomy_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`autonomy_afterDelete` AFTER DELETE ON `autonomy` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/autonomy_beforeInsert.sql b/db/routines/vn/triggers/autonomy_beforeInsert.sql index 3a6448b81..cdceba0b9 100644 --- a/db/routines/vn/triggers/autonomy_beforeInsert.sql +++ b/db/routines/vn/triggers/autonomy_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`autonomy_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`autonomy_beforeInsert` BEFORE INSERT ON `autonomy` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/autonomy_beforeUpdate.sql b/db/routines/vn/triggers/autonomy_beforeUpdate.sql index a2c9a2a11..7a8b1c838 100644 --- a/db/routines/vn/triggers/autonomy_beforeUpdate.sql +++ b/db/routines/vn/triggers/autonomy_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`autonomy_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`autonomy_beforeUpdate` BEFORE UPDATE ON `autonomy` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/awbInvoiceIn_afterDelete.sql b/db/routines/vn/triggers/awbInvoiceIn_afterDelete.sql index fd7f4c6e7..d36f6b4f5 100644 --- a/db/routines/vn/triggers/awbInvoiceIn_afterDelete.sql +++ b/db/routines/vn/triggers/awbInvoiceIn_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`awbInvoiceIn_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`awbInvoiceIn_afterDelete` AFTER DELETE ON `awbInvoiceIn` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/awb_beforeInsert.sql b/db/routines/vn/triggers/awb_beforeInsert.sql index 8dc216024..e632ca858 100644 --- a/db/routines/vn/triggers/awb_beforeInsert.sql +++ b/db/routines/vn/triggers/awb_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`awb_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`awb_beforeInsert` BEFORE INSERT ON `awb` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/bankEntity_beforeInsert.sql b/db/routines/vn/triggers/bankEntity_beforeInsert.sql index 6c1ce78a7..b18af3d15 100644 --- a/db/routines/vn/triggers/bankEntity_beforeInsert.sql +++ b/db/routines/vn/triggers/bankEntity_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`bankEntity_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`bankEntity_beforeInsert` BEFORE INSERT ON `bankEntity` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/bankEntity_beforeUpdate.sql b/db/routines/vn/triggers/bankEntity_beforeUpdate.sql index 5bea154a2..bd3c746c1 100644 --- a/db/routines/vn/triggers/bankEntity_beforeUpdate.sql +++ b/db/routines/vn/triggers/bankEntity_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`bankEntity_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`bankEntity_beforeUpdate` BEFORE UPDATE ON `bankEntity` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/budgetNotes_beforeInsert.sql b/db/routines/vn/triggers/budgetNotes_beforeInsert.sql index 6ea5ad5eb..aa4ee1f9e 100644 --- a/db/routines/vn/triggers/budgetNotes_beforeInsert.sql +++ b/db/routines/vn/triggers/budgetNotes_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`budgetNotes_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`budgetNotes_beforeInsert` BEFORE INSERT ON `budgetNotes` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/business_afterDelete.sql b/db/routines/vn/triggers/business_afterDelete.sql index 9b897b4e9..9fac90e21 100644 --- a/db/routines/vn/triggers/business_afterDelete.sql +++ b/db/routines/vn/triggers/business_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`business_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`business_afterDelete` AFTER DELETE ON `business` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/business_afterInsert.sql b/db/routines/vn/triggers/business_afterInsert.sql index 2949eede8..7a560d380 100644 --- a/db/routines/vn/triggers/business_afterInsert.sql +++ b/db/routines/vn/triggers/business_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`business_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`business_afterInsert` AFTER INSERT ON `business` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/business_afterUpdate.sql b/db/routines/vn/triggers/business_afterUpdate.sql index 95746a30d..11aeb88b6 100644 --- a/db/routines/vn/triggers/business_afterUpdate.sql +++ b/db/routines/vn/triggers/business_afterUpdate.sql @@ -1,12 +1,22 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`business_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`business_afterUpdate` AFTER UPDATE ON `business` FOR EACH ROW BEGIN + DECLARE vIsActive BOOL; + DECLARE vExtension VARCHAR(10); + CALL worker_updateBusiness(NEW.workerFk); IF NOT (OLD.workerFk <=> NEW.workerFk) THEN CALL worker_updateBusiness(OLD.workerFk); END IF; + + IF NOT (OLD.departmentFk <=> NEW.departmentFk) THEN + SELECT COUNT(*) INTO vIsActive FROM worker WHERE businessFk = NEW.id; + IF vIsActive THEN + CALL queueMember_updateQueue(NEW.id); + END IF; + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/business_beforeInsert.sql b/db/routines/vn/triggers/business_beforeInsert.sql index 1f136c1e8..36156d023 100644 --- a/db/routines/vn/triggers/business_beforeInsert.sql +++ b/db/routines/vn/triggers/business_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`business_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`business_beforeInsert` BEFORE INSERT ON `business` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/business_beforeUpdate.sql b/db/routines/vn/triggers/business_beforeUpdate.sql index 4b7a10041..f0c09edc2 100644 --- a/db/routines/vn/triggers/business_beforeUpdate.sql +++ b/db/routines/vn/triggers/business_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`business_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`business_beforeUpdate` BEFORE UPDATE ON `business` FOR EACH ROW BEGIN @@ -12,23 +12,21 @@ BEGIN END IF; IF !(OLD.started <=> NEW.started AND OLD.ended <=> NEW.ended) THEN - - SELECT COUNT(*) > 0 INTO isOverlapping - FROM business b - WHERE (util.hasDateOverlapped( - NEW.started, - IFNULL(NEW.ended, b.started), - b.started, - IFNULL(b.ended, NEW.started)) - OR (NEW.ended <=> NULL AND b.ended <=> NULL)) - AND b.id <> OLD.id - AND workerFk = OLD.workerFk; + SELECT util.hasDateOverlapped( + started, + ended, + NEW.started, + IFNULL(NEW.ended, b.started) + ) isOverlapped INTO isOverlapping + FROM vn.business b + WHERE workerFk = NEW.workerFK + AND b.id <> NEW.id + ORDER BY isOverlapped DESC + LIMIT 1; IF isOverlapping THEN CALL util.throw ('IS_OVERLAPPING'); 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 5daaefa33..26df4655f 100644 --- a/db/routines/vn/triggers/buy_afterDelete.sql +++ b/db/routines/vn/triggers/buy_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`buy_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`buy_afterDelete` AFTER DELETE ON `buy` FOR EACH ROW trig: BEGIN diff --git a/db/routines/vn/triggers/buy_afterInsert.sql b/db/routines/vn/triggers/buy_afterInsert.sql index b39842d35..7a6608ada 100644 --- a/db/routines/vn/triggers/buy_afterInsert.sql +++ b/db/routines/vn/triggers/buy_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`buy_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`buy_afterInsert` AFTER INSERT ON `buy` FOR EACH ROW trig: BEGIN diff --git a/db/routines/vn/triggers/buy_afterUpdate.sql b/db/routines/vn/triggers/buy_afterUpdate.sql index fc7ca152d..b82ba1831 100644 --- a/db/routines/vn/triggers/buy_afterUpdate.sql +++ b/db/routines/vn/triggers/buy_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`buy_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`buy_afterUpdate` AFTER UPDATE ON `buy` FOR EACH ROW trig: BEGIN diff --git a/db/routines/vn/triggers/buy_beforeDelete.sql b/db/routines/vn/triggers/buy_beforeDelete.sql index 85f1cf298..82b7e51d6 100644 --- a/db/routines/vn/triggers/buy_beforeDelete.sql +++ b/db/routines/vn/triggers/buy_beforeDelete.sql @@ -1,9 +1,9 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`buy_beforeDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`buy_beforeDelete` BEFORE DELETE ON `buy` FOR EACH ROW BEGIN - CALL entry_checkBooked(OLD.entryFk); + CALL entry_isEditable(OLD.entryFk); IF OLD.printedStickers <> 0 THEN CALL util.throw("it is not possible to delete buys with printed labels "); END IF; diff --git a/db/routines/vn/triggers/buy_beforeInsert.sql b/db/routines/vn/triggers/buy_beforeInsert.sql index 6ad72916b..9c1059266 100644 --- a/db/routines/vn/triggers/buy_beforeInsert.sql +++ b/db/routines/vn/triggers/buy_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`buy_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`buy_beforeInsert` BEFORE INSERT ON `buy` FOR EACH ROW trig: BEGIN @@ -15,7 +15,7 @@ trig: BEGIN LEAVE trig; END IF; - CALL entry_checkBooked(NEW.entryFk); + CALL entry_isEditable(NEW.entryFk); IF NEW.printedStickers <> 0 THEN CALL util.throw('it is not possible to create buy lines with printedstickers other than 0'); END IF; diff --git a/db/routines/vn/triggers/buy_beforeUpdate.sql b/db/routines/vn/triggers/buy_beforeUpdate.sql index 2403091c6..24246329b 100644 --- a/db/routines/vn/triggers/buy_beforeUpdate.sql +++ b/db/routines/vn/triggers/buy_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`buy_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`buy_beforeUpdate` BEFORE UPDATE ON `buy` FOR EACH ROW trig:BEGIN @@ -13,7 +13,15 @@ trig:BEGIN LEAVE trig; END IF; - CALL entry_checkBooked(OLD.entryFk); + IF NOT (NEW.entryFk <=> OLD.entryFk) OR + NOT (NEW.quantity <=> OLD.quantity) OR + NOT (NEW.buyingValue <=> OLD.buyingValue) OR + NOT (NEW.packing <=> OLD.packing) + THEN + + CALL entry_isEditable(OLD.entryFk); + END IF; + SET NEW.editorFk = account.myUser_getId(); SELECT defaultEntry INTO vDefaultEntry @@ -61,6 +69,10 @@ trig:BEGIN IF NOT NEW.printedStickers <=> OLD.printedStickers THEN CALL util.throw("Stickers cannot be modified if they are inventory"); END IF; + + IF OLD.entryFk <> NEW.entryFk THEN + CALL util.throw("Cannot transfer lines to inventory entry"); + END IF; END IF; IF NEW.quantity < 0 THEN diff --git a/db/routines/vn/triggers/calendar_afterDelete.sql b/db/routines/vn/triggers/calendar_afterDelete.sql index 5d0114ea8..d67710a67 100644 --- a/db/routines/vn/triggers/calendar_afterDelete.sql +++ b/db/routines/vn/triggers/calendar_afterDelete.sql @@ -1,12 +1,12 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`calendar_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`calendar_afterDelete` AFTER DELETE ON `calendar` FOR EACH ROW -BEGIN - INSERT INTO workerLog - SET `action` = 'delete', - `changedModel` = 'Calendar', - `changedModelId` = OLD.id, - `userFk` = account.myUser_getId(); +BEGIN + INSERT INTO workerLog + SET `action` = 'delete', + `changedModel` = 'Calendar', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/calendar_beforeInsert.sql b/db/routines/vn/triggers/calendar_beforeInsert.sql index 3e265a099..6351f5391 100644 --- a/db/routines/vn/triggers/calendar_beforeInsert.sql +++ b/db/routines/vn/triggers/calendar_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`calendar_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`calendar_beforeInsert` BEFORE INSERT ON `calendar` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/calendar_beforeUpdate.sql b/db/routines/vn/triggers/calendar_beforeUpdate.sql index f015dc29a..73618aa2a 100644 --- a/db/routines/vn/triggers/calendar_beforeUpdate.sql +++ b/db/routines/vn/triggers/calendar_beforeUpdate.sql @@ -1,8 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`calendar_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`calendar_beforeUpdate` BEFORE UPDATE ON `calendar` FOR EACH ROW -BEGIN - SET NEW.editorFk = account.myUser_getId(); +BEGIN + SET NEW.editorFk = account.myUser_getId(); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/claimBeginning_afterDelete.sql b/db/routines/vn/triggers/claimBeginning_afterDelete.sql index 5e12d9feb..c61abeeb2 100644 --- a/db/routines/vn/triggers/claimBeginning_afterDelete.sql +++ b/db/routines/vn/triggers/claimBeginning_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimBeginning_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimBeginning_afterDelete` AFTER DELETE ON `claimBeginning` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claimBeginning_beforeInsert.sql b/db/routines/vn/triggers/claimBeginning_beforeInsert.sql index f6ad1672b..aa67bbdb3 100644 --- a/db/routines/vn/triggers/claimBeginning_beforeInsert.sql +++ b/db/routines/vn/triggers/claimBeginning_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimBeginning_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimBeginning_beforeInsert` BEFORE INSERT ON `claimBeginning` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claimBeginning_beforeUpdate.sql b/db/routines/vn/triggers/claimBeginning_beforeUpdate.sql index 500d08cb6..b4c06a2d7 100644 --- a/db/routines/vn/triggers/claimBeginning_beforeUpdate.sql +++ b/db/routines/vn/triggers/claimBeginning_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimBeginning_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimBeginning_beforeUpdate` BEFORE UPDATE ON `claimBeginning` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claimDevelopment_afterDelete.sql b/db/routines/vn/triggers/claimDevelopment_afterDelete.sql index 90b1e89eb..af14b8817 100644 --- a/db/routines/vn/triggers/claimDevelopment_afterDelete.sql +++ b/db/routines/vn/triggers/claimDevelopment_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimDevelopment_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimDevelopment_afterDelete` AFTER DELETE ON `claimDevelopment` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claimDevelopment_beforeInsert.sql b/db/routines/vn/triggers/claimDevelopment_beforeInsert.sql index 15ec36138..5d1365a43 100644 --- a/db/routines/vn/triggers/claimDevelopment_beforeInsert.sql +++ b/db/routines/vn/triggers/claimDevelopment_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimDevelopment_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimDevelopment_beforeInsert` BEFORE INSERT ON `claimDevelopment` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claimDevelopment_beforeUpdate.sql b/db/routines/vn/triggers/claimDevelopment_beforeUpdate.sql index b0727adb3..c51c7c6d8 100644 --- a/db/routines/vn/triggers/claimDevelopment_beforeUpdate.sql +++ b/db/routines/vn/triggers/claimDevelopment_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimDevelopment_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimDevelopment_beforeUpdate` BEFORE UPDATE ON `claimDevelopment` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claimDms_afterDelete.sql b/db/routines/vn/triggers/claimDms_afterDelete.sql index 53bf819e2..1a3630695 100644 --- a/db/routines/vn/triggers/claimDms_afterDelete.sql +++ b/db/routines/vn/triggers/claimDms_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimDms_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimDms_afterDelete` AFTER DELETE ON `claimDms` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claimDms_beforeInsert.sql b/db/routines/vn/triggers/claimDms_beforeInsert.sql index bb84e7a81..dfaffda36 100644 --- a/db/routines/vn/triggers/claimDms_beforeInsert.sql +++ b/db/routines/vn/triggers/claimDms_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimDms_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimDms_beforeInsert` BEFORE INSERT ON `claimDms` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claimDms_beforeUpdate.sql b/db/routines/vn/triggers/claimDms_beforeUpdate.sql index 8ffab268e..420b4d999 100644 --- a/db/routines/vn/triggers/claimDms_beforeUpdate.sql +++ b/db/routines/vn/triggers/claimDms_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimDms_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimDms_beforeUpdate` BEFORE UPDATE ON `claimDms` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claimEnd_afterDelete.sql b/db/routines/vn/triggers/claimEnd_afterDelete.sql index dee80fc77..b63db488f 100644 --- a/db/routines/vn/triggers/claimEnd_afterDelete.sql +++ b/db/routines/vn/triggers/claimEnd_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimEnd_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimEnd_afterDelete` AFTER DELETE ON `claimEnd` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claimEnd_beforeInsert.sql b/db/routines/vn/triggers/claimEnd_beforeInsert.sql index beb66c297..113fb8179 100644 --- a/db/routines/vn/triggers/claimEnd_beforeInsert.sql +++ b/db/routines/vn/triggers/claimEnd_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimEnd_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimEnd_beforeInsert` BEFORE INSERT ON `claimEnd` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claimEnd_beforeUpdate.sql b/db/routines/vn/triggers/claimEnd_beforeUpdate.sql index 7e91996dd..74d79c240 100644 --- a/db/routines/vn/triggers/claimEnd_beforeUpdate.sql +++ b/db/routines/vn/triggers/claimEnd_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimEnd_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimEnd_beforeUpdate` BEFORE UPDATE ON `claimEnd` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claimObservation_afterDelete.sql b/db/routines/vn/triggers/claimObservation_afterDelete.sql index b61368310..30899b2c5 100644 --- a/db/routines/vn/triggers/claimObservation_afterDelete.sql +++ b/db/routines/vn/triggers/claimObservation_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimObservation_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimObservation_afterDelete` AFTER DELETE ON `claimObservation` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claimObservation_beforeInsert.sql b/db/routines/vn/triggers/claimObservation_beforeInsert.sql index e6cf4a42a..b510f5c7a 100644 --- a/db/routines/vn/triggers/claimObservation_beforeInsert.sql +++ b/db/routines/vn/triggers/claimObservation_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimObservation_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimObservation_beforeInsert` BEFORE INSERT ON `claimObservation` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claimObservation_beforeUpdate.sql b/db/routines/vn/triggers/claimObservation_beforeUpdate.sql index 79008eb1b..a374856d0 100644 --- a/db/routines/vn/triggers/claimObservation_beforeUpdate.sql +++ b/db/routines/vn/triggers/claimObservation_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimObservation_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimObservation_beforeUpdate` BEFORE UPDATE ON `claimObservation` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claimRatio_afterInsert.sql b/db/routines/vn/triggers/claimRatio_afterInsert.sql new file mode 100644 index 000000000..ff203e9ba --- /dev/null +++ b/db/routines/vn/triggers/claimRatio_afterInsert.sql @@ -0,0 +1,11 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimRatio_afterInsert` + AFTER INSERT ON `claimRatio` + FOR EACH ROW +BEGIN + INSERT INTO clientRate(clientFk, `value`) + VALUES(NEW.clientFk, NEW.priceIncreasing) + ON DUPLICATE KEY UPDATE + `value` = VALUES(`value`); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/claimRatio_afterUpdate.sql b/db/routines/vn/triggers/claimRatio_afterUpdate.sql new file mode 100644 index 000000000..5a3272d5c --- /dev/null +++ b/db/routines/vn/triggers/claimRatio_afterUpdate.sql @@ -0,0 +1,11 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimRatio_afterUpdate` + AFTER UPDATE ON `claimRatio` + FOR EACH ROW +BEGIN + INSERT INTO clientRate(clientFk, `value`) + VALUES(NEW.clientFk, NEW.priceIncreasing) + ON DUPLICATE KEY UPDATE + `value` = VALUES(`value`); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/claimState_afterDelete.sql b/db/routines/vn/triggers/claimState_afterDelete.sql index 00c0a203d..890ef3f73 100644 --- a/db/routines/vn/triggers/claimState_afterDelete.sql +++ b/db/routines/vn/triggers/claimState_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimState_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimState_afterDelete` AFTER DELETE ON `claimState` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claimState_beforeInsert.sql b/db/routines/vn/triggers/claimState_beforeInsert.sql index e289e8067..fb7460c53 100644 --- a/db/routines/vn/triggers/claimState_beforeInsert.sql +++ b/db/routines/vn/triggers/claimState_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimState_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimState_beforeInsert` BEFORE INSERT ON `claimState` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claimState_beforeUpdate.sql b/db/routines/vn/triggers/claimState_beforeUpdate.sql index 53c8c254b..e113d4ec8 100644 --- a/db/routines/vn/triggers/claimState_beforeUpdate.sql +++ b/db/routines/vn/triggers/claimState_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimState_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimState_beforeUpdate` BEFORE UPDATE ON `claimState` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claim_afterDelete.sql b/db/routines/vn/triggers/claim_afterDelete.sql index bd01ad80f..57566d400 100644 --- a/db/routines/vn/triggers/claim_afterDelete.sql +++ b/db/routines/vn/triggers/claim_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claim_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claim_afterDelete` AFTER DELETE ON `claim` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claim_beforeInsert.sql b/db/routines/vn/triggers/claim_beforeInsert.sql index 36f73902b..dc3ef8c7a 100644 --- a/db/routines/vn/triggers/claim_beforeInsert.sql +++ b/db/routines/vn/triggers/claim_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claim_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claim_beforeInsert` BEFORE INSERT ON `claim` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/claim_beforeUpdate.sql b/db/routines/vn/triggers/claim_beforeUpdate.sql index 9dec746ad..2898a0c61 100644 --- a/db/routines/vn/triggers/claim_beforeUpdate.sql +++ b/db/routines/vn/triggers/claim_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claim_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claim_beforeUpdate` BEFORE UPDATE ON `claim` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/clientContact_afterDelete.sql b/db/routines/vn/triggers/clientContact_afterDelete.sql index b138a0957..5b76d960d 100644 --- a/db/routines/vn/triggers/clientContact_afterDelete.sql +++ b/db/routines/vn/triggers/clientContact_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientContact_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`clientContact_afterDelete` AFTER DELETE ON `clientContact` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/clientContact_beforeInsert.sql b/db/routines/vn/triggers/clientContact_beforeInsert.sql index 7ddf4d7dd..fd810e140 100644 --- a/db/routines/vn/triggers/clientContact_beforeInsert.sql +++ b/db/routines/vn/triggers/clientContact_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientContact_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`clientContact_beforeInsert` BEFORE INSERT ON `clientContact` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/clientCredit_afterInsert.sql b/db/routines/vn/triggers/clientCredit_afterInsert.sql index 440f24865..76ee34d58 100644 --- a/db/routines/vn/triggers/clientCredit_afterInsert.sql +++ b/db/routines/vn/triggers/clientCredit_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientCredit_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`clientCredit_afterInsert` AFTER INSERT ON `clientCredit` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/clientDms_afterDelete.sql b/db/routines/vn/triggers/clientDms_afterDelete.sql index 9b6fb4876..c36632d5c 100644 --- a/db/routines/vn/triggers/clientDms_afterDelete.sql +++ b/db/routines/vn/triggers/clientDms_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientDms_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`clientDms_afterDelete` AFTER DELETE ON `clientDms` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/clientDms_beforeInsert.sql b/db/routines/vn/triggers/clientDms_beforeInsert.sql index 011cc6e96..42181d5c6 100644 --- a/db/routines/vn/triggers/clientDms_beforeInsert.sql +++ b/db/routines/vn/triggers/clientDms_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientDms_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`clientDms_beforeInsert` BEFORE INSERT ON `clientDms` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/clientDms_beforeUpdate.sql b/db/routines/vn/triggers/clientDms_beforeUpdate.sql index 56eaec7eb..7138caa5f 100644 --- a/db/routines/vn/triggers/clientDms_beforeUpdate.sql +++ b/db/routines/vn/triggers/clientDms_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientDms_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`clientDms_beforeUpdate` BEFORE UPDATE ON `clientDms` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/clientObservation_afterDelete.sql b/db/routines/vn/triggers/clientObservation_afterDelete.sql index c93564aa5..f855dccf8 100644 --- a/db/routines/vn/triggers/clientObservation_afterDelete.sql +++ b/db/routines/vn/triggers/clientObservation_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientObservation_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`clientObservation_afterDelete` AFTER DELETE ON `clientObservation` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/clientObservation_beforeInsert.sql b/db/routines/vn/triggers/clientObservation_beforeInsert.sql index 684873031..9767d0e58 100644 --- a/db/routines/vn/triggers/clientObservation_beforeInsert.sql +++ b/db/routines/vn/triggers/clientObservation_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientObservation_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`clientObservation_beforeInsert` BEFORE INSERT ON `clientObservation` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/clientObservation_beforeUpdate.sql b/db/routines/vn/triggers/clientObservation_beforeUpdate.sql index 6e0b63794..d1cb50e80 100644 --- a/db/routines/vn/triggers/clientObservation_beforeUpdate.sql +++ b/db/routines/vn/triggers/clientObservation_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientObservation_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`clientObservation_beforeUpdate` BEFORE UPDATE ON `clientObservation` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/clientSample_afterDelete.sql b/db/routines/vn/triggers/clientSample_afterDelete.sql index 1ac9e77be..5db0ce39e 100644 --- a/db/routines/vn/triggers/clientSample_afterDelete.sql +++ b/db/routines/vn/triggers/clientSample_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientSample_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`clientSample_afterDelete` AFTER DELETE ON `clientSample` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/clientSample_beforeInsert.sql b/db/routines/vn/triggers/clientSample_beforeInsert.sql index c7fe43c9b..956013ba9 100644 --- a/db/routines/vn/triggers/clientSample_beforeInsert.sql +++ b/db/routines/vn/triggers/clientSample_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientSample_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`clientSample_beforeInsert` BEFORE INSERT ON `clientSample` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/clientSample_beforeUpdate.sql b/db/routines/vn/triggers/clientSample_beforeUpdate.sql index 5c16950b5..d9c7e045f 100644 --- a/db/routines/vn/triggers/clientSample_beforeUpdate.sql +++ b/db/routines/vn/triggers/clientSample_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientSample_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`clientSample_beforeUpdate` BEFORE UPDATE ON `clientSample` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/clientUnpaid_beforeInsert.sql b/db/routines/vn/triggers/clientUnpaid_beforeInsert.sql new file mode 100644 index 000000000..de4bf2c20 --- /dev/null +++ b/db/routines/vn/triggers/clientUnpaid_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`clientUnpaid_beforeInsert` + BEFORE INSERT ON `clientUnpaid` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/clientUnpaid_beforeUpdate.sql b/db/routines/vn/triggers/clientUnpaid_beforeUpdate.sql new file mode 100644 index 000000000..f3dfbe356 --- /dev/null +++ b/db/routines/vn/triggers/clientUnpaid_beforeUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`clientUnpaid_beforeUpdate` + BEFORE UPDATE ON `clientUnpaid` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/client_afterDelete.sql b/db/routines/vn/triggers/client_afterDelete.sql index e6849ef49..c5391d89b 100644 --- a/db/routines/vn/triggers/client_afterDelete.sql +++ b/db/routines/vn/triggers/client_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`client_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`client_afterDelete` AFTER DELETE ON `client` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/client_afterInsert.sql b/db/routines/vn/triggers/client_afterInsert.sql index 764d8f067..47ab3fb6f 100644 --- a/db/routines/vn/triggers/client_afterInsert.sql +++ b/db/routines/vn/triggers/client_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`client_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`client_afterInsert` AFTER INSERT ON `client` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/client_afterUpdate.sql b/db/routines/vn/triggers/client_afterUpdate.sql index e316fb08a..eb977faa3 100644 --- a/db/routines/vn/triggers/client_afterUpdate.sql +++ b/db/routines/vn/triggers/client_afterUpdate.sql @@ -1,14 +1,37 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`client_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`client_afterUpdate` AFTER UPDATE ON `client` FOR EACH ROW BEGIN - IF !(NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN + IF NOT (NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN UPDATE `address` SET isDefaultAddress = FALSE WHERE clientFk = NEW.id; UPDATE `address` SET isDefaultAddress = TRUE WHERE id = NEW.defaultAddressFk; END IF; + + IF NEW.id <> OLD.id + OR NOT (NEW.provinceFk <=> OLD.provinceFk) + OR NOT (NEW.socialName <=> OLD.socialName) + OR NOT (NEW.street <=> OLD.street) + OR NOT (NEW.accountingAccount <=> OLD.accountingAccount) + OR NOT (NEW.isVies <=> OLD.isVies) + OR NOT (NEW.fi <=> OLD.fi) + OR NOT (NEW.postcode <=> OLD.postcode) + OR NOT (NEW.city <=> OLD.city) + OR NOT (NEW.countryFk <=> OLD.countryFk) + OR NOT (NEW.taxTypeSageFk <=> OLD.taxTypeSageFk) + OR NOT (NEW.transactionTypeSageFk <=> OLD.transactionTypeSageFk) + OR NOT (NEW.email <=> OLD.email) + OR NOT (NEW.iban <=> OLD.iban) + OR NOT (NEW.phone <=> OLD.phone) + OR NOT (NEW.mobile <=> OLD.mobile) THEN + + UPDATE sage.clientSupplier + SET isSync = FALSE + WHERE idClientSupplier IN (NEW.id, OLD.id) + AND `type` = 'C'; + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/client_beforeInsert.sql b/db/routines/vn/triggers/client_beforeInsert.sql index 75b69c7dd..45de107f1 100644 --- a/db/routines/vn/triggers/client_beforeInsert.sql +++ b/db/routines/vn/triggers/client_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`client_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`client_beforeInsert` BEFORE INSERT ON `client` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/client_beforeUpdate.sql b/db/routines/vn/triggers/client_beforeUpdate.sql index 2f384c535..7142d6604 100644 --- a/db/routines/vn/triggers/client_beforeUpdate.sql +++ b/db/routines/vn/triggers/client_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`client_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`client_beforeUpdate` BEFORE UPDATE ON `client` FOR EACH ROW BEGIN @@ -65,11 +65,11 @@ BEGIN END IF; END IF; - IF !(NEW.salesPersonFk <=> OLD.salesPersonFk) THEN + IF NOT (NEW.salesPersonFk <=> OLD.salesPersonFk) THEN SET NEW.lastSalesPersonFk = IFNULL(NEW.salesPersonFk, OLD.salesPersonFk); END IF; - IF !(NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN + IF NOT (NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN SET NEW.isTaxDataChecked = 0; END IF; END$$ diff --git a/db/routines/vn/triggers/cmr_beforeDelete.sql b/db/routines/vn/triggers/cmr_beforeDelete.sql index 2cb789244..566f3a1bc 100644 --- a/db/routines/vn/triggers/cmr_beforeDelete.sql +++ b/db/routines/vn/triggers/cmr_beforeDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`cmr_beforeDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`cmr_beforeDelete` BEFORE DELETE ON `cmr` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/collectionColors_beforeInsert.sql b/db/routines/vn/triggers/collectionColors_beforeInsert.sql index 254529932..96a7d8aa1 100644 --- a/db/routines/vn/triggers/collectionColors_beforeInsert.sql +++ b/db/routines/vn/triggers/collectionColors_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`collectionColors_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`collectionColors_beforeInsert` BEFORE INSERT ON `collectionColors` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/collectionColors_beforeUpdate.sql b/db/routines/vn/triggers/collectionColors_beforeUpdate.sql index 1ee83ab74..c46460841 100644 --- a/db/routines/vn/triggers/collectionColors_beforeUpdate.sql +++ b/db/routines/vn/triggers/collectionColors_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`collectionColors_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`collectionColors_beforeUpdate` BEFORE UPDATE ON `collectionColors` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/collectionVolumetry_afterDelete.sql b/db/routines/vn/triggers/collectionVolumetry_afterDelete.sql index 53c6340ee..e5461a221 100644 --- a/db/routines/vn/triggers/collectionVolumetry_afterDelete.sql +++ b/db/routines/vn/triggers/collectionVolumetry_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`collectionVolumetry_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`collectionVolumetry_afterDelete` AFTER DELETE ON `collectionVolumetry` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/collectionVolumetry_afterInsert.sql b/db/routines/vn/triggers/collectionVolumetry_afterInsert.sql index 9f061742c..1cc9d377d 100644 --- a/db/routines/vn/triggers/collectionVolumetry_afterInsert.sql +++ b/db/routines/vn/triggers/collectionVolumetry_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`collectionVolumetry_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`collectionVolumetry_afterInsert` AFTER INSERT ON `collectionVolumetry` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/collectionVolumetry_afterUpdate.sql b/db/routines/vn/triggers/collectionVolumetry_afterUpdate.sql index 6dc4311c5..745cddfbe 100644 --- a/db/routines/vn/triggers/collectionVolumetry_afterUpdate.sql +++ b/db/routines/vn/triggers/collectionVolumetry_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`collectionVolumetry_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`collectionVolumetry_afterUpdate` AFTER UPDATE ON `collectionVolumetry` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/collection_beforeUpdate.sql b/db/routines/vn/triggers/collection_beforeUpdate.sql index 40a0b7bed..d6b2f6b8a 100644 --- a/db/routines/vn/triggers/collection_beforeUpdate.sql +++ b/db/routines/vn/triggers/collection_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`collection_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`collection_beforeUpdate` BEFORE UPDATE ON `collection` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/country_afterDelete.sql b/db/routines/vn/triggers/country_afterDelete.sql index 30fbfc817..8be887bb8 100644 --- a/db/routines/vn/triggers/country_afterDelete.sql +++ b/db/routines/vn/triggers/country_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`country_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`country_afterDelete` AFTER DELETE ON `country` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/country_afterInsert.sql b/db/routines/vn/triggers/country_afterInsert.sql index 69294a9d5..af9626b9c 100644 --- a/db/routines/vn/triggers/country_afterInsert.sql +++ b/db/routines/vn/triggers/country_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`country_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`country_afterInsert` AFTER INSERT ON `country` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/country_afterUpdate.sql b/db/routines/vn/triggers/country_afterUpdate.sql index a38994735..95d823c60 100644 --- a/db/routines/vn/triggers/country_afterUpdate.sql +++ b/db/routines/vn/triggers/country_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`country_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`country_afterUpdate` AFTER UPDATE ON `country` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/country_beforeInsert.sql b/db/routines/vn/triggers/country_beforeInsert.sql index 5ba5b832d..eb43cf989 100644 --- a/db/routines/vn/triggers/country_beforeInsert.sql +++ b/db/routines/vn/triggers/country_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`country_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`country_beforeInsert` BEFORE INSERT ON `country` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/country_beforeUpdate.sql b/db/routines/vn/triggers/country_beforeUpdate.sql index 31de99f34..f63672788 100644 --- a/db/routines/vn/triggers/country_beforeUpdate.sql +++ b/db/routines/vn/triggers/country_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`country_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`country_beforeUpdate` BEFORE UPDATE ON `country` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/creditClassification_beforeUpdate.sql b/db/routines/vn/triggers/creditClassification_beforeUpdate.sql index 410ce2bc4..e586e7685 100644 --- a/db/routines/vn/triggers/creditClassification_beforeUpdate.sql +++ b/db/routines/vn/triggers/creditClassification_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`creditClassification_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`creditClassification_beforeUpdate` BEFORE UPDATE ON `creditClassification` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/creditInsurance_afterInsert.sql b/db/routines/vn/triggers/creditInsurance_afterInsert.sql index 22f94854b..f4857a730 100644 --- a/db/routines/vn/triggers/creditInsurance_afterInsert.sql +++ b/db/routines/vn/triggers/creditInsurance_afterInsert.sql @@ -1,11 +1,11 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`creditInsurance_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`creditInsurance_afterInsert` AFTER INSERT ON `creditInsurance` FOR EACH ROW BEGIN UPDATE `client` c JOIN vn.creditClassification cc ON cc.client = c.id - SET creditInsurance = NEW.credit WHERE cc.id = NEW.creditClassification; + SET creditInsurance = NEW.credit WHERE cc.id = NEW.creditClassificationFk; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/creditInsurance_beforeInsert.sql b/db/routines/vn/triggers/creditInsurance_beforeInsert.sql deleted file mode 100644 index 51ab223b1..000000000 --- a/db/routines/vn/triggers/creditInsurance_beforeInsert.sql +++ /dev/null @@ -1,10 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`creditInsurance_beforeInsert` - BEFORE INSERT ON `creditInsurance` - FOR EACH ROW -BEGIN - IF NEW.creditClassificationFk THEN - SET NEW.creditClassification = NEW.creditClassificationFk; - END IF; -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/delivery_beforeInsert.sql b/db/routines/vn/triggers/delivery_beforeInsert.sql index 89431c30f..7996e0aef 100644 --- a/db/routines/vn/triggers/delivery_beforeInsert.sql +++ b/db/routines/vn/triggers/delivery_beforeInsert.sql @@ -1,20 +1,13 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`delivery_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`delivery_beforeInsert` BEFORE INSERT ON `delivery` FOR EACH ROW BEGIN - - IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) + IF (NEW.longitude IS NOT NULL + AND NEW.latitude IS NOT NULL + AND NEW.ticketFK IS NOT NULL) THEN - UPDATE address - SET longitude = NEW.longitude, - latitude = NEW.latitude - WHERE id IN ( - SELECT addressFK - FROM ticket - WHERE id = NEW.ticketFk - ); + CALL address_updateCoordinates(NEW.ticketFk, NEW.longitude, NEW.latitude); END IF; - END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/delivery_beforeUpdate.sql b/db/routines/vn/triggers/delivery_beforeUpdate.sql index 7e6aa7d4c..4ddb932e9 100644 --- a/db/routines/vn/triggers/delivery_beforeUpdate.sql +++ b/db/routines/vn/triggers/delivery_beforeUpdate.sql @@ -1,20 +1,13 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`delivery_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`delivery_beforeUpdate` BEFORE UPDATE ON `delivery` FOR EACH ROW BEGIN - -IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) + IF (NEW.longitude IS NOT NULL + AND NEW.latitude IS NOT NULL + AND NEW.ticketFK IS NOT NULL) THEN - UPDATE address - SET longitude = NEW.longitude, - latitude = NEW.latitude - WHERE id IN ( - SELECT addressFK - FROM ticket - WHERE id = NEW.ticketFk - ); + CALL address_updateCoordinates(NEW.ticketFk, NEW.longitude, NEW.latitude); END IF; - END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/department_afterDelete.sql b/db/routines/vn/triggers/department_afterDelete.sql index 311847556..09fcf3ea1 100644 --- a/db/routines/vn/triggers/department_afterDelete.sql +++ b/db/routines/vn/triggers/department_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`department_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`department_afterDelete` AFTER DELETE ON `department` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/department_afterUpdate.sql b/db/routines/vn/triggers/department_afterUpdate.sql index a425e1809..559fad9a3 100644 --- a/db/routines/vn/triggers/department_afterUpdate.sql +++ b/db/routines/vn/triggers/department_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`department_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`department_afterUpdate` AFTER UPDATE ON `department` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/department_beforeDelete.sql b/db/routines/vn/triggers/department_beforeDelete.sql index 6eaa5b42e..307af6b72 100644 --- a/db/routines/vn/triggers/department_beforeDelete.sql +++ b/db/routines/vn/triggers/department_beforeDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`department_beforeDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`department_beforeDelete` BEFORE DELETE ON `department` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/department_beforeInsert.sql b/db/routines/vn/triggers/department_beforeInsert.sql index 6bd6617ae..8fa89fad6 100644 --- a/db/routines/vn/triggers/department_beforeInsert.sql +++ b/db/routines/vn/triggers/department_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`department_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`department_beforeInsert` BEFORE INSERT ON `department` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/deviceProductionConfig_afterUpdate.sql b/db/routines/vn/triggers/deviceProductionConfig_afterUpdate.sql deleted file mode 100644 index 98e4f844f..000000000 --- a/db/routines/vn/triggers/deviceProductionConfig_afterUpdate.sql +++ /dev/null @@ -1,13 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionConfig_afterUpdate` - AFTER UPDATE ON `deviceProductionConfig` - FOR EACH ROW -BEGIN - IF NEW.isAllUsersAllowed = 1 OR NEW.isAllUsersAllowed = -1 THEN - SET @username := (SELECT account.myUser_getName()); - INSERT INTO vn.mail (receiver, subject, body) - VALUES ('cau@verdnatura.es', 'Se ha activado la autenticación sin restricciones en la app', - CONCAT('El usuario ', @username,' ha habilitado la opción para que todos los usuarios puedan acceder a la app sin restricciones')); - END IF; -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/deviceProductionModels_beforeInsert.sql b/db/routines/vn/triggers/deviceProductionModels_beforeInsert.sql index 3994520b7..f39ad28db 100644 --- a/db/routines/vn/triggers/deviceProductionModels_beforeInsert.sql +++ b/db/routines/vn/triggers/deviceProductionModels_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionModels_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`deviceProductionModels_beforeInsert` BEFORE INSERT ON `deviceProductionModels` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/deviceProductionModels_beforeUpdate.sql b/db/routines/vn/triggers/deviceProductionModels_beforeUpdate.sql index 01c8d347e..ea43db8a0 100644 --- a/db/routines/vn/triggers/deviceProductionModels_beforeUpdate.sql +++ b/db/routines/vn/triggers/deviceProductionModels_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionModels_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`deviceProductionModels_beforeUpdate` BEFORE UPDATE ON `deviceProductionModels` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/deviceProductionState_beforeInsert.sql b/db/routines/vn/triggers/deviceProductionState_beforeInsert.sql index 1a2a66e10..6fb4bd67a 100644 --- a/db/routines/vn/triggers/deviceProductionState_beforeInsert.sql +++ b/db/routines/vn/triggers/deviceProductionState_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionState_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`deviceProductionState_beforeInsert` BEFORE INSERT ON `deviceProductionState` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/deviceProductionState_beforeUpdate.sql b/db/routines/vn/triggers/deviceProductionState_beforeUpdate.sql index e8172fb42..56a1d2aad 100644 --- a/db/routines/vn/triggers/deviceProductionState_beforeUpdate.sql +++ b/db/routines/vn/triggers/deviceProductionState_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionState_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`deviceProductionState_beforeUpdate` BEFORE UPDATE ON `deviceProductionState` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/deviceProductionUser_afterDelete.sql b/db/routines/vn/triggers/deviceProductionUser_afterDelete.sql index a95170e9a..4e8d7ddf2 100644 --- a/db/routines/vn/triggers/deviceProductionUser_afterDelete.sql +++ b/db/routines/vn/triggers/deviceProductionUser_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionUser_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`deviceProductionUser_afterDelete` AFTER DELETE ON `deviceProductionUser` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/deviceProductionUser_afterInsert.sql b/db/routines/vn/triggers/deviceProductionUser_afterInsert.sql index 3c8a9a51d..f33241d3b 100644 --- a/db/routines/vn/triggers/deviceProductionUser_afterInsert.sql +++ b/db/routines/vn/triggers/deviceProductionUser_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionUser_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`deviceProductionUser_afterInsert` AFTER INSERT ON `deviceProductionUser` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/deviceProductionUser_beforeInsert.sql b/db/routines/vn/triggers/deviceProductionUser_beforeInsert.sql index b392cf5a1..ab9e43cd4 100644 --- a/db/routines/vn/triggers/deviceProductionUser_beforeInsert.sql +++ b/db/routines/vn/triggers/deviceProductionUser_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionUser_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`deviceProductionUser_beforeInsert` BEFORE INSERT ON `deviceProductionUser` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/deviceProductionUser_beforeUpdate.sql b/db/routines/vn/triggers/deviceProductionUser_beforeUpdate.sql index 7318bd99b..85846fb84 100644 --- a/db/routines/vn/triggers/deviceProductionUser_beforeUpdate.sql +++ b/db/routines/vn/triggers/deviceProductionUser_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionUser_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`deviceProductionUser_beforeUpdate` BEFORE UPDATE ON `deviceProductionUser` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/deviceProduction_afterDelete.sql b/db/routines/vn/triggers/deviceProduction_afterDelete.sql index af2b640e5..b7cbac9ff 100644 --- a/db/routines/vn/triggers/deviceProduction_afterDelete.sql +++ b/db/routines/vn/triggers/deviceProduction_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProduction_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`deviceProduction_afterDelete` AFTER DELETE ON `deviceProduction` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/deviceProduction_beforeInsert.sql b/db/routines/vn/triggers/deviceProduction_beforeInsert.sql index 66b5c2aef..022a1fbb9 100644 --- a/db/routines/vn/triggers/deviceProduction_beforeInsert.sql +++ b/db/routines/vn/triggers/deviceProduction_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProduction_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`deviceProduction_beforeInsert` BEFORE INSERT ON `deviceProduction` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/deviceProduction_beforeUpdate.sql b/db/routines/vn/triggers/deviceProduction_beforeUpdate.sql index 9206195fe..83e26e224 100644 --- a/db/routines/vn/triggers/deviceProduction_beforeUpdate.sql +++ b/db/routines/vn/triggers/deviceProduction_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProduction_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`deviceProduction_beforeUpdate` BEFORE UPDATE ON `deviceProduction` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/dms_beforeDelete.sql b/db/routines/vn/triggers/dms_beforeDelete.sql index 3bbc05ba3..603514afa 100644 --- a/db/routines/vn/triggers/dms_beforeDelete.sql +++ b/db/routines/vn/triggers/dms_beforeDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`dms_beforeDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`dms_beforeDelete` BEFORE DELETE ON `dms` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/dms_beforeInsert.sql b/db/routines/vn/triggers/dms_beforeInsert.sql index f7877ecb8..c7ed6bb47 100644 --- a/db/routines/vn/triggers/dms_beforeInsert.sql +++ b/db/routines/vn/triggers/dms_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`dms_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`dms_beforeInsert` BEFORE INSERT ON `dms` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/dms_beforeUpdate.sql b/db/routines/vn/triggers/dms_beforeUpdate.sql index c93659d45..12a640c1b 100644 --- a/db/routines/vn/triggers/dms_beforeUpdate.sql +++ b/db/routines/vn/triggers/dms_beforeUpdate.sql @@ -1,7 +1,7 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`dms_beforeUpdate` - BEFORE UPDATE ON `dms` - FOR EACH ROW +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`dms_beforeUpdate` + BEFORE UPDATE ON `dms` + FOR EACH ROW BEGIN DECLARE vHardCopyNumber INT; @@ -24,5 +24,5 @@ BEGIN SET NEW.hasFile = 0; END IF; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/duaTax_beforeInsert.sql b/db/routines/vn/triggers/duaTax_beforeInsert.sql index 9ca1d970d..8ce66429b 100644 --- a/db/routines/vn/triggers/duaTax_beforeInsert.sql +++ b/db/routines/vn/triggers/duaTax_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`duaTax_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`duaTax_beforeInsert` BEFORE INSERT ON `duaTax` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/duaTax_beforeUpdate.sql b/db/routines/vn/triggers/duaTax_beforeUpdate.sql index dca8958a9..2d3a59985 100644 --- a/db/routines/vn/triggers/duaTax_beforeUpdate.sql +++ b/db/routines/vn/triggers/duaTax_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`duaTax_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`duaTax_beforeUpdate` BEFORE UPDATE ON `duaTax` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ektEntryAssign_afterInsert.sql b/db/routines/vn/triggers/ektEntryAssign_afterInsert.sql index e42b43ca1..6df9df941 100644 --- a/db/routines/vn/triggers/ektEntryAssign_afterInsert.sql +++ b/db/routines/vn/triggers/ektEntryAssign_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ektEntryAssign_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ektEntryAssign_afterInsert` AFTER INSERT ON `ektEntryAssign` FOR EACH ROW UPDATE entry SET reference = NEW.`ref` WHERE id = NEW.entryFk$$ diff --git a/db/routines/vn/triggers/ektEntryAssign_afterUpdate.sql b/db/routines/vn/triggers/ektEntryAssign_afterUpdate.sql index 8d2791d0f..c85d72e14 100644 --- a/db/routines/vn/triggers/ektEntryAssign_afterUpdate.sql +++ b/db/routines/vn/triggers/ektEntryAssign_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ektEntryAssign_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ektEntryAssign_afterUpdate` AFTER UPDATE ON `ektEntryAssign` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/entryDms_afterDelete.sql b/db/routines/vn/triggers/entryDms_afterDelete.sql index 9ae8e7058..3c32fbd26 100644 --- a/db/routines/vn/triggers/entryDms_afterDelete.sql +++ b/db/routines/vn/triggers/entryDms_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entryDms_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entryDms_afterDelete` AFTER DELETE ON `entryDms` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/entryDms_beforeInsert.sql b/db/routines/vn/triggers/entryDms_beforeInsert.sql index 4f9550f48..f0712b481 100644 --- a/db/routines/vn/triggers/entryDms_beforeInsert.sql +++ b/db/routines/vn/triggers/entryDms_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entryDms_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entryDms_beforeInsert` BEFORE INSERT ON `entryDms` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/entryDms_beforeUpdate.sql b/db/routines/vn/triggers/entryDms_beforeUpdate.sql index ecc047029..d9b548f60 100644 --- a/db/routines/vn/triggers/entryDms_beforeUpdate.sql +++ b/db/routines/vn/triggers/entryDms_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entryDms_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entryDms_beforeUpdate` BEFORE UPDATE ON `entryDms` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/entryObservation_afterDelete.sql b/db/routines/vn/triggers/entryObservation_afterDelete.sql index d143e105a..d61c678d2 100644 --- a/db/routines/vn/triggers/entryObservation_afterDelete.sql +++ b/db/routines/vn/triggers/entryObservation_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entryObservation_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entryObservation_afterDelete` AFTER DELETE ON `entryObservation` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/entryObservation_beforeInsert.sql b/db/routines/vn/triggers/entryObservation_beforeInsert.sql index b842aeee7..9a9a8a3ee 100644 --- a/db/routines/vn/triggers/entryObservation_beforeInsert.sql +++ b/db/routines/vn/triggers/entryObservation_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entryObservation_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entryObservation_beforeInsert` BEFORE INSERT ON `entryObservation` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/entryObservation_beforeUpdate.sql b/db/routines/vn/triggers/entryObservation_beforeUpdate.sql index 501631c69..3d1b73bec 100644 --- a/db/routines/vn/triggers/entryObservation_beforeUpdate.sql +++ b/db/routines/vn/triggers/entryObservation_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entryObservation_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entryObservation_beforeUpdate` BEFORE UPDATE ON `entryObservation` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/entry_afterDelete.sql b/db/routines/vn/triggers/entry_afterDelete.sql index c723930fa..ebc6cd0e1 100644 --- a/db/routines/vn/triggers/entry_afterDelete.sql +++ b/db/routines/vn/triggers/entry_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entry_afterDelete` AFTER DELETE ON `entry` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/entry_afterUpdate.sql b/db/routines/vn/triggers/entry_afterUpdate.sql index 47d61ed30..3a0227cf9 100644 --- a/db/routines/vn/triggers/entry_afterUpdate.sql +++ b/db/routines/vn/triggers/entry_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entry_afterUpdate` AFTER UPDATE ON `entry` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/entry_beforeDelete.sql b/db/routines/vn/triggers/entry_beforeDelete.sql index 1d2c84b9e..4e933e1f4 100644 --- a/db/routines/vn/triggers/entry_beforeDelete.sql +++ b/db/routines/vn/triggers/entry_beforeDelete.sql @@ -1,9 +1,9 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_beforeDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entry_beforeDelete` BEFORE DELETE ON `entry` FOR EACH ROW BEGIN - CALL entry_checkBooked(OLD.id); + CALL entry_isEditable(OLD.id); DELETE FROM buy WHERE entryFk = OLD.id; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/entry_beforeInsert.sql b/db/routines/vn/triggers/entry_beforeInsert.sql index c0c0aa28c..8a114c13f 100644 --- a/db/routines/vn/triggers/entry_beforeInsert.sql +++ b/db/routines/vn/triggers/entry_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entry_beforeInsert` BEFORE INSERT ON `entry` FOR EACH ROW BEGIN @@ -7,8 +7,8 @@ BEGIN CALL supplier_checkIsActive(NEW.supplierFk); SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk); SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk); - IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN - CALL util.throw('The travel is incorrect, there is a different AWB in the associated entries'); + IF NEW.travelFk IS NOT NULL THEN + CALL travel_throwAwb(NEW.travelFk); END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/entry_beforeUpdate.sql b/db/routines/vn/triggers/entry_beforeUpdate.sql index d56db5e01..8e5a326a0 100644 --- a/db/routines/vn/triggers/entry_beforeUpdate.sql +++ b/db/routines/vn/triggers/entry_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`entry_beforeUpdate` BEFORE UPDATE ON `entry` FOR EACH ROW BEGIN @@ -7,10 +7,19 @@ BEGIN DECLARE vPrintedCount INT; DECLARE vHasDistinctWarehouses BOOL; DECLARE vTotalBuy INT; - - IF NEW.isBooked = OLD.isBooked THEN - CALL entry_checkBooked(OLD.id); + + IF NEW.isBooked = OLD.isBooked AND ( + NOT (NEW.supplierFk <=> OLD.supplierFk) OR + NOT (NEW.dated <=> OLD.dated) OR + NOT (NEW.travelFk <=> OLD.travelFk) OR + NOT (NEW.companyFk <=> OLD.companyFk) OR + NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) OR + NOT (NEW.typeFk <=> OLD.typeFk) + ) THEN + + CALL entry_isEditable(OLD.id); ELSE + IF NEW.isBooked THEN SELECT COUNT(*) INTO vTotalBuy FROM buy @@ -25,8 +34,8 @@ BEGIN IF NOT (NEW.travelFk <=> OLD.travelFk) THEN - IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN - CALL util.throw('The travel is incorrect, there is a different AWB in the associated entries'); + IF NEW.travelFk IS NOT NULL THEN + CALL travel_throwAwb(NEW.travelFk); END IF; SELECT COUNT(*) > 0 INTO vIsVirtual @@ -62,7 +71,10 @@ BEGIN SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk); END IF; - IF NOT (NEW.travelFk <=> OLD.travelFk) OR NOT (NEW.currencyFk <=> OLD.currencyFk) THEN + IF NOT (NEW.travelFk <=> OLD.travelFk) + OR NOT (NEW.currencyFk <=> OLD.currencyFk) + OR NOT (NEW.supplierFk <=> OLD.supplierFk) THEN + SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk, NEW.supplierFk); END IF; END$$ diff --git a/db/routines/vn/triggers/expeditionPallet_beforeInsert.sql b/db/routines/vn/triggers/expeditionPallet_beforeInsert.sql index 419cc2553..d2ea7ef76 100644 --- a/db/routines/vn/triggers/expeditionPallet_beforeInsert.sql +++ b/db/routines/vn/triggers/expeditionPallet_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expeditionPallet_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`expeditionPallet_beforeInsert` BEFORE INSERT ON `expeditionPallet` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/expeditionScan_beforeInsert.sql b/db/routines/vn/triggers/expeditionScan_beforeInsert.sql index 1dce8fe9b..ec1dbc7c7 100644 --- a/db/routines/vn/triggers/expeditionScan_beforeInsert.sql +++ b/db/routines/vn/triggers/expeditionScan_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expeditionScan_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`expeditionScan_beforeInsert` BEFORE INSERT ON `expeditionScan` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/expeditionState_afterInsert.sql b/db/routines/vn/triggers/expeditionState_afterInsert.sql index 3d8f4130c..6f0e4c622 100644 --- a/db/routines/vn/triggers/expeditionState_afterInsert.sql +++ b/db/routines/vn/triggers/expeditionState_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expeditionState_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`expeditionState_afterInsert` AFTER INSERT ON `expeditionState` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/expeditionState_beforeInsert.sql b/db/routines/vn/triggers/expeditionState_beforeInsert.sql index 350240aab..c4dd40611 100644 --- a/db/routines/vn/triggers/expeditionState_beforeInsert.sql +++ b/db/routines/vn/triggers/expeditionState_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expeditionState_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`expeditionState_beforeInsert` BEFORE INSERT ON `expeditionState` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/expeditionTruck_beforeInsert.sql b/db/routines/vn/triggers/expeditionTruck_beforeInsert.sql deleted file mode 100644 index 23cba7b3a..000000000 --- a/db/routines/vn/triggers/expeditionTruck_beforeInsert.sql +++ /dev/null @@ -1,10 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expeditionTruck_beforeInsert` - BEFORE INSERT ON `expeditionTruck` - FOR EACH ROW -BEGIN - - SET NEW.description = UCASE(NEW.description); - -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/expeditionTruck_beforeUpdate.sql b/db/routines/vn/triggers/expeditionTruck_beforeUpdate.sql deleted file mode 100644 index 1b3b97238..000000000 --- a/db/routines/vn/triggers/expeditionTruck_beforeUpdate.sql +++ /dev/null @@ -1,10 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expeditionTruck_beforeUpdate` - BEFORE UPDATE ON `expeditionTruck` - FOR EACH ROW -BEGIN - - SET NEW.description = UCASE(NEW.description); - -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/expedition_afterDelete.sql b/db/routines/vn/triggers/expedition_afterDelete.sql index e05cbf279..5d74a71e5 100644 --- a/db/routines/vn/triggers/expedition_afterDelete.sql +++ b/db/routines/vn/triggers/expedition_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expedition_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`expedition_afterDelete` AFTER DELETE ON `expedition` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/expedition_beforeDelete.sql b/db/routines/vn/triggers/expedition_beforeDelete.sql index cbcc5a3bb..13ba19631 100644 --- a/db/routines/vn/triggers/expedition_beforeDelete.sql +++ b/db/routines/vn/triggers/expedition_beforeDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expedition_beforeDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`expedition_beforeDelete` BEFORE DELETE ON `expedition` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/expedition_beforeInsert.sql b/db/routines/vn/triggers/expedition_beforeInsert.sql index 685de72cb..42365c28f 100644 --- a/db/routines/vn/triggers/expedition_beforeInsert.sql +++ b/db/routines/vn/triggers/expedition_beforeInsert.sql @@ -1,27 +1,27 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expedition_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`expedition_beforeInsert` BEFORE INSERT ON `expedition` FOR EACH ROW BEGIN - DECLARE intcounter INT; - DECLARE vShipFk INT; + DECLARE vMaxCounter INT; SET NEW.editorFk = account.myUser_getId(); - IF NEW.freightItemFk IS NOT NULL THEN + IF NEW.freightItemFk IS NOT NULL THEN UPDATE ticket SET packages = IFNULL(packages, 0) + 1 WHERE id = NEW.ticketFk; - SELECT IFNULL(MAX(counter),0) +1 INTO intcounter - FROM expedition e - INNER JOIN ticket t1 ON e.ticketFk = t1.id + SELECT IFNULL(MAX(counter),0) + 1 INTO vMaxCounter + FROM expedition e + JOIN alertLevel al ON al.code = 'DELIVERED' + JOIN ticket t1 ON e.ticketFk = t1.id LEFT JOIN ticketState ts ON ts.ticketFk = t1.id - INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped) + JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped) AND t1.warehouseFk = t2.warehouseFk - WHERE t2.id = NEW.ticketFk AND ts.alertLevel < 3 AND t1.companyFk = t2.companyFk + WHERE t2.id = NEW.ticketFk AND ts.alertLevel < al.id AND t1.companyFk = t2.companyFk AND t1.agencyModeFk = t2.agencyModeFk; - SET NEW.`counter` = intcounter; + SET NEW.`counter` = vMaxCounter; END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/expedition_beforeUpdate.sql b/db/routines/vn/triggers/expedition_beforeUpdate.sql index 870c1a285..49cb6e816 100644 --- a/db/routines/vn/triggers/expedition_beforeUpdate.sql +++ b/db/routines/vn/triggers/expedition_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expedition_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`expedition_beforeUpdate` BEFORE UPDATE ON `expedition` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/floramondoConfig_afterInsert.sql b/db/routines/vn/triggers/floramondoConfig_afterInsert.sql index f64cb7878..8c94ecbc4 100644 --- a/db/routines/vn/triggers/floramondoConfig_afterInsert.sql +++ b/db/routines/vn/triggers/floramondoConfig_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`floramondoConfig_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`floramondoConfig_afterInsert` AFTER INSERT ON `floramondoConfig` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/gregue_beforeInsert.sql b/db/routines/vn/triggers/gregue_beforeInsert.sql index 76e178356..46e867bc8 100644 --- a/db/routines/vn/triggers/gregue_beforeInsert.sql +++ b/db/routines/vn/triggers/gregue_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`gregue_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`gregue_beforeInsert` BEFORE INSERT ON `greuge` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/greuge_afterDelete.sql b/db/routines/vn/triggers/greuge_afterDelete.sql index 947359b4c..5d6784579 100644 --- a/db/routines/vn/triggers/greuge_afterDelete.sql +++ b/db/routines/vn/triggers/greuge_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`greuge_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`greuge_afterDelete` AFTER DELETE ON `greuge` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/greuge_beforeInsert.sql b/db/routines/vn/triggers/greuge_beforeInsert.sql index 100f2f244..b37c9d2d0 100644 --- a/db/routines/vn/triggers/greuge_beforeInsert.sql +++ b/db/routines/vn/triggers/greuge_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`greuge_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`greuge_beforeInsert` BEFORE INSERT ON `greuge` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/greuge_beforeUpdate.sql b/db/routines/vn/triggers/greuge_beforeUpdate.sql index 265861db5..af9f06206 100644 --- a/db/routines/vn/triggers/greuge_beforeUpdate.sql +++ b/db/routines/vn/triggers/greuge_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`greuge_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`greuge_beforeUpdate` BEFORE UPDATE ON `greuge` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/host_beforeInsert.sql b/db/routines/vn/triggers/host_beforeInsert.sql new file mode 100644 index 000000000..96b78bfb7 --- /dev/null +++ b/db/routines/vn/triggers/host_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`host_beforeInsert` + BEFORE INSERT ON `host` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/host_beforeUpdate.sql b/db/routines/vn/triggers/host_beforeUpdate.sql index 0b0962e86..7f279e655 100644 --- a/db/routines/vn/triggers/host_beforeUpdate.sql +++ b/db/routines/vn/triggers/host_beforeUpdate.sql @@ -1,8 +1,9 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`host_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`host_beforeUpdate` BEFORE UPDATE ON `host` FOR EACH ROW BEGIN SET new.updated = util.VN_NOW(); + SET NEW.editorFk = account.myUser_getId(); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInDueDay_afterDelete.sql b/db/routines/vn/triggers/invoiceInDueDay_afterDelete.sql index 1e5b75bb2..1e43fb816 100644 --- a/db/routines/vn/triggers/invoiceInDueDay_afterDelete.sql +++ b/db/routines/vn/triggers/invoiceInDueDay_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceInDueDay_afterDelete` AFTER DELETE ON `invoiceInDueDay` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql index f7e4265a7..4e859496e 100644 --- a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceInDueDay_beforeInsert` BEFORE INSERT ON `invoiceInDueDay` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql index 2452ff0d1..9ca9aae50 100644 --- a/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceInDueDay_beforeUpdate` BEFORE UPDATE ON `invoiceInDueDay` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/invoiceInTax_afterDelete.sql b/db/routines/vn/triggers/invoiceInTax_afterDelete.sql index f541503ff..e48135ba6 100644 --- a/db/routines/vn/triggers/invoiceInTax_afterDelete.sql +++ b/db/routines/vn/triggers/invoiceInTax_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceInTax_afterDelete` AFTER DELETE ON `invoiceInTax` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/invoiceInTax_beforeInsert.sql b/db/routines/vn/triggers/invoiceInTax_beforeInsert.sql index b1138fc3a..c20e60b40 100644 --- a/db/routines/vn/triggers/invoiceInTax_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceInTax_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeInsert` BEFORE INSERT ON `invoiceInTax` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql index 30918b7c5..68450bb5e 100644 --- a/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeUpdate` BEFORE UPDATE ON `invoiceInTax` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/invoiceIn_afterDelete.sql b/db/routines/vn/triggers/invoiceIn_afterDelete.sql index c088f6492..6b6a05765 100644 --- a/db/routines/vn/triggers/invoiceIn_afterDelete.sql +++ b/db/routines/vn/triggers/invoiceIn_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceIn_afterDelete` AFTER DELETE ON `invoiceIn` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql index 1a9105c9e..95b1d98a9 100644 --- a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql +++ b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceIn_afterUpdate` AFTER UPDATE ON `invoiceIn` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/invoiceIn_beforeDelete.sql b/db/routines/vn/triggers/invoiceIn_beforeDelete.sql index 2ffff923a..3f3d48a2a 100644 --- a/db/routines/vn/triggers/invoiceIn_beforeDelete.sql +++ b/db/routines/vn/triggers/invoiceIn_beforeDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceIn_beforeDelete` BEFORE DELETE ON `invoiceIn` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/invoiceIn_beforeInsert.sql b/db/routines/vn/triggers/invoiceIn_beforeInsert.sql index 2b80f2534..f01557b5e 100644 --- a/db/routines/vn/triggers/invoiceIn_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceIn_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceIn_beforeInsert` BEFORE INSERT ON `invoiceIn` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql index 4503c7dbd..e58fadbdf 100644 --- a/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceIn_beforeUpdate` BEFORE UPDATE ON `invoiceIn` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/invoiceOut_afterInsert.sql b/db/routines/vn/triggers/invoiceOut_afterInsert.sql index 389c01111..868350f20 100644 --- a/db/routines/vn/triggers/invoiceOut_afterInsert.sql +++ b/db/routines/vn/triggers/invoiceOut_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceOut_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceOut_afterInsert` AFTER INSERT ON `invoiceOut` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/invoiceOut_beforeDelete.sql b/db/routines/vn/triggers/invoiceOut_beforeDelete.sql index 8c8d7464c..5c9839f05 100644 --- a/db/routines/vn/triggers/invoiceOut_beforeDelete.sql +++ b/db/routines/vn/triggers/invoiceOut_beforeDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceOut_beforeDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceOut_beforeDelete` BEFORE DELETE ON `invoiceOut` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql index 0081c8803..9fd027ba0 100644 --- a/db/routines/vn/triggers/invoiceOut_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceOut_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceOut_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceOut_beforeInsert` BEFORE INSERT ON `invoiceOut` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/invoiceOut_beforeUpdate.sql b/db/routines/vn/triggers/invoiceOut_beforeUpdate.sql index 72be9cef0..5efb79c77 100644 --- a/db/routines/vn/triggers/invoiceOut_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceOut_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceOut_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceOut_beforeUpdate` BEFORE UPDATE ON `invoiceOut` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/itemBarcode_afterDelete.sql b/db/routines/vn/triggers/itemBarcode_afterDelete.sql index 4453d4a2f..4efde371d 100644 --- a/db/routines/vn/triggers/itemBarcode_afterDelete.sql +++ b/db/routines/vn/triggers/itemBarcode_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemBarcode_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemBarcode_afterDelete` AFTER DELETE ON `itemBarcode` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/itemBarcode_beforeInsert.sql b/db/routines/vn/triggers/itemBarcode_beforeInsert.sql index 503f1eb8a..53563b754 100644 --- a/db/routines/vn/triggers/itemBarcode_beforeInsert.sql +++ b/db/routines/vn/triggers/itemBarcode_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemBarcode_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemBarcode_beforeInsert` BEFORE INSERT ON `itemBarcode` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/itemBarcode_beforeUpdate.sql b/db/routines/vn/triggers/itemBarcode_beforeUpdate.sql index 2131427b2..e73fae473 100644 --- a/db/routines/vn/triggers/itemBarcode_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemBarcode_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemBarcode_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemBarcode_beforeUpdate` BEFORE UPDATE ON `itemBarcode` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/itemBotanical_afterDelete.sql b/db/routines/vn/triggers/itemBotanical_afterDelete.sql index 1b3c50ad1..7858bf1f5 100644 --- a/db/routines/vn/triggers/itemBotanical_afterDelete.sql +++ b/db/routines/vn/triggers/itemBotanical_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemBotanical_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemBotanical_afterDelete` AFTER DELETE ON `itemBotanical` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/itemBotanical_beforeInsert.sql b/db/routines/vn/triggers/itemBotanical_beforeInsert.sql index 8a1b9346d..312c8c9c7 100644 --- a/db/routines/vn/triggers/itemBotanical_beforeInsert.sql +++ b/db/routines/vn/triggers/itemBotanical_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemBotanical_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemBotanical_beforeInsert` BEFORE INSERT ON `itemBotanical` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/itemBotanical_beforeUpdate.sql b/db/routines/vn/triggers/itemBotanical_beforeUpdate.sql index 55939c403..30a1778a6 100644 --- a/db/routines/vn/triggers/itemBotanical_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemBotanical_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemBotanical_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemBotanical_beforeUpdate` BEFORE UPDATE ON `itemBotanical` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/itemCategory_afterInsert.sql b/db/routines/vn/triggers/itemCategory_afterInsert.sql index 9449737d1..7f32b4af2 100644 --- a/db/routines/vn/triggers/itemCategory_afterInsert.sql +++ b/db/routines/vn/triggers/itemCategory_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemCategory_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemCategory_afterInsert` AFTER INSERT ON `itemCategory` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/itemCost_beforeInsert.sql b/db/routines/vn/triggers/itemCost_beforeInsert.sql index ba80193a6..0c1b92548 100644 --- a/db/routines/vn/triggers/itemCost_beforeInsert.sql +++ b/db/routines/vn/triggers/itemCost_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemCost_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemCost_beforeInsert` BEFORE INSERT ON `itemCost` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/itemCost_beforeUpdate.sql b/db/routines/vn/triggers/itemCost_beforeUpdate.sql index 242c768f5..bd5fde85a 100644 --- a/db/routines/vn/triggers/itemCost_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemCost_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemCost_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemCost_beforeUpdate` BEFORE UPDATE ON `itemCost` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/itemMinimumQuantity_afterDelete.sql b/db/routines/vn/triggers/itemMinimumQuantity_afterDelete.sql new file mode 100644 index 000000000..41a1c41ef --- /dev/null +++ b/db/routines/vn/triggers/itemMinimumQuantity_afterDelete.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemMinimumQuantity_afterDelete` + AFTER DELETE ON `itemMinimumQuantity` + FOR EACH ROW +BEGIN + INSERT INTO itemLog + SET `action` = 'delete', + `changedModel` = 'ItemMinimumQuantity', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/itemMinimumQuantity_beforeInsert.sql b/db/routines/vn/triggers/itemMinimumQuantity_beforeInsert.sql new file mode 100644 index 000000000..de19b68c7 --- /dev/null +++ b/db/routines/vn/triggers/itemMinimumQuantity_beforeInsert.sql @@ -0,0 +1,9 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemMinimumQuantity_beforeInsert` + BEFORE INSERT ON `itemMinimumQuantity` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); + CALL itemMinimumQuantity_check(NEW.id, NEW.itemFk, NEW.started, NEW.ended, NEW.warehouseFk); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/itemMinimumQuantity_beforeUpdate.sql b/db/routines/vn/triggers/itemMinimumQuantity_beforeUpdate.sql new file mode 100644 index 000000000..42b9d7f22 --- /dev/null +++ b/db/routines/vn/triggers/itemMinimumQuantity_beforeUpdate.sql @@ -0,0 +1,9 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemMinimumQuantity_beforeUpdate` + BEFORE UPDATE ON `itemMinimumQuantity` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); + CALL itemMinimumQuantity_check(NEW.id, NEW.itemFk, NEW.started, NEW.ended, NEW.warehouseFk); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql index 63ca893bd..3531b094c 100644 --- a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql +++ b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql @@ -1,12 +1,12 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelvingSale_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelvingSale_afterInsert` AFTER INSERT ON `itemShelvingSale` FOR EACH ROW -BEGIN - - UPDATE vn.sale - SET isPicked = TRUE - WHERE id = NEW.saleFk; - +BEGIN + + UPDATE sale s + JOIN operator o ON o.workerFk = account.myUser_getId() + SET s.isPicked = IF(o.isOnReservationMode, s.isPicked, TRUE) + WHERE id = NEW.saleFk; END$$ -DELIMITER ; +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/itemShelving _afterDelete.sql b/db/routines/vn/triggers/itemShelving_afterDelete.sql similarity index 62% rename from db/routines/vn/triggers/itemShelving _afterDelete.sql rename to db/routines/vn/triggers/itemShelving_afterDelete.sql index 7c0d54358..f4bafd75c 100644 --- a/db/routines/vn/triggers/itemShelving _afterDelete.sql +++ b/db/routines/vn/triggers/itemShelving_afterDelete.sql @@ -1,11 +1,11 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving _afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelving_afterDelete` AFTER DELETE ON `itemShelving` FOR EACH ROW BEGIN INSERT INTO shelvingLog SET `action` = 'delete', - `changedModel` = 'itemShelving', + `changedModel` = 'ItemShelving', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); END$$ diff --git a/db/routines/vn/triggers/itemShelving_afterInsert.sql b/db/routines/vn/triggers/itemShelving_afterInsert.sql index 5c0cb3853..92243ca03 100644 --- a/db/routines/vn/triggers/itemShelving_afterInsert.sql +++ b/db/routines/vn/triggers/itemShelving_afterInsert.sql @@ -1,22 +1,18 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelving_afterInsert` AFTER INSERT ON `itemShelving` FOR EACH ROW -INSERT INTO vn.itemShelvingLog( itemShelvingFk, - workerFk, - accion, - itemFk, - shelvingFk, - visible, - `grouping`, - packing) - VALUES( NEW.id, - NEW.userFk, - 'CREA REGISTRO', - NEW.itemFk, - NEW.shelvingFk, - NEW.visible, - NEW.`grouping`, - NEW.packing - )$$ +BEGIN + INSERT INTO itemShelvingLog + SET itemShelvingFk = NEW.id, + workerFk = account.myUser_getId(), + accion = 'CREA REGISTRO', + itemFk = NEW.itemFk, + shelvingFk = NEW.shelvingFk, + visible = NEW.visible, + `grouping` = NEW.`grouping`, + packing = NEW.packing, + available = NEW.available; + +END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/itemShelving_afterUpdate.sql b/db/routines/vn/triggers/itemShelving_afterUpdate.sql index 107e8ecdc..e5e63db43 100644 --- a/db/routines/vn/triggers/itemShelving_afterUpdate.sql +++ b/db/routines/vn/triggers/itemShelving_afterUpdate.sql @@ -1,8 +1,9 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelving_afterUpdate` AFTER UPDATE ON `itemShelving` FOR EACH ROW -INSERT INTO itemShelvingLog +BEGIN + INSERT INTO itemShelvingLog SET itemShelvingFk = NEW.id, workerFk = account.myUser_getId(), accion = 'CAMBIO', @@ -10,5 +11,8 @@ INSERT INTO itemShelvingLog shelvingFk = NEW.shelvingFk, visible = NEW.visible, `grouping` = NEW.`grouping`, - packing = NEW.packing$$ + packing = NEW.packing, + available = NEW.available; + +END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/itemShelving_beforeDelete.sql b/db/routines/vn/triggers/itemShelving_beforeDelete.sql index a9f59e011..89737a841 100644 --- a/db/routines/vn/triggers/itemShelving_beforeDelete.sql +++ b/db/routines/vn/triggers/itemShelving_beforeDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_beforeDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelving_beforeDelete` BEFORE DELETE ON `itemShelving` FOR EACH ROW INSERT INTO vn.itemShelvingLog(itemShelvingFk, diff --git a/db/routines/vn/triggers/itemShelving_beforeInsert.sql b/db/routines/vn/triggers/itemShelving_beforeInsert.sql index 011cf3701..484e785f5 100644 --- a/db/routines/vn/triggers/itemShelving_beforeInsert.sql +++ b/db/routines/vn/triggers/itemShelving_beforeInsert.sql @@ -1,10 +1,11 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelving_beforeInsert` BEFORE INSERT ON `itemShelving` FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); SET NEW.userFk = account.myUser_getId(); + SET NEW.available = NEW.visible; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/itemShelving_beforeUpdate.sql b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql index 6fd919d2e..53f85de01 100644 --- a/db/routines/vn/triggers/itemShelving_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql @@ -1,11 +1,16 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelving_beforeUpdate` BEFORE UPDATE ON `itemShelving` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); IF NEW.userFk IS NULL THEN SET NEW.userFk = account.myUser_getId(); END IF; + + IF NEW.shelvingFk <> OLD.shelvingFk THEN + SET NEW.movingState = NULL; + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/itemTag_afterDelete.sql b/db/routines/vn/triggers/itemTag_afterDelete.sql index 4014c88b5..e79c1ac5a 100644 --- a/db/routines/vn/triggers/itemTag_afterDelete.sql +++ b/db/routines/vn/triggers/itemTag_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemTag_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemTag_afterDelete` AFTER DELETE ON `itemTag` FOR EACH ROW trig: BEGIN diff --git a/db/routines/vn/triggers/itemTag_afterInsert.sql b/db/routines/vn/triggers/itemTag_afterInsert.sql index 3dfb25ad3..9e3e9f4e3 100644 --- a/db/routines/vn/triggers/itemTag_afterInsert.sql +++ b/db/routines/vn/triggers/itemTag_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemTag_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemTag_afterInsert` AFTER INSERT ON `itemTag` FOR EACH ROW trig: BEGIN diff --git a/db/routines/vn/triggers/itemTag_afterUpdate.sql b/db/routines/vn/triggers/itemTag_afterUpdate.sql index 61b45a161..494ffe76c 100644 --- a/db/routines/vn/triggers/itemTag_afterUpdate.sql +++ b/db/routines/vn/triggers/itemTag_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemTag_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemTag_afterUpdate` AFTER UPDATE ON `itemTag` FOR EACH ROW trig: BEGIN diff --git a/db/routines/vn/triggers/itemTag_beforeInsert.sql b/db/routines/vn/triggers/itemTag_beforeInsert.sql index cec4fd02f..d97d97106 100644 --- a/db/routines/vn/triggers/itemTag_beforeInsert.sql +++ b/db/routines/vn/triggers/itemTag_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemTag_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemTag_beforeInsert` BEFORE INSERT ON `itemTag` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/itemTag_beforeUpdate.sql b/db/routines/vn/triggers/itemTag_beforeUpdate.sql index 41de249ef..1bdfbad1e 100644 --- a/db/routines/vn/triggers/itemTag_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemTag_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemTag_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemTag_beforeUpdate` BEFORE UPDATE ON `itemTag` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/itemTaxCountry_afterDelete.sql b/db/routines/vn/triggers/itemTaxCountry_afterDelete.sql index 8f91b26e1..0cdf01283 100644 --- a/db/routines/vn/triggers/itemTaxCountry_afterDelete.sql +++ b/db/routines/vn/triggers/itemTaxCountry_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemTaxCountry_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemTaxCountry_afterDelete` AFTER DELETE ON `itemTaxCountry` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/itemTaxCountry_beforeInsert.sql b/db/routines/vn/triggers/itemTaxCountry_beforeInsert.sql index 348dac023..569be2d98 100644 --- a/db/routines/vn/triggers/itemTaxCountry_beforeInsert.sql +++ b/db/routines/vn/triggers/itemTaxCountry_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemTaxCountry_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemTaxCountry_beforeInsert` BEFORE INSERT ON `itemTaxCountry` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/itemTaxCountry_beforeUpdate.sql b/db/routines/vn/triggers/itemTaxCountry_beforeUpdate.sql index 7470cd81e..ad7d6327b 100644 --- a/db/routines/vn/triggers/itemTaxCountry_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemTaxCountry_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemTaxCountry_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemTaxCountry_beforeUpdate` BEFORE UPDATE ON `itemTaxCountry` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/itemType_beforeUpdate.sql b/db/routines/vn/triggers/itemType_beforeUpdate.sql index 0e0aa0098..613ae8bfa 100644 --- a/db/routines/vn/triggers/itemType_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemType_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemType_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemType_beforeUpdate` BEFORE UPDATE ON `itemType` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/item_afterDelete.sql b/db/routines/vn/triggers/item_afterDelete.sql index 34f702cdd..175d0ae44 100644 --- a/db/routines/vn/triggers/item_afterDelete.sql +++ b/db/routines/vn/triggers/item_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`item_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`item_afterDelete` AFTER DELETE ON `item` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/item_afterInsert.sql b/db/routines/vn/triggers/item_afterInsert.sql index a4f9c5f5a..6c0137a2f 100644 --- a/db/routines/vn/triggers/item_afterInsert.sql +++ b/db/routines/vn/triggers/item_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`item_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`item_afterInsert` AFTER INSERT ON `item` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/item_afterUpdate.sql b/db/routines/vn/triggers/item_afterUpdate.sql index 3b433c302..92cc6f78c 100644 --- a/db/routines/vn/triggers/item_afterUpdate.sql +++ b/db/routines/vn/triggers/item_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`item_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`item_afterUpdate` AFTER UPDATE ON `item` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/item_beforeInsert.sql b/db/routines/vn/triggers/item_beforeInsert.sql index d7ee4db34..6f5cdaa71 100644 --- a/db/routines/vn/triggers/item_beforeInsert.sql +++ b/db/routines/vn/triggers/item_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`item_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`item_beforeInsert` BEFORE INSERT ON `item` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/item_beforeUpdate.sql b/db/routines/vn/triggers/item_beforeUpdate.sql index 3cf630d18..0db1dbb40 100644 --- a/db/routines/vn/triggers/item_beforeUpdate.sql +++ b/db/routines/vn/triggers/item_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`item_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`item_beforeUpdate` BEFORE UPDATE ON `item` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/machine_beforeInsert.sql b/db/routines/vn/triggers/machine_beforeInsert.sql index 269879b22..81f4bb346 100644 --- a/db/routines/vn/triggers/machine_beforeInsert.sql +++ b/db/routines/vn/triggers/machine_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`machine_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`machine_beforeInsert` BEFORE INSERT ON `machine` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/mail_beforeInsert.sql b/db/routines/vn/triggers/mail_beforeInsert.sql index fc598f829..04c9db61c 100644 --- a/db/routines/vn/triggers/mail_beforeInsert.sql +++ b/db/routines/vn/triggers/mail_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`mail_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`mail_beforeInsert` BEFORE INSERT ON `mail` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/mandate_beforeInsert.sql b/db/routines/vn/triggers/mandate_beforeInsert.sql index 7d1e9a59e..bfc36cc31 100644 --- a/db/routines/vn/triggers/mandate_beforeInsert.sql +++ b/db/routines/vn/triggers/mandate_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`mandate_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`mandate_beforeInsert` BEFORE INSERT ON `mandate` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/operator_beforeInsert.sql b/db/routines/vn/triggers/operator_beforeInsert.sql index c1805d0fc..e6d82dcc6 100644 --- a/db/routines/vn/triggers/operator_beforeInsert.sql +++ b/db/routines/vn/triggers/operator_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`operator_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`operator_beforeInsert` BEFORE INSERT ON `operator` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/operator_beforeUpdate.sql b/db/routines/vn/triggers/operator_beforeUpdate.sql index 84fb8ca04..1294fcb8e 100644 --- a/db/routines/vn/triggers/operator_beforeUpdate.sql +++ b/db/routines/vn/triggers/operator_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`operator_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`operator_beforeUpdate` BEFORE UPDATE ON `operator` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/packaging_beforeInsert.sql b/db/routines/vn/triggers/packaging_beforeInsert.sql index 02ba3cf4f..abbe24a45 100644 --- a/db/routines/vn/triggers/packaging_beforeInsert.sql +++ b/db/routines/vn/triggers/packaging_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`packaging_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`packaging_beforeInsert` BEFORE INSERT ON `packaging` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/packaging_beforeUpdate.sql b/db/routines/vn/triggers/packaging_beforeUpdate.sql index 515c94bb5..c11b76902 100644 --- a/db/routines/vn/triggers/packaging_beforeUpdate.sql +++ b/db/routines/vn/triggers/packaging_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`packaging_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`packaging_beforeUpdate` BEFORE UPDATE ON `packaging` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/packingSite_afterDelete.sql b/db/routines/vn/triggers/packingSite_afterDelete.sql index 7c76ae7ec..a1fccf67d 100644 --- a/db/routines/vn/triggers/packingSite_afterDelete.sql +++ b/db/routines/vn/triggers/packingSite_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`packingSite_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`packingSite_afterDelete` AFTER DELETE ON `packingSite` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/packingSite_beforeInsert.sql b/db/routines/vn/triggers/packingSite_beforeInsert.sql index 966dfdd53..aab2d4b19 100644 --- a/db/routines/vn/triggers/packingSite_beforeInsert.sql +++ b/db/routines/vn/triggers/packingSite_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`packingSite_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`packingSite_beforeInsert` BEFORE INSERT ON `packingSite` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/packingSite_beforeUpdate.sql b/db/routines/vn/triggers/packingSite_beforeUpdate.sql index 4d56ac1b5..dc365fc41 100644 --- a/db/routines/vn/triggers/packingSite_beforeUpdate.sql +++ b/db/routines/vn/triggers/packingSite_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`packingSite_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`packingSite_beforeUpdate` BEFORE UPDATE ON `packingSite` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/parking_afterDelete.sql b/db/routines/vn/triggers/parking_afterDelete.sql index 1ec96c24d..1237b5dc6 100644 --- a/db/routines/vn/triggers/parking_afterDelete.sql +++ b/db/routines/vn/triggers/parking_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`parking_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`parking_afterDelete` AFTER DELETE ON `parking` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/parking_beforeInsert.sql b/db/routines/vn/triggers/parking_beforeInsert.sql index cdec4c759..f55e9c1b2 100644 --- a/db/routines/vn/triggers/parking_beforeInsert.sql +++ b/db/routines/vn/triggers/parking_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`parking_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`parking_beforeInsert` BEFORE INSERT ON `parking` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/parking_beforeUpdate.sql b/db/routines/vn/triggers/parking_beforeUpdate.sql index 3e808f505..1418abc34 100644 --- a/db/routines/vn/triggers/parking_beforeUpdate.sql +++ b/db/routines/vn/triggers/parking_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`parking_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`parking_beforeUpdate` BEFORE UPDATE ON `parking` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/payment_afterInsert.sql b/db/routines/vn/triggers/payment_afterInsert.sql index 5585d6682..f9c9e2314 100644 --- a/db/routines/vn/triggers/payment_afterInsert.sql +++ b/db/routines/vn/triggers/payment_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`payment_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`payment_afterInsert` AFTER INSERT ON `payment` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/payment_beforeInsert.sql b/db/routines/vn/triggers/payment_beforeInsert.sql index 0a4cd1f12..85c6060c0 100644 --- a/db/routines/vn/triggers/payment_beforeInsert.sql +++ b/db/routines/vn/triggers/payment_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`payment_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`payment_beforeInsert` BEFORE INSERT ON `payment` FOR EACH ROW BEGIN @@ -9,13 +9,12 @@ BEGIN DECLARE vIsCash BOOLEAN; DECLARE vIsSupplierActive BOOLEAN; - -- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH SELECT (at2.code = 'cash') INTO vIsCash FROM accounting a JOIN accountingType at2 ON at2.id = a.accountingTypeFk WHERE a.id = NEW.bankFk; - IF vIsCash THEN + IF vIsCash THEN SELECT account INTO vBankAccount FROM accounting WHERE id = NEW.bankFk; @@ -24,7 +23,7 @@ BEGIN FROM supplier WHERE id = NEW.supplierFk; - CALL ledger_next(YEAR(NEW.received), NEW.companyFk, vNewBookEntry); + CALL ledger_next(YEAR(NEW.received), vNewBookEntry); INSERT INTO XDiario ( ASIEN, diff --git a/db/routines/vn/triggers/payment_beforeUpdate.sql b/db/routines/vn/triggers/payment_beforeUpdate.sql index b3ef1342b..9a3bbe460 100644 --- a/db/routines/vn/triggers/payment_beforeUpdate.sql +++ b/db/routines/vn/triggers/payment_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`payment_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`payment_beforeUpdate` BEFORE UPDATE ON `payment` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/postCode_afterDelete.sql b/db/routines/vn/triggers/postCode_afterDelete.sql index 736d5f5f3..4afcee770 100644 --- a/db/routines/vn/triggers/postCode_afterDelete.sql +++ b/db/routines/vn/triggers/postCode_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`postCode_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`postCode_afterDelete` AFTER DELETE ON `postCode` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/postCode_afterUpdate.sql b/db/routines/vn/triggers/postCode_afterUpdate.sql index c1e56044a..f1019342f 100644 --- a/db/routines/vn/triggers/postCode_afterUpdate.sql +++ b/db/routines/vn/triggers/postCode_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`postCode_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`postCode_afterUpdate` AFTER UPDATE ON `postCode` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/postCode_beforeInsert.sql b/db/routines/vn/triggers/postCode_beforeInsert.sql index 9e6d7e592..503d917a8 100644 --- a/db/routines/vn/triggers/postCode_beforeInsert.sql +++ b/db/routines/vn/triggers/postCode_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`postCode_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`postCode_beforeInsert` BEFORE INSERT ON `postCode` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/postCode_beforeUpdate.sql b/db/routines/vn/triggers/postCode_beforeUpdate.sql index 1b3c228a3..fa8f03a15 100644 --- a/db/routines/vn/triggers/postCode_beforeUpdate.sql +++ b/db/routines/vn/triggers/postCode_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`postCode_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`postCode_beforeUpdate` BEFORE UPDATE ON `postCode` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/priceFixed_beforeInsert.sql b/db/routines/vn/triggers/priceFixed_beforeInsert.sql index ecf6f3e30..b278f3749 100644 --- a/db/routines/vn/triggers/priceFixed_beforeInsert.sql +++ b/db/routines/vn/triggers/priceFixed_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`priceFixed_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`priceFixed_beforeInsert` BEFORE INSERT ON `priceFixed` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/priceFixed_beforeUpdate.sql b/db/routines/vn/triggers/priceFixed_beforeUpdate.sql index f675322b9..1b8efa7f5 100644 --- a/db/routines/vn/triggers/priceFixed_beforeUpdate.sql +++ b/db/routines/vn/triggers/priceFixed_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`priceFixed_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`priceFixed_beforeUpdate` BEFORE UPDATE ON `priceFixed` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/productionConfig_afterDelete.sql b/db/routines/vn/triggers/productionConfig_afterDelete.sql new file mode 100644 index 000000000..6b6800d4f --- /dev/null +++ b/db/routines/vn/triggers/productionConfig_afterDelete.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`productionConfig_afterDelete` + AFTER DELETE ON `productionConfig` + FOR EACH ROW +BEGIN + INSERT INTO productionConfig + SET `action` = 'delete', + `changedModel` = 'ProductionConfig', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/productionConfig_beforeInsert.sql b/db/routines/vn/triggers/productionConfig_beforeInsert.sql new file mode 100644 index 000000000..4ece1297a --- /dev/null +++ b/db/routines/vn/triggers/productionConfig_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`productionConfig_beforeInsert` + BEFORE INSERT ON `productionConfig` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/productionConfig_beforeUpdate.sql b/db/routines/vn/triggers/productionConfig_beforeUpdate.sql new file mode 100644 index 000000000..e8b6bc294 --- /dev/null +++ b/db/routines/vn/triggers/productionConfig_beforeUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`productionConfig_beforeUpdate` + BEFORE UPDATE ON `productionConfig` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/projectNotes_beforeInsert.sql b/db/routines/vn/triggers/projectNotes_beforeInsert.sql index 58d75bec7..ccc7078d3 100644 --- a/db/routines/vn/triggers/projectNotes_beforeInsert.sql +++ b/db/routines/vn/triggers/projectNotes_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`projectNotes_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`projectNotes_beforeInsert` BEFORE INSERT ON `projectNotes` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/province_afterDelete.sql b/db/routines/vn/triggers/province_afterDelete.sql index d0cee78e7..b338340e3 100644 --- a/db/routines/vn/triggers/province_afterDelete.sql +++ b/db/routines/vn/triggers/province_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`province_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`province_afterDelete` AFTER DELETE ON `province` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/province_afterUpdate.sql b/db/routines/vn/triggers/province_afterUpdate.sql index e8f3958b2..4e99cdac4 100644 --- a/db/routines/vn/triggers/province_afterUpdate.sql +++ b/db/routines/vn/triggers/province_afterUpdate.sql @@ -1,7 +1,7 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`province_afterUpdate` - AFTER UPDATE ON `province` - FOR EACH ROW +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`province_afterUpdate` + AFTER UPDATE ON `province` + FOR EACH ROW BEGIN IF !(OLD.autonomyFk <=> NEW.autonomyFk) THEN CALL zoneGeo_setParent(NEW.geoFk, @@ -12,5 +12,5 @@ BEGIN UPDATE zoneGeo SET `name` = NEW.`name` WHERE id = NEW.geoFk; END IF; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/province_beforeInsert.sql b/db/routines/vn/triggers/province_beforeInsert.sql index f3f039fc3..eff8f397a 100644 --- a/db/routines/vn/triggers/province_beforeInsert.sql +++ b/db/routines/vn/triggers/province_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`province_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`province_beforeInsert` BEFORE INSERT ON `province` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/province_beforeUpdate.sql b/db/routines/vn/triggers/province_beforeUpdate.sql index 23ca49d4a..ef553b2bc 100644 --- a/db/routines/vn/triggers/province_beforeUpdate.sql +++ b/db/routines/vn/triggers/province_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`province_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`province_beforeUpdate` BEFORE UPDATE ON `province` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/rate_afterDelete.sql b/db/routines/vn/triggers/rate_afterDelete.sql index dae240c15..69787cd81 100644 --- a/db/routines/vn/triggers/rate_afterDelete.sql +++ b/db/routines/vn/triggers/rate_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`rate_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`rate_afterDelete` AFTER DELETE ON `rate` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/rate_beforeInsert.sql b/db/routines/vn/triggers/rate_beforeInsert.sql index 0d77a95d7..c2117e64c 100644 --- a/db/routines/vn/triggers/rate_beforeInsert.sql +++ b/db/routines/vn/triggers/rate_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`rate_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`rate_beforeInsert` BEFORE INSERT ON `rate` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/rate_beforeUpdate.sql b/db/routines/vn/triggers/rate_beforeUpdate.sql index 2055d14fd..af63e431e 100644 --- a/db/routines/vn/triggers/rate_beforeUpdate.sql +++ b/db/routines/vn/triggers/rate_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`rate_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`rate_beforeUpdate` BEFORE UPDATE ON `rate` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/receipt_afterInsert.sql b/db/routines/vn/triggers/receipt_afterInsert.sql index 3881cb4d2..92e458743 100644 --- a/db/routines/vn/triggers/receipt_afterInsert.sql +++ b/db/routines/vn/triggers/receipt_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`receipt_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`receipt_afterInsert` AFTER INSERT ON `receipt` FOR EACH ROW CALL clientRisk_update(NEW.clientFk, NEW.companyFk, -NEW.amountPaid)$$ diff --git a/db/routines/vn/triggers/receipt_afterUpdate.sql b/db/routines/vn/triggers/receipt_afterUpdate.sql index 3d739e8f1..c17783790 100644 --- a/db/routines/vn/triggers/receipt_afterUpdate.sql +++ b/db/routines/vn/triggers/receipt_afterUpdate.sql @@ -1,7 +1,7 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`receipt_afterUpdate` - AFTER UPDATE ON `receipt` - FOR EACH ROW +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`receipt_afterUpdate` + AFTER UPDATE ON `receipt` + FOR EACH ROW BEGIN IF NEW.isConciliate = FALSE AND NEW.payed > OLD.payed THEN CALL mail_insert( @@ -11,5 +11,5 @@ BEGIN CONCAT('Se ha cambiado el recibo: ', NEW.Id, ' de ', OLD.payed, ' a ', NEW.payed) ); END IF; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/receipt_beforeDelete.sql b/db/routines/vn/triggers/receipt_beforeDelete.sql index fc75a4c35..1c1f0a0b1 100644 --- a/db/routines/vn/triggers/receipt_beforeDelete.sql +++ b/db/routines/vn/triggers/receipt_beforeDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`receipt_beforeDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`receipt_beforeDelete` BEFORE DELETE ON `receipt` FOR EACH ROW CALL clientRisk_update(OLD.clientFk, OLD.companyFk, OLD.amountPaid)$$ diff --git a/db/routines/vn/triggers/receipt_beforeInsert.sql b/db/routines/vn/triggers/receipt_beforeInsert.sql index 696cad241..85bc2c4a2 100644 --- a/db/routines/vn/triggers/receipt_beforeInsert.sql +++ b/db/routines/vn/triggers/receipt_beforeInsert.sql @@ -1,7 +1,7 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`receipt_beforeInsert` - BEFORE INSERT ON `receipt` - FOR EACH ROW +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`receipt_beforeInsert` + BEFORE INSERT ON `receipt` + FOR EACH ROW BEGIN DECLARE vIsAutoConciliated BOOLEAN; @@ -13,5 +13,5 @@ BEGIN SET NEW.isConciliate = vIsAutoConciliated; END IF; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/receipt_beforeUpdate.sql b/db/routines/vn/triggers/receipt_beforeUpdate.sql index 8ea14c17c..3c66719a4 100644 --- a/db/routines/vn/triggers/receipt_beforeUpdate.sql +++ b/db/routines/vn/triggers/receipt_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`receipt_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`receipt_beforeUpdate` BEFORE UPDATE ON `receipt` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/recovery_afterDelete.sql b/db/routines/vn/triggers/recovery_afterDelete.sql index 429f562ac..27679a2a5 100644 --- a/db/routines/vn/triggers/recovery_afterDelete.sql +++ b/db/routines/vn/triggers/recovery_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`recovery_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`recovery_afterDelete` AFTER DELETE ON `recovery` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/recovery_beforeInsert.sql b/db/routines/vn/triggers/recovery_beforeInsert.sql index 2318e0b7b..4671e95cc 100644 --- a/db/routines/vn/triggers/recovery_beforeInsert.sql +++ b/db/routines/vn/triggers/recovery_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`recovery_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`recovery_beforeInsert` BEFORE INSERT ON `recovery` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/recovery_beforeUpdate.sql b/db/routines/vn/triggers/recovery_beforeUpdate.sql index 4d485c075..45710b773 100644 --- a/db/routines/vn/triggers/recovery_beforeUpdate.sql +++ b/db/routines/vn/triggers/recovery_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`recovery_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`recovery_beforeUpdate` BEFORE UPDATE ON `recovery` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/roadmapStop_beforeInsert.sql b/db/routines/vn/triggers/roadmapStop_beforeInsert.sql new file mode 100644 index 000000000..d71942fea --- /dev/null +++ b/db/routines/vn/triggers/roadmapStop_beforeInsert.sql @@ -0,0 +1,10 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`roadmapStop_beforeInsert` + BEFORE INSERT ON `roadmapStop` + FOR EACH ROW +BEGIN + + SET NEW.description = UCASE(NEW.description); + +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/roadmapStop_beforeUpdate.sql b/db/routines/vn/triggers/roadmapStop_beforeUpdate.sql new file mode 100644 index 000000000..c3cbf2597 --- /dev/null +++ b/db/routines/vn/triggers/roadmapStop_beforeUpdate.sql @@ -0,0 +1,10 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`roadmapStop_beforeUpdate` + BEFORE UPDATE ON `roadmapStop` + FOR EACH ROW +BEGIN + + SET NEW.description = UCASE(NEW.description); + +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/roadmap_beforeInsert.sql b/db/routines/vn/triggers/roadmap_beforeInsert.sql new file mode 100644 index 000000000..2f9481140 --- /dev/null +++ b/db/routines/vn/triggers/roadmap_beforeInsert.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`roadmap_beforeInsert` + BEFORE INSERT ON `roadmap` + FOR EACH ROW +BEGIN + IF NEW.driver1Fk IS NOT NULL THEN + SET NEW.driverName = (SELECT firstName FROM worker WHERE id = NEW.driver1Fk); + ELSE + SET NEW.driverName = NULL; + END IF; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/roadmap_beforeUpdate.sql b/db/routines/vn/triggers/roadmap_beforeUpdate.sql new file mode 100644 index 000000000..a2a02e96a --- /dev/null +++ b/db/routines/vn/triggers/roadmap_beforeUpdate.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`roadmap_beforeUpdate` + BEFORE UPDATE ON `roadmap` + FOR EACH ROW +BEGIN + IF NEW.driver1Fk IS NOT NULL THEN + SET NEW.driverName = (SELECT firstName FROM worker WHERE id = NEW.driver1Fk); + ELSE + SET NEW.driverName = NULL; + END IF; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/route_afterDelete.sql b/db/routines/vn/triggers/route_afterDelete.sql index e929bd519..2bd1e3ab6 100644 --- a/db/routines/vn/triggers/route_afterDelete.sql +++ b/db/routines/vn/triggers/route_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`route_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`route_afterDelete` AFTER DELETE ON `route` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/route_afterInsert.sql b/db/routines/vn/triggers/route_afterInsert.sql index f030f09fa..50e14426c 100644 --- a/db/routines/vn/triggers/route_afterInsert.sql +++ b/db/routines/vn/triggers/route_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`route_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`route_afterInsert` AFTER INSERT ON `route` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/route_afterUpdate.sql b/db/routines/vn/triggers/route_afterUpdate.sql index 14b53c2a5..ec205090e 100644 --- a/db/routines/vn/triggers/route_afterUpdate.sql +++ b/db/routines/vn/triggers/route_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`route_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`route_afterUpdate` AFTER UPDATE ON `route` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/route_beforeInsert.sql b/db/routines/vn/triggers/route_beforeInsert.sql index 442b0620e..788efe662 100644 --- a/db/routines/vn/triggers/route_beforeInsert.sql +++ b/db/routines/vn/triggers/route_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`route_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`route_beforeInsert` BEFORE INSERT ON `route` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/route_beforeUpdate.sql b/db/routines/vn/triggers/route_beforeUpdate.sql index 43ee802f5..0ea403de3 100644 --- a/db/routines/vn/triggers/route_beforeUpdate.sql +++ b/db/routines/vn/triggers/route_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`route_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`route_beforeUpdate` BEFORE UPDATE ON `route` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/routesMonitor_afterDelete.sql b/db/routines/vn/triggers/routesMonitor_afterDelete.sql index 000425dad..aad3ad0ec 100644 --- a/db/routines/vn/triggers/routesMonitor_afterDelete.sql +++ b/db/routines/vn/triggers/routesMonitor_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`routesMonitor_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`routesMonitor_afterDelete` AFTER DELETE ON `routesMonitor` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/routesMonitor_beforeInsert.sql b/db/routines/vn/triggers/routesMonitor_beforeInsert.sql index 70b723d54..731a73b0c 100644 --- a/db/routines/vn/triggers/routesMonitor_beforeInsert.sql +++ b/db/routines/vn/triggers/routesMonitor_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`routesMonitor_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`routesMonitor_beforeInsert` BEFORE INSERT ON `routesMonitor` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/routesMonitor_beforeUpdate.sql b/db/routines/vn/triggers/routesMonitor_beforeUpdate.sql index 0ca867b7a..31b47f52e 100644 --- a/db/routines/vn/triggers/routesMonitor_beforeUpdate.sql +++ b/db/routines/vn/triggers/routesMonitor_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`routesMonitor_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`routesMonitor_beforeUpdate` BEFORE UPDATE ON `routesMonitor` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/saleBuy_beforeInsert.sql b/db/routines/vn/triggers/saleBuy_beforeInsert.sql index 1c36671d5..e00480ad4 100644 --- a/db/routines/vn/triggers/saleBuy_beforeInsert.sql +++ b/db/routines/vn/triggers/saleBuy_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleBuy_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`saleBuy_beforeInsert` BEFORE INSERT ON `saleBuy` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/saleGroupDetail._beforeInsert.sql b/db/routines/vn/triggers/saleGroupDetail._beforeInsert.sql new file mode 100644 index 000000000..da975933c --- /dev/null +++ b/db/routines/vn/triggers/saleGroupDetail._beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`saleGroupDetail_beforeInsert` + BEFORE INSERT ON `saleGroupDetail` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/saleGroupDetail_afterDelete.sql b/db/routines/vn/triggers/saleGroupDetail_afterDelete.sql new file mode 100644 index 000000000..37c3e9a2b --- /dev/null +++ b/db/routines/vn/triggers/saleGroupDetail_afterDelete.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`saleGroupDetail_afterDelete` + AFTER DELETE ON `saleGroupDetail` + FOR EACH ROW +BEGIN + INSERT INTO saleGroupLog + SET `action` = 'delete', + `changedModel` = 'SaleGroupDetail', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/saleGroupDetail_beforeUpdate.sql b/db/routines/vn/triggers/saleGroupDetail_beforeUpdate.sql new file mode 100644 index 000000000..1f4238cdc --- /dev/null +++ b/db/routines/vn/triggers/saleGroupDetail_beforeUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`saleGroupDetail_beforeUpdate` + BEFORE UPDATE ON `saleGroupDetail` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/saleGroup_afterDelete.sql b/db/routines/vn/triggers/saleGroup_afterDelete.sql index 1e0163187..f74411b37 100644 --- a/db/routines/vn/triggers/saleGroup_afterDelete.sql +++ b/db/routines/vn/triggers/saleGroup_afterDelete.sql @@ -1,9 +1,9 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleGroup_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`saleGroup_afterDelete` AFTER DELETE ON `saleGroup` FOR EACH ROW BEGIN - INSERT INTO ticketLog + INSERT INTO saleGroupLog SET `action` = 'delete', `changedModel` = 'SaleGroup', `changedModelId` = OLD.id, diff --git a/db/routines/vn/triggers/saleGroup_beforeInsert.sql b/db/routines/vn/triggers/saleGroup_beforeInsert.sql index 18be92ed6..b50489a07 100644 --- a/db/routines/vn/triggers/saleGroup_beforeInsert.sql +++ b/db/routines/vn/triggers/saleGroup_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleGroup_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`saleGroup_beforeInsert` BEFORE INSERT ON `saleGroup` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/saleGroup_beforeUpdate.sql b/db/routines/vn/triggers/saleGroup_beforeUpdate.sql index 1f6aa6def..a3358b22c 100644 --- a/db/routines/vn/triggers/saleGroup_beforeUpdate.sql +++ b/db/routines/vn/triggers/saleGroup_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleGroup_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`saleGroup_beforeUpdate` BEFORE UPDATE ON `saleGroup` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/saleLabel_afterUpdate.sql b/db/routines/vn/triggers/saleLabel_afterUpdate.sql index ff3787358..38fab771a 100644 --- a/db/routines/vn/triggers/saleLabel_afterUpdate.sql +++ b/db/routines/vn/triggers/saleLabel_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleLabel_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`saleLabel_afterUpdate` AFTER UPDATE ON `vn`.`saleLabel` FOR EACH ROW IF NEW.stem >= (SELECT s.quantity FROM sale s WHERE s.id = NEW.saleFk) THEN diff --git a/db/routines/vn/triggers/saleTracking_afterInsert.sql b/db/routines/vn/triggers/saleTracking_afterInsert.sql index 00bef8486..e3dce8747 100644 --- a/db/routines/vn/triggers/saleTracking_afterInsert.sql +++ b/db/routines/vn/triggers/saleTracking_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleTracking_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`saleTracking_afterInsert` AFTER INSERT ON `saleTracking` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/sale_afterDelete.sql b/db/routines/vn/triggers/sale_afterDelete.sql index 6365208b2..2751d88c2 100644 --- a/db/routines/vn/triggers/sale_afterDelete.sql +++ b/db/routines/vn/triggers/sale_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`sale_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`sale_afterDelete` AFTER DELETE ON `sale` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/sale_afterInsert.sql b/db/routines/vn/triggers/sale_afterInsert.sql index b5b28257f..f15b17722 100644 --- a/db/routines/vn/triggers/sale_afterInsert.sql +++ b/db/routines/vn/triggers/sale_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`sale_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`sale_afterInsert` AFTER INSERT ON `sale` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/sale_afterUpdate.sql b/db/routines/vn/triggers/sale_afterUpdate.sql index 3f59c9188..82da55486 100644 --- a/db/routines/vn/triggers/sale_afterUpdate.sql +++ b/db/routines/vn/triggers/sale_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`sale_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`sale_afterUpdate` AFTER UPDATE ON `sale` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/sale_beforeDelete.sql b/db/routines/vn/triggers/sale_beforeDelete.sql index a91e7f010..ad97f8b55 100644 --- a/db/routines/vn/triggers/sale_beforeDelete.sql +++ b/db/routines/vn/triggers/sale_beforeDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`sale_beforeDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`sale_beforeDelete` BEFORE DELETE ON `sale` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/sale_beforeInsert.sql b/db/routines/vn/triggers/sale_beforeInsert.sql index 0ef368513..31d5882fc 100644 --- a/db/routines/vn/triggers/sale_beforeInsert.sql +++ b/db/routines/vn/triggers/sale_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`sale_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`sale_beforeInsert` BEFORE INSERT ON `sale` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/sale_beforeUpdate.sql b/db/routines/vn/triggers/sale_beforeUpdate.sql index c5a748503..fa45dad5c 100644 --- a/db/routines/vn/triggers/sale_beforeUpdate.sql +++ b/db/routines/vn/triggers/sale_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`sale_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`sale_beforeUpdate` BEFORE UPDATE ON `sale` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/sharingCart_beforeDelete.sql b/db/routines/vn/triggers/sharingCart_beforeDelete.sql index 6996b3138..aa3c0c2bf 100644 --- a/db/routines/vn/triggers/sharingCart_beforeDelete.sql +++ b/db/routines/vn/triggers/sharingCart_beforeDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`sharingCart_beforeDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`sharingCart_beforeDelete` BEFORE DELETE ON `sharingCart` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/sharingCart_beforeInsert.sql b/db/routines/vn/triggers/sharingCart_beforeInsert.sql index 116337b62..0dd59a91a 100644 --- a/db/routines/vn/triggers/sharingCart_beforeInsert.sql +++ b/db/routines/vn/triggers/sharingCart_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`sharingCart_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`sharingCart_beforeInsert` BEFORE INSERT ON `sharingCart` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/sharingCart_beforeUpdate.sql b/db/routines/vn/triggers/sharingCart_beforeUpdate.sql index 91cbfb3d0..e1dd26938 100644 --- a/db/routines/vn/triggers/sharingCart_beforeUpdate.sql +++ b/db/routines/vn/triggers/sharingCart_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`sharingCart_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`sharingCart_beforeUpdate` BEFORE UPDATE ON `sharingCart` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/sharingClient_beforeInsert.sql b/db/routines/vn/triggers/sharingClient_beforeInsert.sql index eea65e74c..03a0e0ce0 100644 --- a/db/routines/vn/triggers/sharingClient_beforeInsert.sql +++ b/db/routines/vn/triggers/sharingClient_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`sharingClient_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`sharingClient_beforeInsert` BEFORE INSERT ON `sharingClient` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/sharingClient_beforeUpdate.sql b/db/routines/vn/triggers/sharingClient_beforeUpdate.sql index fceab691c..d3358586b 100644 --- a/db/routines/vn/triggers/sharingClient_beforeUpdate.sql +++ b/db/routines/vn/triggers/sharingClient_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`sharingClient_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`sharingClient_beforeUpdate` BEFORE UPDATE ON `sharingClient` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/shelving_afterDelete.sql b/db/routines/vn/triggers/shelving_afterDelete.sql index 964a866e7..aa3c3bcea 100644 --- a/db/routines/vn/triggers/shelving_afterDelete.sql +++ b/db/routines/vn/triggers/shelving_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`shelving_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`shelving_afterDelete` AFTER DELETE ON `shelving` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/shelving_beforeInsert.sql b/db/routines/vn/triggers/shelving_beforeInsert.sql index ef3c7030c..21528ef78 100644 --- a/db/routines/vn/triggers/shelving_beforeInsert.sql +++ b/db/routines/vn/triggers/shelving_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`shelving_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`shelving_beforeInsert` BEFORE INSERT ON `shelving` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/shelving_beforeUpdate.sql b/db/routines/vn/triggers/shelving_beforeUpdate.sql index 89e7cb7e9..23210c4be 100644 --- a/db/routines/vn/triggers/shelving_beforeUpdate.sql +++ b/db/routines/vn/triggers/shelving_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`shelving_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`shelving_beforeUpdate` BEFORE UPDATE ON `shelving` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/solunionCAP_afterInsert.sql b/db/routines/vn/triggers/solunionCAP_afterInsert.sql index 0d6e510ad..d09cadd95 100644 --- a/db/routines/vn/triggers/solunionCAP_afterInsert.sql +++ b/db/routines/vn/triggers/solunionCAP_afterInsert.sql @@ -1,11 +1,11 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`solunionCAP_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`solunionCAP_afterInsert` AFTER INSERT ON `solunionCAP` FOR EACH ROW BEGIN UPDATE client c JOIN creditClassification cc ON cc.client = c.id - JOIN creditInsurance ci ON ci.creditClassification = cc.id + JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id SET creditInsurance = ci.credit * 2 WHERE ci.id = NEW.creditInsurance; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/solunionCAP_afterUpdate.sql b/db/routines/vn/triggers/solunionCAP_afterUpdate.sql index 40ff57f35..1199067bb 100644 --- a/db/routines/vn/triggers/solunionCAP_afterUpdate.sql +++ b/db/routines/vn/triggers/solunionCAP_afterUpdate.sql @@ -1,17 +1,17 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`solunionCAP_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`solunionCAP_afterUpdate` AFTER UPDATE ON `solunionCAP` FOR EACH ROW BEGIN IF NEW.dateLeaving IS NOT NULL THEN UPDATE client c JOIN creditClassification cc ON cc.client = c.id - JOIN creditInsurance ci ON ci.creditClassification = cc.id + JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance; ELSE UPDATE client c JOIN creditClassification cc ON cc.client = c.id - JOIN creditInsurance ci ON ci.creditClassification = cc.id + JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id SET creditInsurance = ci.credit * 2 WHERE ci.id = OLD.creditInsurance; END IF; END$$ diff --git a/db/routines/vn/triggers/solunionCAP_beforeDelete.sql b/db/routines/vn/triggers/solunionCAP_beforeDelete.sql index 29c4298fd..7913a0d78 100644 --- a/db/routines/vn/triggers/solunionCAP_beforeDelete.sql +++ b/db/routines/vn/triggers/solunionCAP_beforeDelete.sql @@ -1,11 +1,11 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`solunionCAP_beforeDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`solunionCAP_beforeDelete` BEFORE DELETE ON `solunionCAP` FOR EACH ROW BEGIN UPDATE client c JOIN creditClassification cc ON cc.client = c.id - JOIN creditInsurance ci ON ci.creditClassification = cc.id + JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/specie_beforeInsert.sql b/db/routines/vn/triggers/specie_beforeInsert.sql index 68abf0d30..8a9f299fd 100644 --- a/db/routines/vn/triggers/specie_beforeInsert.sql +++ b/db/routines/vn/triggers/specie_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`specie_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`specie_beforeInsert` BEFORE INSERT ON `specie` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/specie_beforeUpdate.sql b/db/routines/vn/triggers/specie_beforeUpdate.sql index 364b1d52f..d859e2cdc 100644 --- a/db/routines/vn/triggers/specie_beforeUpdate.sql +++ b/db/routines/vn/triggers/specie_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`specie_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`specie_beforeUpdate` BEFORE UPDATE ON `specie` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/supplierAccount_afterDelete.sql b/db/routines/vn/triggers/supplierAccount_afterDelete.sql index 23c2cd4a4..81e936140 100644 --- a/db/routines/vn/triggers/supplierAccount_afterDelete.sql +++ b/db/routines/vn/triggers/supplierAccount_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplierAccount_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplierAccount_afterDelete` AFTER DELETE ON `supplierAccount` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/supplierAccount_beforeInsert.sql b/db/routines/vn/triggers/supplierAccount_beforeInsert.sql index 512f172e1..231479ad6 100644 --- a/db/routines/vn/triggers/supplierAccount_beforeInsert.sql +++ b/db/routines/vn/triggers/supplierAccount_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplierAccount_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplierAccount_beforeInsert` BEFORE INSERT ON `supplierAccount` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/supplierAccount_beforeUpdate.sql b/db/routines/vn/triggers/supplierAccount_beforeUpdate.sql index 0fac19deb..2937227a4 100644 --- a/db/routines/vn/triggers/supplierAccount_beforeUpdate.sql +++ b/db/routines/vn/triggers/supplierAccount_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplierAccount_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplierAccount_beforeUpdate` BEFORE UPDATE ON `supplierAccount` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/supplierAddress_afterDelete.sql b/db/routines/vn/triggers/supplierAddress_afterDelete.sql index 69dd94dfe..0840d6fe9 100644 --- a/db/routines/vn/triggers/supplierAddress_afterDelete.sql +++ b/db/routines/vn/triggers/supplierAddress_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplierAddress_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplierAddress_afterDelete` AFTER DELETE ON `supplierAddress` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/supplierAddress_beforeInsert.sql b/db/routines/vn/triggers/supplierAddress_beforeInsert.sql index db8d0ea94..d66b9d3d2 100644 --- a/db/routines/vn/triggers/supplierAddress_beforeInsert.sql +++ b/db/routines/vn/triggers/supplierAddress_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplierAddress_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplierAddress_beforeInsert` BEFORE INSERT ON `supplierAddress` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/supplierAddress_beforeUpdate.sql b/db/routines/vn/triggers/supplierAddress_beforeUpdate.sql index 8e484e4de..94d70834e 100644 --- a/db/routines/vn/triggers/supplierAddress_beforeUpdate.sql +++ b/db/routines/vn/triggers/supplierAddress_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplierAddress_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplierAddress_beforeUpdate` BEFORE UPDATE ON `supplierAddress` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/supplierContact_afterDelete.sql b/db/routines/vn/triggers/supplierContact_afterDelete.sql index 401ec9e9e..18797e383 100644 --- a/db/routines/vn/triggers/supplierContact_afterDelete.sql +++ b/db/routines/vn/triggers/supplierContact_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplierContact_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplierContact_afterDelete` AFTER DELETE ON `supplierContact` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/supplierContact_beforeInsert.sql b/db/routines/vn/triggers/supplierContact_beforeInsert.sql index 76e78ba5a..444f9e9c8 100644 --- a/db/routines/vn/triggers/supplierContact_beforeInsert.sql +++ b/db/routines/vn/triggers/supplierContact_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplierContact_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplierContact_beforeInsert` BEFORE INSERT ON `supplierContact` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/supplierContact_beforeUpdate.sql b/db/routines/vn/triggers/supplierContact_beforeUpdate.sql index 24723656a..194218a91 100644 --- a/db/routines/vn/triggers/supplierContact_beforeUpdate.sql +++ b/db/routines/vn/triggers/supplierContact_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplierContact_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplierContact_beforeUpdate` BEFORE UPDATE ON `supplierContact` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/supplierDms_afterDelete.sql b/db/routines/vn/triggers/supplierDms_afterDelete.sql index 482decbb6..0dbf8e86b 100644 --- a/db/routines/vn/triggers/supplierDms_afterDelete.sql +++ b/db/routines/vn/triggers/supplierDms_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplierDms_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplierDms_afterDelete` AFTER DELETE ON `supplierDms` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/supplierDms_beforeInsert.sql b/db/routines/vn/triggers/supplierDms_beforeInsert.sql index 130428d1e..2098d6a34 100644 --- a/db/routines/vn/triggers/supplierDms_beforeInsert.sql +++ b/db/routines/vn/triggers/supplierDms_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplierDms_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplierDms_beforeInsert` BEFORE INSERT ON `supplierDms` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/supplierDms_beforeUpdate.sql b/db/routines/vn/triggers/supplierDms_beforeUpdate.sql index 54dcef049..6e38018e5 100644 --- a/db/routines/vn/triggers/supplierDms_beforeUpdate.sql +++ b/db/routines/vn/triggers/supplierDms_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplierDms_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplierDms_beforeUpdate` BEFORE UPDATE ON `supplierDms` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/supplier_afterDelete.sql b/db/routines/vn/triggers/supplier_afterDelete.sql index d4b8e0d21..d70830423 100644 --- a/db/routines/vn/triggers/supplier_afterDelete.sql +++ b/db/routines/vn/triggers/supplier_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplier_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplier_afterDelete` AFTER DELETE ON `supplier` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/supplier_afterUpdate.sql b/db/routines/vn/triggers/supplier_afterUpdate.sql new file mode 100644 index 000000000..07f31b5e0 --- /dev/null +++ b/db/routines/vn/triggers/supplier_afterUpdate.sql @@ -0,0 +1,26 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplier_afterUpdate` + BEFORE UPDATE ON `supplier` + FOR EACH ROW +BEGIN + IF NEW.id <> OLD.id + OR NOT (NEW.name <=> OLD.name) + OR NOT (NEW.street <=> OLD.street) + OR NOT (NEW.account <=> OLD.account) + OR NOT (NEW.nif <=> OLD.nif) + OR NOT (NEW.isVies <=> OLD.isVies) + OR NOT (NEW.provinceFk <=> OLD.provinceFk) + OR NOT (NEW.countryFk <=> OLD.countryFk) + OR NOT (NEW.postCode <=> OLD.postCode) + OR NOT (NEW.city <=> OLD.city) + OR NOT (NEW.taxTypeSageFk <=> OLD.taxTypeSageFk) + OR NOT (NEW.transactionTypeSageFk <=> OLD.transactionTypeSageFk) + OR NOT (NEW.withholdingSageFk <=> OLD.withholdingSageFk) THEN + + UPDATE sage.clientSupplier + SET isSync = FALSE + WHERE idClientSupplier IN (NEW.id, OLD.id) + AND `type` = 'P'; + END IF; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/supplier_beforeInsert.sql b/db/routines/vn/triggers/supplier_beforeInsert.sql index aef8d02ab..b141ec8fb 100644 --- a/db/routines/vn/triggers/supplier_beforeInsert.sql +++ b/db/routines/vn/triggers/supplier_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplier_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplier_beforeInsert` BEFORE INSERT ON `supplier` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/supplier_beforeUpdate.sql b/db/routines/vn/triggers/supplier_beforeUpdate.sql index f462d6f57..af730b49d 100644 --- a/db/routines/vn/triggers/supplier_beforeUpdate.sql +++ b/db/routines/vn/triggers/supplier_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplier_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplier_beforeUpdate` BEFORE UPDATE ON `supplier` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/tag_beforeInsert.sql b/db/routines/vn/triggers/tag_beforeInsert.sql index 27057754d..e24dec000 100644 --- a/db/routines/vn/triggers/tag_beforeInsert.sql +++ b/db/routines/vn/triggers/tag_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`tag_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`tag_beforeInsert` BEFORE INSERT ON `tag` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketCollection_afterDelete.sql b/db/routines/vn/triggers/ticketCollection_afterDelete.sql index e0917452a..0b688022f 100644 --- a/db/routines/vn/triggers/ticketCollection_afterDelete.sql +++ b/db/routines/vn/triggers/ticketCollection_afterDelete.sql @@ -1,7 +1,7 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketCollection_afterDelete` - AFTER DELETE ON `ticketCollection` - FOR EACH ROW +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketCollection_afterDelete` + AFTER DELETE ON `ticketCollection` + FOR EACH ROW BEGIN DECLARE vSalesRemaining INT; @@ -24,5 +24,5 @@ BEGIN END IF; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/ticketDms_afterDelete.sql b/db/routines/vn/triggers/ticketDms_afterDelete.sql index 834079520..40c10a494 100644 --- a/db/routines/vn/triggers/ticketDms_afterDelete.sql +++ b/db/routines/vn/triggers/ticketDms_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketDms_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketDms_afterDelete` AFTER DELETE ON `ticketDms` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketDms_beforeDelete.sql b/db/routines/vn/triggers/ticketDms_beforeDelete.sql index 9c251fba1..93c335be9 100644 --- a/db/routines/vn/triggers/ticketDms_beforeDelete.sql +++ b/db/routines/vn/triggers/ticketDms_beforeDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketDms_beforeDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketDms_beforeDelete` BEFORE DELETE ON `ticketDms` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketDms_beforeInsert.sql b/db/routines/vn/triggers/ticketDms_beforeInsert.sql index 0c00dba28..9b35c6e71 100644 --- a/db/routines/vn/triggers/ticketDms_beforeInsert.sql +++ b/db/routines/vn/triggers/ticketDms_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketDms_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketDms_beforeInsert` BEFORE INSERT ON `ticketDms` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketDms_beforeUpdate.sql b/db/routines/vn/triggers/ticketDms_beforeUpdate.sql index aab22dd99..6f3d1522a 100644 --- a/db/routines/vn/triggers/ticketDms_beforeUpdate.sql +++ b/db/routines/vn/triggers/ticketDms_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketDms_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketDms_beforeUpdate` BEFORE UPDATE ON `ticketDms` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketObservation_afterDelete.sql b/db/routines/vn/triggers/ticketObservation_afterDelete.sql index f8d88add6..160d3cbdd 100644 --- a/db/routines/vn/triggers/ticketObservation_afterDelete.sql +++ b/db/routines/vn/triggers/ticketObservation_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketObservation_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketObservation_afterDelete` AFTER DELETE ON `ticketObservation` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketObservation_beforeInsert.sql b/db/routines/vn/triggers/ticketObservation_beforeInsert.sql index ce141d56a..9915b541b 100644 --- a/db/routines/vn/triggers/ticketObservation_beforeInsert.sql +++ b/db/routines/vn/triggers/ticketObservation_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketObservation_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketObservation_beforeInsert` BEFORE INSERT ON `ticketObservation` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketObservation_beforeUpdate.sql b/db/routines/vn/triggers/ticketObservation_beforeUpdate.sql index 466e17e85..a94a4160b 100644 --- a/db/routines/vn/triggers/ticketObservation_beforeUpdate.sql +++ b/db/routines/vn/triggers/ticketObservation_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketObservation_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketObservation_beforeUpdate` BEFORE UPDATE ON `ticketObservation` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketPackaging_afterDelete.sql b/db/routines/vn/triggers/ticketPackaging_afterDelete.sql index 320f7e01e..dfdc2ffe1 100644 --- a/db/routines/vn/triggers/ticketPackaging_afterDelete.sql +++ b/db/routines/vn/triggers/ticketPackaging_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketPackaging_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketPackaging_afterDelete` AFTER DELETE ON `ticketPackaging` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketPackaging_beforeInsert.sql b/db/routines/vn/triggers/ticketPackaging_beforeInsert.sql index f47a7ae35..17bf41daa 100644 --- a/db/routines/vn/triggers/ticketPackaging_beforeInsert.sql +++ b/db/routines/vn/triggers/ticketPackaging_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketPackaging_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketPackaging_beforeInsert` BEFORE INSERT ON `ticketPackaging` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketPackaging_beforeUpdate.sql b/db/routines/vn/triggers/ticketPackaging_beforeUpdate.sql index 5d15249c4..9ce7ca3db 100644 --- a/db/routines/vn/triggers/ticketPackaging_beforeUpdate.sql +++ b/db/routines/vn/triggers/ticketPackaging_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketPackaging_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketPackaging_beforeUpdate` BEFORE UPDATE ON `ticketPackaging` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketParking_beforeInsert.sql b/db/routines/vn/triggers/ticketParking_beforeInsert.sql index 2add4f3ea..77c2aeab7 100644 --- a/db/routines/vn/triggers/ticketParking_beforeInsert.sql +++ b/db/routines/vn/triggers/ticketParking_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketParking_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketParking_beforeInsert` BEFORE INSERT ON `ticketParking` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketRefund_afterDelete.sql b/db/routines/vn/triggers/ticketRefund_afterDelete.sql index 167030d4a..677e25905 100644 --- a/db/routines/vn/triggers/ticketRefund_afterDelete.sql +++ b/db/routines/vn/triggers/ticketRefund_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketRefund_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketRefund_afterDelete` AFTER DELETE ON `ticketRefund` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketRefund_beforeInsert.sql b/db/routines/vn/triggers/ticketRefund_beforeInsert.sql index 7893f6c51..dd1da6650 100644 --- a/db/routines/vn/triggers/ticketRefund_beforeInsert.sql +++ b/db/routines/vn/triggers/ticketRefund_beforeInsert.sql @@ -1,9 +1,10 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketRefund_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketRefund_beforeInsert` BEFORE INSERT ON `ticketRefund` FOR EACH ROW BEGIN + CALL ticketRefund_upsert(NEW.refundTicketFk, NEW.originalTicketFk); + SET NEW.editorFk = account.myUser_getId(); - CALL ticketRefund_beforeUpsert(NEW.refundTicketFk, NEW.originalTicketFk); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/ticketRefund_beforeUpdate.sql b/db/routines/vn/triggers/ticketRefund_beforeUpdate.sql index 51c7db8f2..f27e3f092 100644 --- a/db/routines/vn/triggers/ticketRefund_beforeUpdate.sql +++ b/db/routines/vn/triggers/ticketRefund_beforeUpdate.sql @@ -1,9 +1,10 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketRefund_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketRefund_beforeUpdate` BEFORE UPDATE ON `ticketRefund` FOR EACH ROW BEGIN + CALL ticketRefund_upsert(NEW.refundTicketFk, NEW.originalTicketFk); + SET NEW.editorFk = account.myUser_getId(); - CALL ticketRefund_beforeUpsert(NEW.refundTicketFk, NEW.originalTicketFk); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/ticketRequest_afterDelete.sql b/db/routines/vn/triggers/ticketRequest_afterDelete.sql index a8932a744..051db6b2e 100644 --- a/db/routines/vn/triggers/ticketRequest_afterDelete.sql +++ b/db/routines/vn/triggers/ticketRequest_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketRequest_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketRequest_afterDelete` AFTER DELETE ON `ticketRequest` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketRequest_beforeInsert.sql b/db/routines/vn/triggers/ticketRequest_beforeInsert.sql index 00e659abc..fcad2f593 100644 --- a/db/routines/vn/triggers/ticketRequest_beforeInsert.sql +++ b/db/routines/vn/triggers/ticketRequest_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketRequest_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketRequest_beforeInsert` BEFORE INSERT ON `ticketRequest` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketRequest_beforeUpdate.sql b/db/routines/vn/triggers/ticketRequest_beforeUpdate.sql index 954df8ed3..a30b9464f 100644 --- a/db/routines/vn/triggers/ticketRequest_beforeUpdate.sql +++ b/db/routines/vn/triggers/ticketRequest_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketRequest_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketRequest_beforeUpdate` BEFORE UPDATE ON `ticketRequest` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketService_afterDelete.sql b/db/routines/vn/triggers/ticketService_afterDelete.sql index ca2675ce8..9b1f6e812 100644 --- a/db/routines/vn/triggers/ticketService_afterDelete.sql +++ b/db/routines/vn/triggers/ticketService_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketService_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketService_afterDelete` AFTER DELETE ON `ticketService` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketService_beforeInsert.sql b/db/routines/vn/triggers/ticketService_beforeInsert.sql index 81b7e5e91..b886d764e 100644 --- a/db/routines/vn/triggers/ticketService_beforeInsert.sql +++ b/db/routines/vn/triggers/ticketService_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketService_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketService_beforeInsert` BEFORE INSERT ON `ticketService` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketService_beforeUpdate.sql b/db/routines/vn/triggers/ticketService_beforeUpdate.sql index a24af8269..8b706d312 100644 --- a/db/routines/vn/triggers/ticketService_beforeUpdate.sql +++ b/db/routines/vn/triggers/ticketService_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketService_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketService_beforeUpdate` BEFORE UPDATE ON `ticketService` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketTracking_afterDelete.sql b/db/routines/vn/triggers/ticketTracking_afterDelete.sql index 2683e8d3c..aee31fe5f 100644 --- a/db/routines/vn/triggers/ticketTracking_afterDelete.sql +++ b/db/routines/vn/triggers/ticketTracking_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketTracking_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketTracking_afterDelete` AFTER DELETE ON `ticketTracking` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketTracking_afterInsert.sql b/db/routines/vn/triggers/ticketTracking_afterInsert.sql index b246cd44f..c2dca56ef 100644 --- a/db/routines/vn/triggers/ticketTracking_afterInsert.sql +++ b/db/routines/vn/triggers/ticketTracking_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketTracking_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketTracking_afterInsert` AFTER INSERT ON `ticketTracking` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketTracking_afterUpdate.sql b/db/routines/vn/triggers/ticketTracking_afterUpdate.sql index ce5586569..fab8b3d34 100644 --- a/db/routines/vn/triggers/ticketTracking_afterUpdate.sql +++ b/db/routines/vn/triggers/ticketTracking_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketTracking_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketTracking_afterUpdate` AFTER UPDATE ON `ticketTracking` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketTracking_beforeInsert.sql b/db/routines/vn/triggers/ticketTracking_beforeInsert.sql index 685713aea..8c0b557ba 100644 --- a/db/routines/vn/triggers/ticketTracking_beforeInsert.sql +++ b/db/routines/vn/triggers/ticketTracking_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketTracking_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketTracking_beforeInsert` BEFORE INSERT ON `ticketTracking` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketTracking_beforeUpdate.sql b/db/routines/vn/triggers/ticketTracking_beforeUpdate.sql index ec875387e..3605ca360 100644 --- a/db/routines/vn/triggers/ticketTracking_beforeUpdate.sql +++ b/db/routines/vn/triggers/ticketTracking_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketTracking_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketTracking_beforeUpdate` BEFORE UPDATE ON `ticketTracking` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketWeekly_afterDelete.sql b/db/routines/vn/triggers/ticketWeekly_afterDelete.sql index d0ef0b8df..066ab2d08 100644 --- a/db/routines/vn/triggers/ticketWeekly_afterDelete.sql +++ b/db/routines/vn/triggers/ticketWeekly_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketWeekly_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketWeekly_afterDelete` AFTER DELETE ON `ticketWeekly` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketWeekly_beforeInsert.sql b/db/routines/vn/triggers/ticketWeekly_beforeInsert.sql index e4a61d203..a9f2780e4 100644 --- a/db/routines/vn/triggers/ticketWeekly_beforeInsert.sql +++ b/db/routines/vn/triggers/ticketWeekly_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketWeekly_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketWeekly_beforeInsert` BEFORE INSERT ON `ticketWeekly` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticketWeekly_beforeUpdate.sql b/db/routines/vn/triggers/ticketWeekly_beforeUpdate.sql index 1a631bec1..76a633e23 100644 --- a/db/routines/vn/triggers/ticketWeekly_beforeUpdate.sql +++ b/db/routines/vn/triggers/ticketWeekly_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketWeekly_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketWeekly_beforeUpdate` BEFORE UPDATE ON `ticketWeekly` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticket_afterDelete.sql b/db/routines/vn/triggers/ticket_afterDelete.sql index c80f3dbe1..bcde76e0a 100644 --- a/db/routines/vn/triggers/ticket_afterDelete.sql +++ b/db/routines/vn/triggers/ticket_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticket_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticket_afterDelete` AFTER DELETE ON `ticket` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticket_afterInsert.sql b/db/routines/vn/triggers/ticket_afterInsert.sql index 0fad0aaee..d3936af0b 100644 --- a/db/routines/vn/triggers/ticket_afterInsert.sql +++ b/db/routines/vn/triggers/ticket_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticket_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticket_afterInsert` AFTER INSERT ON `ticket` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticket_afterUpdate.sql b/db/routines/vn/triggers/ticket_afterUpdate.sql index 0ce13e0a5..f6c5e6523 100644 --- a/db/routines/vn/triggers/ticket_afterUpdate.sql +++ b/db/routines/vn/triggers/ticket_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticket_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticket_afterUpdate` AFTER UPDATE ON `ticket` FOR EACH ROW BEGIN @@ -8,7 +8,9 @@ BEGIN SET hasNewRoute = TRUE WHERE ticketFk = NEW.id; - CALL ticket_doCmr(NEW.id); + IF NEW.cmrFk THEN + CALL ticket_doCmr(NEW.id); + END IF; END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/ticket_beforeDelete.sql b/db/routines/vn/triggers/ticket_beforeDelete.sql index 02c5352e6..953fa509a 100644 --- a/db/routines/vn/triggers/ticket_beforeDelete.sql +++ b/db/routines/vn/triggers/ticket_beforeDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticket_beforeDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticket_beforeDelete` BEFORE DELETE ON `ticket` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticket_beforeInsert.sql b/db/routines/vn/triggers/ticket_beforeInsert.sql index 7e0fc57b8..02b60b6b3 100644 --- a/db/routines/vn/triggers/ticket_beforeInsert.sql +++ b/db/routines/vn/triggers/ticket_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticket_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticket_beforeInsert` BEFORE INSERT ON `ticket` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/ticket_beforeUpdate.sql b/db/routines/vn/triggers/ticket_beforeUpdate.sql index 72831bc3d..3208a93d0 100644 --- a/db/routines/vn/triggers/ticket_beforeUpdate.sql +++ b/db/routines/vn/triggers/ticket_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticket_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticket_beforeUpdate` BEFORE UPDATE ON `ticket` FOR EACH ROW BEGIN @@ -8,13 +8,22 @@ BEGIN SET NEW.editorFk = account.myUser_getId(); IF NOT (NEW.routeFk <=> OLD.routeFk) THEN - INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`) - SELECT r.id - FROM vn.route r - WHERE r.isOk = FALSE - AND r.id IN (OLD.routeFk,NEW.routeFk) - AND r.created >= util.VN_CURDATE() - GROUP BY r.id; + IF NEW.isSigned AND NOT ( + SELECT (COUNT(s.id) = COUNT(cb.saleFk) + AND SUM(s.quantity) = SUM(cb.quantity)) + FROM sale s + LEFT JOIN claimBeginning cb ON cb.saleFk = s.id + WHERE s.ticketFk = NEW.id + ) THEN + CALL util.throw('A signed ticket cannot be rerouted'); + END IF; + INSERT IGNORE INTO routeRecalc(routeFk) + SELECT id + FROM `route` + WHERE NOT isOk + AND id IN (OLD.routeFk, NEW.routeFk) + AND created >= util.VN_CURDATE() + GROUP BY id; END IF; IF NOT (DATE(NEW.shipped) <=> DATE(OLD.shipped)) THEN diff --git a/db/routines/vn/triggers/time_afterUpdate.sql b/db/routines/vn/triggers/time_afterUpdate.sql index 1eb735923..e7f3551c5 100644 --- a/db/routines/vn/triggers/time_afterUpdate.sql +++ b/db/routines/vn/triggers/time_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`time_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`time_afterUpdate` AFTER UPDATE ON `time` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/town_afterDelete.sql b/db/routines/vn/triggers/town_afterDelete.sql index e6ca82d80..51696b633 100644 --- a/db/routines/vn/triggers/town_afterDelete.sql +++ b/db/routines/vn/triggers/town_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`town_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`town_afterDelete` AFTER DELETE ON `town` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/town_afterUpdate.sql b/db/routines/vn/triggers/town_afterUpdate.sql index 830428061..dd3fddebd 100644 --- a/db/routines/vn/triggers/town_afterUpdate.sql +++ b/db/routines/vn/triggers/town_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`town_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`town_afterUpdate` AFTER UPDATE ON `town` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/town_beforeInsert.sql b/db/routines/vn/triggers/town_beforeInsert.sql index f3a060b2d..4a1ce887e 100644 --- a/db/routines/vn/triggers/town_beforeInsert.sql +++ b/db/routines/vn/triggers/town_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`town_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`town_beforeInsert` BEFORE INSERT ON `town` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/town_beforeUpdate.sql b/db/routines/vn/triggers/town_beforeUpdate.sql index e607b3f41..fc1410d5c 100644 --- a/db/routines/vn/triggers/town_beforeUpdate.sql +++ b/db/routines/vn/triggers/town_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`town_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`town_beforeUpdate` BEFORE UPDATE ON `town` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/travelThermograph_afterDelete.sql b/db/routines/vn/triggers/travelThermograph_afterDelete.sql index 14a875799..1e51426ef 100644 --- a/db/routines/vn/triggers/travelThermograph_afterDelete.sql +++ b/db/routines/vn/triggers/travelThermograph_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travelThermograph_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`travelThermograph_afterDelete` AFTER DELETE ON `travelThermograph` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/travelThermograph_beforeInsert.sql b/db/routines/vn/triggers/travelThermograph_beforeInsert.sql index 4ebe14e75..256ee12a6 100644 --- a/db/routines/vn/triggers/travelThermograph_beforeInsert.sql +++ b/db/routines/vn/triggers/travelThermograph_beforeInsert.sql @@ -1,8 +1,17 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travelThermograph_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`travelThermograph_beforeInsert` BEFORE INSERT ON `travelThermograph` FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); + + IF NEW.travelFk IS NULL AND + (SELECT COUNT(*) FROM travelThermograph + WHERE thermographFk = NEW.thermographFk + AND travelFk IS NULL + AND id <> NEW.id) > 0 + THEN + CALL util.throw('Duplicate thermographFk without travelFk not allowed.'); + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/travelThermograph_beforeUpdate.sql b/db/routines/vn/triggers/travelThermograph_beforeUpdate.sql index 381e655f3..ffe81b38d 100644 --- a/db/routines/vn/triggers/travelThermograph_beforeUpdate.sql +++ b/db/routines/vn/triggers/travelThermograph_beforeUpdate.sql @@ -1,8 +1,17 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travelThermograph_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`travelThermograph_beforeUpdate` BEFORE UPDATE ON `travelThermograph` FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); + + IF NEW.travelFk IS NULL AND + (SELECT COUNT(*) FROM travelThermograph + WHERE thermographFk = NEW.thermographFk + AND travelFk IS NULL + AND id <> NEW.id) > 0 + THEN + CALL util.throw('Duplicate thermographFk without travelFk not allowed.'); + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/travel_afterDelete.sql b/db/routines/vn/triggers/travel_afterDelete.sql index a528793e9..35fdfb4fc 100644 --- a/db/routines/vn/triggers/travel_afterDelete.sql +++ b/db/routines/vn/triggers/travel_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travel_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`travel_afterDelete` AFTER DELETE ON `travel` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/travel_afterUpdate.sql b/db/routines/vn/triggers/travel_afterUpdate.sql index 7cfe865f3..75de5ab4a 100644 --- a/db/routines/vn/triggers/travel_afterUpdate.sql +++ b/db/routines/vn/triggers/travel_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travel_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`travel_afterUpdate` AFTER UPDATE ON `travel` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/travel_beforeInsert.sql b/db/routines/vn/triggers/travel_beforeInsert.sql index 817bd69bb..4563c9a81 100644 --- a/db/routines/vn/triggers/travel_beforeInsert.sql +++ b/db/routines/vn/triggers/travel_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travel_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`travel_beforeInsert` BEFORE INSERT ON `travel` FOR EACH ROW BEGIN @@ -9,8 +9,8 @@ BEGIN CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk); - IF NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN - CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries'); + IF NEW.awbFk IS NOT NULL THEN + CALL travel_throwAwb(NEW.id); END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/travel_beforeUpdate.sql b/db/routines/vn/triggers/travel_beforeUpdate.sql index 5e43c8761..33578fea1 100644 --- a/db/routines/vn/triggers/travel_beforeUpdate.sql +++ b/db/routines/vn/triggers/travel_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travel_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`travel_beforeUpdate` BEFORE UPDATE ON `travel` FOR EACH ROW BEGIN @@ -33,8 +33,8 @@ BEGIN END IF; END IF; - IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN - CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries'); + IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL THEN + CALL travel_throwAwb(NEW.id); END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/vehicle_beforeInsert.sql b/db/routines/vn/triggers/vehicle_beforeInsert.sql index 046e11703..22505ffb0 100644 --- a/db/routines/vn/triggers/vehicle_beforeInsert.sql +++ b/db/routines/vn/triggers/vehicle_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`vehicle_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`vehicle_beforeInsert` BEFORE INSERT ON `vehicle` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/vehicle_beforeUpdate.sql b/db/routines/vn/triggers/vehicle_beforeUpdate.sql index d61005468..b435c90a4 100644 --- a/db/routines/vn/triggers/vehicle_beforeUpdate.sql +++ b/db/routines/vn/triggers/vehicle_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`vehicle_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`vehicle_beforeUpdate` BEFORE UPDATE ON `vehicle` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/warehouse_afterInsert.sql b/db/routines/vn/triggers/warehouse_afterInsert.sql index 97a8c4152..9063d8e15 100644 --- a/db/routines/vn/triggers/warehouse_afterInsert.sql +++ b/db/routines/vn/triggers/warehouse_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`warehouse_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`warehouse_afterInsert` BEFORE UPDATE ON `warehouse` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/workerDocument_afterDelete.sql b/db/routines/vn/triggers/workerDms_afterDelete.sql similarity index 51% rename from db/routines/vn/triggers/workerDocument_afterDelete.sql rename to db/routines/vn/triggers/workerDms_afterDelete.sql index b266d3bf6..bfb7d481e 100644 --- a/db/routines/vn/triggers/workerDocument_afterDelete.sql +++ b/db/routines/vn/triggers/workerDms_afterDelete.sql @@ -1,11 +1,11 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`workerDocument_afterDelete` - AFTER DELETE ON `workerDocument` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDms_afterDelete` + AFTER DELETE ON `workerDms` FOR EACH ROW BEGIN INSERT INTO workerLog SET `action` = 'delete', - `changedModel` = 'WorkerDocument', + `changedModel` = 'WorkerDms', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); END$$ diff --git a/db/routines/vn/triggers/workerDms_beforeInsert.sql b/db/routines/vn/triggers/workerDms_beforeInsert.sql new file mode 100644 index 000000000..a52c60961 --- /dev/null +++ b/db/routines/vn/triggers/workerDms_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDms_beforeInsert` + BEFORE INSERT ON `workerDms` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/workerDms_beforeUpdate.sql b/db/routines/vn/triggers/workerDms_beforeUpdate.sql new file mode 100644 index 000000000..564064444 --- /dev/null +++ b/db/routines/vn/triggers/workerDms_beforeUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerDms_beforeUpdate` + BEFORE UPDATE ON `workerDms` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/workerDocument_beforeInsert.sql b/db/routines/vn/triggers/workerDocument_beforeInsert.sql deleted file mode 100644 index 2a795ba38..000000000 --- a/db/routines/vn/triggers/workerDocument_beforeInsert.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`workerDocument_beforeInsert` - BEFORE INSERT ON `workerDocument` - FOR EACH ROW -BEGIN - SET NEW.editorFk = account.myUser_getId(); -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/workerDocument_beforeUpdate.sql b/db/routines/vn/triggers/workerDocument_beforeUpdate.sql deleted file mode 100644 index ffa137b3a..000000000 --- a/db/routines/vn/triggers/workerDocument_beforeUpdate.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`workerDocument_beforeUpdate` - BEFORE UPDATE ON `workerDocument` - FOR EACH ROW -BEGIN - SET NEW.editorFk = account.myUser_getId(); -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/workerIncome_afterDelete.sql b/db/routines/vn/triggers/workerIncome_afterDelete.sql index e19df59a8..42580061e 100644 --- a/db/routines/vn/triggers/workerIncome_afterDelete.sql +++ b/db/routines/vn/triggers/workerIncome_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`workerIncome_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerIncome_afterDelete` AFTER DELETE ON `workerIncome` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/workerIncome_afterInsert.sql b/db/routines/vn/triggers/workerIncome_afterInsert.sql index 8837f9c07..fcb24e42b 100644 --- a/db/routines/vn/triggers/workerIncome_afterInsert.sql +++ b/db/routines/vn/triggers/workerIncome_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`workerIncome_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerIncome_afterInsert` AFTER INSERT ON `workerIncome` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/workerIncome_afterUpdate.sql b/db/routines/vn/triggers/workerIncome_afterUpdate.sql index a2584df22..f6b27c761 100644 --- a/db/routines/vn/triggers/workerIncome_afterUpdate.sql +++ b/db/routines/vn/triggers/workerIncome_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`workerIncome_afterUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerIncome_afterUpdate` AFTER UPDATE ON `workerIncome` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/workerTimeControl_afterDelete.sql b/db/routines/vn/triggers/workerTimeControl_afterDelete.sql index 19653c913..27432fccb 100644 --- a/db/routines/vn/triggers/workerTimeControl_afterDelete.sql +++ b/db/routines/vn/triggers/workerTimeControl_afterDelete.sql @@ -1,12 +1,12 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`workerTimeControl_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerTimeControl_afterDelete` AFTER DELETE ON `workerTimeControl` FOR EACH ROW -BEGIN - INSERT INTO workerLog - SET `action` = 'delete', - `changedModel` = 'WorkerTimeControl', - `changedModelId` = OLD.id, - `userFk` = account.myUser_getId(); +BEGIN + INSERT INTO workerLog + SET `action` = 'delete', + `changedModel` = 'WorkerTimeControl', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/workerTimeControl_afterInsert.sql b/db/routines/vn/triggers/workerTimeControl_afterInsert.sql index b8b9c3b01..84e53a5cd 100644 --- a/db/routines/vn/triggers/workerTimeControl_afterInsert.sql +++ b/db/routines/vn/triggers/workerTimeControl_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`workerTimeControl_afterInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerTimeControl_afterInsert` AFTER INSERT ON `workerTimeControl` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/workerTimeControl_beforeInsert.sql b/db/routines/vn/triggers/workerTimeControl_beforeInsert.sql index ad7acb784..4112c8de6 100644 --- a/db/routines/vn/triggers/workerTimeControl_beforeInsert.sql +++ b/db/routines/vn/triggers/workerTimeControl_beforeInsert.sql @@ -1,8 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`workerTimeControl_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerTimeControl_beforeInsert` BEFORE INSERT ON `workerTimeControl` FOR EACH ROW -BEGIN - SET NEW.editorFk = account.myUser_getId(); +BEGIN + SET NEW.editorFk = account.myUser_getId(); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/workerTimeControl_beforeUpdate.sql b/db/routines/vn/triggers/workerTimeControl_beforeUpdate.sql index bb391ad61..3e673d847 100644 --- a/db/routines/vn/triggers/workerTimeControl_beforeUpdate.sql +++ b/db/routines/vn/triggers/workerTimeControl_beforeUpdate.sql @@ -1,8 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`workerTimeControl_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerTimeControl_beforeUpdate` BEFORE UPDATE ON `workerTimeControl` FOR EACH ROW -BEGIN - SET NEW.editorFk = account.myUser_getId(); +BEGIN + SET NEW.editorFk = account.myUser_getId(); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/worker_afterDelete.sql b/db/routines/vn/triggers/worker_afterDelete.sql index 0104248ff..bf21547ac 100644 --- a/db/routines/vn/triggers/worker_afterDelete.sql +++ b/db/routines/vn/triggers/worker_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`worker_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`worker_afterDelete` AFTER DELETE ON `worker` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/worker_beforeInsert.sql b/db/routines/vn/triggers/worker_beforeInsert.sql index 8830bd77e..24adbdbb6 100644 --- a/db/routines/vn/triggers/worker_beforeInsert.sql +++ b/db/routines/vn/triggers/worker_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`worker_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`worker_beforeInsert` BEFORE INSERT ON `worker` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/worker_beforeUpdate.sql b/db/routines/vn/triggers/worker_beforeUpdate.sql index 05705d273..35b854836 100644 --- a/db/routines/vn/triggers/worker_beforeUpdate.sql +++ b/db/routines/vn/triggers/worker_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`worker_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`worker_beforeUpdate` BEFORE UPDATE ON `worker` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/workingHours_beforeInsert.sql b/db/routines/vn/triggers/workingHours_beforeInsert.sql index dce726f10..57fd1e6f8 100644 --- a/db/routines/vn/triggers/workingHours_beforeInsert.sql +++ b/db/routines/vn/triggers/workingHours_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`workingHours_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workingHours_beforeInsert` BEFORE INSERT ON `workingHours` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/zoneEvent_afterDelete.sql b/db/routines/vn/triggers/zoneEvent_afterDelete.sql index 1eecc21dc..aaf477752 100644 --- a/db/routines/vn/triggers/zoneEvent_afterDelete.sql +++ b/db/routines/vn/triggers/zoneEvent_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneEvent_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`zoneEvent_afterDelete` AFTER DELETE ON `zoneEvent` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/zoneEvent_beforeInsert.sql b/db/routines/vn/triggers/zoneEvent_beforeInsert.sql index ae1542851..b8f5486f8 100644 --- a/db/routines/vn/triggers/zoneEvent_beforeInsert.sql +++ b/db/routines/vn/triggers/zoneEvent_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneEvent_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`zoneEvent_beforeInsert` BEFORE INSERT ON `zoneEvent` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/zoneEvent_beforeUpdate.sql b/db/routines/vn/triggers/zoneEvent_beforeUpdate.sql index 09698a2c9..4ba7858d0 100644 --- a/db/routines/vn/triggers/zoneEvent_beforeUpdate.sql +++ b/db/routines/vn/triggers/zoneEvent_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneEvent_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`zoneEvent_beforeUpdate` BEFORE UPDATE ON `zoneEvent` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/zoneExclusion_afterDelete.sql b/db/routines/vn/triggers/zoneExclusion_afterDelete.sql index 6c8a441aa..b701c0434 100644 --- a/db/routines/vn/triggers/zoneExclusion_afterDelete.sql +++ b/db/routines/vn/triggers/zoneExclusion_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneExclusion_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`zoneExclusion_afterDelete` AFTER DELETE ON `zoneExclusion` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/zoneExclusion_beforeInsert.sql b/db/routines/vn/triggers/zoneExclusion_beforeInsert.sql index 6b2d2f5c7..59bd39ef5 100644 --- a/db/routines/vn/triggers/zoneExclusion_beforeInsert.sql +++ b/db/routines/vn/triggers/zoneExclusion_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneExclusion_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`zoneExclusion_beforeInsert` BEFORE INSERT ON `zoneExclusion` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/zoneExclusion_beforeUpdate.sql b/db/routines/vn/triggers/zoneExclusion_beforeUpdate.sql index 1daa6d2f0..ac7626696 100644 --- a/db/routines/vn/triggers/zoneExclusion_beforeUpdate.sql +++ b/db/routines/vn/triggers/zoneExclusion_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneExclusion_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`zoneExclusion_beforeUpdate` BEFORE UPDATE ON `zoneExclusion` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/zoneGeo_beforeInsert.sql b/db/routines/vn/triggers/zoneGeo_beforeInsert.sql index 1dbefbed9..7c9aa5004 100644 --- a/db/routines/vn/triggers/zoneGeo_beforeInsert.sql +++ b/db/routines/vn/triggers/zoneGeo_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneGeo_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`zoneGeo_beforeInsert` BEFORE INSERT ON `zoneGeo` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/zoneGeo_beforeUpdate.sql b/db/routines/vn/triggers/zoneGeo_beforeUpdate.sql index 0fdd7a682..b916ee366 100644 --- a/db/routines/vn/triggers/zoneGeo_beforeUpdate.sql +++ b/db/routines/vn/triggers/zoneGeo_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneGeo_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`zoneGeo_beforeUpdate` BEFORE UPDATE ON `zoneGeo` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql index 18332bb55..2990626ca 100644 --- a/db/routines/vn/triggers/zoneIncluded_afterDelete.sql +++ b/db/routines/vn/triggers/zoneIncluded_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`zoneIncluded_afterDelete` AFTER DELETE ON `zoneIncluded` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql b/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql index 18895c9a5..614c153f6 100644 --- a/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql +++ b/db/routines/vn/triggers/zoneIncluded_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeInsert` BEFORE INSERT ON `zoneIncluded` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql index e3f0a27e2..a718ca178 100644 --- a/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql +++ b/db/routines/vn/triggers/zoneIncluded_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeUpdate` BEFORE UPDATE ON `zoneIncluded` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/zoneWarehouse_afterDelete.sql b/db/routines/vn/triggers/zoneWarehouse_afterDelete.sql index 3befff38a..b72bc46d4 100644 --- a/db/routines/vn/triggers/zoneWarehouse_afterDelete.sql +++ b/db/routines/vn/triggers/zoneWarehouse_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneWarehouse_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`zoneWarehouse_afterDelete` AFTER DELETE ON `zoneWarehouse` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/zoneWarehouse_beforeInsert.sql b/db/routines/vn/triggers/zoneWarehouse_beforeInsert.sql index 099e66587..68218d09b 100644 --- a/db/routines/vn/triggers/zoneWarehouse_beforeInsert.sql +++ b/db/routines/vn/triggers/zoneWarehouse_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneWarehouse_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`zoneWarehouse_beforeInsert` BEFORE INSERT ON `zoneWarehouse` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/zoneWarehouse_beforeUpdate.sql b/db/routines/vn/triggers/zoneWarehouse_beforeUpdate.sql index 2a6563dc5..de63c802e 100644 --- a/db/routines/vn/triggers/zoneWarehouse_beforeUpdate.sql +++ b/db/routines/vn/triggers/zoneWarehouse_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneWarehouse_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`zoneWarehouse_beforeUpdate` BEFORE UPDATE ON `zoneWarehouse` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/zone_afterDelete.sql b/db/routines/vn/triggers/zone_afterDelete.sql index 463fa89e8..036f657e6 100644 --- a/db/routines/vn/triggers/zone_afterDelete.sql +++ b/db/routines/vn/triggers/zone_afterDelete.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zone_afterDelete` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`zone_afterDelete` AFTER DELETE ON `zone` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/zone_beforeInsert.sql b/db/routines/vn/triggers/zone_beforeInsert.sql index e0449a989..c87e548d9 100644 --- a/db/routines/vn/triggers/zone_beforeInsert.sql +++ b/db/routines/vn/triggers/zone_beforeInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zone_beforeInsert` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`zone_beforeInsert` BEFORE INSERT ON `zone` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/zone_beforeUpdate.sql b/db/routines/vn/triggers/zone_beforeUpdate.sql index f945ad32c..fe017ce6a 100644 --- a/db/routines/vn/triggers/zone_beforeUpdate.sql +++ b/db/routines/vn/triggers/zone_beforeUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zone_beforeUpdate` +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`zone_beforeUpdate` BEFORE UPDATE ON `zone` FOR EACH ROW BEGIN diff --git a/db/routines/vn/views/NewView.sql b/db/routines/vn/views/NewView.sql index 389564966..5276456d1 100644 --- a/db/routines/vn/views/NewView.sql +++ b/db/routines/vn/views/NewView.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`NewView` AS SELECT `c`.`id` AS `clientFk`, diff --git a/db/routines/vn/views/agencyTerm.sql b/db/routines/vn/views/agencyTerm.sql index 5f54cf39f..dbd80cad8 100644 --- a/db/routines/vn/views/agencyTerm.sql +++ b/db/routines/vn/views/agencyTerm.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`agencyTerm` AS SELECT `sat`.`agencyFk` AS `agencyFk`, diff --git a/db/routines/vn/views/annualAverageInvoiced.sql b/db/routines/vn/views/annualAverageInvoiced.sql index 30e81e1ec..4c74572d1 100644 --- a/db/routines/vn/views/annualAverageInvoiced.sql +++ b/db/routines/vn/views/annualAverageInvoiced.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`annualAverageInvoiced` AS SELECT `cec`.`clientFk` AS `clientFk`, diff --git a/db/routines/vn/views/awbVolume.sql b/db/routines/vn/views/awbVolume.sql index df3b1ed1a..fd0a12ca2 100644 --- a/db/routines/vn/views/awbVolume.sql +++ b/db/routines/vn/views/awbVolume.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`awbVolume` AS SELECT `t`.`awbFk` AS `awbFk`, diff --git a/db/routines/vn/views/businessCalendar.sql b/db/routines/vn/views/businessCalendar.sql index feda22793..3981a91d2 100644 --- a/db/routines/vn/views/businessCalendar.sql +++ b/db/routines/vn/views/businessCalendar.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`businessCalendar` AS SELECT `c`.`id` AS `id`, diff --git a/db/routines/vn/views/buyer.sql b/db/routines/vn/views/buyer.sql index 7114c50bc..4f668d35d 100644 --- a/db/routines/vn/views/buyer.sql +++ b/db/routines/vn/views/buyer.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`buyer` AS SELECT DISTINCT `u`.`id` AS `userFk`, diff --git a/db/routines/vn/views/buyerSales.sql b/db/routines/vn/views/buyerSales.sql index b67e17569..97c181419 100644 --- a/db/routines/vn/views/buyerSales.sql +++ b/db/routines/vn/views/buyerSales.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`buyerSales` AS SELECT `v`.`importe` AS `importe`, diff --git a/db/routines/vn/views/clientLost.sql b/db/routines/vn/views/clientLost.sql index 764782d08..e445776ce 100644 --- a/db/routines/vn/views/clientLost.sql +++ b/db/routines/vn/views/clientLost.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`clientLost` AS SELECT `c`.`id` AS `clientFk`, diff --git a/db/routines/vn/views/clientPhoneBook.sql b/db/routines/vn/views/clientPhoneBook.sql index 7ab2a99db..6fe2a5a5e 100644 --- a/db/routines/vn/views/clientPhoneBook.sql +++ b/db/routines/vn/views/clientPhoneBook.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`clientPhoneBook` AS SELECT `c`.`id` AS `clientFk`, diff --git a/db/routines/vn/views/companyL10n.sql b/db/routines/vn/views/companyL10n.sql index fa5c4c5d8..20292c4be 100644 --- a/db/routines/vn/views/companyL10n.sql +++ b/db/routines/vn/views/companyL10n.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`companyL10n` AS SELECT `c`.`id` AS `id`, diff --git a/db/routines/vn/views/defaulter.sql b/db/routines/vn/views/defaulter.sql index 9d48978b2..d98d6ccd7 100644 --- a/db/routines/vn/views/defaulter.sql +++ b/db/routines/vn/views/defaulter.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`defaulter` AS SELECT `d`.`clientFk` AS `clientFk`, diff --git a/db/routines/vn/views/departmentTree.sql b/db/routines/vn/views/departmentTree.sql index 6f5a1205a..36a21cb51 100644 --- a/db/routines/vn/views/departmentTree.sql +++ b/db/routines/vn/views/departmentTree.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`departmentTree` AS SELECT `node`.`id` AS `id`, diff --git a/db/routines/vn/views/ediGenus.sql b/db/routines/vn/views/ediGenus.sql index 4546afa33..bb56d54a8 100644 --- a/db/routines/vn/views/ediGenus.sql +++ b/db/routines/vn/views/ediGenus.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`ediGenus` AS SELECT `g`.`genus_id` AS `id`, diff --git a/db/routines/vn/views/ediSpecie.sql b/db/routines/vn/views/ediSpecie.sql index 9587cb530..9d5893aa8 100644 --- a/db/routines/vn/views/ediSpecie.sql +++ b/db/routines/vn/views/ediSpecie.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`ediSpecie` AS SELECT `s`.`specie_id` AS `id`, diff --git a/db/routines/vn/views/ektSubAddress.sql b/db/routines/vn/views/ektSubAddress.sql index 11f6e2e70..6684a9812 100644 --- a/db/routines/vn/views/ektSubAddress.sql +++ b/db/routines/vn/views/ektSubAddress.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`ektSubAddress` AS SELECT `eea`.`sub` AS `sub`, diff --git a/db/routines/vn/views/especialPrice.sql b/db/routines/vn/views/especialPrice.sql index 79d3e1384..a5631544e 100644 --- a/db/routines/vn/views/especialPrice.sql +++ b/db/routines/vn/views/especialPrice.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`especialPrice` AS SELECT `sp`.`id` AS `id`, diff --git a/db/routines/vn/views/exchangeInsuranceEntry.sql b/db/routines/vn/views/exchangeInsuranceEntry.sql index e9c7a7bbe..dc103eed4 100644 --- a/db/routines/vn/views/exchangeInsuranceEntry.sql +++ b/db/routines/vn/views/exchangeInsuranceEntry.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`exchangeInsuranceEntry` AS SELECT max(`tr`.`landed`) AS `dated`, diff --git a/db/routines/vn/views/exchangeInsuranceIn.sql b/db/routines/vn/views/exchangeInsuranceIn.sql index aa27cfb4c..93ca8e2da 100644 --- a/db/routines/vn/views/exchangeInsuranceIn.sql +++ b/db/routines/vn/views/exchangeInsuranceIn.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`exchangeInsuranceIn` AS SELECT `exchangeInsuranceInPrevious`.`dated` AS `dated`, diff --git a/db/routines/vn/views/exchangeInsuranceInPrevious.sql b/db/routines/vn/views/exchangeInsuranceInPrevious.sql index 3f997e8bf..afafe76e3 100644 --- a/db/routines/vn/views/exchangeInsuranceInPrevious.sql +++ b/db/routines/vn/views/exchangeInsuranceInPrevious.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`exchangeInsuranceInPrevious` AS SELECT `ei`.`dueDated` AS `dated`, diff --git a/db/routines/vn/views/exchangeInsuranceOut.sql b/db/routines/vn/views/exchangeInsuranceOut.sql index 5c41dbb24..1975ba594 100644 --- a/db/routines/vn/views/exchangeInsuranceOut.sql +++ b/db/routines/vn/views/exchangeInsuranceOut.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`exchangeInsuranceOut` AS SELECT `p`.`received` AS `received`, diff --git a/db/routines/vn/views/expeditionCommon.sql b/db/routines/vn/views/expeditionCommon.sql index d1ce80880..5687bc348 100644 --- a/db/routines/vn/views/expeditionCommon.sql +++ b/db/routines/vn/views/expeditionCommon.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`expeditionCommon` AS SELECT `rs`.`id` AS `truckFk`, @@ -8,7 +8,7 @@ AS SELECT `rs`.`id` AS `truckFk`, `t`.`routeFk` AS `routeFk`, `es`.`id` AS `scanFk`, `e`.`id` AS `expeditionFk`, - `r`.`expeditionTruckFk` AS `expeditionTruckFk`, + `r`.`roadmapStopFk` AS `roadmapStopFk`, `t`.`warehouseFk` AS `warehouseFk`, `e`.`created` AS `lastPacked`, `t`.`id` AS `ticketFk` @@ -18,7 +18,7 @@ FROM ( ( ( `vn`.`roadmapStop` `rs` - LEFT JOIN `vn`.`routesMonitor` `r` ON(`rs`.`id` = `r`.`expeditionTruckFk`) + LEFT JOIN `vn`.`routesMonitor` `r` ON(`rs`.`id` = `r`.`roadmapStopFk`) ) LEFT JOIN `vn`.`ticket` `t` ON(`r`.`routeFk` = `t`.`routeFk`) ) diff --git a/db/routines/vn/views/expeditionPallet_Print.sql b/db/routines/vn/views/expeditionPallet_Print.sql index c0b8208c3..7b933a0a1 100644 --- a/db/routines/vn/views/expeditionPallet_Print.sql +++ b/db/routines/vn/views/expeditionPallet_Print.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`expeditionPallet_Print` AS SELECT `rs2`.`description` AS `truck`, @@ -6,7 +6,7 @@ AS SELECT `rs2`.`description` AS `truck`, `r`.`description` AS `zone`, COUNT(`es`.`id`) AS `eti`, `ep`.`id` AS `palletFk`, - `rs`.`id` <=> `rm`.`expeditionTruckFk` AS `isMatch`, + `rs`.`id` <=> `rm`.`roadmapStopFk` AS `isMatch`, `t`.`warehouseFk` AS `warehouseFk`, IF( `r`.`created` > `util`.`VN_CURDATE`() + INTERVAL 1 DAY, @@ -33,7 +33,7 @@ FROM ( ) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`rm`.`routeFk` = `r`.`id`) ) - LEFT JOIN `vn`.`roadmapStop` `rs2` ON(`rs2`.`id` = `rm`.`expeditionTruckFk`) + LEFT JOIN `vn`.`roadmapStop` `rs2` ON(`rs2`.`id` = `rm`.`roadmapStopFk`) ) GROUP BY `ep`.`id`, `t`.`routeFk` diff --git a/db/routines/vn/views/expeditionRoute_Monitor.sql b/db/routines/vn/views/expeditionRoute_Monitor.sql index cc1f16894..9b46c8237 100644 --- a/db/routines/vn/views/expeditionRoute_Monitor.sql +++ b/db/routines/vn/views/expeditionRoute_Monitor.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`expeditionRoute_Monitor` AS SELECT `r`.`id` AS `routeFk`, @@ -15,7 +15,7 @@ FROM ( `vn`.`route` `r` LEFT JOIN `vn`.`routesMonitor` `rm` ON(`r`.`id` = `rm`.`routeFk`) ) - LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`expeditionTruckFk`) + LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`roadmapStopFk`) ) JOIN `vn`.`ticket` `t` ON(`t`.`routeFk` = `r`.`id`) ) diff --git a/db/routines/vn/views/expeditionRoute_freeTickets.sql b/db/routines/vn/views/expeditionRoute_freeTickets.sql index 85e6297c9..d49cee22e 100644 --- a/db/routines/vn/views/expeditionRoute_freeTickets.sql +++ b/db/routines/vn/views/expeditionRoute_freeTickets.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`expeditionRoute_freeTickets` AS SELECT `t`.`routeFk` AS `routeFk`, diff --git a/db/routines/vn/views/expeditionScan_Monitor.sql b/db/routines/vn/views/expeditionScan_Monitor.sql index 94bda1863..6d2e855de 100644 --- a/db/routines/vn/views/expeditionScan_Monitor.sql +++ b/db/routines/vn/views/expeditionScan_Monitor.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`expeditionScan_Monitor` AS SELECT `rs`.`id` AS `truckFk`, diff --git a/db/routines/vn/views/expeditionSticker.sql b/db/routines/vn/views/expeditionSticker.sql index 05fbc42a1..f9855d764 100644 --- a/db/routines/vn/views/expeditionSticker.sql +++ b/db/routines/vn/views/expeditionSticker.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`expeditionSticker` AS SELECT `e`.`id` AS `expeditionFk`, @@ -45,7 +45,7 @@ FROM ( ) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`rm`.`routeFk` = `t`.`routeFk`) ) - LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`expeditionTruckFk`) + LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`roadmapStopFk`) ) LEFT JOIN `vn`.`beach` `b` ON(`b`.`code` = `rm`.`beachFk`) ) diff --git a/db/routines/vn/views/expeditionTicket_NoBoxes.sql b/db/routines/vn/views/expeditionTicket_NoBoxes.sql index 8acbe17fe..be3619b21 100644 --- a/db/routines/vn/views/expeditionTicket_NoBoxes.sql +++ b/db/routines/vn/views/expeditionTicket_NoBoxes.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`expeditionTicket_NoBoxes` AS SELECT `t`.`id` AS `ticketFk`, @@ -13,7 +13,7 @@ FROM ( ) JOIN `vn`.`routesMonitor` `rm` ON(`rm`.`routeFk` = `t`.`routeFk`) ) - JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`expeditionTruckFk`) + JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`roadmapStopFk`) ) WHERE `e`.`id` IS NULL AND `rs`.`eta` > `util`.`VN_CURDATE`() diff --git a/db/routines/vn/views/expeditionTimeExpended.sql b/db/routines/vn/views/expeditionTimeExpended.sql index 65aeb72b2..3666f51d9 100644 --- a/db/routines/vn/views/expeditionTimeExpended.sql +++ b/db/routines/vn/views/expeditionTimeExpended.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`expeditionTimeExpended` AS SELECT `e`.`ticketFk` AS `ticketFk`, diff --git a/db/routines/vn/views/expeditionTruck.sql b/db/routines/vn/views/expeditionTruck.sql new file mode 100644 index 000000000..a5e0cf350 --- /dev/null +++ b/db/routines/vn/views/expeditionTruck.sql @@ -0,0 +1,11 @@ +CREATE OR REPLACE DEFINER=`vn`@`localhost` + SQL SECURITY DEFINER + VIEW `vn`.`expeditionTruck` +AS SELECT `rs`.`id` AS `id`, + `rs`.`roadmapFk` AS `roadmapFk`, + `rs`.`eta` AS `eta`, + `rs`.`description` AS `description`, + `rs`.`bufferFk` AS `bufferFk`, + `rs`.`created` AS `created`, + `rs`.`userFk` AS `userFk` +FROM `vn`.`roadmapStop` `rs`; diff --git a/db/routines/vn/views/expeditionTruck_Control.sql b/db/routines/vn/views/expeditionTruck_Control.sql deleted file mode 100644 index 838e1f89e..000000000 --- a/db/routines/vn/views/expeditionTruck_Control.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`expeditionTruck_Control` -AS SELECT `e`.`truckFk` AS `id`, - `e`.`eta` AS `ETD`, - `e`.`description` AS `description`, - COUNT( - DISTINCT IF(`e`.`expeditionFk` IS NULL, `e`.`ticketFk`, NULL) - ) AS `ticketsSinBultos`, - COUNT(DISTINCT `e`.`palletFk`) AS `pallets`, - COUNT(DISTINCT `e`.`routeFk`) AS `routes`, - COUNT(DISTINCT `e`.`scanFk`) AS `scans`, - COUNT(DISTINCT `e`.`expeditionFk`) AS `expeditions`, - sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, - max(`e`.`lastPacked`) AS `lastPacked` -FROM `vn`.`expeditionCommon` `e` -GROUP BY `e`.`truckFk` -ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, - `e`.`eta` diff --git a/db/routines/vn/views/expeditionTruck_Control_Detail.sql b/db/routines/vn/views/expeditionTruck_Control_Detail.sql deleted file mode 100644 index 96a5b78e6..000000000 --- a/db/routines/vn/views/expeditionTruck_Control_Detail.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`expeditionTruck_Control_Detail` -AS SELECT `e`.`truckFk` AS `id`, - `e`.`eta` AS `eta`, - `e`.`description` AS `destino`, - `e`.`palletFk` AS `pallet`, - COUNT(DISTINCT `e`.`routeFk`) AS `routes`, - COUNT(DISTINCT `e`.`scanFk`) AS `scans`, - COUNT(DISTINCT `e`.`expeditionTruckFk`) AS `destinos`, - sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, - max(`e`.`lastPacked`) AS `lastPacked` -FROM `vn`.`expeditionCommon` `e` -GROUP BY `e`.`truckFk`, - `e`.`palletFk` -ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, - `e`.`eta`, - `e`.`truckFk` diff --git a/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql b/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql deleted file mode 100644 index 3f239432d..000000000 --- a/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`expeditionTruck_Control_Detail_Pallet` -AS SELECT `e`.`truckFk` AS `id`, - `e`.`eta` AS `eta`, - `e`.`description` AS `destino`, - `e`.`palletFk` AS `pallet`, - `e`.`routeFk` AS `route`, - COUNT(DISTINCT `e`.`scanFk`) AS `scans`, - `rs`.`description` AS `destinos`, - sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, - `e`.`expeditionTruckFk` AS `expeditionTruckFk`, - max(`e`.`lastPacked`) AS `lastPacked` -FROM ( - `vn`.`expeditionCommon` `e` - LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `e`.`expeditionTruckFk`) - ) -GROUP BY `e`.`truckFk`, - `e`.`palletFk`, - `e`.`routeFk` -ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, - `e`.`palletFk` diff --git a/db/routines/vn/views/firstTicketShipped.sql b/db/routines/vn/views/firstTicketShipped.sql index c01a17976..c2e9f55e6 100644 --- a/db/routines/vn/views/firstTicketShipped.sql +++ b/db/routines/vn/views/firstTicketShipped.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`firstTicketShipped` AS SELECT min(`vn`.`ticket`.`shipped`) AS `shipped`, diff --git a/db/routines/vn/views/floraHollandBuyedItems.sql b/db/routines/vn/views/floraHollandBuyedItems.sql index b695c49fd..b8699a889 100644 --- a/db/routines/vn/views/floraHollandBuyedItems.sql +++ b/db/routines/vn/views/floraHollandBuyedItems.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`floraHollandBuyedItems` AS SELECT `b`.`itemFk` AS `itemFk`, diff --git a/db/routines/vn/views/inkL10n.sql b/db/routines/vn/views/inkL10n.sql index 14958ff0a..dfe449d96 100644 --- a/db/routines/vn/views/inkL10n.sql +++ b/db/routines/vn/views/inkL10n.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`inkL10n` AS SELECT `k`.`id` AS `id`, diff --git a/db/routines/vn/views/invoiceCorrectionDataSource.sql b/db/routines/vn/views/invoiceCorrectionDataSource.sql index d401c20f1..34dc39d85 100644 --- a/db/routines/vn/views/invoiceCorrectionDataSource.sql +++ b/db/routines/vn/views/invoiceCorrectionDataSource.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`invoiceCorrectionDataSource` AS SELECT `s`.`itemFk` AS `itemFk`, diff --git a/db/routines/vn/views/itemBotanicalWithGenus.sql b/db/routines/vn/views/itemBotanicalWithGenus.sql index 3bc0b943d..fda6e6cc4 100644 --- a/db/routines/vn/views/itemBotanicalWithGenus.sql +++ b/db/routines/vn/views/itemBotanicalWithGenus.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemBotanicalWithGenus` AS SELECT `ib`.`itemFk` AS `itemFk`, diff --git a/db/routines/vn/views/itemCategoryL10n.sql b/db/routines/vn/views/itemCategoryL10n.sql index 08a7c7321..8d47ca662 100644 --- a/db/routines/vn/views/itemCategoryL10n.sql +++ b/db/routines/vn/views/itemCategoryL10n.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemCategoryL10n` AS SELECT `c`.`id` AS `id`, diff --git a/db/routines/vn/views/itemColor.sql b/db/routines/vn/views/itemColor.sql index 5ab8a4c4f..f2c3f87e0 100644 --- a/db/routines/vn/views/itemColor.sql +++ b/db/routines/vn/views/itemColor.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemColor` AS SELECT `it`.`itemFk` AS `itemFk`, diff --git a/db/routines/vn/views/itemEntryIn.sql b/db/routines/vn/views/itemEntryIn.sql index 184ccbf59..4f7855d2b 100644 --- a/db/routines/vn/views/itemEntryIn.sql +++ b/db/routines/vn/views/itemEntryIn.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemEntryIn` AS SELECT `t`.`warehouseInFk` AS `warehouseInFk`, diff --git a/db/routines/vn/views/itemEntryOut.sql b/db/routines/vn/views/itemEntryOut.sql index 82b065985..1e8718c53 100644 --- a/db/routines/vn/views/itemEntryOut.sql +++ b/db/routines/vn/views/itemEntryOut.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemEntryOut` AS SELECT `t`.`warehouseOutFk` AS `warehouseOutFk`, diff --git a/db/routines/vn/views/itemInk.sql b/db/routines/vn/views/itemInk.sql index d13a862e7..6a5a10388 100644 --- a/db/routines/vn/views/itemInk.sql +++ b/db/routines/vn/views/itemInk.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemInk` AS SELECT `i`.`longName` AS `longName`, diff --git a/db/routines/vn/views/itemPlacementSupplyList.sql b/db/routines/vn/views/itemPlacementSupplyList.sql index 10e7ae3ef..d8d3cc705 100644 --- a/db/routines/vn/views/itemPlacementSupplyList.sql +++ b/db/routines/vn/views/itemPlacementSupplyList.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemPlacementSupplyList` AS SELECT `ips`.`id` AS `id`, diff --git a/db/routines/vn/views/itemProductor.sql b/db/routines/vn/views/itemProductor.sql index f6cb0eb19..8d7833489 100644 --- a/db/routines/vn/views/itemProductor.sql +++ b/db/routines/vn/views/itemProductor.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemProductor` AS SELECT `it`.`itemFk` AS `itemFk`, diff --git a/db/routines/vn/views/itemSearch.sql b/db/routines/vn/views/itemSearch.sql index 6a21b9e92..0b51b7397 100644 --- a/db/routines/vn/views/itemSearch.sql +++ b/db/routines/vn/views/itemSearch.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemSearch` AS SELECT `s`.`itemFk` AS `itemFk`, diff --git a/db/routines/vn/views/itemShelvingAvailable.sql b/db/routines/vn/views/itemShelvingAvailable.sql index 868d6a963..15083e6cc 100644 --- a/db/routines/vn/views/itemShelvingAvailable.sql +++ b/db/routines/vn/views/itemShelvingAvailable.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemShelvingAvailable` AS SELECT `s`.`id` AS `saleFk`, @@ -10,7 +10,6 @@ AS SELECT `s`.`id` AS `saleFk`, `s`.`concept` AS `concept`, `i`.`size` AS `size`, `st`.`name` AS `Estado`, - `st`.`sectorProdPriority` AS `sectorProdPriority`, `stock`.`visible` AS `available`, `stock`.`sectorFk` AS `sectorFk`, `stock`.`shelvingFk` AS `matricula`, diff --git a/db/routines/vn/views/itemShelvingList.sql b/db/routines/vn/views/itemShelvingList.sql index 570bf0be6..457d6f28a 100644 --- a/db/routines/vn/views/itemShelvingList.sql +++ b/db/routines/vn/views/itemShelvingList.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemShelvingList` AS SELECT `ish`.`shelvingFk` AS `shelvingFk`, diff --git a/db/routines/vn/views/itemShelvingPlacementSupplyStock.sql b/db/routines/vn/views/itemShelvingPlacementSupplyStock.sql index 217aaf6ac..fa1c11314 100644 --- a/db/routines/vn/views/itemShelvingPlacementSupplyStock.sql +++ b/db/routines/vn/views/itemShelvingPlacementSupplyStock.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemShelvingPlacementSupplyStock` AS SELECT `ish`.`id` AS `itemShelvingFk`, diff --git a/db/routines/vn/views/itemShelvingSaleSum.sql b/db/routines/vn/views/itemShelvingSaleSum.sql index 566e20a69..9a402d6f4 100644 --- a/db/routines/vn/views/itemShelvingSaleSum.sql +++ b/db/routines/vn/views/itemShelvingSaleSum.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemShelvingSaleSum` AS SELECT `iss`.`id` AS `id`, diff --git a/db/routines/vn/views/itemShelvingStock.sql b/db/routines/vn/views/itemShelvingStock.sql index e0825eae5..41777eaec 100644 --- a/db/routines/vn/views/itemShelvingStock.sql +++ b/db/routines/vn/views/itemShelvingStock.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemShelvingStock` AS SELECT `ish`.`itemFk` AS `itemFk`, diff --git a/db/routines/vn/views/itemShelvingStockFull.sql b/db/routines/vn/views/itemShelvingStockFull.sql index 71ce5ed79..c767823d6 100644 --- a/db/routines/vn/views/itemShelvingStockFull.sql +++ b/db/routines/vn/views/itemShelvingStockFull.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemShelvingStockFull` AS SELECT `ish`.`itemFk` AS `itemFk`, diff --git a/db/routines/vn/views/itemShelvingStockRemoved.sql b/db/routines/vn/views/itemShelvingStockRemoved.sql index fb201e0f1..7baf3a6c6 100644 --- a/db/routines/vn/views/itemShelvingStockRemoved.sql +++ b/db/routines/vn/views/itemShelvingStockRemoved.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemShelvingStockRemoved` AS SELECT `ish`.`id` AS `itemShelvingFk`, diff --git a/db/routines/vn/views/itemTagged.sql b/db/routines/vn/views/itemTagged.sql index c22354bda..db7460fcc 100644 --- a/db/routines/vn/views/itemTagged.sql +++ b/db/routines/vn/views/itemTagged.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemTagged` AS SELECT DISTINCT `vn`.`itemTag`.`itemFk` AS `itemFk` diff --git a/db/routines/vn/views/itemTaxCountrySpain.sql b/db/routines/vn/views/itemTaxCountrySpain.sql index 9dfaf0b41..992535bdc 100644 --- a/db/routines/vn/views/itemTaxCountrySpain.sql +++ b/db/routines/vn/views/itemTaxCountrySpain.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemTaxCountrySpain` AS SELECT `i`.`id` AS `id`, diff --git a/db/routines/vn/views/itemTicketOut.sql b/db/routines/vn/views/itemTicketOut.sql index d9bbd54bd..7a5e17d76 100644 --- a/db/routines/vn/views/itemTicketOut.sql +++ b/db/routines/vn/views/itemTicketOut.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemTicketOut` AS SELECT `t`.`warehouseFk` AS `warehouseFk`, diff --git a/db/routines/vn/views/itemTypeL10n.sql b/db/routines/vn/views/itemTypeL10n.sql index 03d72f0d4..66ef9ac90 100644 --- a/db/routines/vn/views/itemTypeL10n.sql +++ b/db/routines/vn/views/itemTypeL10n.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`itemTypeL10n` AS SELECT `t`.`id` AS `id`, diff --git a/db/routines/vn/views/item_Free_Id.sql b/db/routines/vn/views/item_Free_Id.sql index 36464004c..d148a18e6 100644 --- a/db/routines/vn/views/item_Free_Id.sql +++ b/db/routines/vn/views/item_Free_Id.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`item_Free_Id` AS SELECT `i1`.`id` + 1 AS `newId` diff --git a/db/routines/vn/views/labelInfo.sql b/db/routines/vn/views/labelInfo.sql index ccc6fc6ac..eef0145fb 100644 --- a/db/routines/vn/views/labelInfo.sql +++ b/db/routines/vn/views/labelInfo.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`labelInfo` AS SELECT `i`.`id` AS `itemId`, diff --git a/db/routines/vn/views/lastHourProduction.sql b/db/routines/vn/views/lastHourProduction.sql index 90bc0cd76..e0b66481d 100644 --- a/db/routines/vn/views/lastHourProduction.sql +++ b/db/routines/vn/views/lastHourProduction.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`lastHourProduction` AS SELECT `t`.`warehouseFk` AS `warehouseFk`, diff --git a/db/routines/vn/views/lastPurchases.sql b/db/routines/vn/views/lastPurchases.sql index 04a9f8c05..3099acd00 100644 --- a/db/routines/vn/views/lastPurchases.sql +++ b/db/routines/vn/views/lastPurchases.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`lastPurchases` AS SELECT `tr`.`landed` AS `landed`, diff --git a/db/routines/vn/views/lastTopClaims.sql b/db/routines/vn/views/lastTopClaims.sql index 0bc36e3c2..93dbc4b45 100644 --- a/db/routines/vn/views/lastTopClaims.sql +++ b/db/routines/vn/views/lastTopClaims.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`lastTopClaims` AS SELECT `s`.`itemFk` AS `itemFk`, diff --git a/db/routines/vn/views/mistake.sql b/db/routines/vn/views/mistake.sql index 0ed4dccf2..ca9223c3b 100644 --- a/db/routines/vn/views/mistake.sql +++ b/db/routines/vn/views/mistake.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`mistake` AS SELECT `wr`.`code` AS `revisador`, diff --git a/db/routines/vn/views/mistakeRatio.sql b/db/routines/vn/views/mistakeRatio.sql index 4b7fd5a1f..0aa80a966 100644 --- a/db/routines/vn/views/mistakeRatio.sql +++ b/db/routines/vn/views/mistakeRatio.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`mistakeRatio` AS SELECT `wr`.`code` AS `revisador`, diff --git a/db/routines/vn/views/newBornSales.sql b/db/routines/vn/views/newBornSales.sql index d34eff4ef..b4aac208c 100644 --- a/db/routines/vn/views/newBornSales.sql +++ b/db/routines/vn/views/newBornSales.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`newBornSales` AS SELECT `v`.`importe` AS `amount`, diff --git a/db/routines/vn/views/operatorWorkerCode.sql b/db/routines/vn/views/operatorWorkerCode.sql index 340d833a7..343f74254 100644 --- a/db/routines/vn/views/operatorWorkerCode.sql +++ b/db/routines/vn/views/operatorWorkerCode.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`operatorWorkerCode` AS SELECT `o`.`workerFk` AS `workerFk`, diff --git a/db/routines/vn/views/originL10n.sql b/db/routines/vn/views/originL10n.sql index 2ff368e14..ffceccd50 100644 --- a/db/routines/vn/views/originL10n.sql +++ b/db/routines/vn/views/originL10n.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`originL10n` AS SELECT `o`.`id` AS `id`, diff --git a/db/routines/vn/views/packageEquivalentItem.sql b/db/routines/vn/views/packageEquivalentItem.sql index ba2897c14..767fa326e 100644 --- a/db/routines/vn/views/packageEquivalentItem.sql +++ b/db/routines/vn/views/packageEquivalentItem.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`packageEquivalentItem` AS SELECT `p`.`itemFk` AS `itemFk`, diff --git a/db/routines/vn/views/paymentExchangeInsurance.sql b/db/routines/vn/views/paymentExchangeInsurance.sql index f3e07eaaf..c5800e48b 100644 --- a/db/routines/vn/views/paymentExchangeInsurance.sql +++ b/db/routines/vn/views/paymentExchangeInsurance.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`paymentExchangeInsurance` AS SELECT `ei`.`id` AS `pago_sdc_id`, diff --git a/db/routines/vn/views/payrollCenter.sql b/db/routines/vn/views/payrollCenter.sql index dfe7e4728..f06dc702f 100644 --- a/db/routines/vn/views/payrollCenter.sql +++ b/db/routines/vn/views/payrollCenter.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`payrollCenter` AS SELECT `b`.`workCenterFkA3` AS `codCenter`, diff --git a/db/routines/vn/views/personMedia.sql b/db/routines/vn/views/personMedia.sql index d17410ef1..367f67c8e 100644 --- a/db/routines/vn/views/personMedia.sql +++ b/db/routines/vn/views/personMedia.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`personMedia` AS SELECT `c`.`id` AS `workerFk`, diff --git a/db/routines/vn/views/phoneBook.sql b/db/routines/vn/views/phoneBook.sql index 5fcafe99c..c51b912aa 100644 --- a/db/routines/vn/views/phoneBook.sql +++ b/db/routines/vn/views/phoneBook.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`phoneBook` AS SELECT 'C' AS `Tipo`, diff --git a/db/routines/vn/views/productionVolume.sql b/db/routines/vn/views/productionVolume.sql index fd83b96bc..14cf5518b 100644 --- a/db/routines/vn/views/productionVolume.sql +++ b/db/routines/vn/views/productionVolume.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`productionVolume` AS SELECT HOUR(`e`.`created`) AS `hora`, diff --git a/db/routines/vn/views/productionVolume_LastHour.sql b/db/routines/vn/views/productionVolume_LastHour.sql index 561a23f9b..bafb5a67a 100644 --- a/db/routines/vn/views/productionVolume_LastHour.sql +++ b/db/routines/vn/views/productionVolume_LastHour.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`productionVolume_LastHour` AS SELECT cast( diff --git a/db/routines/vn/views/role.sql b/db/routines/vn/views/role.sql index 310951570..db2fa109e 100644 --- a/db/routines/vn/views/role.sql +++ b/db/routines/vn/views/role.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`role` AS SELECT `account`.`role`.`id` AS `id`, diff --git a/db/routines/vn/views/routesControl.sql b/db/routines/vn/views/routesControl.sql index 282dd21e3..9f9e23da1 100644 --- a/db/routines/vn/views/routesControl.sql +++ b/db/routines/vn/views/routesControl.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`routesControl` AS SELECT `t`.`routeFk` AS `routeFk`, diff --git a/db/routines/vn/views/saleCost.sql b/db/routines/vn/views/saleCost.sql index 27265aa93..27f492abd 100644 --- a/db/routines/vn/views/saleCost.sql +++ b/db/routines/vn/views/saleCost.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`saleCost` AS SELECT `s`.`itemFk` AS `itemFk`, @@ -19,4 +19,4 @@ FROM ( ) JOIN `vn`.`componentType` `ct` ON(`ct`.`id` = `c`.`typeFk`) ) -WHERE `ct`.`type` = 'coste' +WHERE `ct`.`code` = 'cost' diff --git a/db/routines/vn/views/saleMistakeList.sql b/db/routines/vn/views/saleMistakeList.sql index d362e0d97..0cad951fe 100644 --- a/db/routines/vn/views/saleMistakeList.sql +++ b/db/routines/vn/views/saleMistakeList.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`saleMistakeList` AS SELECT `st`.`saleFk` AS `saleFk`, diff --git a/db/routines/vn/views/saleMistake_list__2.sql b/db/routines/vn/views/saleMistake_list__2.sql index 1f40a89d9..e65761c75 100644 --- a/db/routines/vn/views/saleMistake_list__2.sql +++ b/db/routines/vn/views/saleMistake_list__2.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`saleMistake_list__2` AS SELECT `st`.`saleFk` AS `saleFk`, diff --git a/db/routines/vn/views/saleSaleTracking.sql b/db/routines/vn/views/saleSaleTracking.sql index 9ada798cf..7e6531a01 100644 --- a/db/routines/vn/views/saleSaleTracking.sql +++ b/db/routines/vn/views/saleSaleTracking.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`saleSaleTracking` AS SELECT DISTINCT `st`.`saleFk` AS `saleFk` diff --git a/db/routines/vn/views/saleValue.sql b/db/routines/vn/views/saleValue.sql index 2dee4695e..84741990f 100644 --- a/db/routines/vn/views/saleValue.sql +++ b/db/routines/vn/views/saleValue.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`saleValue` AS SELECT `wh`.`name` AS `warehouse`, diff --git a/db/routines/vn/views/saleVolume.sql b/db/routines/vn/views/saleVolume.sql index ffc6714c6..a1a1b2925 100644 --- a/db/routines/vn/views/saleVolume.sql +++ b/db/routines/vn/views/saleVolume.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`saleVolume` AS SELECT `s`.`ticketFk` AS `ticketFk`, diff --git a/db/routines/vn/views/saleVolume_Today_VNH.sql b/db/routines/vn/views/saleVolume_Today_VNH.sql index c36779146..f81253a76 100644 --- a/db/routines/vn/views/saleVolume_Today_VNH.sql +++ b/db/routines/vn/views/saleVolume_Today_VNH.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`saleVolume_Today_VNH` AS SELECT `t`.`nickname` AS `Cliente`, diff --git a/db/routines/vn/views/sale_freightComponent.sql b/db/routines/vn/views/sale_freightComponent.sql index 7a329e0ee..a76a8666c 100644 --- a/db/routines/vn/views/sale_freightComponent.sql +++ b/db/routines/vn/views/sale_freightComponent.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`sale_freightComponent` AS SELECT `t`.`id` AS `ticketFk`, @@ -16,6 +16,6 @@ FROM ( ) JOIN `vn`.`componentType` `ct` ON( `ct`.`id` = `c`.`typeFk` - AND `ct`.`type` = 'agencia' + AND `ct`.`code` = 'freight' ) ) diff --git a/db/routines/vn/views/salesPersonSince.sql b/db/routines/vn/views/salesPersonSince.sql index 4234ecac4..0e1646f1b 100644 --- a/db/routines/vn/views/salesPersonSince.sql +++ b/db/routines/vn/views/salesPersonSince.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`salesPersonSince` AS SELECT `b`.`workerFk` AS `workerFk`, diff --git a/db/routines/vn/views/salesPreparedLastHour.sql b/db/routines/vn/views/salesPreparedLastHour.sql index caa7866cb..33e86b29c 100644 --- a/db/routines/vn/views/salesPreparedLastHour.sql +++ b/db/routines/vn/views/salesPreparedLastHour.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`salesPreparedLastHour` AS SELECT `t`.`warehouseFk` AS `warehouseFk`, diff --git a/db/routines/vn/views/salesPreviousPreparated.sql b/db/routines/vn/views/salesPreviousPreparated.sql index 40ae29eda..bd55862c9 100644 --- a/db/routines/vn/views/salesPreviousPreparated.sql +++ b/db/routines/vn/views/salesPreviousPreparated.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`salesPreviousPreparated` AS SELECT `st`.`saleFk` AS `saleFk` diff --git a/db/routines/vn/views/supplierPackaging.sql b/db/routines/vn/views/supplierPackaging.sql index 45a9d46d3..01c9c69e7 100644 --- a/db/routines/vn/views/supplierPackaging.sql +++ b/db/routines/vn/views/supplierPackaging.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`supplierPackaging` AS SELECT `e`.`supplierFk` AS `supplierFk`, diff --git a/db/routines/vn/views/tagL10n.sql b/db/routines/vn/views/tagL10n.sql index 982122b13..68ed9541c 100644 --- a/db/routines/vn/views/tagL10n.sql +++ b/db/routines/vn/views/tagL10n.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`tagL10n` AS SELECT `t`.`id` AS `id`, diff --git a/db/routines/vn/views/ticketDownBuffer.sql b/db/routines/vn/views/ticketDownBuffer.sql index 4d157f20c..e951de9e0 100644 --- a/db/routines/vn/views/ticketDownBuffer.sql +++ b/db/routines/vn/views/ticketDownBuffer.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`ticketDownBuffer` AS SELECT `td`.`ticketFk` AS `ticketFk`, diff --git a/db/routines/vn/views/ticketLastUpdated.sql b/db/routines/vn/views/ticketLastUpdated.sql index 96b6eaa17..8a6a66c8e 100644 --- a/db/routines/vn/views/ticketLastUpdated.sql +++ b/db/routines/vn/views/ticketLastUpdated.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`ticketLastUpdated` AS SELECT `ticketLastUpdatedList`.`ticketFk` AS `ticketFk`, diff --git a/db/routines/vn/views/ticketLastUpdatedList.sql b/db/routines/vn/views/ticketLastUpdatedList.sql index bfc769e47..5d087a596 100644 --- a/db/routines/vn/views/ticketLastUpdatedList.sql +++ b/db/routines/vn/views/ticketLastUpdatedList.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`ticketLastUpdatedList` AS SELECT `s`.`ticketFk` AS `ticketFk`, diff --git a/db/routines/vn/views/ticketNotInvoiced.sql b/db/routines/vn/views/ticketNotInvoiced.sql index c35b414ce..f966bf85d 100644 --- a/db/routines/vn/views/ticketNotInvoiced.sql +++ b/db/routines/vn/views/ticketNotInvoiced.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`ticketNotInvoiced` AS SELECT `t`.`companyFk` AS `companyFk`, diff --git a/db/routines/vn/views/ticketPackingList.sql b/db/routines/vn/views/ticketPackingList.sql index bafe3c00c..c185bb7c0 100644 --- a/db/routines/vn/views/ticketPackingList.sql +++ b/db/routines/vn/views/ticketPackingList.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`ticketPackingList` AS SELECT `t`.`nickname` AS `nickname`, diff --git a/db/routines/vn/views/ticketPreviousPreparingList.sql b/db/routines/vn/views/ticketPreviousPreparingList.sql index 9c84b8af3..4e19c0bb8 100644 --- a/db/routines/vn/views/ticketPreviousPreparingList.sql +++ b/db/routines/vn/views/ticketPreviousPreparingList.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`ticketPreviousPreparingList` AS SELECT `s`.`ticketFk` AS `ticketFk`, @@ -20,7 +20,7 @@ FROM ( `vn`.`saleGroup` `sg` JOIN `vn`.`saleGroupDetail` `sgd` ON(`sgd`.`saleGroupFk` = `sg`.`id`) ) - JOIN `vn`.`sale` `s` ON(`s`.`id` = `sgd`.`saleFk`) + JOIN `vn`.`sale` `s` FORCE INDEX (PRIMARY) ON(`s`.`id` = `sgd`.`saleFk`) ) JOIN `vn`.`ticketState` `tls` ON(`tls`.`ticketFk` = `s`.`ticketFk`) ) diff --git a/db/routines/vn/views/ticketState.sql b/db/routines/vn/views/ticketState.sql index 118a58b34..588c5c61a 100644 --- a/db/routines/vn/views/ticketState.sql +++ b/db/routines/vn/views/ticketState.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`ticketState` AS SELECT `tt`.`created` AS `updated`, diff --git a/db/routines/vn/views/ticketStateToday.sql b/db/routines/vn/views/ticketStateToday.sql index 1f10aceb1..8c11fcc87 100644 --- a/db/routines/vn/views/ticketStateToday.sql +++ b/db/routines/vn/views/ticketStateToday.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`ticketStateToday` AS SELECT `ts`.`ticketFk` AS `ticketFk`, @@ -13,4 +13,4 @@ FROM ( `vn`.`ticketState` `ts` JOIN `vn`.`ticket` `t` ON(`t`.`id` = `ts`.`ticketFk`) ) -WHERE `t`.`shipped` BETWEEN `util`.`VN_CURDATE`() AND `MIDNIGHT`(`util`.`VN_CURDATE`()) +WHERE `t`.`shipped` BETWEEN `util`.`VN_CURDATE`() AND `util`.`midnight`() diff --git a/db/routines/vn/views/tr2.sql b/db/routines/vn/views/tr2.sql index 5abc2bfa8..525554f04 100644 --- a/db/routines/vn/views/tr2.sql +++ b/db/routines/vn/views/tr2.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`tr2` AS SELECT `vn`.`travel`.`id` AS `id`, diff --git a/db/routines/vn/views/traceabilityBuy.sql b/db/routines/vn/views/traceabilityBuy.sql index 0257c2f5d..8189a8b0e 100644 --- a/db/routines/vn/views/traceabilityBuy.sql +++ b/db/routines/vn/views/traceabilityBuy.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`traceabilityBuy` AS SELECT `b`.`id` AS `buyFk`, diff --git a/db/routines/vn/views/traceabilitySale.sql b/db/routines/vn/views/traceabilitySale.sql index 9caf11d5e..a251e11d5 100644 --- a/db/routines/vn/views/traceabilitySale.sql +++ b/db/routines/vn/views/traceabilitySale.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`traceabilitySale` AS SELECT `s`.`ticketFk` AS `ticketFk`, diff --git a/db/routines/vn/views/workerBusinessDated.sql b/db/routines/vn/views/workerBusinessDated.sql index 83d6eb48c..783c18ffd 100644 --- a/db/routines/vn/views/workerBusinessDated.sql +++ b/db/routines/vn/views/workerBusinessDated.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`workerBusinessDated` AS SELECT `t`.`dated` AS `dated`, diff --git a/db/routines/vn/views/workerDepartment.sql b/db/routines/vn/views/workerDepartment.sql index 4be3122da..e4f3bbe90 100644 --- a/db/routines/vn/views/workerDepartment.sql +++ b/db/routines/vn/views/workerDepartment.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`workerDepartment` AS SELECT `b`.`workerFk` AS `workerFk`, diff --git a/db/routines/vn/views/workerLabour.sql b/db/routines/vn/views/workerLabour.sql index 2f4067c2d..633d95c4a 100644 --- a/db/routines/vn/views/workerLabour.sql +++ b/db/routines/vn/views/workerLabour.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`workerLabour` AS SELECT `b`.`id` AS `businessFk`, diff --git a/db/routines/vn/views/workerMedia.sql b/db/routines/vn/views/workerMedia.sql index 72ee04299..bc6961422 100644 --- a/db/routines/vn/views/workerMedia.sql +++ b/db/routines/vn/views/workerMedia.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`workerMedia` AS SELECT `w`.`id` AS `workerFk`, diff --git a/db/routines/vn/views/workerSpeedExpedition.sql b/db/routines/vn/views/workerSpeedExpedition.sql index db13cf16a..0bbd250b3 100644 --- a/db/routines/vn/views/workerSpeedExpedition.sql +++ b/db/routines/vn/views/workerSpeedExpedition.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`workerSpeedExpedition` AS SELECT `sv`.`ticketFk` AS `ticketFk`, diff --git a/db/routines/vn/views/workerSpeedSaleTracking.sql b/db/routines/vn/views/workerSpeedSaleTracking.sql index 21f07ea8a..d426af3a5 100644 --- a/db/routines/vn/views/workerSpeedSaleTracking.sql +++ b/db/routines/vn/views/workerSpeedSaleTracking.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`workerSpeedSaleTracking` AS SELECT `salesPreparedLastHour`.`warehouseFk` AS `warehouseFk`, diff --git a/db/routines/vn/views/workerTeamCollegues.sql b/db/routines/vn/views/workerTeamCollegues.sql index dbe245a16..c43bb6a4a 100644 --- a/db/routines/vn/views/workerTeamCollegues.sql +++ b/db/routines/vn/views/workerTeamCollegues.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`workerTeamCollegues` AS SELECT DISTINCT `w`.`workerFk` AS `workerFk`, diff --git a/db/routines/vn/views/workerTimeControlUserInfo.sql b/db/routines/vn/views/workerTimeControlUserInfo.sql index eea8ffd7c..5d122fc09 100644 --- a/db/routines/vn/views/workerTimeControlUserInfo.sql +++ b/db/routines/vn/views/workerTimeControlUserInfo.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`workerTimeControlUserInfo` AS SELECT `u`.`id` AS `userFk`, diff --git a/db/routines/vn/views/workerTimeJourneyNG.sql b/db/routines/vn/views/workerTimeJourneyNG.sql index b45b855b7..e55062e64 100644 --- a/db/routines/vn/views/workerTimeJourneyNG.sql +++ b/db/routines/vn/views/workerTimeJourneyNG.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`workerTimeJourneyNG` AS SELECT `wtc`.`userFk` AS `userFk`, diff --git a/db/routines/vn/views/workerWithoutTractor.sql b/db/routines/vn/views/workerWithoutTractor.sql index e0c0978a5..205c66599 100644 --- a/db/routines/vn/views/workerWithoutTractor.sql +++ b/db/routines/vn/views/workerWithoutTractor.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`workerWithoutTractor` AS SELECT `c`.`workerFk` AS `workerFk`, diff --git a/db/routines/vn/views/zoneEstimatedDelivery.sql b/db/routines/vn/views/zoneEstimatedDelivery.sql index 90c7381d8..953a2b25a 100644 --- a/db/routines/vn/views/zoneEstimatedDelivery.sql +++ b/db/routines/vn/views/zoneEstimatedDelivery.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` +CREATE OR REPLACE DEFINER=`vn`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`zoneEstimatedDelivery` AS SELECT `t`.`zoneFk` AS `zoneFk`, diff --git a/db/routines/vn2008/views/Agencias.sql b/db/routines/vn2008/views/Agencias.sql index d70ec73f4..1176d02c4 100644 --- a/db/routines/vn2008/views/Agencias.sql +++ b/db/routines/vn2008/views/Agencias.sql @@ -13,6 +13,5 @@ AS SELECT `am`.`id` AS `Id_Agencia`, `am`.`reportMail` AS `send_mail`, `am`.`isActive` AS `tpv`, `am`.`code` AS `code`, - `am`.`showAgencyName` AS `show_AgencyName`, `am`.`isRiskFree` AS `isRiskFree` FROM `vn`.`agencyMode` `am` diff --git a/db/routines/vn2008/views/Articles.sql b/db/routines/vn2008/views/Articles.sql index 385bf310b..87f1b6d5e 100644 --- a/db/routines/vn2008/views/Articles.sql +++ b/db/routines/vn2008/views/Articles.sql @@ -41,7 +41,6 @@ AS SELECT `i`.`id` AS `Id_Article`, `i`.`hasKgPrice` AS `hasKgPrice`, `i`.`equivalent` AS `Equivalente`, `i`.`isToPrint` AS `Imprimir`, - `i`.`family` AS `Familia__`, `i`.`doPhoto` AS `do_photo`, `i`.`created` AS `odbc_date`, `i`.`isFloramondo` AS `isFloramondo`, diff --git a/db/routines/vn2008/views/Compres_mark.sql b/db/routines/vn2008/views/Compres_mark.sql deleted file mode 100644 index 7138c4e4c..000000000 --- a/db/routines/vn2008/views/Compres_mark.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Compres_mark` -AS SELECT `bm`.`id` AS `Id_Compra`, - `bm`.`comment` AS `comment`, - `bm`.`mark` AS `mark`, - `bm`.`odbcDate` AS `odbc_date` -FROM `vn`.`buyMark` `bm` diff --git a/db/routines/vn2008/views/Cubos.sql b/db/routines/vn2008/views/Cubos.sql index 4ece9c435..1b23af4fc 100644 --- a/db/routines/vn2008/views/Cubos.sql +++ b/db/routines/vn2008/views/Cubos.sql @@ -17,5 +17,6 @@ AS SELECT `p`.`id` AS `Id_Cubo`, `p`.`upload` AS `Suben`, `p`.`base` AS `Base`, `p`.`isBox` AS `box`, - `p`.`returnCost` AS `costeRetorno` + `p`.`returnCost` AS `costeRetorno`, + `p`.`isActive` AS `isActive` FROM `vn`.`packaging` `p` diff --git a/db/routines/vn2008/views/Saldos_Prevision.sql b/db/routines/vn2008/views/Saldos_Prevision.sql deleted file mode 100644 index f4749d30f..000000000 --- a/db/routines/vn2008/views/Saldos_Prevision.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Saldos_Prevision` -AS SELECT `fb`.`id` AS `Saldos_Prevision_id`, - `fb`.`description` AS `Descripcion`, - `fb`.`amount` AS `Importe`, - `fb`.`dated` AS `Fecha`, - `fb`.`accountingFk` AS `Id_Banco`, - `fb`.`companyFk` AS `empresa_id` -FROM `vn`.`forecastedBalance` `fb` \ No newline at end of file diff --git a/db/routines/vn2008/views/Tickets.sql b/db/routines/vn2008/views/Tickets.sql index c24b87b72..59dcb9100 100644 --- a/db/routines/vn2008/views/Tickets.sql +++ b/db/routines/vn2008/views/Tickets.sql @@ -21,7 +21,6 @@ AS SELECT `t`.`id` AS `Id_Ticket`, `t`.`workerFk` AS `Id_Trabajador`, `t`.`observations` AS `Observaciones`, `t`.`isSigned` AS `Firmado`, - `t`.`isLabeled` AS `Etiquetasemitidas`, `t`.`isPrinted` AS `PedidoImpreso`, `t`.`hour` AS `Hora`, `t`.`isBlocked` AS `blocked`, diff --git a/db/routines/vn2008/views/Tipos.sql b/db/routines/vn2008/views/Tipos.sql index 4cde954f1..5b96c1766 100644 --- a/db/routines/vn2008/views/Tipos.sql +++ b/db/routines/vn2008/views/Tipos.sql @@ -9,14 +9,9 @@ AS SELECT `it`.`id` AS `tipo_id`, `it`.`workerFk` AS `Id_Trabajador`, `it`.`life` AS `life`, `it`.`isPackaging` AS `isPackaging`, - `it`.`density` AS `density`, `it`.`isInventory` AS `inventory`, `it`.`created` AS `odbc_date`, `it`.`making` AS `confeccion`, `it`.`temperatureFk` AS `Temperatura`, - `it`.`promo` AS `promo`, - `it`.`maneuver` AS `maneuver`, - `it`.`target` AS `target`, - `it`.`topMargin` AS `top_margin`, - `it`.`profit` AS `profit` + `it`.`promo` AS `promo` FROM `vn`.`itemType` `it` diff --git a/db/routines/vn2008/views/buySource.sql b/db/routines/vn2008/views/buySource.sql index 33226a1dc..850483833 100644 --- a/db/routines/vn2008/views/buySource.sql +++ b/db/routines/vn2008/views/buySource.sql @@ -54,8 +54,7 @@ AS SELECT `b`.`entryFk` AS `Id_Entrada`, `i`.`packingOut` AS `packingOut`, `b`.`itemOriginalFk` AS `itemOriginalFk`, `io`.`longName` AS `itemOriginalName`, - `it`.`gramsMax` AS `gramsMax`, - `i`.`minQuantity` AS `minQuantity` + `it`.`gramsMax` AS `gramsMax` FROM ( ( ( diff --git a/db/routines/vn2008/views/buy_edi.sql b/db/routines/vn2008/views/buy_edi.sql index 0d194c89e..d00196e95 100644 --- a/db/routines/vn2008/views/buy_edi.sql +++ b/db/routines/vn2008/views/buy_edi.sql @@ -2,7 +2,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn2008`.`buy_edi` AS SELECT `t`.`id` AS `id`, - `t`.`barcode` AS `barcode`, `t`.`entryYear` AS `entry_year`, `t`.`deliveryNumber` AS `delivery_number`, `t`.`fec` AS `fec`, diff --git a/db/routines/vn2008/views/mandato_tipo.sql b/db/routines/vn2008/views/mandato_tipo.sql index a1b5b0a9f..bc3f74632 100644 --- a/db/routines/vn2008/views/mandato_tipo.sql +++ b/db/routines/vn2008/views/mandato_tipo.sql @@ -2,5 +2,5 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn2008`.`mandato_tipo` AS SELECT `m`.`id` AS `idmandato_tipo`, - `m`.`name` AS `Nombre` + `m`.`code` AS `Nombre` FROM `vn`.`mandateType` `m` diff --git a/db/routines/vn2008/views/state.sql b/db/routines/vn2008/views/state.sql index 63f6589af..9f7fcccd8 100644 --- a/db/routines/vn2008/views/state.sql +++ b/db/routines/vn2008/views/state.sql @@ -6,7 +6,6 @@ AS SELECT `s`.`id` AS `id`, `s`.`order` AS `order`, `s`.`alertLevel` AS `alert_level`, `s`.`code` AS `code`, - `s`.`sectorProdPriority` AS `sectorProdPriority`, `s`.`nextStateFk` AS `nextStateFk`, `s`.`isPreviousPreparable` AS `isPreviousPreparable`, `s`.`isPicked` AS `isPicked` diff --git a/db/versions/10852-pinkOak/00-firstScript.sql b/db/versions/10852-pinkOak/00-firstScript.sql new file mode 100644 index 000000000..41b75c7e1 --- /dev/null +++ b/db/versions/10852-pinkOak/00-firstScript.sql @@ -0,0 +1,32 @@ +ALTER TABLE vn.itemShelvingSale DROP COLUMN IF EXISTS isPicked; + +ALTER TABLE vn.itemShelvingSale + ADD isPicked TINYINT(1) DEFAULT FALSE NOT NULL; + +UPDATE vn.itemShelvingSale SET isPicked = TRUE; + +ALTER TABLE vn.productionConfig DROP COLUMN IF EXISTS orderMode; + +ALTER TABLE vn.productionConfig + ADD orderMode ENUM('Location', 'Age') NOT NULL DEFAULT 'Location'; + +ALTER TABLE vn.itemShelving DROP COLUMN IF EXISTS available; + +ALTER TABLE vn.itemShelving ADD available INT NULL; + +UPDATE vn.itemShelving SET available = visible; + +CREATE TABLE vn.itemShelvingSaleReserve ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `saleFk` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `itemShelvingSaleReserve_ibfk_1` (`saleFk`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci + COMMENT='Queue of changed itemShelvingSale to reserve'; + +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) + VALUES + + ('Collection', 'assignCollection', 'WRITE', 'ALLOW', 'ROLE', 'production'); + +ALTER TABLE vn.operator ADD IF NOT EXISTS isOnReservationMode TINYINT(1) NOT NULL DEFAULT FALSE; \ No newline at end of file diff --git a/db/versions/10960-silverRoebelini/00-firstScript.sql b/db/versions/10960-silverRoebelini/00-firstScript.sql new file mode 100644 index 000000000..c53a09549 --- /dev/null +++ b/db/versions/10960-silverRoebelini/00-firstScript.sql @@ -0,0 +1,23 @@ +-- Place your SQL code here +CREATE TABLE IF NOT EXISTS `vn`.`agencyIncoming` ( + `agencyModeFk` int(11) NOT NULL, + PRIMARY KEY (`agencyModeFk`) +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci COMMENT='Agencias de entrada de mercancias'; + +INSERT IGNORE INTO vn.agencyIncoming (agencyModeFk) VALUES +(1343), (1002), (1282), (841), (1303), (714), (556), (1786), (1785), (1784), +(1780), (1783), (1758), (1782), (1772), (1789), (1776), (1791), (1778), (1792), +(1779), (1362), (681), (1765), (15), (1594), (1706), (1707), (907), (1260), +(1715), (1371), (1372), (53), (689), (1375), (738), (742), (1307), (1700), (608), +(1311), (1315), (1339), (1433), (1338), (1332), (1844), (842), (1382), (1466), +(1719), (1723), (1725), (1720), (1732), (1736), (1728), (1724), (1726), (1727), +(1767), (1734), (1730), (1845), (1729), (1746), (1699), (2), (671), (1379), (614), +(1718), (1697), (62), (1529), (1392), (1378), (1438), (1796), (1688), (686), +(1326), (1691), (1), (1560), (1695), (1696), (1558), (1648), (1649), (1598), +(1680), (1694), (1600), (1601), (1602), (1712), (1603), (1604), (1641), (1692), +(1693), (1650), (1683), (1682), (1681), (1713), (1826), (1768), (1769), (1770), +(1593), (1443), (1244), (1679), (1006), (1361), (1102), (1655), (1744), (1225), +(1007); diff --git a/db/versions/10978-wheatMoss/00-firstScript.sql b/db/versions/10978-wheatMoss/00-firstScript.sql new file mode 100644 index 000000000..39bf1c318 --- /dev/null +++ b/db/versions/10978-wheatMoss/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here +INSERT INTO salix.defaultViewConfig +(tableCode, `columns`) +VALUES('routesList', '{"ID":true,"worker":true,"agency":true,"vehicle":true,"date":true,"volume":true,"description":true,"started":true,"finished":true,"actions":true}'); diff --git a/db/versions/10983-chocolateDracena/00-firstScript.sql b/db/versions/10983-chocolateDracena/00-firstScript.sql new file mode 100644 index 000000000..2baf1b21f --- /dev/null +++ b/db/versions/10983-chocolateDracena/00-firstScript.sql @@ -0,0 +1,5 @@ +-- Place your SQL code here +USE vn; + +DROP TRIGGER IF EXISTS itemShelving_AFTER_UPDATE; +DROP TRIGGER IF EXISTS itemShelving_AFTER_INSERT; diff --git a/db/versions/10986-pinkChrysanthemum/00-addSummaryId.sql b/db/versions/10986-pinkChrysanthemum/00-addSummaryId.sql new file mode 100644 index 000000000..288785191 --- /dev/null +++ b/db/versions/10986-pinkChrysanthemum/00-addSummaryId.sql @@ -0,0 +1,22 @@ +ALTER TABLE vn.claimLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE vn.clientLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE vn.deviceProductionLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE vn.entryLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE vn.invoiceInLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE vn.itemLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE vn.packingSiteDeviceLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE vn.parkingLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE vn.rateLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE vn.routeLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE vn.shelvingLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE vn.supplierLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE vn.ticketLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE vn.travelLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE vn.userLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE vn.workerLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE vn.zoneLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); + +ALTER TABLE account.userLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE account.signInLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE account.roleLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE account.accountLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); \ No newline at end of file diff --git a/db/versions/11015-silverBamboo/00-photoMotivation.sql b/db/versions/11015-silverBamboo/00-photoMotivation.sql new file mode 100644 index 000000000..366694e12 --- /dev/null +++ b/db/versions/11015-silverBamboo/00-photoMotivation.sql @@ -0,0 +1 @@ +ALTER TABLE vn.item ADD COLUMN photoMotivation VARCHAR(255); \ No newline at end of file diff --git a/db/versions/11042-turquoiseAspidistra/00-firstScript.sql b/db/versions/11042-turquoiseAspidistra/00-firstScript.sql new file mode 100644 index 000000000..43038ab6d --- /dev/null +++ b/db/versions/11042-turquoiseAspidistra/00-firstScript.sql @@ -0,0 +1,53 @@ +ALTER TABLE bs.waste ADD buyerFk int(10) unsigned NOT NULL; +USE vn; +CREATE OR REPLACE TEMPORARY TABLE tBuyers + ENGINE = MEMORY + WITH tDistinctBuyers AS ( + SELECT DISTINCT buyer + FROM bs.waste w + ) + SELECT buyer, u.id + FROM tDistinctBuyers tdb + JOIN account.`user` u ON u.name = tdb.buyer COLLATE utf8mb3_unicode_ci; + +UPDATE bs.waste w + JOIN tBuyers tb ON tb.buyer = w.buyer + SET w.buyerFk = tb.id; + +DROP TEMPORARY TABLE tBuyers; + +ALTER TABLE bs.waste + DROP PRIMARY KEY, + DROP COLUMN family, + DROP COLUMN rate, + DROP COLUMN buyer; + +ALTER TABLE bs.waste CHANGE buyerFk buyerFk int(10) unsigned NOT NULL AFTER `week`; +ALTER TABLE bs.waste ADD CONSTRAINT waste_user_FK FOREIGN KEY (buyerFk) REFERENCES account.user(id) ON DELETE RESTRICT ON UPDATE RESTRICT; +ALTER TABLE bs.waste ADD saleQuantity int(11) DEFAULT NULL NULL; +ALTER TABLE bs.waste MODIFY COLUMN saleTotal decimal(10,2) DEFAULT NULL NULL; +ALTER TABLE bs.waste MODIFY COLUMN saleWaste decimal(10,2) DEFAULT NULL NULL; +ALTER TABLE bs.waste CHANGE saleWaste saleInternalWaste decimal(10,2) DEFAULT NULL NULL; +ALTER TABLE bs.waste ADD saleExternalWaste decimal(10,2) DEFAULT NULL NULL; +ALTER TABLE bs.waste CHANGE saleQuantity saleQuantity decimal(10,2) DEFAULT NULL NULL AFTER itemTypeFk; +ALTER TABLE bs.waste CHANGE itemFk itemFk int(11) DEFAULT 0 NOT NULL AFTER itemTypeFk; + +CREATE OR REPLACE TEMPORARY TABLE tWasteUnique + SELECT * + FROM bs.waste + GROUP BY `year`, `week`, buyerFk, itemTypeFk, itemFk + HAVING COUNT(*) > 1; + +DELETE w.* FROM bs.waste w + JOIN tWasteUnique twu ON twu.`year` = w.`year` + AND twu.`week` = w.`week` + AND twu.`buyerFk` = w.`buyerFk` + AND twu.`itemTypeFk` = w.`itemTypeFk` + AND twu.`itemFk` = w.`itemFk`; + +INSERT INTO bs.waste + SELECT * FROM tWasteUnique; + +ALTER TABLE bs.waste ADD CONSTRAINT waste_pk PRIMARY KEY (`year`, `week`, buyerFk, itemTypeFk, itemFk); + +DROP TEMPORARY TABLE tWasteUnique; diff --git a/db/versions/11050-wheatAnthurium/00-firstScript.sql b/db/versions/11050-wheatAnthurium/00-firstScript.sql new file mode 100644 index 000000000..cb8034ff5 --- /dev/null +++ b/db/versions/11050-wheatAnthurium/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here + +ALTER TABLE floranet.catalogue ADD addressFk int(11) NOT NULL; +ALTER TABLE floranet.catalogue ADD CONSTRAINT catalogue_address_FK FOREIGN KEY (addressFk) REFERENCES vn.address(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/11050-wheatAnthurium/01-elementFilter.sql b/db/versions/11050-wheatAnthurium/01-elementFilter.sql new file mode 100644 index 000000000..3f2bb78ac --- /dev/null +++ b/db/versions/11050-wheatAnthurium/01-elementFilter.sql @@ -0,0 +1,6 @@ +ALTER TABLE floranet.builder DROP FOREIGN KEY builder_FK_1; +ALTER TABLE floranet.`element` DROP PRIMARY KEY; +ALTER TABLE floranet.`element` ADD id INT NOT NULL; +ALTER TABLE floranet.`element` ADD CONSTRAINT element_pk PRIMARY KEY (id); +ALTER TABLE floranet.builder ADD CONSTRAINT builder_element_FK FOREIGN KEY (elementFk) REFERENCES floranet.`element`(id) ON DELETE CASCADE ON UPDATE CASCADE; + diff --git a/db/versions/11060-tealGalax/00-createRoleReviewer.sql b/db/versions/11060-tealGalax/00-createRoleReviewer.sql new file mode 100644 index 000000000..bf2984702 --- /dev/null +++ b/db/versions/11060-tealGalax/00-createRoleReviewer.sql @@ -0,0 +1,46 @@ +use account; + +INSERT INTO role + SET name = 'reviewer', + description = 'Revisor de producción', + hasLogin = TRUE, + created = util.VN_CURDATE(), + modified = util.VN_CURDATE(), + editorFk = NULL; + +INSERT INTO roleInherit( + role, + inheritsFrom +) + SELECT r1.id, + r2.id + FROM role r1 + JOIN role r2 + WHERE r1.name = 'reviewer' + AND r2.name = 'production' + UNION + SELECT ri.role, + r2.id + FROM roleInherit ri + JOIN role r1 ON r1.id = ri.role + JOIN role r2 ON r2.name = 'reviewer' + WHERE r1.name IN ('claimManager', 'productionBoss') + GROUP BY ri.role; + +DELETE ri + FROM roleInherit ri + JOIN role r1 ON ri.role = r1.id + JOIN role r2 ON ri.inheritsFrom = r2.id + WHERE r1.name = 'replenisher' + AND r2.name = 'buyer'; + +UPDATE salix.ACL + SET principalId = 'reviewer' + WHERE property = 'isInPreparing'; + +UPDATE user u + JOIN vn.workerDepartment wd ON wd.workerFk = u.id + JOIN vn.department d ON wd.departmentFk = d.id + JOIN role r ON r.name = 'reviewer' + SET u.role = r.id + WHERE d.name IN ('REVISION', 'PREVIA'); \ No newline at end of file diff --git a/db/versions/11063-purpleAnthurium/00-roadmapAddress.sql b/db/versions/11063-purpleAnthurium/00-roadmapAddress.sql new file mode 100644 index 000000000..6435da1c9 --- /dev/null +++ b/db/versions/11063-purpleAnthurium/00-roadmapAddress.sql @@ -0,0 +1,8 @@ +CREATE TABLE `vn`.`roadmapAddress` ( + addressFk int(11) NULL, + isActive TINYINT DEFAULT 1 NULL, + PRIMARY KEY (addressFk) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Direcciones de los troncales'; + +ALTER TABLE vn.roadmapAddress + ADD CONSTRAINT roadmapAddress_address_FK FOREIGN KEY (addressFk) REFERENCES vn.address(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11063-purpleAnthurium/01-roadmapStop.sql b/db/versions/11063-purpleAnthurium/01-roadmapStop.sql new file mode 100644 index 000000000..844abf45f --- /dev/null +++ b/db/versions/11063-purpleAnthurium/01-roadmapStop.sql @@ -0,0 +1,7 @@ +ALTER TABLE vn.roadmapStop DROP FOREIGN KEY expeditionTruck_FK_1; +ALTER TABLE vn.roadmapStop DROP COLUMN warehouseFk; +ALTER TABLE vn.roadmapStop ADD addressFk int(11) NULL; +ALTER TABLE vn.roadmapStop CHANGE addressFk addressFk int(11) DEFAULT NULL NULL AFTER roadmapFk; + +ALTER TABLE vn.roadmapStop + ADD CONSTRAINT roadmapStop_roadmapAddress_FK FOREIGN KEY (addressFk) REFERENCES vn.roadmapAddress(addressFk) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql b/db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql new file mode 100644 index 000000000..bba1c019c --- /dev/null +++ b/db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql @@ -0,0 +1,11 @@ +DELETE FROM salix.ACL + WHERE model in ('expeditionTruck', 'Roadmap', 'roadmapStop', 'roadmapAddress'); + +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) + VALUES + ('RoadmapAddress', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'), + ('RoadmapAddress', '*', 'READ', 'ALLOW', 'ROLE', 'production'), + ('Roadmap', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'), + ('Roadmap', '*', 'READ', 'ALLOW', 'ROLE', 'production'), + ('RoadmapStop', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'), + ('RoadmapStop', '*', 'READ', 'ALLOW', 'ROLE', 'production'); diff --git a/db/versions/11064-grayMedeola/00-firstScript.sql b/db/versions/11064-grayMedeola/00-firstScript.sql new file mode 100644 index 000000000..b5af3599b --- /dev/null +++ b/db/versions/11064-grayMedeola/00-firstScript.sql @@ -0,0 +1,5 @@ +-- Place your SQL code here + +USE vn; + +ALTER TABLE vn.productionConfig ADD itemOlderReviewHours int(11) DEFAULT 0 NOT NULL COMMENT 'Horas que se tienen en cuenta para comprobar si un ítem es más viejo.'; diff --git a/db/versions/11065-yellowChrysanthemum/00-modifyInvoiceInPrivileges.sql b/db/versions/11065-yellowChrysanthemum/00-modifyInvoiceInPrivileges.sql new file mode 100644 index 000000000..b65ca1c17 --- /dev/null +++ b/db/versions/11065-yellowChrysanthemum/00-modifyInvoiceInPrivileges.sql @@ -0,0 +1,24 @@ +REVOKE UPDATE ON vn. invoiceIn FROM administrative, hrBoss, buyer, logistic; +GRANT UPDATE (id, + serialNumber, + serial, + supplierFk, + issued, + supplierRef, + currencyFk, + created, + companyFk, + docFk, + booked, + operated, + siiTypeInvoiceInFk, + cplusRectificationTypeFk, + cplusSubjectOpFk, + cplusTaxBreakFk, + siiTrascendencyInvoiceInFk, + bookEntried, + isVatDeductible, + withholdingSageFk, + expenseFkDeductible, + editorFk +) ON vn.invoiceIn TO administrative, hrBoss, buyer, logistic; \ No newline at end of file diff --git a/db/versions/11065-yellowChrysanthemum/01-modifyInvoiceInAcls.sql b/db/versions/11065-yellowChrysanthemum/01-modifyInvoiceInAcls.sql new file mode 100644 index 000000000..5475b70ac --- /dev/null +++ b/db/versions/11065-yellowChrysanthemum/01-modifyInvoiceInAcls.sql @@ -0,0 +1,23 @@ +UPDATE salix.ACL + SET accessType = 'READ' + WHERE principalId IN ('administrative','buyer') + AND model = 'invoiceIn' + AND property = '*'; + +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) +VALUES + ('InvoiceIn', 'updateInvoiceIn', 'WRITE', 'ALLOW', 'ROLE', 'administrative'), + ('InvoiceIn', 'clone', 'WRITE', 'ALLOW', 'ROLE', 'administrative'), + ('InvoiceIn', 'corrective', 'WRITE', 'ALLOW', 'ROLE', 'administrative'), + ('InvoiceIn', 'exchangeRateUpdate', 'WRITE', 'ALLOW', 'ROLE', 'administrative'), + ('InvoiceIn', 'invoiceInEmail', 'WRITE', 'ALLOW', 'ROLE', 'administrative'), + ('InvoiceIn', 'toBook', 'WRITE', 'ALLOW', 'ROLE', 'administrative'), + ('InvoiceIn', 'toUnbook', 'WRITE', 'ALLOW', 'ROLE', 'administrative'), + ('InvoiceIn', 'deleteById', 'WRITE', 'ALLOW', 'ROLE', 'administrative'), + ('InvoiceIn', 'updateInvoiceIn', 'WRITE', 'ALLOW', 'ROLE', 'buyer'), + ('InvoiceIn', 'clone', 'WRITE', 'ALLOW', 'ROLE', 'buyer'), + ('InvoiceIn', 'corrective', 'WRITE', 'ALLOW', 'ROLE', 'buyer'), + ('InvoiceIn', 'exchangeRateUpdate', 'WRITE', 'ALLOW', 'ROLE', 'buyer'), + ('InvoiceIn', 'invoiceInEmail', 'WRITE', 'ALLOW', 'ROLE', 'buyer'), + ('InvoiceIn', 'toBook', 'WRITE', 'ALLOW', 'ROLE', 'buyer'), + ('InvoiceIn', 'deleteById', 'WRITE', 'ALLOW', 'ROLE', 'buyer'); diff --git a/db/versions/11068-blueGerbera/00-firstScript.sql b/db/versions/11068-blueGerbera/00-firstScript.sql new file mode 100644 index 000000000..6342981a7 --- /dev/null +++ b/db/versions/11068-blueGerbera/00-firstScript.sql @@ -0,0 +1,9 @@ +-- Place your SQL code here +CREATE OR REPLACE TABLE floranet.config ( + email varchar(255) DEFAULT 'floranet@verdnatura.es' NOT NULL +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci; + + diff --git a/db/versions/11069-brownChrysanthemum/00-firstScript.sql b/db/versions/11069-brownChrysanthemum/00-firstScript.sql new file mode 100644 index 000000000..3220d1257 --- /dev/null +++ b/db/versions/11069-brownChrysanthemum/00-firstScript.sql @@ -0,0 +1,35 @@ +-- Place your SQL code here +DROP TABLE IF EXISTS floranet.builder; + +CREATE OR REPLACE TABLE floranet.`element` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(30) NOT NULL, + `itemFk` int(11) DEFAULT NULL, + `longNameFilter` varchar(30) DEFAULT NULL, + `typeFk` smallint(5) unsigned DEFAULT NULL, + `minSize` int(10) unsigned DEFAULT NULL, + `maxSize` int(10) unsigned DEFAULT NULL, + `inkFk` char(3) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `originFk` tinyint(2) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `element_FK` (`itemFk`), + KEY `element_FK_1` (`typeFk`), + KEY `element_FK_2` (`inkFk`), + KEY `element_FK_3` (`originFk`), + CONSTRAINT `element_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `element_FK_1` FOREIGN KEY (`typeFk`) REFERENCES `vn`.`itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `element_FK_2` FOREIGN KEY (`inkFk`) REFERENCES `vn`.`ink` (`id`) ON UPDATE CASCADE, + CONSTRAINT `element_FK_3` FOREIGN KEY (`originFk`) REFERENCES `vn`.`origin` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Filtro para localizar posibles items que coincidan con la descripción'; + +CREATE OR REPLACE TABLE floranet.`recipe` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemFk` int(11) NOT NULL, + `elementFk` int(11) NOT NULL, + `quantity` int(10) unsigned NOT NULL DEFAULT 1, + PRIMARY KEY (`id`), + KEY `recipe_FK` (`itemFk`), + KEY `recipe_FK_1` (`elementFk`), + CONSTRAINT `recipe_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `recipe_element_FK` FOREIGN KEY (`elementFk`) REFERENCES `element` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Links handmade products with their elements'; diff --git a/db/versions/11070-turquoiseCordyline/00-firstScript.sql b/db/versions/11070-turquoiseCordyline/00-firstScript.sql new file mode 100644 index 000000000..db123eb55 --- /dev/null +++ b/db/versions/11070-turquoiseCordyline/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.routesMonitor CHANGE expeditionTruckFk roadmapStopFk int(11) DEFAULT NULL NULL; + +ALTER TABLE vn.routesMonitor ADD COLUMN expeditionTruckFk int(11) AS (roadmapStopFk) VIRTUAL; \ No newline at end of file diff --git a/db/versions/11071-turquoiseMoss/00-firstScript.sql b/db/versions/11071-turquoiseMoss/00-firstScript.sql new file mode 100644 index 000000000..f1de5987f --- /dev/null +++ b/db/versions/11071-turquoiseMoss/00-firstScript.sql @@ -0,0 +1,5 @@ +-- Auto-generated SQL script. Actual values for binary/complex data types may differ - what you see is the default string representation of values. +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('RoadmapStop','*','*','ALLOW','ROLE','production'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('RoadmapStop','*','*','ALLOW','ROLE','productionBoss'); diff --git a/db/versions/11073-crimsonBirch/00-firstScript.sql b/db/versions/11073-crimsonBirch/00-firstScript.sql new file mode 100644 index 000000000..e82d342c9 --- /dev/null +++ b/db/versions/11073-crimsonBirch/00-firstScript.sql @@ -0,0 +1,9 @@ +-- Auto-generated SQL script. Actual values for binary/complex data types may differ - what you see is the default string representation of values. +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('TrainingCourse','*','*','ALLOW','ROLE','hr'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('TrainingCourseType','*','*','ALLOW','ROLE','hr'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('TrainingCenter','*','*','ALLOW','ROLE','hr'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Worker','__get__trainingCourse','*','ALLOW','ROLE','hr'); diff --git a/db/versions/11074-brownRuscus/00-firstScript.sql b/db/versions/11074-brownRuscus/00-firstScript.sql new file mode 100644 index 000000000..f78ba98ae --- /dev/null +++ b/db/versions/11074-brownRuscus/00-firstScript.sql @@ -0,0 +1,20 @@ +-- Place your SQL code here + + +-- floranet.recipe definition + +CREATE OR REPLACE TABLE floranet.`recipe` + ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemFk` int(11) NOT NULL COMMENT 'Bouquet or plant name', + `elementFk` int(11) NOT NULL COMMENT 'Item detail for bouquet''s composition', + `quantity` int(10) unsigned NOT NULL DEFAULT 1, + `cost` decimal(10,2) NOT NULL DEFAULT 1.00, + PRIMARY KEY (`id`), + KEY `recipe_FK` (`itemFk`), + KEY `recipe_FK_1` (`elementFk`), + CONSTRAINT `recipe_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE, + CONSTRAINT `recipe_item_FK` FOREIGN KEY (`elementFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Links handmade products with their elements'; + +DROP TABLE IF EXISTS floranet.`element`; \ No newline at end of file diff --git a/db/versions/11075-salmonLilium/00-firstScript.sql b/db/versions/11075-salmonLilium/00-firstScript.sql new file mode 100644 index 000000000..6e487e503 --- /dev/null +++ b/db/versions/11075-salmonLilium/00-firstScript.sql @@ -0,0 +1,5 @@ +-- Place your SQL code here +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS defaultHeight INT UNSIGNED NULL COMMENT 'default height in centimeters'; +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS defaultLength INT UNSIGNED NULL COMMENT 'default length in centimeters'; +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS defaultWidth INT UNSIGNED NULL COMMENT 'default width in centimeters'; +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS defaultWeight INT UNSIGNED NULL COMMENT 'default weight in centimeters'; diff --git a/db/versions/11078-goldenFern/00-firstScript.sql b/db/versions/11078-goldenFern/00-firstScript.sql new file mode 100644 index 000000000..63888a1bb --- /dev/null +++ b/db/versions/11078-goldenFern/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.productionConfig ADD scannablePreviusCodeType enum('qr','barcode') + CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT 'barcode' NOT NULL; \ No newline at end of file diff --git a/db/versions/11079-goldenFern/00-firstScript.sql b/db/versions/11079-goldenFern/00-firstScript.sql new file mode 100644 index 000000000..14d9ddb5f --- /dev/null +++ b/db/versions/11079-goldenFern/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS expeditionDeadLine TIME NULL +COMMENT 'This field stores the latest time by which expeditions can be generated to be sent today'; \ No newline at end of file diff --git a/db/versions/11080-maroonAnthurium/00-firstScript.sql b/db/versions/11080-maroonAnthurium/00-firstScript.sql new file mode 100644 index 000000000..651cd4c7c --- /dev/null +++ b/db/versions/11080-maroonAnthurium/00-firstScript.sql @@ -0,0 +1,9 @@ +-- Place your SQL code here +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS counterWidth INT UNSIGNED NULL + COMMENT 'If it does not reach the required value, it will be padded with zeros on the left to meet the specified length.'; + +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS serviceTypeWidth INT UNSIGNED NULL + COMMENT 'If it does not reach the required value, it will be padded with zeros on the left to meet the specified length.'; + +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS portugalPostCodeTrim INT UNSIGNED NULL + COMMENT 'It will trim the last characters of the postal code'; diff --git a/db/versions/11081-wheatRaphis/00-firstScript.sql b/db/versions/11081-wheatRaphis/00-firstScript.sql new file mode 100644 index 000000000..70bbaabdb --- /dev/null +++ b/db/versions/11081-wheatRaphis/00-firstScript.sql @@ -0,0 +1,8 @@ +-- Place your SQL code here + +USE vn; + +ALTER TABLE vn.roadmap ADD kmStart mediumint(9) DEFAULT NULL NULL; +ALTER TABLE vn.roadmap ADD kmEnd mediumint(9) DEFAULT NULL NULL; +ALTER TABLE vn.roadmap ADD started DATETIME NULL; +ALTER TABLE vn.roadmap ADD finished DATETIME NULL; diff --git a/db/versions/11082-goldenCordyline/00-firstScript.sql b/db/versions/11082-goldenCordyline/00-firstScript.sql new file mode 100644 index 000000000..71b98f4a9 --- /dev/null +++ b/db/versions/11082-goldenCordyline/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.country DROP COLUMN country; diff --git a/db/versions/11083-purpleBamboo/00-firstScript.sql b/db/versions/11083-purpleBamboo/00-firstScript.sql new file mode 100644 index 000000000..95e5c30a1 --- /dev/null +++ b/db/versions/11083-purpleBamboo/00-firstScript.sql @@ -0,0 +1,3 @@ + +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Ticket','refund','WRITE','ALLOW','ROLE','logistic'); diff --git a/db/versions/11084-whitePalmetto/00-firstScript.sql b/db/versions/11084-whitePalmetto/00-firstScript.sql new file mode 100644 index 000000000..c5f841ea4 --- /dev/null +++ b/db/versions/11084-whitePalmetto/00-firstScript.sql @@ -0,0 +1,9 @@ +CREATE TABLE `vn`.`clientRate` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `clientFk` int(11) NOT NULL, + `dated` date NOT NULL DEFAULT current_timestamp(), + `value` decimal(10,2) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `clientRate_unique` (`clientFk`,`dated`), + CONSTRAINT `clientRate_client_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; \ No newline at end of file diff --git a/db/versions/11086-grayCataractarum/00-firstScript.sql b/db/versions/11086-grayCataractarum/00-firstScript.sql new file mode 100644 index 000000000..86107b159 --- /dev/null +++ b/db/versions/11086-grayCataractarum/00-firstScript.sql @@ -0,0 +1,12 @@ +-- Place your SQL code here +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS notified TIMESTAMP NULL +COMMENT 'Date when it was notified that the web service deadline was exceeded'; + +INSERT IGNORE INTO util.notification + SET name = 'mrw-deadline', + description = 'The MRW deadline has passed'; + +INSERT IGNORE INTO util.notificationAcl (notificationFk, roleFK) + SELECT LAST_INSERT_ID(), r.id + FROM account.role r + WHERE r.name = 'delivery' \ No newline at end of file diff --git a/db/versions/11087-aquaDendro/00-firstScript.sql b/db/versions/11087-aquaDendro/00-firstScript.sql new file mode 100644 index 000000000..3490919a9 --- /dev/null +++ b/db/versions/11087-aquaDendro/00-firstScript.sql @@ -0,0 +1,4 @@ +ALTER TABLE vn.ticket MODIFY COLUMN IF EXISTS isLabeled__ tinyint(1) DEFAULT 0 NOT NULL COMMENT 'refs #7496 deprecated 2024-06-20'; + +ALTER TABLE IF EXISTS vn.forecastedBalance RENAME vn.forecastedBalance__ ; +ALTER TABLE IF EXISTS vn.forecastedBalance__ COMMENT='@deprecated 2024-05-21'; \ No newline at end of file diff --git a/db/versions/11088-bronzeAspidistra/00-firstScript.sql b/db/versions/11088-bronzeAspidistra/00-firstScript.sql new file mode 100644 index 000000000..5c56993fd --- /dev/null +++ b/db/versions/11088-bronzeAspidistra/00-firstScript.sql @@ -0,0 +1,19 @@ +ALTER TABLE vn.collectionWagonTicket DROP FOREIGN KEY IF EXISTS collectionWagonTicket_tray; +ALTER TABLE vn.wagonConfig DROP FOREIGN KEY IF EXISTS wagonConfig_wagonTypeColor_FK; +CREATE OR REPLACE TABLE vn.wagonTypeTray ( + id INT(11) UNSIGNED auto_increment, + wagonTypeFk INT(11) UNSIGNED NULL, + height INT(11) UNSIGNED NULL, + wagonTypeColorFk int(11) UNSIGNED NULL, + CONSTRAINT wagonTypeTray_pk PRIMARY KEY (id), + CONSTRAINT wagonTypeTray_wagonType_FK FOREIGN KEY (wagonTypeFk) REFERENCES vn.wagonType(id) ON DELETE CASCADE ON UPDATE RESTRICT, + CONSTRAINT wagonTypeTray_wagonTypeColor_FK FOREIGN KEY (wagonTypeColorFk) REFERENCES vn.wagonTypeColor(id) +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci; + +ALTER TABLE vn.wagonConfig ADD IF NOT EXISTS defaultHeight INT UNSIGNED DEFAULT 0 NULL COMMENT 'Default height in cm for a base tray'; +ALTER TABLE vn.wagonConfig ADD IF NOT EXISTS defaultTrayColorFk int(11) UNSIGNED NULL COMMENT 'Default color for a base tray'; +ALTER TABLE vn.wagonConfig ADD CONSTRAINT wagonConfig_wagonTypeColor_FK FOREIGN KEY (defaultTrayColorFk) REFERENCES vn.wagonTypeColor(id); +ALTER TABLE vn.collectionWagonTicket ADD CONSTRAINT collectionWagonTicket_tray FOREIGN KEY (trayFk) REFERENCES vn.wagonTypeTray(id); diff --git a/db/versions/11089-blueMastic/00-firstScript.sql b/db/versions/11089-blueMastic/00-firstScript.sql new file mode 100644 index 000000000..a3a92c56c --- /dev/null +++ b/db/versions/11089-blueMastic/00-firstScript.sql @@ -0,0 +1,5 @@ +-- Place your SQL code here + +USE vn; + +ALTER TABLE vn.expeditionState ADD isScanned tinyint(1) DEFAULT false NOT NULL; diff --git a/db/versions/11090-silverErica/00-firstScript.sql b/db/versions/11090-silverErica/00-firstScript.sql new file mode 100644 index 000000000..ec4959de9 --- /dev/null +++ b/db/versions/11090-silverErica/00-firstScript.sql @@ -0,0 +1,3 @@ +INSERT INTO salix.ACL(model,property,accessType,permission,principalType,principalId) + VALUES('InvoiceIn', 'create', 'WRITE', 'ALLOW', 'ROLE', 'administrative'), + ('InvoiceIn', 'create', 'WRITE', 'ALLOW', 'ROLE', 'buyer'); \ No newline at end of file diff --git a/db/versions/11092-azureBirch/00-firstScript.sql b/db/versions/11092-azureBirch/00-firstScript.sql new file mode 100644 index 000000000..12b9d7a20 --- /dev/null +++ b/db/versions/11092-azureBirch/00-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX ticketLog_creationDate_IDX USING BTREE ON vn.ticketLog (creationDate,changedModel,`action`); diff --git a/db/versions/11093-purpleGerbera/00-firstScript.sql b/db/versions/11093-purpleGerbera/00-firstScript.sql new file mode 100644 index 000000000..024b0bb59 --- /dev/null +++ b/db/versions/11093-purpleGerbera/00-firstScript.sql @@ -0,0 +1,4 @@ +UPDATE salix.ACL + SET property = 'cmrs' + WHERE property = 'getExternalCmrs' + AND model = 'Route'; \ No newline at end of file diff --git a/db/versions/11096-blackChico/00-addBuyerAcl.sql b/db/versions/11096-blackChico/00-addBuyerAcl.sql new file mode 100644 index 000000000..1b4adee5c --- /dev/null +++ b/db/versions/11096-blackChico/00-addBuyerAcl.sql @@ -0,0 +1,8 @@ +INSERT INTO salix.ACL + SET + model = 'Ticket', + property = 'editZone', + accessType = 'WRITE', + permission = 'ALLOW', + principalType = 'ROLE', + principalId = 'buyer'; \ No newline at end of file diff --git a/db/versions/11099-greenFern/00-firstScript.sql b/db/versions/11099-greenFern/00-firstScript.sql new file mode 100644 index 000000000..7dd84d1b7 --- /dev/null +++ b/db/versions/11099-greenFern/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.client + CHANGE hasIncoterms hasIncoterms__ tinyint(1) DEFAULT 0 NOT NULL + COMMENT '@deprecated 2024-06-12 refs #7545 Received incoterms authorization from client'; \ No newline at end of file diff --git a/db/versions/11100-silverGerbera/00-modifyTimeControlAcls.sql b/db/versions/11100-silverGerbera/00-modifyTimeControlAcls.sql new file mode 100644 index 000000000..473441a7e --- /dev/null +++ b/db/versions/11100-silverGerbera/00-modifyTimeControlAcls.sql @@ -0,0 +1,18 @@ +UPDATE salix.ACL + SET principalId = 'teamBoss' + WHERE property IN ('addTimeEntry', 'deleteTimeEntry', 'updateTimeEntry', 'weeklyHourRecordEmail'); + +UPDATE salix.ACL SET principalId = 'developer' WHERE property = 'sendMail'; + +UPDATE salix.ACL + SET property = 'updateMailState' + WHERE property = 'updateWorkerTimeControlMail'; + +INSERT INTO salix.ACL(model, property, accessType, permission, principalType, principalId) + VALUES + ('WorkerTimeControl', 'addTimeEntry', 'WRITE', 'ALLOW', 'ROLE', 'hr'), + ('WorkerTimeControl', 'deleteTimeEntry', 'WRITE', 'ALLOW', 'ROLE', 'hr'), + ('WorkerTimeControl', 'updateTimeEntry', 'WRITE', 'ALLOW', 'ROLE', 'hr'), + ('WorkerTimeControl', 'weeklyHourRecordEmail', 'WRITE', 'ALLOW', 'ROLE', 'hr'), + ('WorkerTimeControl', 'sendMail', 'WRITE', 'ALLOW', 'ROLE', 'hr'), + ('WorkerTimeControl', 'updateMailState', 'WRITE', 'ALLOW', 'ROLE', 'hr'); \ No newline at end of file diff --git a/db/versions/11101-limeCordyline/00-firstScript.sql b/db/versions/11101-limeCordyline/00-firstScript.sql new file mode 100644 index 000000000..d6f30ce3f --- /dev/null +++ b/db/versions/11101-limeCordyline/00-firstScript.sql @@ -0,0 +1,12 @@ +UPDATE IGNORE bs.nightTask + SET `schema` = 'vn', + `procedure` = 'claimRatio_add' + WHERE `procedure` = 'claim_ratio_routine'; + +ALTER TABLE vn.claimConfig + ADD monthsToRefund int(11) DEFAULT NULL NULL, + ADD minShipped date DEFAULT NULL NULL; + +UPDATE IGNORE vn.claimConfig + SET monthsToRefund = 4, + minShipped = '2016-10-01'; diff --git a/db/versions/11102-wheatCarnation/00-createTravelKgPercentage.sql b/db/versions/11102-wheatCarnation/00-createTravelKgPercentage.sql new file mode 100644 index 000000000..3abcd0074 --- /dev/null +++ b/db/versions/11102-wheatCarnation/00-createTravelKgPercentage.sql @@ -0,0 +1,17 @@ +CREATE TABLE IF NOT EXISTS vn.travelKgPercentage ( + value INT(3) PRIMARY KEY, + className VARCHAR(50) +); + +INSERT IGNORE INTO vn.travelKgPercentage (value, className) + VALUES + (80, 'primary'), + (100, 'alert'); + +INSERT INTO salix.ACL + SET model = 'TravelKgPercentage', + property = '*', + accessType = 'READ', + permission = 'ALLOW', + principalType = 'ROLE', + principalId = 'employee'; \ No newline at end of file diff --git a/db/versions/11103-limeBirch/00-firstScript.sql b/db/versions/11103-limeBirch/00-firstScript.sql new file mode 100644 index 000000000..2c0a396ce --- /dev/null +++ b/db/versions/11103-limeBirch/00-firstScript.sql @@ -0,0 +1,6 @@ +-- Place your SQL code here +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) + VALUES + ('WorkerIncome', '*', '*', 'ALLOW', 'ROLE', 'hr'), + ('PayrollComponent', '*', '*', 'ALLOW', 'ROLE', 'hr'), + ('Worker', '__get__incomes', '*', 'ALLOW', 'ROLE', 'hr'); diff --git a/db/versions/11104-wheatErica/00-firstScript.sql b/db/versions/11104-wheatErica/00-firstScript.sql new file mode 100644 index 000000000..11811f399 --- /dev/null +++ b/db/versions/11104-wheatErica/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.ticketPackaging DROP FOREIGN KEY ticketPackaging_fk3; +ALTER TABLE vn.ticketPackaging DROP COLUMN workerFk; \ No newline at end of file diff --git a/db/versions/11105-bronzeChrysanthemum/00-firstScript.sql b/db/versions/11105-bronzeChrysanthemum/00-firstScript.sql new file mode 100644 index 000000000..685cd8f75 --- /dev/null +++ b/db/versions/11105-bronzeChrysanthemum/00-firstScript.sql @@ -0,0 +1,9 @@ + +CREATE OR REPLACE TABLE sage.clientSupplier ( + `companyFk` smallint(6) NOT NULL, + `type` ENUM('C','P') NOT NULL, + `idClientSupplier` INT NOT NULL, + `isSync` TINYINT(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`companyFk`,`idClientSupplier`,`type`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci + COMMENT='Clients and suppliers present in Sage and their synchronization status'; \ No newline at end of file diff --git a/db/versions/11106-salmonPhormium/00-firstScript.sql b/db/versions/11106-salmonPhormium/00-firstScript.sql new file mode 100644 index 000000000..9f63e6075 --- /dev/null +++ b/db/versions/11106-salmonPhormium/00-firstScript.sql @@ -0,0 +1,9 @@ +-- Place your SQL code here + +USE vn; + +ALTER TABLE vn.productionConfig ADD sectorFromCode varchar(15) NULL COMMENT 'Sector origen que se revisa ítems más nuevos al parkinear'; +ALTER TABLE vn.productionConfig ADD sectorToCode varchar(15) NULL COMMENT 'Sector destino que se revisa ítems más nuevos al parkinear'; + +ALTER TABLE vn.productionConfig ADD CONSTRAINT productionConfig_sector_FK FOREIGN KEY (sectorFromCode) REFERENCES vn.sector(code) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE vn.productionConfig ADD CONSTRAINT productionConfig_sector_FK_1 FOREIGN KEY (sectorToCode) REFERENCES vn.sector(code) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11107-pinkAspidistra/00-firstScript.sql b/db/versions/11107-pinkAspidistra/00-firstScript.sql new file mode 100644 index 000000000..62af9c306 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/00-firstScript.sql @@ -0,0 +1,13 @@ +CREATE OR REPLACE TABLE `util`.`logCleanMultiConfig` ( + `schemaName` varchar(64) NOT NULL, + `tableName` varchar(64) NOT NULL, + `retentionDays` int(11) DEFAULT NULL, + `order` int(11) DEFAULT NULL, + `started` datetime DEFAULT NULL, + `finished` datetime DEFAULT NULL, + PRIMARY KEY (`schemaName`,`tableName`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT INTO `util`.`logCleanMultiConfig` (`schemaName`, `tableName`) + SELECT TABLE_SCHEMA, TABLE_NAME FROM information_schema.`COLUMNS` + WHERE COLUMN_NAME IN ('newInstance', 'newInstance'); diff --git a/db/versions/11107-pinkAspidistra/01-firstScript.sql b/db/versions/11107-pinkAspidistra/01-firstScript.sql new file mode 100644 index 000000000..426fcc5b8 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/01-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX userLog_creationDate_IDX USING BTREE ON account.userLog (creationDate DESC); diff --git a/db/versions/11107-pinkAspidistra/02-firstScript.sql b/db/versions/11107-pinkAspidistra/02-firstScript.sql new file mode 100644 index 000000000..e916754e3 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/02-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX roleLog_creationDate_IDX USING BTREE ON account.roleLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/03-firstScript.sql b/db/versions/11107-pinkAspidistra/03-firstScript.sql new file mode 100644 index 000000000..f7400c866 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/03-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX ACLLog_creationDate_IDX USING BTREE ON salix.ACLLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/04-firstScript.sql b/db/versions/11107-pinkAspidistra/04-firstScript.sql new file mode 100644 index 000000000..0c118284e --- /dev/null +++ b/db/versions/11107-pinkAspidistra/04-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX supplierLog_creationDate_IDX USING BTREE ON vn.supplierLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/05-firstScript.sql b/db/versions/11107-pinkAspidistra/05-firstScript.sql new file mode 100644 index 000000000..5cb4070bb --- /dev/null +++ b/db/versions/11107-pinkAspidistra/05-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX deviceProductionLog_creationDate_IDX USING BTREE ON vn.deviceProductionLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/06-firstScript.sql b/db/versions/11107-pinkAspidistra/06-firstScript.sql new file mode 100644 index 000000000..332b8a60a --- /dev/null +++ b/db/versions/11107-pinkAspidistra/06-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX routeLog_creationDate_IDX USING BTREE ON vn.routeLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/07-firstScript.sql b/db/versions/11107-pinkAspidistra/07-firstScript.sql new file mode 100644 index 000000000..b80f8b75f --- /dev/null +++ b/db/versions/11107-pinkAspidistra/07-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX itemLog_creationDate_IDX USING BTREE ON vn.itemLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/08-firstScript.sql b/db/versions/11107-pinkAspidistra/08-firstScript.sql new file mode 100644 index 000000000..315f9b256 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/08-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX userLog_creationDate_IDX USING BTREE ON vn.userLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/09-firstScript.sql b/db/versions/11107-pinkAspidistra/09-firstScript.sql new file mode 100644 index 000000000..7bb604915 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/09-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX invoiceInLog_creationDate_IDX USING BTREE ON vn.invoiceInLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/10-firstScript.sql b/db/versions/11107-pinkAspidistra/10-firstScript.sql new file mode 100644 index 000000000..06e186e0e --- /dev/null +++ b/db/versions/11107-pinkAspidistra/10-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX zoneLog_creationDate_IDX USING BTREE ON vn.zoneLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/11-firstScript.sql b/db/versions/11107-pinkAspidistra/11-firstScript.sql new file mode 100644 index 000000000..be539e7b0 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/11-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX clientLog_creationDate_IDX USING BTREE ON vn.clientLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/12-firstScript.sql b/db/versions/11107-pinkAspidistra/12-firstScript.sql new file mode 100644 index 000000000..4abc284b6 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/12-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX workerLog_creationDate_IDX USING BTREE ON vn.workerLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/14-firstScript.sql b/db/versions/11107-pinkAspidistra/14-firstScript.sql new file mode 100644 index 000000000..02d2a37b0 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/14-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX rateLog_creationDate_IDX USING BTREE ON vn.rateLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/15-firstScript.sql b/db/versions/11107-pinkAspidistra/15-firstScript.sql new file mode 100644 index 000000000..ad75ff6d0 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/15-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX claimLog_creationDate_IDX USING BTREE ON vn.claimLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/17-firstScript.sql b/db/versions/11107-pinkAspidistra/17-firstScript.sql new file mode 100644 index 000000000..3de084bcf --- /dev/null +++ b/db/versions/11107-pinkAspidistra/17-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX packingSiteDeviceLog_creationDate_IDX USING BTREE ON vn.packingSiteDeviceLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/18-firstScript.sql b/db/versions/11107-pinkAspidistra/18-firstScript.sql new file mode 100644 index 000000000..1181f8263 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/18-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX travelLog_creationDate_IDX USING BTREE ON vn.travelLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/19-firstScript.sql b/db/versions/11107-pinkAspidistra/19-firstScript.sql new file mode 100644 index 000000000..e95f93031 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/19-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX shelvingLog_creationDate_IDX USING BTREE ON vn.shelvingLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/20-firstScript.sql b/db/versions/11107-pinkAspidistra/20-firstScript.sql new file mode 100644 index 000000000..d3598466d --- /dev/null +++ b/db/versions/11107-pinkAspidistra/20-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX productionConfigLog_creationDate_IDX USING BTREE ON vn.productionConfigLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/21-firstScript.sql b/db/versions/11107-pinkAspidistra/21-firstScript.sql new file mode 100644 index 000000000..5db8d3c63 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/21-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX entryLog_creationDate_IDX USING BTREE ON vn.entryLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/22-firstScript.sql b/db/versions/11107-pinkAspidistra/22-firstScript.sql new file mode 100644 index 000000000..91e68c43b --- /dev/null +++ b/db/versions/11107-pinkAspidistra/22-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX agencyLog_creationDate_IDX USING BTREE ON vn.agencyLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/23-firstScript.sql b/db/versions/11107-pinkAspidistra/23-firstScript.sql new file mode 100644 index 000000000..edd79473e --- /dev/null +++ b/db/versions/11107-pinkAspidistra/23-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX parkingLog_creationDate_IDX USING BTREE ON vn.parkingLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11107-pinkAspidistra/24-firstScript.sql b/db/versions/11107-pinkAspidistra/24-firstScript.sql new file mode 100644 index 000000000..81e84c405 --- /dev/null +++ b/db/versions/11107-pinkAspidistra/24-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX bufferLog_creationDate_IDX USING BTREE ON srt.bufferLog (creationDate DESC); \ No newline at end of file diff --git a/db/versions/11108-redRose/00-firstScript.sql b/db/versions/11108-redRose/00-firstScript.sql new file mode 100644 index 000000000..e70291e8f --- /dev/null +++ b/db/versions/11108-redRose/00-firstScript.sql @@ -0,0 +1,6 @@ +-- Place your SQL code here +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) + VALUES + ('MedicalReview', '*', '*', 'ALLOW', 'ROLE', 'hr'), + ('MedicalCenter', '*', '*', 'ALLOW', 'ROLE', 'hr'), + ('Worker', '__get__medicalReview', '*', 'ALLOW', 'ROLE', 'hr'); diff --git a/db/versions/11109-whiteCarnation/00-firstScript.sql b/db/versions/11109-whiteCarnation/00-firstScript.sql new file mode 100644 index 000000000..a1ff19815 --- /dev/null +++ b/db/versions/11109-whiteCarnation/00-firstScript.sql @@ -0,0 +1,14 @@ +-- Place your SQL code here + +USE vn; + +ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelvingBuy_FK; +ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelving_fk2; +ALTER TABLE vn.itemShelving DROP INDEX itemShelving_UN; + +ALTER TABLE vn.itemShelving ADD CONSTRAINT itemShelving_fk2 FOREIGN KEY (shelvingFk) REFERENCES vn.shelving(code) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE vn.itemShelving ADD CONSTRAINT itemShelvingBuy_FK FOREIGN KEY (buyFk) REFERENCES vn.buy(id) ON DELETE RESTRICT ON UPDATE RESTRICT; + + + + diff --git a/db/versions/11110-grayGerbera/00-clientUnpaid.sql b/db/versions/11110-grayGerbera/00-clientUnpaid.sql new file mode 100644 index 000000000..06fd51555 --- /dev/null +++ b/db/versions/11110-grayGerbera/00-clientUnpaid.sql @@ -0,0 +1,4 @@ +ALTER TABLE vn.clientUnpaid + ADD editorFk INT UNSIGNED NULL, + ADD CONSTRAINT ClientUnpaid_editorFk FOREIGN KEY (editorFk) + REFERENCES account.`user`(id); diff --git a/db/versions/11111-tealAralia/00-firstScript.sql b/db/versions/11111-tealAralia/00-firstScript.sql new file mode 100644 index 000000000..4ef10d5f2 --- /dev/null +++ b/db/versions/11111-tealAralia/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE account.`user` DROP COLUMN password__; diff --git a/db/versions/11112-blackRose/00-firstScript.sql b/db/versions/11112-blackRose/00-firstScript.sql new file mode 100644 index 000000000..c26149240 --- /dev/null +++ b/db/versions/11112-blackRose/00-firstScript.sql @@ -0,0 +1,13 @@ +UPDATE `salix`.`ACL` + SET accessType='READ' + WHERE model = 'ACL'; + +UPDATE `salix`.`ACL` + SET principalId='developerBoss' + WHERE model = 'AccessToken'; + +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) + VALUES + ('VnToken', '*', 'READ', 'ALLOW', 'ROLE', 'developer'), + ('VnToken', 'killSession', '*', 'ALLOW', 'ROLE', 'developer'), + ('ACL', '*', 'WRITE', 'ALLOW', 'ROLE', 'developerBoss'); diff --git a/db/versions/11113-bronzeDendro/00-firstScript.sql b/db/versions/11113-bronzeDendro/00-firstScript.sql new file mode 100644 index 000000000..63db65378 --- /dev/null +++ b/db/versions/11113-bronzeDendro/00-firstScript.sql @@ -0,0 +1,16 @@ +ALTER TABLE IF EXISTS `vn`.`payrollWorker` + MODIFY COLUMN IF EXISTS `nss__` varchar(23) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `codpuesto__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `codcontrato__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `FAntiguedad__` date NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `grupotarifa__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `codcategoria__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `ContratoTemporal__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-03-15'; + +ALTER TABLE IF EXISTS `vn`.`payrollWorkCenter` + MODIFY COLUMN IF EXISTS `Centro__` varchar(255) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `nss_cotizacion__` varchar(15) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `domicilio__` varchar(255) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `poblacion__` varchar(45) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `cp__` varchar(5) NOT NULL COMMENT '@deprecated 2024-03-15', + MODIFY COLUMN IF EXISTS `empresa_id__` int(10) NOT NULL COMMENT '@deprecated 2024-03-15'; diff --git a/db/versions/11115-turquoiseRose/00-firstScript.sql b/db/versions/11115-turquoiseRose/00-firstScript.sql new file mode 100644 index 000000000..3982936fc --- /dev/null +++ b/db/versions/11115-turquoiseRose/00-firstScript.sql @@ -0,0 +1,30 @@ +-- Place your SQL code here +-- vn.stockBought definition + +CREATE TABLE IF NOT EXISTS vn.stockBought ( + id INT UNSIGNED auto_increment NOT NULL, + workerFk int(10) unsigned NOT NULL, + bought decimal(10,2) NOT NULL COMMENT 'purchase volume in m3 for the day', + reserve decimal(10,2) NULL COMMENT 'reserved volume in m3 for the day', + dated DATE NOT NULL DEFAULT current_timestamp(), + CONSTRAINT stockBought_pk PRIMARY KEY (id), + CONSTRAINT stockBought_unique UNIQUE KEY (workerFk,dated), + CONSTRAINT stockBought_worker_FK FOREIGN KEY (workerFk) REFERENCES vn.worker(id) +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci; + + +INSERT IGNORE vn.stockBought (workerFk, bought, reserve, dated) + SELECT userFk, SUM(buyed), SUM(IFNULL(reserved,0)), dated + FROM vn.stockBuyed + WHERE userFk IS NOT NULL + AND buyed IS NOT NULL + GROUP BY userFk, dated; + +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('StockBought','*','READ','ALLOW','ROLE','buyer'), + ('StockBought','*','WRITE','ALLOW','ROLE','buyer'), + ('Buyer','*','READ','ALLOW','ROLE','buyer'); + diff --git a/db/versions/11116-tealRuscus/00-firstScript.sql b/db/versions/11116-tealRuscus/00-firstScript.sql new file mode 100644 index 000000000..dc577a36b --- /dev/null +++ b/db/versions/11116-tealRuscus/00-firstScript.sql @@ -0,0 +1,8 @@ +-- Place your SQL code here +USE vn; +INSERT INTO salix.ACL ( model, property, accessType, permission, principalType, principalId) VALUES('ItemShelvingLog', '*', 'READ', 'ALLOW', 'ROLE', 'production'); + +-- redmine regularitzar parking per a que no tinguen espais +ALTER TABLE parking DROP CONSTRAINT chkParkingCodeFormat; +ALTER TABLE parking +ADD CONSTRAINT chkParkingCodeFormat CHECK (CHAR_LENGTH(code) > 4 AND code REGEXP ('^[^ ]+-[^ ]+$')); \ No newline at end of file diff --git a/db/versions/11117-blueGalax/00-firstScript.sql b/db/versions/11117-blueGalax/00-firstScript.sql new file mode 100644 index 000000000..63ea40cd2 --- /dev/null +++ b/db/versions/11117-blueGalax/00-firstScript.sql @@ -0,0 +1,2 @@ +-- Place your SQL code here +ALTER TABLE vn.routesMonitor DROP COLUMN expeditionTruckFk; \ No newline at end of file diff --git a/db/versions/11118-limeCymbidium/00-firstScript.sql b/db/versions/11118-limeCymbidium/00-firstScript.sql new file mode 100644 index 000000000..b15dfbd41 --- /dev/null +++ b/db/versions/11118-limeCymbidium/00-firstScript.sql @@ -0,0 +1,19 @@ + +INSERT IGNORE INTO salix.ACL (`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) + VALUES ('Entry','filter','READ','ALLOW','ROLE','supplier'); + +INSERT IGNORE INTO salix.ACL (`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) + VALUES ('Entry','getBuys','READ','ALLOW','ROLE','supplier'); + +INSERT IGNORE INTO salix.ACL (`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) + VALUES ('Entry','buyLabel','READ','ALLOW','ROLE','supplier'); + +INSERT IGNORE INTO `account`.`role` (`name`,`description`,`hasLogin`,`created`,`modified`) + VALUES ('supplier','Proveedores',1,'2017-10-10 14:58:58.000','2017-10-10 14:59:20.000'); +SET @supplierFk =LAST_INSERT_ID(); +INSERT IGNORE INTO account.roleInherit (`role`,`inheritsFrom`) + VALUES (@supplierFk,2); + +UPDATE salix.ACL + SET principalId='$authenticated' + WHERE id=(SELECT id FROM salix.ACL WHERE model='StarredModule' and property='*' and `accessType`='*'); diff --git a/db/versions/11119-tealGerbera/00-firstScript.sql b/db/versions/11119-tealGerbera/00-firstScript.sql new file mode 100644 index 000000000..40b3b0424 --- /dev/null +++ b/db/versions/11119-tealGerbera/00-firstScript.sql @@ -0,0 +1,9 @@ +ALTER TABLE vn.componentType + CHANGE code code varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL AFTER id; +ALTER TABLE vn.componentType + CHANGE `type` name varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL; +UPDATE IGNORE vn.componentType + SET code = LOWER(code); +UPDATE IGNORE vn.componentType + SET code = 'other' + WHERE id = 12; \ No newline at end of file diff --git a/db/versions/11120-brownTulip/00-firstScript.sql b/db/versions/11120-brownTulip/00-firstScript.sql new file mode 100644 index 000000000..c4ded80bb --- /dev/null +++ b/db/versions/11120-brownTulip/00-firstScript.sql @@ -0,0 +1,6 @@ +ALTER TABLE vn.itemType + CHANGE maneuver maneuver__ double DEFAULT 0.21 NOT NULL COMMENT '@deprecated 2024-07-01 refs #7418', + CHANGE target target__ double DEFAULT 0.15 NOT NULL COMMENT '@deprecated 2024-07-01 refs #7418', + CHANGE topMargin topMargin__ double DEFAULT 0.3 NOT NULL COMMENT '@deprecated 2024-07-01 refs #7418', + CHANGE profit profit__ double DEFAULT 0.02 NOT NULL COMMENT '@deprecated 2024-07-01 refs #7418', + CHANGE density density__ double DEFAULT 167 NOT NULL COMMENT '@deprecated 2024-07-01 refs #7418 Almacena el valor por defecto de la densidad en kg/m3 para el calculo de los portes aereos, en articulos se guarda la correcta'; \ No newline at end of file diff --git a/db/versions/11121-silverAralia/00-firstScript.sql b/db/versions/11121-silverAralia/00-firstScript.sql new file mode 100644 index 000000000..20b0e8195 --- /dev/null +++ b/db/versions/11121-silverAralia/00-firstScript.sql @@ -0,0 +1,4 @@ +ALTER TABLE account.mailAliasAccount + ADD editorFk INT(10) UNSIGNED DEFAULT NULL, + ADD CONSTRAINT mailAliasAccount_editorFk FOREIGN KEY (editorFk) + REFERENCES account.`user`(id); \ No newline at end of file diff --git a/db/versions/11124-greenBamboo/00-firstScript.sql b/db/versions/11124-greenBamboo/00-firstScript.sql new file mode 100644 index 000000000..6f47cbc21 --- /dev/null +++ b/db/versions/11124-greenBamboo/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.ticket ADD volume decimal(10,6) DEFAULT NULL NULL COMMENT 'Unidad en m3'; diff --git a/db/versions/11124-greenBamboo/01-firstScript.sql b/db/versions/11124-greenBamboo/01-firstScript.sql new file mode 100644 index 000000000..af3a40f14 --- /dev/null +++ b/db/versions/11124-greenBamboo/01-firstScript.sql @@ -0,0 +1,18 @@ +-- Calculamos todos los volumenes de todos los tickets una sola vez +/* Se ejecutará el dia de test - master manualmente para no hacer lenta la subida +CREATE OR REPLACE TEMPORARY TABLE tmp.tTicketVolume + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT t.id, SUM(s.quantity * ic.cm3delivery / 1000000) volume + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.itemCost ic ON ic.itemFk = s.itemFk + AND ic.warehouseFk = t.warehouseFk + GROUP BY t.id; + +UPDATE vn.ticket t + JOIN tmp.tTicketVolume tv ON tv.id = t.id + SET t.volume = tv.volume; + +DROP TEMPORARY TABLE tmp.tTicketVolume; +*/ diff --git a/db/versions/11126-blueCamellia/00-firstScript.sql b/db/versions/11126-blueCamellia/00-firstScript.sql new file mode 100644 index 000000000..40c5e2b37 --- /dev/null +++ b/db/versions/11126-blueCamellia/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE `vn`.`client` +ADD COLUMN `hasDailyInvoice` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'Indica si el cliente requiere facturación diaria por defecto se copiará lo que tenga country.hasDailyInvoice'; diff --git a/db/versions/11128-turquoiseCymbidium/00-firstScript.sql b/db/versions/11128-turquoiseCymbidium/00-firstScript.sql new file mode 100644 index 000000000..4f6cafcf8 --- /dev/null +++ b/db/versions/11128-turquoiseCymbidium/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.calendar ADD created timestamp DEFAULT current_timestamp() NOT NULL AFTER dated; diff --git a/db/versions/11129-limeHydrangea/00-firstScript.sql b/db/versions/11129-limeHydrangea/00-firstScript.sql new file mode 100644 index 000000000..eb2320ee1 --- /dev/null +++ b/db/versions/11129-limeHydrangea/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.greuge CHANGE Id id int(10) unsigned auto_increment NOT NULL; diff --git a/db/versions/11130-crimsonIvy/00-firstScript.sql b/db/versions/11130-crimsonIvy/00-firstScript.sql new file mode 100644 index 000000000..c93f2f6b7 --- /dev/null +++ b/db/versions/11130-crimsonIvy/00-firstScript.sql @@ -0,0 +1,23 @@ +ALTER TABLE vn.productionConfig + ADD editorFk int(10) unsigned DEFAULT NULL NULL; +ALTER TABLE vn.productionConfig + ADD CONSTRAINT productionConfig_user_FK FOREIGN KEY (editorFk) REFERENCES account.`user`(id); + +CREATE OR REPLACE TABLE `vn`.`productionConfigLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete','select') NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `changedModel` enum('ProductionConfig') NOT NULL DEFAULT 'ProductionConfig', + `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)), + `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), + `changedModelId` int(11) NOT NULL, + `changedModelValue` varchar(45) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `productionConfigLog_userFk` (`userFk`), + KEY `productionConfigLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), + KEY `productionConfigLog_originFk` (`originFk`,`creationDate`), + CONSTRAINT `productionConfigUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; diff --git a/db/versions/11131-brownPhormium/00-firstScript.sql b/db/versions/11131-brownPhormium/00-firstScript.sql new file mode 100644 index 000000000..341c9f1a3 --- /dev/null +++ b/db/versions/11131-brownPhormium/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.itemShelving ADD isSplit tinyint(1) NULL COMMENT 'Este valor cambia al splitar un carro que se ha quedado en holanda'; \ No newline at end of file diff --git a/db/versions/11132-aquaDracena/00-firstScript.vn.sql b/db/versions/11132-aquaDracena/00-firstScript.vn.sql new file mode 100644 index 000000000..64f8442b4 --- /dev/null +++ b/db/versions/11132-aquaDracena/00-firstScript.vn.sql @@ -0,0 +1,2 @@ +INSERT IGNORE INTO vn.observationType (`description`,code) + VALUES ('Sustitución','substitution'); diff --git a/db/versions/11134-silverRaphis/00-firstScript.sql b/db/versions/11134-silverRaphis/00-firstScript.sql new file mode 100644 index 000000000..0836abe4e --- /dev/null +++ b/db/versions/11134-silverRaphis/00-firstScript.sql @@ -0,0 +1,42 @@ +USE `vn`; + +CREATE TABLE IF NOT EXISTS vn.`tillSerial` ( + `code` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL, + `description` varchar(30) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `account` varchar(10) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES(' S', 'Saldos final / inicial', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('A', 'Factura cliente', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('B', 'Factura cliente', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('C', 'Facturas Contado', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CC', 'Cuadre caja', '6780000000'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CD', 'Cuenta Director Comercial', '5510000002'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CH', 'Cheques', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CM', 'Cambio', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CR', 'Ingreso/Reintegro Caja Rural', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('CT', 'Correos y telégrafos', '6290000005'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('DC', 'Dietas conductores', '6290000010'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('DH', 'Deudas Holland', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('DT', 'Dietas', '6290000011'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('E', 'Entrada mercancia', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('EN', 'Enric Martinez', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GC', 'Cuenta con dto. Comercial', '5510000003'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GP', 'Gastos de personal', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GR', 'Gastos RRPP dpto comercial', '6290001002'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GS', 'Gasoil', '6280000002'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('GV', 'Gastos viaje', '6290001000'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('JV', 'Juanvi', '6290000553'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('MB', 'Movimiento bancario', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('MP', 'Materias Primas', '6000000000'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('OG', 'Otros gastos', '6290000000'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('PM', 'Pequeño material', '6290000007'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('R', 'Factura proveedor', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('RC', 'Ingreso/Reintegro Ruralcaja', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('RN', 'Reparación nave', '6220000004'); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('SS', 'Gastos Silla', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('T', 'Ticket', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('TA', 'Factura rapida', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('TC', 'Ticket contado', NULL); +INSERT IGNORE vn.tillSerial (code, `description`, account) VALUES('TR', 'Traspaso', NULL); \ No newline at end of file diff --git a/db/versions/11135-whiteErica/00-firstScript.sql b/db/versions/11135-whiteErica/00-firstScript.sql new file mode 100644 index 000000000..902608a3e --- /dev/null +++ b/db/versions/11135-whiteErica/00-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX travel_landed_IDX USING BTREE ON vn.travel (landed DESC,warehouseInFk,warehouseOutFk); diff --git a/db/versions/11136-maroonMedeola/00-firstScript.sql b/db/versions/11136-maroonMedeola/00-firstScript.sql new file mode 100644 index 000000000..b0b92c7e9 --- /dev/null +++ b/db/versions/11136-maroonMedeola/00-firstScript.sql @@ -0,0 +1,6 @@ +RENAME TABLE vn.addressShortage TO vn.addressWaste; +ALTER TABLE vn.addressWaste ADD `type` ENUM('internal', 'external') NOT NULL; +INSERT IGNORE INTO vn.addressWaste (addressFk,`type`) VALUES + (2230,'external'), + (5986,'external'), + (7475,'external'); diff --git a/db/versions/11137-salmonRoebelini/00-firstScript.sql b/db/versions/11137-salmonRoebelini/00-firstScript.sql new file mode 100644 index 000000000..69d20ac6d --- /dev/null +++ b/db/versions/11137-salmonRoebelini/00-firstScript.sql @@ -0,0 +1,4 @@ +ALTER TABLE vn.expeditionState + MODIFY COLUMN userFk INT(10) UNSIGNED, + ADD CONSTRAINT expeditionState_userFk FOREIGN KEY (userFk) + REFERENCES account.`user`(id); \ No newline at end of file diff --git a/db/versions/11138-aquaGalax/00-firstScript.sql b/db/versions/11138-aquaGalax/00-firstScript.sql new file mode 100644 index 000000000..d492e6470 --- /dev/null +++ b/db/versions/11138-aquaGalax/00-firstScript.sql @@ -0,0 +1,8 @@ +ALTER TABLE `vn`.`claimDestination` +ADD COLUMN `code` varchar(45) DEFAULT NULL; + +UPDATE IGNORE vn.claimDestination SET code='Good' WHERE description= 'Bueno'; +UPDATE IGNORE vn.claimDestination SET code='Garbage/Loss' WHERE description = 'Basura/Perd.'; +UPDATE IGNORE vn.claimDestination SET code='Manufacturing' WHERE description = 'Confeccion'; +UPDATE IGNORE vn.claimDestination SET code='Claim' WHERE description = 'Reclam.PRAG'; +UPDATE IGNORE vn.claimDestination SET code='Corrected' WHERE description = 'Corregido'; \ No newline at end of file diff --git a/db/versions/11139-bronzeCataractarum/00-firstScript.sql b/db/versions/11139-bronzeCataractarum/00-firstScript.sql new file mode 100644 index 000000000..2816fab86 --- /dev/null +++ b/db/versions/11139-bronzeCataractarum/00-firstScript.sql @@ -0,0 +1,6 @@ +-- Place your SQL code here +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS clientTypeWidth int(10) unsigned NULL + COMMENT 'If it does not reach the required value, it will be padded with zeros on the left to meet the specified length.'; + +UPDATE vn.mrwConfig + SET clientTypeWidth = 6; \ No newline at end of file diff --git a/db/versions/11140-azurePhormium/00-firstScript.sql b/db/versions/11140-azurePhormium/00-firstScript.sql new file mode 100644 index 000000000..7c89110bb --- /dev/null +++ b/db/versions/11140-azurePhormium/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.vehicle DROP FOREIGN KEY provinceFk; +ALTER TABLE vn.vehicle + ADD CONSTRAINT vehicle_warehouse_FK FOREIGN KEY (warehouseFk) REFERENCES vn.warehouse(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11141-azureRoebelini/00-firstScript.sql b/db/versions/11141-azureRoebelini/00-firstScript.sql new file mode 100644 index 000000000..fd6d79cfb --- /dev/null +++ b/db/versions/11141-azureRoebelini/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE srt.moving DROP INDEX moving_fk1_idx; diff --git a/db/versions/11142-aquaGerbera/00-invoiceOutSerialColumn.sql b/db/versions/11142-aquaGerbera/00-invoiceOutSerialColumn.sql new file mode 100644 index 000000000..09ac00401 --- /dev/null +++ b/db/versions/11142-aquaGerbera/00-invoiceOutSerialColumn.sql @@ -0,0 +1,4 @@ +ALTER TABLE vn.invoiceOutSerial + MODIFY COLUMN `type` enum('global','quick','multiple') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL; + +CREATE UNIQUE INDEX invoiceOutSerial_taxAreaFk_IDX USING BTREE ON vn.invoiceOutSerial (taxAreaFk,`type`); diff --git a/db/versions/11142-aquaGerbera/01-invoiceOutSerialUpdate.sql b/db/versions/11142-aquaGerbera/01-invoiceOutSerialUpdate.sql new file mode 100644 index 000000000..fad33b5dc --- /dev/null +++ b/db/versions/11142-aquaGerbera/01-invoiceOutSerialUpdate.sql @@ -0,0 +1,3 @@ +UPDATE vn.invoiceOutSerial + SET `type`='multiple' + WHERE `description` LIKE '%Múltiple%'; diff --git a/db/versions/11145-pinkLaurel/00-firstScript.sql b/db/versions/11145-pinkLaurel/00-firstScript.sql new file mode 100644 index 000000000..ba1946d3b --- /dev/null +++ b/db/versions/11145-pinkLaurel/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.payrollWorker CHANGE grupotarifa__ grupotarifa int(10) NOT NULL; +ALTER TABLE vn.payrollWorker MODIFY COLUMN grupotarifa int(10) NOT NULL; \ No newline at end of file diff --git a/db/versions/11146-maroonCordyline/00-firstScript.sql b/db/versions/11146-maroonCordyline/00-firstScript.sql new file mode 100644 index 000000000..1b41422f0 --- /dev/null +++ b/db/versions/11146-maroonCordyline/00-firstScript.sql @@ -0,0 +1,11 @@ +RENAME TABLE hedera.shelfConfig TO hedera.shelfMultiConfig ; +RENAME TABLE pbx.queueConfig TO pbx.queueMultiConfig ; +RENAME TABLE salix.defaultViewConfig TO salix.defaultViewMultiConfig; +RENAME TABLE edi.fileConfig TO edi.fileMultiConfig; +RENAME TABLE edi.imapConfig TO edi.imapMultiConfig; +RENAME TABLE edi.tableConfig TO edi.tableMultiConfig; +RENAME TABLE vn.invoiceOutTaxConfig TO vn.invoiceOutTaxMultiConfig; +RENAME TABLE vn.userConfig TO vn.userMultiConfig; +RENAME TABLE vn.conveyorConfig TO vn.conveyorMultiConfig; + +GRANT SELECT ON TABLE hedera.shelfMultiConfig TO employee; diff --git a/db/versions/11149-silverSalal/00-firstScript.sql b/db/versions/11149-silverSalal/00-firstScript.sql new file mode 100644 index 000000000..e642dd2e4 --- /dev/null +++ b/db/versions/11149-silverSalal/00-firstScript.sql @@ -0,0 +1,30 @@ +ALTER TABLE vn.item CHANGE minQuantity minQuantity__ int(10) unsigned DEFAULT + NULL NULL COMMENT '@deprecated 2024-07-11 refs #7704 Cantidad mínima para una línea de venta'; + +CREATE TABLE `vn`.`itemMinimumQuantity` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemFk` int(10) NOT NULL, + `quantity` int(10) NOT NULL, + `started` date NOT NULL, + `ended` date DEFAULT NULL, + `warehouseFk` smallint(5) unsigned DEFAULT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `editorFk` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `itemMinimumQuantity_UNIQUE` (`itemFk`, `started`, `ended`, `warehouseFk`), + KEY `itemFk` (`itemFk`), + KEY `started` (`started`), + KEY `ended` (`ended`), + KEY `warehouseFk` (`warehouseFk`), + KEY `editorFk` (`editorFk`), + CONSTRAINT `itemMinimumQuantity_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `itemMinimumQuantity_ibfk_2` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, + CONSTRAINT `itemMinimumQuantity_ibfk_3` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), + CONSTRAINT `itemMinimumQuantity_check_1` CHECK (`started` <= `ended`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +GRANT SELECT, UPDATE, DELETE, INSERT ON TABLE vn.itemMinimumQuantity TO buyer; +GRANT EXECUTE ON PROCEDURE vn.ticketCalculatePurge TO guest; + +ALTER TABLE vn.itemLog MODIFY COLUMN changedModel enum('Item','ItemBarcode','ItemBotanical','ItemNiche','ItemTag','ItemTaxCountry','ItemMinimumQuantity') + CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT 'Item' NOT NULL; diff --git a/db/versions/11150-bronzeEucalyptus/00-firstScript.sql b/db/versions/11150-bronzeEucalyptus/00-firstScript.sql new file mode 100644 index 000000000..c9a619618 --- /dev/null +++ b/db/versions/11150-bronzeEucalyptus/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.itemMinimumQuantity + ADD CONSTRAINT itemMinimumQuantity_check CHECK (quantity > 0); diff --git a/db/versions/11152-goldenRaphis/00-firstScript.sql b/db/versions/11152-goldenRaphis/00-firstScript.sql new file mode 100644 index 000000000..ad58a570a --- /dev/null +++ b/db/versions/11152-goldenRaphis/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.ticketSms__ DROP FOREIGN KEY IF EXISTS ticketSms_FK; +ALTER TABLE vn.ticketSms__ ADD CONSTRAINT ticketSms_FK FOREIGN KEY (smsFk) REFERENCES vn.sms(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/11154-greenBamboo/00-firstScript.sql b/db/versions/11154-greenBamboo/00-firstScript.sql new file mode 100644 index 000000000..72a9389ec --- /dev/null +++ b/db/versions/11154-greenBamboo/00-firstScript.sql @@ -0,0 +1,2 @@ + +ALTER TABLE vn.ticketLastState MODIFY COLUMN name varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL; \ No newline at end of file diff --git a/db/versions/11154-greenBamboo/00-firstScript.vn.sql b/db/versions/11154-greenBamboo/00-firstScript.vn.sql new file mode 100644 index 000000000..374c9a031 --- /dev/null +++ b/db/versions/11154-greenBamboo/00-firstScript.vn.sql @@ -0,0 +1,2 @@ + +INSERT INTO vn.state ( name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor) VALUES('Entregado en parte', 13, 3, 'PARTIAL_DELIVERED', NULL, 16, 0, 1, 0, 0, 0, 0, 0, 0, NULL); \ No newline at end of file diff --git a/db/versions/11155-purpleMoss/00-firstScript.sql b/db/versions/11155-purpleMoss/00-firstScript.sql new file mode 100644 index 000000000..fec63b193 --- /dev/null +++ b/db/versions/11155-purpleMoss/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.invoiceInConfig + ADD dueDateMarginDays INT UNSIGNED DEFAULT 2 NULL; diff --git a/db/versions/11156-tealCordyline/00-firstScript.sql b/db/versions/11156-tealCordyline/00-firstScript.sql new file mode 100644 index 000000000..18c004b03 --- /dev/null +++ b/db/versions/11156-tealCordyline/00-firstScript.sql @@ -0,0 +1,8 @@ +ALTER TABLE vn.item ADD IF NOT EXISTS tag11 varchar(20) DEFAULT NULL NULL; +ALTER TABLE vn.item ADD IF NOT EXISTS value11 varchar(50) DEFAULT NULL NULL; + +ALTER TABLE vn.item ADD IF NOT EXISTS tag12 varchar(20) DEFAULT NULL NULL; +ALTER TABLE vn.item ADD IF NOT EXISTS value12 varchar(50) DEFAULT NULL NULL; + +ALTER TABLE vn.item ADD IF NOT EXISTS tag13 varchar(20) DEFAULT NULL NULL; +ALTER TABLE vn.item ADD IF NOT EXISTS value13 varchar(50) DEFAULT NULL NULL; \ No newline at end of file diff --git a/db/versions/11157-limeDendro/00-firstScript.sql b/db/versions/11157-limeDendro/00-firstScript.sql new file mode 100644 index 000000000..fa13f14a2 --- /dev/null +++ b/db/versions/11157-limeDendro/00-firstScript.sql @@ -0,0 +1,11 @@ + +ALTER TABLE IF EXISTS vn.sectorCollectionSaleGroup DROP FOREIGN KEY sectorCollectionSaleGroup_ibfk_3; +ALTER TABLE IF EXISTS vn.sectorCollectionSaleGroup DROP FOREIGN KEY sectorCollectionSaleGroup_ibfk_2; +ALTER TABLE IF EXISTS vn.sectorCollectionSaleGroup DROP KEY saleGroupFk; + + +ALTER TABLE IF EXISTS vn.sectorCollectionSaleGroup ADD CONSTRAINT sectorCollectionSaleGroup_saleGroup_FK + FOREIGN KEY (saleGroupFk) REFERENCES vn.saleGroup(id) ON DELETE CASCADE ON UPDATE CASCADE; + + +ALTER TABLE IF EXISTS vn.sectorCollectionSaleGroup ADD CONSTRAINT sectorCollectionSaleGroup_unique UNIQUE KEY (sectorCollectionFk,saleGroupFk); \ No newline at end of file diff --git a/db/versions/11158-redRaphis/00-firstScript.sql b/db/versions/11158-redRaphis/00-firstScript.sql new file mode 100644 index 000000000..7fe41b32b --- /dev/null +++ b/db/versions/11158-redRaphis/00-firstScript.sql @@ -0,0 +1,11 @@ +-- Place your SQL code here + +ALTER TABLE IF EXISTS vn.itemShelvingSaleReserve +ADD IF NOT EXISTS sectorFk int(11) NULL; + +ALTER TABLE IF EXISTS vn.itemShelvingSaleReserve +DROP FOREIGN KEY IF EXISTS itemShelvingSaleReserve_sector_FK; + +ALTER TABLE IF EXISTS vn.itemShelvingSaleReserve +ADD CONSTRAINT itemShelvingSaleReserve_sector_FK FOREIGN KEY (id) +REFERENCES vn.sector(id) ON DELETE RESTRICT ON UPDATE CASCADE; \ No newline at end of file diff --git a/db/versions/11159-redIvy/00-firstScript.sql b/db/versions/11159-redIvy/00-firstScript.sql new file mode 100644 index 000000000..d0b563b7a --- /dev/null +++ b/db/versions/11159-redIvy/00-firstScript.sql @@ -0,0 +1,3 @@ + + +ALTER TABLE vn.itemShelvingSale MODIFY COLUMN IF EXISTS isPicked tinyint(1) DEFAULT 1 NOT NULL; diff --git a/db/versions/11160-blueRoebelini/00-firstScript.sql b/db/versions/11160-blueRoebelini/00-firstScript.sql new file mode 100644 index 000000000..235eda7fd --- /dev/null +++ b/db/versions/11160-blueRoebelini/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.state DROP FOREIGN KEY state_ibfk_1; +ALTER TABLE vn.state ADD CONSTRAINT state_ibfk_1 FOREIGN KEY (alertLevel) REFERENCES vn.alertLevel(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11161-limeOak/00-firstScript.sql b/db/versions/11161-limeOak/00-firstScript.sql new file mode 100644 index 000000000..aab05fa49 --- /dev/null +++ b/db/versions/11161-limeOak/00-firstScript.sql @@ -0,0 +1,8 @@ + +ALTER TABLE dipole.expedition_PrintOut ADD isChecked BOOL DEFAULT FALSE NOT NULL COMMENT 'Indica si la expedición ha sido revisada por un revisor'; + +DELETE FROM salix.ACL + WHERE model = 'Expedition_PrintOut'; + +INSERT INTO salix.ACL ( model, property, accessType, permission, principalType, principalId) +VALUES( 'Expedition_PrintOut', '*', '*', 'ALLOW', 'ROLE', 'production'); \ No newline at end of file diff --git a/db/versions/11164-turquoiseRoebelini/00-firstScript.sql b/db/versions/11164-turquoiseRoebelini/00-firstScript.sql new file mode 100644 index 000000000..be45d9e95 --- /dev/null +++ b/db/versions/11164-turquoiseRoebelini/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.productionConfigLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE vn.agencyLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); diff --git a/db/versions/11165-grayAralia/00-firstScript.sql b/db/versions/11165-grayAralia/00-firstScript.sql new file mode 100644 index 000000000..652b2343a --- /dev/null +++ b/db/versions/11165-grayAralia/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.productionConfig + DROP COLUMN scannableCodeType, + DROP COLUMN scannablePreviusCodeType; diff --git a/db/versions/11166-azureDracena/00-firstScript.sql b/db/versions/11166-azureDracena/00-firstScript.sql new file mode 100644 index 000000000..ba087b5a8 --- /dev/null +++ b/db/versions/11166-azureDracena/00-firstScript.sql @@ -0,0 +1,25 @@ +CREATE OR REPLACE TABLE `salix`.`ACLLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete','select') NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `changedModel` enum('Acl') NOT NULL DEFAULT 'Acl', + `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)), + `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), + `changedModelId` int(11) NOT NULL, + `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `logRateuserFk` (`userFk`), + KEY `ACLLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), + KEY `ACLLog_originFk` (`originFk`,`creationDate`), + CONSTRAINT `aclUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +ALTER TABLE salix.ACL + ADD editorFk int(10) unsigned DEFAULT NULL NULL; + +ALTER TABLE vn.ticket + CHANGE editorFk editorFk int(10) unsigned DEFAULT NULL NULL AFTER risk; diff --git a/db/versions/11168-redFern/00-firstScript.sql b/db/versions/11168-redFern/00-firstScript.sql new file mode 100644 index 000000000..f91780e37 --- /dev/null +++ b/db/versions/11168-redFern/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.calendar + ADD CONSTRAINT calendar_user_FK FOREIGN KEY (editorFk) REFERENCES account.`user`(id); diff --git a/db/versions/11169-azureCyca/00-firstScript.sql b/db/versions/11169-azureCyca/00-firstScript.sql new file mode 100644 index 000000000..49adcfc05 --- /dev/null +++ b/db/versions/11169-azureCyca/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE IF EXISTS vn.itemShelving +MODIFY COLUMN IF EXISTS isSplit tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Este valor cambia al splitar un carro que se ha quedado en holanda'; diff --git a/db/versions/11170-redPaniculata/00-firstScript.sql b/db/versions/11170-redPaniculata/00-firstScript.sql new file mode 100644 index 000000000..b5d34c082 --- /dev/null +++ b/db/versions/11170-redPaniculata/00-firstScript.sql @@ -0,0 +1,6 @@ +-- Place your SQL code here + +ALTER TABLE vn.packingSite DROP COLUMN IF EXISTS hasNewLabelMrwMethod; + +ALTER TABLE vn.productionConfig ADD IF NOT EXISTS hasNewLabelMrwMethod BOOL DEFAULT TRUE NOT NULL + COMMENT 'column to activate the new mrw integration'; diff --git a/db/versions/11171-maroonMoss/00-firstScript.sql b/db/versions/11171-maroonMoss/00-firstScript.sql new file mode 100644 index 000000000..0632239ac --- /dev/null +++ b/db/versions/11171-maroonMoss/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.operator + ADD COLUMN sizeLimit int(10) unsigned DEFAULT 90 NULL COMMENT 'Límite de altura en una colección para la asignación de pedidos' AFTER volumeLimit, + MODIFY COLUMN linesLimit int(10) unsigned DEFAULT 20 NULL COMMENT 'Límite de lineas en una colección para la asignación de pedidos'; diff --git a/db/versions/11172-blueFern/00-firstScript.sql b/db/versions/11172-blueFern/00-firstScript.sql new file mode 100644 index 000000000..04e0813d5 --- /dev/null +++ b/db/versions/11172-blueFern/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.ticket DROP FOREIGN KEY ticket_FK; \ No newline at end of file diff --git a/db/versions/11172-blueFern/01-firstScript.sql b/db/versions/11172-blueFern/01-firstScript.sql new file mode 100644 index 000000000..64255f9de --- /dev/null +++ b/db/versions/11172-blueFern/01-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOut DROP KEY Id_Factura; diff --git a/db/versions/11172-blueFern/02-firstScript.sql b/db/versions/11172-blueFern/02-firstScript.sql new file mode 100644 index 000000000..e76b7f7d6 --- /dev/null +++ b/db/versions/11172-blueFern/02-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOut MODIFY COLUMN id int(10) unsigned NOT NULL; \ No newline at end of file diff --git a/db/versions/11172-blueFern/03-firstScript.sql b/db/versions/11172-blueFern/03-firstScript.sql new file mode 100644 index 000000000..e6def98a4 --- /dev/null +++ b/db/versions/11172-blueFern/03-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceCorrection DROP FOREIGN KEY corrected_fk; diff --git a/db/versions/11172-blueFern/04-firstScript.sql b/db/versions/11172-blueFern/04-firstScript.sql new file mode 100644 index 000000000..a19bc336e --- /dev/null +++ b/db/versions/11172-blueFern/04-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceCorrection DROP FOREIGN KEY correcting_fk; diff --git a/db/versions/11172-blueFern/05-firstScript.sql b/db/versions/11172-blueFern/05-firstScript.sql new file mode 100644 index 000000000..9f5ec2871 --- /dev/null +++ b/db/versions/11172-blueFern/05-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOutExpense DROP FOREIGN KEY invoiceOutExpence_FK_1; diff --git a/db/versions/11172-blueFern/06-firstScript.sql b/db/versions/11172-blueFern/06-firstScript.sql new file mode 100644 index 000000000..2c16e9b77 --- /dev/null +++ b/db/versions/11172-blueFern/06-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOutTax DROP FOREIGN KEY invoiceOutFk; diff --git a/db/versions/11172-blueFern/07-firstScript.sql b/db/versions/11172-blueFern/07-firstScript.sql new file mode 100644 index 000000000..bec72a131 --- /dev/null +++ b/db/versions/11172-blueFern/07-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOut DROP PRIMARY KEY; diff --git a/db/versions/11172-blueFern/08-firstScript.sql b/db/versions/11172-blueFern/08-firstScript.sql new file mode 100644 index 000000000..316db2e32 --- /dev/null +++ b/db/versions/11172-blueFern/08-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOut ADD CONSTRAINT invoiceOut_pk PRIMARY KEY (id); diff --git a/db/versions/11172-blueFern/09-firstScript.sql b/db/versions/11172-blueFern/09-firstScript.sql new file mode 100644 index 000000000..553d7857e --- /dev/null +++ b/db/versions/11172-blueFern/09-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOut ADD CONSTRAINT invoiceOut_unique UNIQUE KEY (`ref`); diff --git a/db/versions/11172-blueFern/10-firstScript.sql b/db/versions/11172-blueFern/10-firstScript.sql new file mode 100644 index 000000000..47ddaff14 --- /dev/null +++ b/db/versions/11172-blueFern/10-firstScript.sql @@ -0,0 +1,5 @@ +UPDATE vn.invoiceOut + SET id = (SELECT MAX(id) + 1 FROM vn.invoiceOut) + WHERE id = 0; + +ALTER TABLE vn.invoiceOut MODIFY COLUMN id int(10) unsigned auto_increment NOT NULL; diff --git a/db/versions/11172-blueFern/11-firstScript.sql b/db/versions/11172-blueFern/11-firstScript.sql new file mode 100644 index 000000000..e1847a877 --- /dev/null +++ b/db/versions/11172-blueFern/11-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.ticket ADD CONSTRAINT ticket_invoiceOut_FK + FOREIGN KEY (refFk) REFERENCES vn.invoiceOut(`ref`) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11172-blueFern/12-firstScript.sql b/db/versions/11172-blueFern/12-firstScript.sql new file mode 100644 index 000000000..720b7962e --- /dev/null +++ b/db/versions/11172-blueFern/12-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.invoiceCorrection ADD CONSTRAINT invoiceCorrection_invoiceOut_FK + FOREIGN KEY (correctingFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/11172-blueFern/13-firstScript.sql b/db/versions/11172-blueFern/13-firstScript.sql new file mode 100644 index 000000000..35099bd5d --- /dev/null +++ b/db/versions/11172-blueFern/13-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.invoiceCorrection ADD CONSTRAINT invoiceCorrection_invoiceOut_FK_1 + FOREIGN KEY (correctedFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; \ No newline at end of file diff --git a/db/versions/11172-blueFern/14-firstScript.sql b/db/versions/11172-blueFern/14-firstScript.sql new file mode 100644 index 000000000..f1aa0a216 --- /dev/null +++ b/db/versions/11172-blueFern/14-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.invoiceOutExpense ADD CONSTRAINT invoiceOutExpense_invoiceOut_FK + FOREIGN KEY (invoiceOutFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/11172-blueFern/15-firstScript.sql b/db/versions/11172-blueFern/15-firstScript.sql new file mode 100644 index 000000000..ba570e20c --- /dev/null +++ b/db/versions/11172-blueFern/15-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.invoiceOutTax ADD CONSTRAINT invoiceOutTax_invoiceOut_FK + FOREIGN KEY (invoiceOutFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/11175-pinkChico/00-firstScript.sql b/db/versions/11175-pinkChico/00-firstScript.sql new file mode 100644 index 000000000..349f4c7f7 --- /dev/null +++ b/db/versions/11175-pinkChico/00-firstScript.sql @@ -0,0 +1,8 @@ +USE vn; + +CREATE TABLE IF NOT EXISTS ormConfig ( + id int(5) NOT NULL AUTO_INCREMENT primary key, + selectLimit int(5) NOT NULL +); + +INSERT IGNORE INTO ormConfig SET selectLimit = 1000; \ No newline at end of file diff --git a/db/versions/11177-crimsonPaniculata/00-firstScript.sql b/db/versions/11177-crimsonPaniculata/00-firstScript.sql new file mode 100644 index 000000000..79bcf1291 --- /dev/null +++ b/db/versions/11177-crimsonPaniculata/00-firstScript.sql @@ -0,0 +1,6 @@ +-- Place your SQL code here + +ALTER TABLE vn.itemShelvingSaleReserve DROP FOREIGN KEY IF EXISTS itemShelvingSaleReserve_sector_FK; + +ALTER TABLE vn.itemShelvingSaleReserve ADD CONSTRAINT itemShelvingSaleReserve_sector_FK + FOREIGN KEY IF NOT EXISTS (sectorFk) REFERENCES vn.sector(id) ON DELETE RESTRICT ON UPDATE CASCADE; \ No newline at end of file diff --git a/db/versions/11178-yellowCamellia/00-aclSetWeight.sql b/db/versions/11178-yellowCamellia/00-aclSetWeight.sql new file mode 100644 index 000000000..d70287738 --- /dev/null +++ b/db/versions/11178-yellowCamellia/00-aclSetWeight.sql @@ -0,0 +1,9 @@ +-- Place your SQL code here +INSERT INTO salix.ACL + SET model = 'Ticket', + property = 'setWeight', + accessType = 'WRITE', + permission = 'ALLOW', + principalType = 'ROLE', + principalId = 'salesPerson'; + \ No newline at end of file diff --git a/db/versions/11179-whiteLaurel/00-firstScript.sql b/db/versions/11179-whiteLaurel/00-firstScript.sql new file mode 100644 index 000000000..4a4e32c9d --- /dev/null +++ b/db/versions/11179-whiteLaurel/00-firstScript.sql @@ -0,0 +1,2 @@ +RENAME TABLE vn.silexACL TO vn.silexACL__; +ALTER TABLE vn.silexACL__ COMMENT='@deprecated 2024-08-05 refs #7820'; diff --git a/db/versions/11180-navyGerbera/00-firstScript.sql b/db/versions/11180-navyGerbera/00-firstScript.sql new file mode 100644 index 000000000..8c5d79ce8 --- /dev/null +++ b/db/versions/11180-navyGerbera/00-firstScript.sql @@ -0,0 +1,2 @@ +-- Place your SQL code here +ALTER TABLE vn.invoiceInConfig ADD balanceStartingDate DATE DEFAULT '2015-01-01' NOT NULL; diff --git a/db/versions/11182-redAralia/00-firstScript.sql b/db/versions/11182-redAralia/00-firstScript.sql new file mode 100644 index 000000000..72c06de65 --- /dev/null +++ b/db/versions/11182-redAralia/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE bs.waste CHANGE saleQuantity saleWasteQuantity decimal(10,2) DEFAULT NULL NULL AFTER saleTotal; +ALTER TABLE bs.waste MODIFY COLUMN saleTotal decimal(10,2) DEFAULT NULL NULL COMMENT 'Coste'; diff --git a/db/versions/11183-limePhormium/00-firstScript.sql b/db/versions/11183-limePhormium/00-firstScript.sql new file mode 100644 index 000000000..a30338f9e --- /dev/null +++ b/db/versions/11183-limePhormium/00-firstScript.sql @@ -0,0 +1,23 @@ +CREATE OR REPLACE TABLE `vn`.`saleGroupLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete','select') NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `changedModel` enum('SaleGroup', 'SaleGroupDetail') NOT NULL DEFAULT 'SaleGroup', + `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)), + `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), + `changedModelId` int(11) NOT NULL, + `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, + `reason` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `saleGroupUserFk` (`userFk`), + KEY `saleGroupLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), + KEY `saleGroupLog_originFk` (`originFk`,`creationDate`), + CONSTRAINT `saleGroupLogUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +ALTER TABLE vn.parkingLog + MODIFY COLUMN changedModel enum('Parking') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT 'Parking' NOT NULL; diff --git a/db/versions/11185-maroonArborvitae/00-firstScript.sql b/db/versions/11185-maroonArborvitae/00-firstScript.sql new file mode 100644 index 000000000..b07126e71 --- /dev/null +++ b/db/versions/11185-maroonArborvitae/00-firstScript.sql @@ -0,0 +1 @@ +DROP TABLE bi.Greuges_comercial_detail; \ No newline at end of file diff --git a/db/versions/11187-yellowErica/00-firstScript.sql b/db/versions/11187-yellowErica/00-firstScript.sql new file mode 100644 index 000000000..fb75b1f2f --- /dev/null +++ b/db/versions/11187-yellowErica/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.host ADD editorFk int(10) unsigned DEFAULT NULL NULL; diff --git a/db/versions/11189-purplePaniculata/00-firstScript.sql b/db/versions/11189-purplePaniculata/00-firstScript.sql new file mode 100644 index 000000000..3319bd154 --- /dev/null +++ b/db/versions/11189-purplePaniculata/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.item + ADD CONSTRAINT item_itemPackingType_FK FOREIGN KEY (itemPackingTypeFk) + REFERENCES vn.itemPackingType(code) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11190-blueLaurel/00-firstScript.sql b/db/versions/11190-blueLaurel/00-firstScript.sql new file mode 100644 index 000000000..75e3f8e59 --- /dev/null +++ b/db/versions/11190-blueLaurel/00-firstScript.sql @@ -0,0 +1,9 @@ +ALTER TABLE hedera.tpvMerchantEnable + DROP FOREIGN KEY tpvMerchantEnable_ibfk_1, + DROP PRIMARY KEY, + ADD CONSTRAINT tpvMerchantEnable_pk PRIMARY KEY (merchantFk), + ADD CONSTRAINT tpvMerchantEnable_tpvMerchant_FK + FOREIGN KEY (merchantFk) + REFERENCES hedera.tpvMerchant(id) + ON DELETE RESTRICT + ON UPDATE CASCADE; diff --git a/db/versions/11191-chocolateBirch/00-firstScript.sql b/db/versions/11191-chocolateBirch/00-firstScript.sql new file mode 100644 index 000000000..4c9924a42 --- /dev/null +++ b/db/versions/11191-chocolateBirch/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.mandateType + CHANGE name code VARCHAR(45) NOT NULL, + ADD UNIQUE (code); \ No newline at end of file diff --git a/db/versions/11191-chocolateBirch/01-firstScript.sql b/db/versions/11191-chocolateBirch/01-firstScript.sql new file mode 100644 index 000000000..c69e92d51 --- /dev/null +++ b/db/versions/11191-chocolateBirch/01-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.accountDetailType + ADD COLUMN code VARCHAR(45), + ADD UNIQUE (code); \ No newline at end of file diff --git a/db/versions/11191-chocolateBirch/02-firstScript.sql b/db/versions/11191-chocolateBirch/02-firstScript.sql new file mode 100644 index 000000000..733cffd63 --- /dev/null +++ b/db/versions/11191-chocolateBirch/02-firstScript.sql @@ -0,0 +1,9 @@ +UPDATE vn.accountDetailType + SET code = CASE description + WHEN 'IBAN' THEN 'iban' + WHEN 'SWIFT' THEN 'swift' + WHEN 'Referencia Remesas' THEN 'remRef' + WHEN 'Referencia Transferencias' THEN 'trnRef' + WHEN 'Referencia Nominas' THEN 'payRef' + WHEN 'ABA' THEN 'aba' + END; \ No newline at end of file diff --git a/db/versions/11192-maroonSalal/00-firstScript.sql b/db/versions/11192-maroonSalal/00-firstScript.sql new file mode 100644 index 000000000..ac35a3db3 --- /dev/null +++ b/db/versions/11192-maroonSalal/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE hedera.tpvMerchantEnable + MODIFY COLUMN companyFk int(10) unsigned NOT NULL, + ADD CONSTRAINT tpvMerchantEnable_company_FK FOREIGN KEY (companyFk) REFERENCES vn.company(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11193-bronzeAspidistra/00-firstScript.sql b/db/versions/11193-bronzeAspidistra/00-firstScript.sql new file mode 100644 index 000000000..cc837d007 --- /dev/null +++ b/db/versions/11193-bronzeAspidistra/00-firstScript.sql @@ -0,0 +1,19 @@ +CREATE OR REPLACE TABLE `srt`.`bufferLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete','select') NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `changedModel` enum('Buffer', 'Config') NOT NULL DEFAULT 'Buffer', + `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)), + `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), + `changedModelId` int(11) NOT NULL, + `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `logBufferUserFk` (`userFk`), + KEY `bufferLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), + KEY `bufferLog_originFk` (`originFk`,`creationDate`), + CONSTRAINT `bufferUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; diff --git a/db/versions/11193-bronzeAspidistra/01-firstScript.sql b/db/versions/11193-bronzeAspidistra/01-firstScript.sql new file mode 100644 index 000000000..748056f3a --- /dev/null +++ b/db/versions/11193-bronzeAspidistra/01-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE srt.buffer ADD editorFk int(10) unsigned DEFAULT NULL NULL; diff --git a/db/versions/11193-bronzeAspidistra/02-firstScript.sql b/db/versions/11193-bronzeAspidistra/02-firstScript.sql new file mode 100644 index 000000000..36aa938d5 --- /dev/null +++ b/db/versions/11193-bronzeAspidistra/02-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE srt.config ADD editorFk int(10) unsigned DEFAULT NULL NULL; diff --git a/db/versions/11194-orangeOrchid/00-firstScript.sql b/db/versions/11194-orangeOrchid/00-firstScript.sql new file mode 100644 index 000000000..59a616edf --- /dev/null +++ b/db/versions/11194-orangeOrchid/00-firstScript.sql @@ -0,0 +1,9 @@ +CREATE TABLE vn.quadMindsApiConfig ( + id int(10) unsigned NULL PRIMARY KEY, + `url` varchar(255) DEFAULT NULL NULL, + `key` varchar(255) DEFAULT NULL NULL, + CONSTRAINT quadMindsConfig_check CHECK (id = 1) +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci; diff --git a/db/versions/11195-salmonPalmetto/00-firstScript.sql b/db/versions/11195-salmonPalmetto/00-firstScript.sql new file mode 100644 index 000000000..980b66c8d --- /dev/null +++ b/db/versions/11195-salmonPalmetto/00-firstScript.sql @@ -0,0 +1,6 @@ +ALTER TABLE vn.roadmap + ADD COLUMN m3 INT UNSIGNED NULL, + ADD COLUMN driver2Fk INT UNSIGNED NULL, + ADD COLUMN driver1Fk INT UNSIGNED NULL, + ADD CONSTRAINT roadmap_worker_FK FOREIGN KEY (driver1Fk) REFERENCES vn.worker(id) ON DELETE RESTRICT ON UPDATE CASCADE, + ADD CONSTRAINT roadmap_worker_FK_2 FOREIGN KEY (driver2Fk) REFERENCES vn.worker(id) ON DELETE RESTRICT ON UPDATE CASCADE; \ No newline at end of file diff --git a/db/versions/11196-blackCymbidium/00-firstScript.sql b/db/versions/11196-blackCymbidium/00-firstScript.sql new file mode 100644 index 000000000..e05225204 --- /dev/null +++ b/db/versions/11196-blackCymbidium/00-firstScript.sql @@ -0,0 +1,7 @@ +RENAME TABLE vn.quadMindsApiConfig TO vn.quadmindsApiConfig; + +ALTER TABLE vn.quadmindsApiConfig + ADD maxObjects INT NULL COMMENT 'Número máximo de objetos en el array por petición', + ADD `limit` INT NULL COMMENT 'Limite de objetos solicitados por petición', + ADD `orderTimeFrom` VARCHAR(5) NULL COMMENT 'Inicio de ventana horaria de pedido', + ADD `orderTimeTo` VARCHAR(5) NULL COMMENT 'Fin de ventana horaria de pedido'; diff --git a/db/versions/11197-aquaSalal/00-firstScript.sql b/db/versions/11197-aquaSalal/00-firstScript.sql new file mode 100644 index 000000000..f07368d3e --- /dev/null +++ b/db/versions/11197-aquaSalal/00-firstScript.sql @@ -0,0 +1,24 @@ +DELETE FROM `salix`.`ACL` + WHERE `model` = 'Ticket' + AND `property` = 'refund' + AND `accessType` = 'WRITE' + AND `permission` = 'ALLOW' + AND `principalType` = 'ROLE' + AND `principalId` = 'salesAssistant'; + +UPDATE `salix`.`ACL` + SET `property` = 'cloneAll' + WHERE `model` = 'Ticket' + AND `property` = 'refund' + AND `accessType` = 'WRITE' + AND `permission` = 'ALLOW' + AND `principalType` = 'ROLE' + AND `principalId` IN ('invoicing', 'claimManager', 'logistic'); + +DELETE FROM `salix`.`ACL` + WHERE `model` = 'Ticket' + AND `property` = 'clone' + AND `accessType` = 'WRITE' + AND `permission` = 'ALLOW' + AND `principalType` = 'ROLE' + AND `principalId` = 'administrative'; diff --git a/db/versions/11198-blackPhormium/00-firstScript.sql b/db/versions/11198-blackPhormium/00-firstScript.sql new file mode 100644 index 000000000..6c181ed21 --- /dev/null +++ b/db/versions/11198-blackPhormium/00-firstScript.sql @@ -0,0 +1,7 @@ +UPDATE vn.itemShelving + SET isChecked = TRUE + WHERE isChecked; + +UPDATE vn.itemShelving + SET isChecked = FALSE + WHERE NOT isChecked; diff --git a/db/versions/11201-limeChrysanthemum/00-firstScript.sql b/db/versions/11201-limeChrysanthemum/00-firstScript.sql new file mode 100644 index 000000000..943368b06 --- /dev/null +++ b/db/versions/11201-limeChrysanthemum/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here +ALTER TABLE vn.saleGroup ADD stateFk TINYINT(3) UNSIGNED; + +ALTER TABLE vn.saleGroup ADD CONSTRAINT saleGroup_state_FK FOREIGN KEY (stateFk) REFERENCES vn.state(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11204-navyMonstera/00-firstScript.sql b/db/versions/11204-navyMonstera/00-firstScript.sql new file mode 100644 index 000000000..492e3d607 --- /dev/null +++ b/db/versions/11204-navyMonstera/00-firstScript.sql @@ -0,0 +1,5 @@ +ALTER TABLE vn.ormConfig +MODIFY COLUMN id INT NOT NULL, +DROP PRIMARY KEY, +ADD CONSTRAINT ormConfig_check CHECK (id = 1), +ADD PRIMARY KEY (id); \ No newline at end of file diff --git a/db/versions/11205-grayCymbidium/00-firstScript.sql b/db/versions/11205-grayCymbidium/00-firstScript.sql new file mode 100644 index 000000000..ba3ab60e1 --- /dev/null +++ b/db/versions/11205-grayCymbidium/00-firstScript.sql @@ -0,0 +1,2 @@ +-- Place your SQL code here +ALTER TABLE dipole.expedition_PrintOut MODIFY COLUMN isPrinted int(11) DEFAULT 0 NOT NULL COMMENT '0.- Not Printed ; 1.- Printed; 2.- Selected ; 3.- Error ; 4.- Waiting to be printed'; diff --git a/db/versions/11206-turquoiseCyca/00-firstScript.sql b/db/versions/11206-turquoiseCyca/00-firstScript.sql new file mode 100644 index 000000000..ab6b35a0f --- /dev/null +++ b/db/versions/11206-turquoiseCyca/00-firstScript.sql @@ -0,0 +1,2 @@ +INSERT IGNORE INTO salix.ACL (model,property,principalId) + VALUES ('Entry','getBuysCsv','supplier'); diff --git a/db/versions/11207-turquoiseMastic/00-firstScript.sql b/db/versions/11207-turquoiseMastic/00-firstScript.sql new file mode 100644 index 000000000..d1fd184aa --- /dev/null +++ b/db/versions/11207-turquoiseMastic/00-firstScript.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) + VALUES ('InvoiceOut','refundAndInvoice','WRITE','ALLOW','ROLE','administrative'); diff --git a/db/versions/11208-limeRoebelini/00-firstScript.vn.sql b/db/versions/11208-limeRoebelini/00-firstScript.vn.sql new file mode 100644 index 000000000..22b3dc924 --- /dev/null +++ b/db/versions/11208-limeRoebelini/00-firstScript.vn.sql @@ -0,0 +1,7 @@ +UPDATE vn.packaging SET id='25E' WHERE id='cactus200'; +UPDATE vn.packaging SET id='35E' WHERE id='kalan330'; +UPDATE vn.packaging SET id='45E' WHERE id='kalan400'; +UPDATE vn.packaging SET id='60E' WHERE id='kalan577'; +UPDATE vn.packaging SET id='60A' WHERE id='guzma650'; +UPDATE vn.packaging SET id='120A' WHERE id='guzma1200'; +UPDATE vn.packaging SET id='140A' WHERE id='guzma1400'; diff --git a/db/versions/11209-pinkOrchid/00-firstScript.sql b/db/versions/11209-pinkOrchid/00-firstScript.sql new file mode 100644 index 000000000..92a7a7569 --- /dev/null +++ b/db/versions/11209-pinkOrchid/00-firstScript.sql @@ -0,0 +1,6 @@ +ALTER TABLE vn.operator + MODIFY COLUMN sizeLimit int(10) unsigned DEFAULT NULL NULL COMMENT 'Límite de altura en una colección para la asignación de pedidos'; + +UPDATE vn.operator + SET sizeLimit = 90 + WHERE itemPackingTypeFk = 'V'; diff --git a/db/versions/11210-greenDendro/00-firstScript.sql b/db/versions/11210-greenDendro/00-firstScript.sql new file mode 100644 index 000000000..58e6450d6 --- /dev/null +++ b/db/versions/11210-greenDendro/00-firstScript.sql @@ -0,0 +1,8 @@ +ALTER TABLE util.config + CHANGE dbVersion dbVersion__ char(11) DEFAULT NULL COMMENT '@deprecated 2024-09-02 refs #7819'; + +ALTER TABLE util.config + CHANGE hasTriggersDisabled hasTriggersDisabled__ tinyint(1) DEFAULT 0 NOT NULL COMMENT '@deprecated 2024-09-02 refs #7819'; + +RENAME TABLE account.accountLog TO account.accountLog__; + ALTER TABLE account.accountLog__ COMMENT='@deprecated 2024-09-02 refs #7819'; diff --git a/db/versions/11210-greenDendro/01-firstScript.sql b/db/versions/11210-greenDendro/01-firstScript.sql new file mode 100644 index 000000000..787011343 --- /dev/null +++ b/db/versions/11210-greenDendro/01-firstScript.sql @@ -0,0 +1 @@ +DROP DATABASE IF EXISTS `.mysqlworkbench`; \ No newline at end of file diff --git a/db/versions/11210-greenDendro/02-firstScript.sql b/db/versions/11210-greenDendro/02-firstScript.sql new file mode 100644 index 000000000..2603c5df5 --- /dev/null +++ b/db/versions/11210-greenDendro/02-firstScript.sql @@ -0,0 +1,84 @@ +ALTER TABLE bi.rutasBoard DROP COLUMN coste_bulto__; +ALTER TABLE bi.rutasBoard DROP COLUMN Dia__; +ALTER TABLE bi.rutasBoard DROP COLUMN km__; +ALTER TABLE bi.rutasBoard DROP COLUMN m3__; +ALTER TABLE bi.rutasBoard DROP COLUMN Matricula__; +ALTER TABLE bi.rutasBoard DROP COLUMN month__; +ALTER TABLE bi.rutasBoard DROP COLUMN Terceros__; +ALTER TABLE bi.rutasBoard DROP COLUMN Tipo__; +ALTER TABLE bi.rutasBoard DROP COLUMN warehouse_id__; +ALTER TABLE bi.rutasBoard DROP COLUMN year__; + +ALTER TABLE bs.clientDied DROP COLUMN Boss__; +ALTER TABLE bs.clientDied DROP COLUMN clientName__; +ALTER TABLE bs.clientDied DROP COLUMN workerCode__; + +ALTER TABLE bs.salesByItemTypeDay DROP COLUMN netSale__; + +ALTER TABLE vn.agency DROP FOREIGN KEY agency_FK; +ALTER TABLE vn.agency DROP COLUMN warehouseAliasFk__; + +ALTER TABLE vn.awbComponent DROP COLUMN dated__; + +ALTER TABLE vn.buy DROP COLUMN containerFk__; + +ALTER TABLE vn.chat DROP COLUMN status__; + +ALTER TABLE vn.claim DROP COLUMN rma__; + +ALTER TABLE vn.client DROP COLUMN clientTypeFk__; +ALTER TABLE vn.client DROP COLUMN hasIncoterms__; + +ALTER TABLE vn.clientType DROP COLUMN id__; + +ALTER TABLE vn.cmr DROP FOREIGN KEY cmr_fk1; +ALTER TABLE vn.cmr DROP COLUMN ticketFk__; + +ALTER TABLE vn.company DROP COLUMN sage200Company__; + +ALTER TABLE vn.country DROP FOREIGN KEY country_FK; +ALTER TABLE vn.country DROP COLUMN politicalCountryFk__; + +ALTER TABLE vn.deliveryNote DROP FOREIGN KEY albaran_FK; +ALTER TABLE vn.deliveryNote DROP COLUMN farmingFk__; + +ALTER TABLE vn.dmsType DROP COLUMN path__; + +ALTER TABLE vn.dua DROP COLUMN awbFk__; + +ALTER TABLE vn.entry DROP COLUMN isBlocked__; + +ALTER TABLE vn.expedition DROP COLUMN itemFk__; + +ALTER TABLE vn.item DROP COLUMN minQuantity__; +ALTER TABLE vn.item DROP COLUMN packingShelve__; + +ALTER TABLE vn.itemType DROP COLUMN compression__; +ALTER TABLE vn.itemType DROP COLUMN density__; +ALTER TABLE vn.itemType DROP COLUMN hasComponents__; +ALTER TABLE vn.itemType DROP COLUMN location__; +ALTER TABLE vn.itemType DROP COLUMN maneuver__; +ALTER TABLE vn.itemType DROP COLUMN profit__; +ALTER TABLE vn.itemType DROP COLUMN target__; +ALTER TABLE vn.itemType DROP COLUMN topMargin__; +ALTER TABLE vn.itemType DROP COLUMN transaction__; +ALTER TABLE vn.itemType DROP FOREIGN KEY warehouseFk5; +ALTER TABLE vn.itemType DROP COLUMN warehouseFk__; + +ALTER TABLE vn.ledgerConfig DROP COLUMN lastBookEntry__; + +ALTER TABLE vn.saleTracking DROP FOREIGN KEY saleTracking_FK_1; +ALTER TABLE vn.saleTracking DROP COLUMN actionFk__; + +ALTER TABLE vn.supplier DROP COLUMN isFarmer__; + +ALTER TABLE vn.supplierAccount DROP COLUMN description__; + +ALTER TABLE vn.ticketRequest DROP COLUMN buyerCode__; + +ALTER TABLE vn.travel DROP COLUMN agencyFk__; + +ALTER TABLE vn.warehouse DROP FOREIGN KEY warehouse_ibfk_2; +ALTER TABLE vn.warehouse DROP COLUMN aliasFk__; + +ALTER TABLE vn.worker DROP COLUMN labelerFk__; diff --git a/db/versions/11210-greenDendro/03-firstScript.sql b/db/versions/11210-greenDendro/03-firstScript.sql new file mode 100644 index 000000000..f8157b756 --- /dev/null +++ b/db/versions/11210-greenDendro/03-firstScript.sql @@ -0,0 +1,21 @@ +DROP TABLE IF EXISTS account.mailClientAccess__; +DROP TABLE IF EXISTS account.mailSenderAccess__; +DROP TABLE IF EXISTS bi.analisis_ventas_familia_evolution__; +DROP TABLE IF EXISTS bi.live_counter__; +DROP TABLE IF EXISTS bi.partitioning_information__; +DROP TABLE IF EXISTS bi.primer_pedido__; +DROP TABLE IF EXISTS bi.tarifa_premisas__; +DROP TABLE IF EXISTS bi.tarifa_warehouse__; +DROP TABLE IF EXISTS bs.compradores__; +DROP TABLE IF EXISTS bs.salesMonthlySnapshot___; +DROP TABLE IF EXISTS bs.salesPerson__; +DROP TABLE IF EXISTS bs.vendedores_evolution__; +DROP TABLE IF EXISTS vn.botanicExport__; +DROP TABLE IF EXISTS vn.claimRma__; +DROP TABLE IF EXISTS vn.coolerPathDetail__; +DROP TABLE IF EXISTS vn.forecastedBalance__; +DROP TABLE IF EXISTS vn.routeLoadWorker__; +DROP TABLE IF EXISTS vn.routeUserPercentage__; +DROP TABLE IF EXISTS vn.ticketSms__; +DROP TABLE IF EXISTS vn.ticketTrackingState__; +DROP TABLE IF EXISTS vn.warehouseAlias__; diff --git a/db/versions/11211-greenCataractarum/00-firstScript.sql b/db/versions/11211-greenCataractarum/00-firstScript.sql new file mode 100644 index 000000000..c9ba73479 --- /dev/null +++ b/db/versions/11211-greenCataractarum/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.parking ADD COLUMN floor VARCHAR(5) DEFAULT NULL AFTER row; diff --git a/db/versions/11213-aquaCarnation/00-firstScript.sql b/db/versions/11213-aquaCarnation/00-firstScript.sql new file mode 100644 index 000000000..9e744b66c --- /dev/null +++ b/db/versions/11213-aquaCarnation/00-firstScript.sql @@ -0,0 +1,129 @@ + +use vn; + +CREATE TABLE IF NOT EXISTS `material` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO `material` (`name`) VALUES ('Abedul'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Acacia'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Acero'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Acero Galvanizado'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Acetato'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Acrílico'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Alambre'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Algodón'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Aluminio'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Antracita'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Arcilla'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Bambú'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Banano'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Canneté'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cartón'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cartulina'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Celofán'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cemento'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cera'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cerámica'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Chapa'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Chenilla'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cloruro de polivinilo'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cobre'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Corcho'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cordel'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cotton'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cotton Chess'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cristal'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cubo Asa'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cuerda'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Cuero'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Doble Raso'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Doble Velvet'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Eco Glass'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Encaje'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Esparto'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Espuma'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Felpa'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Fibra'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Fibra de Coco'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Fibra de Vidrio y Resina'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Fieltro'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Foam'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Gamuza'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Gasa'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Glass'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Goma'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Grafito'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Hierro'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Hoja Carbono'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Hoja de Mirto'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Hormigón'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Jute'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Kraft'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Lana'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Látex'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Latrix'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Lienzo'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Lino'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Lurex'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Madera'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Metacrilato'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Metal'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Mimbre'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Musgo'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Nonwoven'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Nylon'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Organza'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Paja'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Pana'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Papel'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Paperweb'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Paulownia'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Peluche'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Piedra'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Pizarra'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Plástico'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Poliestireno'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Polipropileno'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Poliresina'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Polyester'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Porcelana'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Puntilla'); +INSERT IGNORE INTO `material` (`name`) VALUES ('PVC'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Rafia'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Rama'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Raso'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Rattan'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Rayon'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Reciclable'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Red'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Resina'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Roca'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Rope'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Saco'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Salim'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Seagrass'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Silicona'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Sisal'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Tejido'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Tela'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Terciopelo'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Terracota'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Textil'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Titanio'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Tul'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Velvet'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Vidrio'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Yute'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Zinc'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Base de goma'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Base de madera'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Plumas'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Protección Uva'); +INSERT IGNORE INTO `material` (`name`) VALUES ('Purpurina'); + +UPDATE vn.tag SET isFree=0,sourceTable='material' WHERE name= 'Material'; +UPDATE vn.tag SET isFree=0,sourceTable='material' WHERE name='Material secundario'; \ No newline at end of file diff --git a/db/versions/11215-purpleIvy/00-firstScript.sql b/db/versions/11215-purpleIvy/00-firstScript.sql new file mode 100644 index 000000000..ac82b7773 --- /dev/null +++ b/db/versions/11215-purpleIvy/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) + VALUES ('Worker', '__get__descriptor', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Worker', 'findById', 'READ', 'ALLOW', 'ROLE', '$subordinate'); \ No newline at end of file diff --git a/db/versions/11216-salmonPaniculata/00-firstScript.sql b/db/versions/11216-salmonPaniculata/00-firstScript.sql new file mode 100644 index 000000000..956dcc25b --- /dev/null +++ b/db/versions/11216-salmonPaniculata/00-firstScript.sql @@ -0,0 +1,12 @@ +-- Place your SQL code here +DELETE FROM salix.ACL WHERE model = 'Province' LIMIT 1; +DELETE FROM salix.ACL WHERE model = 'Town' LIMIT 1; + +UPDATE salix.ACL SET accessType = 'READ' WHERE model = 'BankEntity'; +INSERT INTO salix.ACL + SET model = 'BankEntity', + property = '*', + accessType = 'WRITE', + permission = 'ALLOW', + principalType = 'ROLE', + principalId = 'financial'; diff --git a/db/versions/11217-greenDracena/00-hederaMessages.sql b/db/versions/11217-greenDracena/00-hederaMessages.sql new file mode 100644 index 000000000..f6c9bdce3 --- /dev/null +++ b/db/versions/11217-greenDracena/00-hederaMessages.sql @@ -0,0 +1,19 @@ +INSERT INTO hedera.message (code,description) + VALUES ('ORDER_ROW_UNAVAILABLE','The ordered quantity exceeds the available'); +INSERT INTO hedera.message (code,description) + VALUES ('AMOUNT_NOT_MATCH_GROUPING','The quantity ordered does not match the grouping'); + +INSERT INTO hedera.messageI18n (code,lang,description) + VALUES ('ORDER_ROW_UNAVAILABLE','es','La cantidad pedida excede el disponible'); +INSERT INTO hedera.messageI18n (code,lang,description) + VALUES ('AMOUNT_NOT_MATCH_GROUPING','es','La cantidad pedida no coincide con el agrupado'); + +INSERT INTO hedera.messageI18n (code,lang,description) + VALUES ('ORDER_ROW_UNAVAILABLE','fr','La quantité demandée dépasse ce qui est disponible'); +INSERT INTO hedera.messageI18n (code,lang,description) + VALUES ('AMOUNT_NOT_MATCH_GROUPING','fr','La quantité commandée ne correspond pas au regroupement'); + +INSERT INTO hedera.messageI18n (code,lang,description) + VALUES ('ORDER_ROW_UNAVAILABLE','pt','A quantidade de entrega excede a disponibilidade'); +INSERT INTO hedera.messageI18n (code,lang,description) + VALUES ('AMOUNT_NOT_MATCH_GROUPING','pt','A quantidade solicitada não corresponde ao agrupamento'); diff --git a/db/versions/11219-goldenCataractarum/00-firstScript.sql b/db/versions/11219-goldenCataractarum/00-firstScript.sql new file mode 100644 index 000000000..4c4b9eac5 --- /dev/null +++ b/db/versions/11219-goldenCataractarum/00-firstScript.sql @@ -0,0 +1 @@ +CREATE INDEX saleGroupLog_creationDate_IDX USING BTREE ON vn.saleGroupLog (creationDate DESC); diff --git a/db/versions/11221-chocolateSalal/00-firstScript.sql b/db/versions/11221-chocolateSalal/00-firstScript.sql new file mode 100644 index 000000000..bca742585 --- /dev/null +++ b/db/versions/11221-chocolateSalal/00-firstScript.sql @@ -0,0 +1,9 @@ +-- Place your SQL code here +CREATE TABLE IF NOT EXISTS vn.ticketCanAdvanceConfig ( + id int(10) unsigned NOT NULL, + destinationOrder INT NULL, + PRIMARY KEY (`id`), + CONSTRAINT `ticketCanAdvanceConfig_check` CHECK (`id` = 1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT INTO vn.ticketCanAdvanceConfig SET id =1, destinationOrder = 5; \ No newline at end of file diff --git a/db/versions/11222-azureCordyline/00-firstScript.sql b/db/versions/11222-azureCordyline/00-firstScript.sql new file mode 100644 index 000000000..c63228911 --- /dev/null +++ b/db/versions/11222-azureCordyline/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.state DROP COLUMN sectorProdPriority; diff --git a/db/versions/11223-turquoiseLilium/00-firstScript.sql b/db/versions/11223-turquoiseLilium/00-firstScript.sql new file mode 100644 index 000000000..9003451c4 --- /dev/null +++ b/db/versions/11223-turquoiseLilium/00-firstScript.sql @@ -0,0 +1,2 @@ +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) +VALUES( 'Device', 'handleUser', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/versions/11224-whiteMastic/00-firstScript.sql b/db/versions/11224-whiteMastic/00-firstScript.sql new file mode 100644 index 000000000..de74dfc55 --- /dev/null +++ b/db/versions/11224-whiteMastic/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.creditInsurance DROP FOREIGN KEY CreditInsurance_Fk1; +ALTER TABLE vn.creditInsurance + CHANGE creditClassification creditClassification__ int(11) DEFAULT NULL COMMENT '@deprecated 2024-09-11'; diff --git a/db/versions/11225-goldenLaurel/00-firstScript.sql b/db/versions/11225-goldenLaurel/00-firstScript.sql new file mode 100644 index 000000000..87f521a03 --- /dev/null +++ b/db/versions/11225-goldenLaurel/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.workerDocument CHANGE worker workerFk int(10) unsigned DEFAULT NULL NULL; diff --git a/db/versions/11225-goldenLaurel/01-firstScript.sql b/db/versions/11225-goldenLaurel/01-firstScript.sql new file mode 100644 index 000000000..3aa3a1876 --- /dev/null +++ b/db/versions/11225-goldenLaurel/01-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.workerDocument CHANGE document dmsFk int(11) DEFAULT NULL NULL; diff --git a/db/versions/11225-goldenLaurel/02-firstScript.sql b/db/versions/11225-goldenLaurel/02-firstScript.sql new file mode 100644 index 000000000..d0e789534 --- /dev/null +++ b/db/versions/11225-goldenLaurel/02-firstScript.sql @@ -0,0 +1 @@ +RENAME TABLE vn.workerDocument TO vn.workerDms; diff --git a/db/versions/11227-maroonEucalyptus/00-addWorkerTimeControlMailAcl.sql b/db/versions/11227-maroonEucalyptus/00-addWorkerTimeControlMailAcl.sql new file mode 100644 index 000000000..330dcb839 --- /dev/null +++ b/db/versions/11227-maroonEucalyptus/00-addWorkerTimeControlMailAcl.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) + VALUES ('WorkerTimeControlMail', 'count', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('Worker', '__get__mail', 'READ', 'ALLOW', 'ROLE', 'hr'); diff --git a/db/versions/11229-salmonAsparagus/00-firstScript.sql b/db/versions/11229-salmonAsparagus/00-firstScript.sql new file mode 100644 index 000000000..80547db38 --- /dev/null +++ b/db/versions/11229-salmonAsparagus/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.productionConfig ADD IF NOT EXISTS minPlantTrayLength INT DEFAULT 53 NOT NULL +COMMENT 'minimum length for plant tray restriction. Avoid to make collection of the ticket with this kind of item'; diff --git a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql new file mode 100644 index 000000000..f69e20611 --- /dev/null +++ b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.clientObservation DROP COLUMN IF EXISTS observationTypeFk; +ALTER TABLE vn.clientObservation ADD COLUMN IF NOT EXISTS observationTypeFk TINYINT(3) UNSIGNED NULL; +ALTER TABLE vn.clientObservation ADD CONSTRAINT clientObservationTypeFk FOREIGN KEY IF NOT EXISTS (observationTypeFk) REFERENCES vn.observationType(id); diff --git a/db/versions/11230-brownEucalyptus/01-addNewObservation.vn.sql b/db/versions/11230-brownEucalyptus/01-addNewObservation.vn.sql new file mode 100644 index 000000000..983419111 --- /dev/null +++ b/db/versions/11230-brownEucalyptus/01-addNewObservation.vn.sql @@ -0,0 +1,3 @@ +INSERT IGNORE INTO vn.observationType + SET description = 'Finance', + code = 'finance'; \ No newline at end of file diff --git a/db/versions/11234-yellowRuscus/00-firstScript.sql b/db/versions/11234-yellowRuscus/00-firstScript.sql new file mode 100644 index 000000000..2cbac598b --- /dev/null +++ b/db/versions/11234-yellowRuscus/00-firstScript.sql @@ -0,0 +1,13 @@ +ALTER TABLE `vn`.`payrollWorkCenter` DROP PRIMARY KEY; +ALTER TABLE `vn`.`payrollWorkCenter` DROP COLUMN `empresa_id__`; +ALTER TABLE `vn`.`payrollWorkCenter` DROP COLUMN `Centro__`; +ALTER TABLE `vn`.`payrollWorkCenter` DROP COLUMN `nss_cotizacion__`; +ALTER TABLE `vn`.`payrollWorkCenter` DROP COLUMN `domicilio__`; +ALTER TABLE `vn`.`payrollWorkCenter` DROP COLUMN `poblacion__`; +ALTER TABLE `vn`.`payrollWorkCenter` DROP COLUMN `cp__`; +ALTER TABLE `vn`.`payrollWorker` DROP COLUMN `nss__`; +ALTER TABLE `vn`.`payrollWorker` DROP COLUMN `codpuesto__`; +ALTER TABLE `vn`.`payrollWorker` DROP COLUMN `codcontrato__`; +ALTER TABLE `vn`.`payrollWorker` DROP COLUMN `FAntiguedad__`; +ALTER TABLE `vn`.`payrollWorker` DROP COLUMN `codcategoria__`; +ALTER TABLE `vn`.`payrollWorker` DROP COLUMN `ContratoTemporal__`; diff --git a/db/versions/11235-purpleCordyline/00-firstScript.sql b/db/versions/11235-purpleCordyline/00-firstScript.sql new file mode 100644 index 000000000..f3bb6ddab --- /dev/null +++ b/db/versions/11235-purpleCordyline/00-firstScript.sql @@ -0,0 +1,12 @@ +ALTER TABLE vn.collectionWagon DROP FOREIGN KEY IF EXISTS collectionWagon_FK_1; +ALTER TABLE vn.collectionWagonTicket DROP FOREIGN KEY IF EXISTS collectionWagonTicket_FK_1; +ALTER TABLE vn.wagonVolumetry DROP FOREIGN KEY IF EXISTS wagonVolumetry_FK_1; + +ALTER TABLE vn.wagon MODIFY COLUMN id int(11) unsigned auto_increment NOT NULL COMMENT '26 letras de alfabeto inglés'; +ALTER TABLE vn.collectionWagon MODIFY COLUMN wagonFk int(11) unsigned NOT NULL; +ALTER TABLE vn.collectionWagonTicket MODIFY COLUMN wagonFk int(11) unsigned NOT NULL; +ALTER TABLE vn.wagonVolumetry MODIFY COLUMN wagonFk int(11) unsigned NOT NULL; + +ALTER TABLE vn.collectionWagon ADD CONSTRAINT collectionWagon_FK_1 FOREIGN KEY (wagonFk) REFERENCES vn.wagon(id) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE vn.collectionWagonTicket ADD CONSTRAINT collectionWagonTicket_FK_1 FOREIGN KEY (wagonFk) REFERENCES vn.wagon(id) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE vn.wagonVolumetry ADD CONSTRAINT wagonVolumetry_FK_1 FOREIGN KEY (wagonFk) REFERENCES vn.wagon(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11236-blackMedeola/00-firstScript.sql b/db/versions/11236-blackMedeola/00-firstScript.sql new file mode 100644 index 000000000..8729e40e1 --- /dev/null +++ b/db/versions/11236-blackMedeola/00-firstScript.sql @@ -0,0 +1,19 @@ +ALTER TABLE vn.addressWaste + MODIFY COLUMN `type` enum('external', 'fault', 'container', 'break', 'other') + CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL; + +UPDATE vn.addressWaste + SET `type`='container' + WHERE addressFk=77; + +UPDATE vn.addressWaste + SET `type`='fault' + WHERE addressFk=317; + +UPDATE vn.addressWaste + SET `type`='break' + WHERE addressFk=57702; + +UPDATE vn.addressWaste + SET `type`='other' + WHERE addressFk=43432; diff --git a/db/versions/11236-blackMedeola/01-firstScript.sql b/db/versions/11236-blackMedeola/01-firstScript.sql new file mode 100644 index 000000000..87262115b --- /dev/null +++ b/db/versions/11236-blackMedeola/01-firstScript.sql @@ -0,0 +1,6 @@ +ALTER TABLE bs.waste + DROP COLUMN saleInternalWaste, + ADD saleFaultWaste decimal(10,2) DEFAULT NULL NULL, + ADD saleContainerWaste decimal(10,2) DEFAULT NULL NULL, + ADD saleBreakWaste decimal(10,2) DEFAULT NULL NULL, + ADD saleOtherWaste decimal(10,2) DEFAULT NULL NULL; diff --git a/db/versions/11237-goldenBamboo/00-firstScript.sql b/db/versions/11237-goldenBamboo/00-firstScript.sql new file mode 100644 index 000000000..3e387eba8 --- /dev/null +++ b/db/versions/11237-goldenBamboo/00-firstScript.sql @@ -0,0 +1,3 @@ +UPDATE bs.nightTask + SET `procedure` = 'waste_addSalesLauncher' + WHERE `procedure` = 'waste_addSales'; diff --git a/db/versions/11239-goldenBirch/00-firstScript.sql b/db/versions/11239-goldenBirch/00-firstScript.sql new file mode 100644 index 000000000..559982081 --- /dev/null +++ b/db/versions/11239-goldenBirch/00-firstScript.sql @@ -0,0 +1,2 @@ +-- Place your SQL code here +ALTER TABLE vn.packaging ADD IF NOT EXISTS isPlantTray BOOL DEFAULT FALSE NOT NULL COMMENT 'The container is a plant tray. Used to restrict the picking of full plant trays, to make previous picking.'; diff --git a/db/versions/11240-aquaCyca/00-firstScript.sql b/db/versions/11240-aquaCyca/00-firstScript.sql new file mode 100644 index 000000000..97ad39ef1 --- /dev/null +++ b/db/versions/11240-aquaCyca/00-firstScript.sql @@ -0,0 +1 @@ +GRANT EXECUTE ON PROCEDURE bs.waste_addSales TO buyerBoss; diff --git a/db/versions/11241-grayPalmetto/00-firstScript.sql b/db/versions/11241-grayPalmetto/00-firstScript.sql new file mode 100644 index 000000000..b9ae692c6 --- /dev/null +++ b/db/versions/11241-grayPalmetto/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.packaging ADD IF NOT EXISTS isPlantTray BOOL DEFAULT FALSE NOT NULL + COMMENT 'The container is a plant tray. Used to restrict the picking of full plant trays, to make previous picking.'; \ No newline at end of file diff --git a/db/versions/11242-whiteAnthurium/00-firstScript.sql b/db/versions/11242-whiteAnthurium/00-firstScript.sql new file mode 100644 index 000000000..43dccf374 --- /dev/null +++ b/db/versions/11242-whiteAnthurium/00-firstScript.sql @@ -0,0 +1,3 @@ +DELETE FROM salix.ACL + WHERE model = 'WorkerLog' + AND property = '*'; \ No newline at end of file diff --git a/db/versions/11246-whiteMonstera/00-firstScript.sql b/db/versions/11246-whiteMonstera/00-firstScript.sql new file mode 100644 index 000000000..72c46cf79 --- /dev/null +++ b/db/versions/11246-whiteMonstera/00-firstScript.sql @@ -0,0 +1 @@ +DELETE FROM salix.ACL WHERE model = 'Worker' AND property = 'findById' AND principalId = 'employee'; \ No newline at end of file diff --git a/db/versions/11247-chocolateChico/00-firstScript.sql b/db/versions/11247-chocolateChico/00-firstScript.sql new file mode 100644 index 000000000..8cbfebdde --- /dev/null +++ b/db/versions/11247-chocolateChico/00-firstScript.sql @@ -0,0 +1,4 @@ +UPDATE salix.ACL SET principalId = 'employee' WHERE model = 'Worker' AND principalId = '$subordinate'; +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) +VALUES ('Worker', '__get__advancedSummary', 'READ', 'ALLOW', 'ROLE', 'hr'), + ('Worker', '__get__summary', 'READ', 'ALLOW', 'ROLE', 'employee'); diff --git a/db/versions/11248-azureOrchid/00-firstScript.sql b/db/versions/11248-azureOrchid/00-firstScript.sql new file mode 100644 index 000000000..a4a4bd740 --- /dev/null +++ b/db/versions/11248-azureOrchid/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.`zone` + ADD COLUMN IF NOT EXISTS itemMaxLength int(11) NULL COMMENT 'Longitud maxima para articulos acostados que esa agencia puede transportar', + MODIFY COLUMN itemMaxSize int(11) DEFAULT NULL NULL COMMENT 'Altura maxima de los articulos que esa agencia puede transportar'; diff --git a/db/versions/11249-crimsonPhormium/00-firstScript.sql b/db/versions/11249-crimsonPhormium/00-firstScript.sql new file mode 100644 index 000000000..32410c561 --- /dev/null +++ b/db/versions/11249-crimsonPhormium/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.parking DROP FOREIGN KEY IF EXISTS parking_fk1; +ALTER TABLE vn.parking ADD CONSTRAINT parking_fk1 FOREIGN KEY (sectorFk) REFERENCES vn.sector(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11251-navyChrysanthemum/00-firstScript.sql b/db/versions/11251-navyChrysanthemum/00-firstScript.sql new file mode 100644 index 000000000..801405e59 --- /dev/null +++ b/db/versions/11251-navyChrysanthemum/00-firstScript.sql @@ -0,0 +1,3 @@ +UPDATE vn.sale + SET originalQuantity = quantity + WHERE originalQuantity IS NULL diff --git a/db/versions/11251-navyChrysanthemum/01-firstScript.sql b/db/versions/11251-navyChrysanthemum/01-firstScript.sql new file mode 100644 index 000000000..e3e08e0aa --- /dev/null +++ b/db/versions/11251-navyChrysanthemum/01-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.sale MODIFY COLUMN originalQuantity decimal(10,2) DEFAULT 0.00 NOT NULL COMMENT 'Se utiliza para notificar a través de rocket los cambios de quantity'; \ No newline at end of file diff --git a/db/versions/11253-limeChico/00-firstScript.sql b/db/versions/11253-limeChico/00-firstScript.sql new file mode 100644 index 000000000..acf1de15c --- /dev/null +++ b/db/versions/11253-limeChico/00-firstScript.sql @@ -0,0 +1,3 @@ +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Postcode','*','WRITE','ALLOW','ROLE','administrative'); + diff --git a/db/versions/11254-tealCarnation/00-thermographTemperature.sql b/db/versions/11254-tealCarnation/00-thermographTemperature.sql new file mode 100644 index 000000000..123e6c665 --- /dev/null +++ b/db/versions/11254-tealCarnation/00-thermographTemperature.sql @@ -0,0 +1,3 @@ +ALTER TABLE `vn`.`travelThermograph` +ADD COLUMN `maxTemperature` DECIMAL(5,2) NULL AFTER `temperatureFk`, +ADD COLUMN `minTemperature` DECIMAL(5,2) NULL AFTER `maxTemperature`; diff --git a/db/versions/11254-tealCarnation/01-thermographFk.sql b/db/versions/11254-tealCarnation/01-thermographFk.sql new file mode 100644 index 000000000..2baf99a45 --- /dev/null +++ b/db/versions/11254-tealCarnation/01-thermographFk.sql @@ -0,0 +1,2 @@ +ALTER TABLE `vn`.`travelThermograph` DROP FOREIGN KEY travelThermographDmsFgn; +ALTER TABLE `vn`.`travelThermograph` ADD CONSTRAINT travelThermographDmsFgn FOREIGN KEY (dmsFk) REFERENCES vn.dms(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/11255-maroonRaphis/00-firstScript.sql b/db/versions/11255-maroonRaphis/00-firstScript.sql new file mode 100644 index 000000000..7febf0e6c --- /dev/null +++ b/db/versions/11255-maroonRaphis/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.worker + CHANGE isF11Allowed isF11Allowed__ TINYINT(1) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-09-22'; \ No newline at end of file diff --git a/db/versions/11256-grayFern/00-firstScript.sql b/db/versions/11256-grayFern/00-firstScript.sql new file mode 100644 index 000000000..7dcd380a7 --- /dev/null +++ b/db/versions/11256-grayFern/00-firstScript.sql @@ -0,0 +1,6 @@ +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Province','*','WRITE','ALLOW','ROLE','administrative'); + +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Town','*','WRITE','ALLOW','ROLE','administrative'); + diff --git a/db/versions/11258-silverTulip/00-firstScript.sql b/db/versions/11258-silverTulip/00-firstScript.sql new file mode 100644 index 000000000..79910fa76 --- /dev/null +++ b/db/versions/11258-silverTulip/00-firstScript.sql @@ -0,0 +1,31 @@ +-- vn.priceDelta definition + +CREATE OR REPLACE TABLE vn.priceDelta ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `itemTypeFk` smallint(5) unsigned NOT NULL, + `minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size', + `maxSize` int(10) unsigned DEFAULT NULL COMMENT 'Maximum item.size', + `inkFk` varchar(3) DEFAULT NULL, + `originFk` tinyint(2) unsigned DEFAULT NULL, + `producerFk` mediumint(3) unsigned DEFAULT NULL, + `fromDated` date DEFAULT NULL, + `toDated` date DEFAULT NULL, + `absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price', + `ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price', + `warehouseFk` smallint(6) unsigned NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `editorFk` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `priceDelta_itemType_FK` (`itemTypeFk`), + KEY `priceDelta_ink_FK` (`inkFk`), + KEY `priceDelta_producer_FK` (`producerFk`), + KEY `priceDelta_warehouse_FK` (`warehouseFk`), + KEY `priceDelta_worker_FK` (`editorFk`), + CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_worker_FK` FOREIGN KEY (`editorFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items'; + +GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE vn.priceDelta TO buyer; \ No newline at end of file diff --git a/db/versions/11260-navyCyca/00-firstScript.sql b/db/versions/11260-navyCyca/00-firstScript.sql new file mode 100644 index 000000000..0824ea5f7 --- /dev/null +++ b/db/versions/11260-navyCyca/00-firstScript.sql @@ -0,0 +1,32 @@ +-- Place your SQL code here +-- vn.priceDelta definition + +CREATE OR REPLACE TABLE vn.priceDelta ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `itemTypeFk` smallint(5) unsigned NOT NULL, + `minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size', + `maxSize` int(10) unsigned DEFAULT NULL COMMENT 'Maximum item.size', + `inkFk` varchar(3) DEFAULT NULL, + `originFk` tinyint(2) unsigned DEFAULT NULL, + `producerFk` mediumint(3) unsigned DEFAULT NULL, + `fromDated` date DEFAULT NULL, + `toDated` date DEFAULT NULL, + `absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price', + `ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price', + `warehouseFk` smallint(6) unsigned NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `editorFk` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `priceDelta_itemType_FK` (`itemTypeFk`), + KEY `priceDelta_ink_FK` (`inkFk`), + KEY `priceDelta_producer_FK` (`producerFk`), + KEY `priceDelta_warehouse_FK` (`warehouseFk`), + KEY `priceDelta_worker_FK` (`editorFk`), + CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_worker_FK` FOREIGN KEY (`editorFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items'; + +GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE vn.priceDelta TO buyer; \ No newline at end of file diff --git a/db/versions/11261-bronzeDracena/00-firstScript.sql b/db/versions/11261-bronzeDracena/00-firstScript.sql new file mode 100644 index 000000000..1ef944db2 --- /dev/null +++ b/db/versions/11261-bronzeDracena/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.agencyMode + CHANGE IF EXISTS showAgencyName showAgencyName__ tinyint(1) DEFAULT 1 COMMENT '@deprecated 2024-09-24'; \ No newline at end of file diff --git a/db/versions/11262-chocolateCamellia/00-firstScript.sql b/db/versions/11262-chocolateCamellia/00-firstScript.sql new file mode 100644 index 000000000..79910fa76 --- /dev/null +++ b/db/versions/11262-chocolateCamellia/00-firstScript.sql @@ -0,0 +1,31 @@ +-- vn.priceDelta definition + +CREATE OR REPLACE TABLE vn.priceDelta ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `itemTypeFk` smallint(5) unsigned NOT NULL, + `minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size', + `maxSize` int(10) unsigned DEFAULT NULL COMMENT 'Maximum item.size', + `inkFk` varchar(3) DEFAULT NULL, + `originFk` tinyint(2) unsigned DEFAULT NULL, + `producerFk` mediumint(3) unsigned DEFAULT NULL, + `fromDated` date DEFAULT NULL, + `toDated` date DEFAULT NULL, + `absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price', + `ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price', + `warehouseFk` smallint(6) unsigned NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `editorFk` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `priceDelta_itemType_FK` (`itemTypeFk`), + KEY `priceDelta_ink_FK` (`inkFk`), + KEY `priceDelta_producer_FK` (`producerFk`), + KEY `priceDelta_warehouse_FK` (`warehouseFk`), + KEY `priceDelta_worker_FK` (`editorFk`), + CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_worker_FK` FOREIGN KEY (`editorFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items'; + +GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE vn.priceDelta TO buyer; \ No newline at end of file diff --git a/db/versions/11263-brownAnthurium/00-firstScript.sql b/db/versions/11263-brownAnthurium/00-firstScript.sql new file mode 100644 index 000000000..0824ea5f7 --- /dev/null +++ b/db/versions/11263-brownAnthurium/00-firstScript.sql @@ -0,0 +1,32 @@ +-- Place your SQL code here +-- vn.priceDelta definition + +CREATE OR REPLACE TABLE vn.priceDelta ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `itemTypeFk` smallint(5) unsigned NOT NULL, + `minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size', + `maxSize` int(10) unsigned DEFAULT NULL COMMENT 'Maximum item.size', + `inkFk` varchar(3) DEFAULT NULL, + `originFk` tinyint(2) unsigned DEFAULT NULL, + `producerFk` mediumint(3) unsigned DEFAULT NULL, + `fromDated` date DEFAULT NULL, + `toDated` date DEFAULT NULL, + `absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price', + `ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price', + `warehouseFk` smallint(6) unsigned NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `editorFk` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `priceDelta_itemType_FK` (`itemTypeFk`), + KEY `priceDelta_ink_FK` (`inkFk`), + KEY `priceDelta_producer_FK` (`producerFk`), + KEY `priceDelta_warehouse_FK` (`warehouseFk`), + KEY `priceDelta_worker_FK` (`editorFk`), + CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_worker_FK` FOREIGN KEY (`editorFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items'; + +GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE vn.priceDelta TO buyer; \ No newline at end of file diff --git a/db/versions/11264-turquoisePaniculata/00-firstScript.sql b/db/versions/11264-turquoisePaniculata/00-firstScript.sql new file mode 100644 index 000000000..8ca3df265 --- /dev/null +++ b/db/versions/11264-turquoisePaniculata/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE dipole.expedition_PrintOut DROP COLUMN IF EXISTS isChecked; diff --git a/db/versions/11271-blackMastic/00-firstScript.sql b/db/versions/11271-blackMastic/00-firstScript.sql new file mode 100644 index 000000000..dcc8349a5 --- /dev/null +++ b/db/versions/11271-blackMastic/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.priceDelta ADD IF NOT EXISTS zoneGeoFk int(11) NULL COMMENT 'Application area for the bonus component'; +ALTER TABLE vn.priceDelta ADD CONSTRAINT priceDelta_zoneGeo_FK FOREIGN KEY IF NOT EXISTS (zoneGeoFk) REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11272-azureLilium/00-firstScript.sql b/db/versions/11272-azureLilium/00-firstScript.sql new file mode 100644 index 000000000..0194ece18 --- /dev/null +++ b/db/versions/11272-azureLilium/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here +RENAME TABLE vn.stockBuyed TO vn.stockBuyed__; +ALTER TABLE vn.stockBuyed__ +COMMENT='@deprecated 2024-10-01 rename and refactor to stockBought'; diff --git a/db/versions/11273-goldenDendro/00-firstScript.sql b/db/versions/11273-goldenDendro/00-firstScript.sql new file mode 100644 index 000000000..2fc6809e5 --- /dev/null +++ b/db/versions/11273-goldenDendro/00-firstScript.sql @@ -0,0 +1,22 @@ +CREATE TABLE IF NOT EXISTS `vn`.`itemStateTag` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT + CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO `vn`.`itemStateTag` (`name`) VALUES ('Artificial'); +INSERT IGNORE INTO `vn`.`itemStateTag` (`name`) VALUES ('Inactivo'); +INSERT IGNORE INTO `vn`.`itemStateTag` (`name`) VALUES ('Preservado'); +INSERT IGNORE INTO `vn`.`itemStateTag` (`name`) VALUES ('Seco'); +INSERT IGNORE INTO `vn`.`itemStateTag` (`name`) VALUES ('Seco y preservado'); +INSERT IGNORE INTO `vn`.`itemStateTag` (`name`) VALUES ('Estabilizada'); +INSERT IGNORE INTO `vn`.`itemStateTag` (`name`) VALUES ('Natural y seco'); +INSERT IGNORE INTO `vn`.`itemStateTag` (`name`) VALUES ('Preservado y artificial'); +INSERT IGNORE INTO `vn`.`itemStateTag` (`name`) VALUES ('Usado'); + +UPDATE vn.tag + SET isFree=0, + sourceTable='itemStateTag' + WHERE name= 'Estado'; diff --git a/db/versions/11274-redGerbera/00-firstScript copy 2.sql b/db/versions/11274-redGerbera/00-firstScript copy 2.sql new file mode 100644 index 000000000..452accf2e --- /dev/null +++ b/db/versions/11274-redGerbera/00-firstScript copy 2.sql @@ -0,0 +1 @@ +ALTER TABLE vn.address MODIFY COLUMN isEqualizated tinyint(1) DEFAULT FALSE NOT NULL; diff --git a/db/versions/11274-redGerbera/00-firstScript copy 3.sql b/db/versions/11274-redGerbera/00-firstScript copy 3.sql new file mode 100644 index 000000000..c1f574379 --- /dev/null +++ b/db/versions/11274-redGerbera/00-firstScript copy 3.sql @@ -0,0 +1 @@ +ALTER TABLE vn.autonomy MODIFY COLUMN isUeeMember tinyint(1) DEFAULT FALSE NOT NULL; \ No newline at end of file diff --git a/db/versions/11274-redGerbera/00-firstScript copy 4.sql b/db/versions/11274-redGerbera/00-firstScript copy 4.sql new file mode 100644 index 000000000..18a4d3314 --- /dev/null +++ b/db/versions/11274-redGerbera/00-firstScript copy 4.sql @@ -0,0 +1 @@ +ALTER TABLE vn.chat MODIFY COLUMN checkUserStatus tinyint(1) DEFAULT FALSE NOT NULL; diff --git a/db/versions/11274-redGerbera/00-firstScript copy 5.sql b/db/versions/11274-redGerbera/00-firstScript copy 5.sql new file mode 100644 index 000000000..c75965735 --- /dev/null +++ b/db/versions/11274-redGerbera/00-firstScript copy 5.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.warehouse + MODIFY COLUMN isOrigin tinyint(1) DEFAULT FALSE NOT NULL, + MODIFY COLUMN isDestiny tinyint(1) DEFAULT FALSE NOT NULL; \ No newline at end of file diff --git a/db/versions/11274-redGerbera/00-firstScript copy 6.sql b/db/versions/11274-redGerbera/00-firstScript copy 6.sql new file mode 100644 index 000000000..63b942e9d --- /dev/null +++ b/db/versions/11274-redGerbera/00-firstScript copy 6.sql @@ -0,0 +1 @@ +ALTER TABLE vn.zoneIncluded MODIFY COLUMN isIncluded tinyint(1) DEFAULT FALSE NOT NULL; diff --git a/db/versions/11274-redGerbera/00-firstScript copy.sql b/db/versions/11274-redGerbera/00-firstScript copy.sql new file mode 100644 index 000000000..f14ff371d --- /dev/null +++ b/db/versions/11274-redGerbera/00-firstScript copy.sql @@ -0,0 +1 @@ +ALTER TABLE bs.defaulter MODIFY COLUMN hasChanged tinyint(1) DEFAULT FALSE NOT NULL; diff --git a/db/versions/11274-redGerbera/00-firstScript.sql b/db/versions/11274-redGerbera/00-firstScript.sql new file mode 100644 index 000000000..8bcf7e027 --- /dev/null +++ b/db/versions/11274-redGerbera/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE account.user MODIFY COLUMN emailVerified tinyint(1) DEFAULT FALSE NOT NULL; diff --git a/db/versions/11277-wheatChico/00-firstScript.sql b/db/versions/11277-wheatChico/00-firstScript.sql new file mode 100644 index 000000000..c2b5963a4 --- /dev/null +++ b/db/versions/11277-wheatChico/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE hedera.`order` ADD IF NOT EXISTS rowUpdated DATETIME NULL + COMMENT 'Timestamp for last updated record in orderRow table'; diff --git a/db/versions/11278-crimsonEucalyptus/00-firstScript.sql b/db/versions/11278-crimsonEucalyptus/00-firstScript.sql new file mode 100644 index 000000000..f69f75f1d --- /dev/null +++ b/db/versions/11278-crimsonEucalyptus/00-firstScript.sql @@ -0,0 +1,6 @@ +-- Place your SQL code here + +ALTER TABLE vn.priceDelta ADD IF NOT EXISTS zoneGeoFk int(11) NULL; + +ALTER TABLE vn.priceDelta ADD CONSTRAINT priceDelta_zoneGeo_FK FOREIGN KEY IF NOT EXISTS (zoneGeoFk) +REFERENCES vn.zoneGeo (`id`) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11279-turquoiseDendro/00-firstScript.sql b/db/versions/11279-turquoiseDendro/00-firstScript.sql new file mode 100644 index 000000000..a241e6af2 --- /dev/null +++ b/db/versions/11279-turquoiseDendro/00-firstScript.sql @@ -0,0 +1,6 @@ +-- Place your SQL code here + +ALTER TABLE vn.priceDelta ADD IF NOT EXISTS zoneGeoFk int(11) NULL; + +ALTER TABLE vn.priceDelta ADD CONSTRAINT priceDelta_zoneGeo_FK FOREIGN KEY IF NOT EXISTS (zoneGeoFk) +REFERENCES vn.zoneGeo (`id`) ON DELETE RESTRICT ON UPDATE CASCADE; \ No newline at end of file diff --git a/db/versions/11280-goldenCamellia/00-firstScript.sql b/db/versions/11280-goldenCamellia/00-firstScript.sql new file mode 100644 index 000000000..fd55760c1 --- /dev/null +++ b/db/versions/11280-goldenCamellia/00-firstScript.sql @@ -0,0 +1,24 @@ +ALTER TABLE `vn`.`packaging` + ADD COLUMN IF NOT EXISTS `isActive` TINYINT(1) DEFAULT 1; + +UPDATE vn.packaging + SET isActive = FALSE + WHERE id IN('06x04x06','07x04x03','1000','100SM','1031','104','105','1060','10x04x06','10x04x07','1100','118','119','1200','129','1300', + '134','146','147','148','158','159','17x01x02','17X01X03','17x01x04','17x01x05','18X01X04','198','199', + '20P','20x01x03','246','273','278','279','280','290','359','37247','382','40P','453','463','464','465','466', + '467','469','471','473','494','508','509','511','512','514','515','516','518','519-50B','575','598-3x6','604','605','606', + '607','609','647','67515','676','680','682','685','687','688','691','692','693','694','695','730','751','7808','790','7910', + '7920','79450','7950','7952','7960','7976','7982','7986','7988', + '7993','8000','8046','8049','8053','8057','8058','8065','8076','8085','8086','8088', + '8091','8095','8096','8097','8101','8106','8108','8110','8112','8124','8134','8140','8141','8143','8145','8149','8150', + '8170','8174','8192','8200','8210','8249','8270','8275','8288','8300','8350','8375','8399','8400','8420','845','847','8480','8500', + '855','858','8600','862','869','871','872','8720','878','879','880','8800','882','885','910','911','912','914','916','917','918','919', + '920','921','922','923','924','925','926','927','930','9300','932','934','935','936','938','942','948','9600','980','984','9920', + 'B20x16','B43x13','Bande Rota','bb3','Bcesta','BcestaOVAL','BcestaRED','Bcirios','BciriosG','BjarronBLN','BjarronNGR', + 'Btazon','Bvelas','cactus200','Caja040','CajaTGLF','CC Alza Pl','CC_falso', + 'EB-RSMINA','EMB 1_4','EMB 2_5','espuma','FB-BENCH','granel','Grenex','guzma1200','guzma1400','guzma330','guzma400','guzma650','guzma900','HB-ALEX', + 'HB-APOSENT','HB-MAGIC','HB-NATUF','HB-RSMINA','HB-TES-RSR','HB068','HB117','HB2-CIRCA','JB-AROMA','jumboX3','kalan330','kalan400', + 'kalan577','kalan900','L12','L120','L14','L2-120','L200','L3-120','L4-120','L44','L6','L6-180','L8','L8-200','MB-BENCH','MBOLA','mc_11', + 'mc_13','Msp','NO VALIDO','NO-002','PANIC','PBLG','PISOCC/3','PISOCC/4','PISOCC/5','PISOCC/6', + 'procona','QB-CARDENA','QB-PANDERO','QB-TES-RSR','QB7-TOSCA','QB9-TOSCA','RB-BENCH','SemiEuroPa','spolette','t_flori11','T26x23', + 'T26x25','T27x24','T27x30','T28x26','T30x24','T33x30','THA50','ti_13','Tumbado','UB-BENCH') \ No newline at end of file diff --git a/db/versions/11281-purpleCyca/00-firstScript.sql b/db/versions/11281-purpleCyca/00-firstScript.sql new file mode 100644 index 000000000..eadba5ae1 --- /dev/null +++ b/db/versions/11281-purpleCyca/00-firstScript.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS vn.buyMark; diff --git a/db/versions/11283-redAspidistra/00-firstScript.sql b/db/versions/11283-redAspidistra/00-firstScript.sql new file mode 100644 index 000000000..a88091297 --- /dev/null +++ b/db/versions/11283-redAspidistra/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelving_fk2; +ALTER TABLE vn.itemShelving ADD CONSTRAINT itemShelving_fk2 + FOREIGN KEY (shelvingFk) REFERENCES vn.shelving(code) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11284-turquoiseLaurel/00-firstScript.sql b/db/versions/11284-turquoiseLaurel/00-firstScript.sql new file mode 100644 index 000000000..34762faf6 --- /dev/null +++ b/db/versions/11284-turquoiseLaurel/00-firstScript.sql @@ -0,0 +1,2 @@ +-- Place your SQL code here +ALTER TABLE vn.itemShelving ADD IF NOT EXISTS isMoving BOOL DEFAULT FALSE NOT NULL COMMENT 'Indica que se ha marcado este registro para transferirlo a otro sector'; diff --git a/db/versions/11285-orangeErica/00-firstScript.sql b/db/versions/11285-orangeErica/00-firstScript.sql new file mode 100644 index 000000000..c13571f3a --- /dev/null +++ b/db/versions/11285-orangeErica/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.itemShelving DROP COLUMN IF EXISTS isMoving; +ALTER TABLE vn.itemShelving ADD IF NOT EXISTS movingState ENUM('selected','printed') NULL; diff --git a/db/versions/11287-azureRaphis/00-firstScript.sql b/db/versions/11287-azureRaphis/00-firstScript.sql new file mode 100644 index 000000000..77d60eb40 --- /dev/null +++ b/db/versions/11287-azureRaphis/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE hedera.`order` ADD IF NOT EXISTS rowUpdated DATETIME NULL + COMMENT 'Timestamp for last updated record in orderRow table'; \ No newline at end of file diff --git a/db/versions/11288-purpleFern/00-firstScript.sql b/db/versions/11288-purpleFern/00-firstScript.sql new file mode 100644 index 000000000..77d60eb40 --- /dev/null +++ b/db/versions/11288-purpleFern/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE hedera.`order` ADD IF NOT EXISTS rowUpdated DATETIME NULL + COMMENT 'Timestamp for last updated record in orderRow table'; \ No newline at end of file diff --git a/db/versions/11289-azureAralia/00-firstScript.sql b/db/versions/11289-azureAralia/00-firstScript.sql new file mode 100644 index 000000000..ab091f53f --- /dev/null +++ b/db/versions/11289-azureAralia/00-firstScript.sql @@ -0,0 +1,2 @@ + +ALTER TABLE vn.sector ADD isOnReservationMode tinyint(1) DEFAULT FALSE NULL; diff --git a/db/versions/11294-azureFern/00-firstScript.sql b/db/versions/11294-azureFern/00-firstScript.sql new file mode 100644 index 000000000..2d6ed3a5b --- /dev/null +++ b/db/versions/11294-azureFern/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.itemShelving DROP COLUMN IF EXISTS isMoving; +ALTER TABLE vn.itemShelving ADD IF NOT EXISTS movingState ENUM('selected','printed') NULL; \ No newline at end of file diff --git a/db/versions/11295-brownLaurel/00-firstScript.sql b/db/versions/11295-brownLaurel/00-firstScript.sql new file mode 100644 index 000000000..2d6ed3a5b --- /dev/null +++ b/db/versions/11295-brownLaurel/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.itemShelving DROP COLUMN IF EXISTS isMoving; +ALTER TABLE vn.itemShelving ADD IF NOT EXISTS movingState ENUM('selected','printed') NULL; \ No newline at end of file diff --git a/db/versions/11298-wheatIvy/00-closure.sql b/db/versions/11298-wheatIvy/00-closure.sql new file mode 100644 index 000000000..7b33939cf --- /dev/null +++ b/db/versions/11298-wheatIvy/00-closure.sql @@ -0,0 +1,3 @@ +ALTER TABLE `vn`.`ticketConfig` +ADD COLUMN `closureDaysAgo` int(11) NOT NULL DEFAULT 2 COMMENT 'Number of days to look back for ticket closure', +ADD CONSTRAINT `closureDaysAgo_check` CHECK (`closureDaysAgo` > 0); diff --git a/docker-compose.yml b/docker-compose.yml index ec40311c0..923bb5780 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,62 +4,8 @@ services: image: registry.verdnatura.es/salix-front:${VERSION:?} build: context: front - environment: - - TZ - - NODE_ENV - ports: - - 80 - deploy: - replicas: 2 - placement: - constraints: - - node.role == worker - resources: - limits: - memory: 1G back: image: registry.verdnatura.es/salix-back:${VERSION:?} build: context: . dockerfile: back/Dockerfile - environment: - - TZ - - NODE_ENV - - DEBUG - ports: - - 3000 - configs: - - source: datasources - target: /etc/salix/datasources.json - - source: datasources_local - target: /etc/salix/datasources.local.json - - source: print - target: /etc/salix/print.json - - source: print_local - target: /etc/salix/print.local.json - volumes: - - /mnt/appdata/pdfs:/var/lib/salix/pdfs - - /mnt/appdata/dms:/var/lib/salix/dms - - /mnt/appdata/image:/var/lib/salix/image - - /mnt/appdata/vn-access:/var/lib/salix/vn-access - deploy: - replicas: ${BACK_REPLICAS:?} - placement: - constraints: - - node.role == worker - resources: - limits: - memory: 8G -configs: - datasources: - external: true - name: salix_datasources - datasources_local: - external: true - name: salix-${BRANCH_NAME:?}_datasources - print: - external: true - name: salix_print - print_local: - external: true - name: salix-${BRANCH_NAME:?}_print diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 685345273..0a3892c86 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -687,8 +687,8 @@ export default { ticketFuture: { searchResult: 'vn-ticket-future tbody tr', openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]', - originDated: 'vn-date-picker[label="Origin date"]', - futureDated: 'vn-date-picker[label="Destination date"]', + originScopeDays: 'vn-date-picker[label="Origin date"]', + futureScopeDays: 'vn-date-picker[label="Destination date"]', linesMax: 'vn-textfield[label="Max Lines"]', litersMax: 'vn-textfield[label="Max Liters"]', ipt: 'vn-autocomplete[label="Origin IPT"]', @@ -738,69 +738,6 @@ export default { worker: 'vn-worker-autocomplete[ng-model="$ctrl.userFk"]', saveStateButton: `button[type=submit]` }, - claimsIndex: { - searchResult: 'vn-claim-index vn-card > vn-table > div > vn-tbody > a' - }, - claimDescriptor: { - moreMenu: 'vn-claim-descriptor vn-icon-button[icon=more_vert]', - moreMenuDeleteClaim: '.vn-menu [name="deleteClaim"]', - acceptDeleteClaim: '.vn-confirm.shown button[response="accept"]' - }, - claimSummary: { - header: 'vn-claim-summary > vn-card > h5', - state: 'vn-claim-summary vn-label-value[label="State"] > section > span', - observation: 'vn-claim-summary vn-horizontal.text', - firstSaleItemId: 'vn-claim-summary vn-horizontal > vn-auto:nth-child(5) vn-table > div > vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(1) > span', - firstSaleDescriptorImage: '.vn-popover.shown vn-item-descriptor img', - itemDescriptorPopover: '.vn-popover.shown vn-item-descriptor', - itemDescriptorPopoverItemDiaryButton: '.vn-popover vn-item-descriptor vn-quick-link[icon="icon-transaction"] > a', - firstDevelopmentWorker: 'vn-claim-summary vn-horizontal > vn-auto:nth-child(4) vn-table > div > vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(4) > span', - firstDevelopmentWorkerGoToClientButton: '.vn-popover vn-worker-descriptor vn-quick-link[icon="person"] > a', - firstActionTicketId: 'vn-claim-summary > vn-card > vn-horizontal > vn-auto:nth-child(5) vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > span', - firstActionTicketDescriptor: '.vn-popover.shown vn-ticket-descriptor' - }, - claimBasicData: { - claimState: 'vn-claim-basic-data vn-autocomplete[ng-model="$ctrl.claim.claimStateFk"]', - packages: 'vn-input-number[ng-model="$ctrl.claim.packages"]', - saveButton: `button[type=submit]` - }, - claimDetail: { - secondItemDiscount: 'vn-claim-detail > vn-vertical > vn-card > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(6) > span', - discount: '.vn-popover.shown vn-input-number[ng-model="$ctrl.newDiscount"]', - discoutPopoverMana: '.vn-popover.shown .content > div > vn-horizontal > h5', - addItemButton: 'vn-claim-detail a vn-float-button', - firstClaimableSaleFromTicket: '.vn-dialog.shown vn-tbody > vn-tr', - claimDetailLine: 'vn-claim-detail > vn-vertical > vn-card > vn-vertical > vn-table > div > vn-tbody > vn-tr', - totalClaimed: 'vn-claim-detail > vn-vertical > vn-card > vn-vertical > vn-horizontal > div > vn-label-value:nth-child(2) > section > span', - secondItemDeleteButton: 'vn-claim-detail > vn-vertical > vn-card > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(8) > vn-icon-button > button > vn-icon > i' - }, - claimDevelopment: { - addDevelopmentButton: 'vn-claim-development > vn-vertical > vn-card > vn-vertical > vn-one > vn-icon-button > button > vn-icon', - firstDeleteDevelopmentButton: 'vn-claim-development > vn-vertical > vn-card > vn-vertical > form > vn-horizontal:nth-child(2) > vn-icon-button > button > vn-icon', - firstClaimReason: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimReasonFk"]', - firstClaimResult: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimResultFk"]', - firstClaimResponsible: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimResponsibleFk"]', - firstClaimWorker: 'vn-claim-development vn-horizontal:nth-child(1) vn-worker-autocomplete[ng-model="claimDevelopment.workerFk"]', - firstClaimRedelivery: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimRedeliveryFk"]', - secondClaimReason: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimReasonFk"]', - secondClaimResult: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimResultFk"]', - secondClaimResponsible: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimResponsibleFk"]', - secondClaimWorker: 'vn-claim-development vn-horizontal:nth-child(2) vn-worker-autocomplete[ng-model="claimDevelopment.workerFk"]', - secondClaimRedelivery: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimRedeliveryFk"]', - saveDevelopmentButton: 'button[type=submit]' - }, - claimNote: { - addNoteFloatButton: 'vn-float-button', - note: 'vn-textarea[ng-model="$ctrl.note.text"]', - saveButton: 'button[type=submit]', - firstNoteText: 'vn-claim-note .text' - }, - claimAction: { - importClaimButton: 'vn-claim-action vn-button[label="Import claim"]', - anyLine: 'vn-claim-action vn-tbody > vn-tr', - firstDeleteLine: 'vn-claim-action tr:nth-child(2) vn-icon-button[icon="delete"]', - isPaidWithManaCheckbox: 'vn-claim-action vn-check[ng-model="$ctrl.claim.isChargedToMana"]' - }, ordersIndex: { secondSearchResultTotal: 'vn-order-index vn-card > vn-table > div > vn-tbody .vn-tr:nth-child(2) vn-td:nth-child(9)', advancedSearchButton: 'vn-order-search-panel vn-submit[label="Search"]', diff --git a/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js b/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js deleted file mode 100644 index 9c37ce9ba..000000000 --- a/e2e/paths/01-salix/03_smartTable_searchBar_integrations.spec.js +++ /dev/null @@ -1,68 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('SmartTable SearchBar integration', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('salesPerson', 'item'); - await page.waitToClick(selectors.globalItems.searchButton); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should search by type in searchBar, reload page and have same results', async() => { - await page.waitToClick(selectors.itemsIndex.openAdvancedSearchButton); - await page.autocompleteSearch(selectors.itemsIndex.advancedSearchItemType, 'Anthurium'); - await page.waitToClick(selectors.itemsIndex.advancedSearchButton); - await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 4); - - await page.reload({ - waitUntil: 'networkidle2' - }); - - await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 4); - - await page.write(selectors.itemsIndex.advancedSmartTableGrouping, '1'); - await page.keyboard.press('Enter'); - await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2); - - await page.reload({ - waitUntil: 'networkidle2' - }); - - await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1); - }); - - it('should filter in section without smart-table and search in searchBar go to zone section', async() => { - await page.loginAndModule('salesPerson', 'zone'); - await page.waitToClick(selectors.globalItems.searchButton); - - await page.doSearch('A'); - const firstCount = await page.countElement(selectors.zoneIndex.searchResult); - - await page.doSearch('A'); - const secondCount = await page.countElement(selectors.zoneIndex.searchResult); - - expect(firstCount).toEqual(7); - expect(secondCount).toEqual(7); - }); - - it('should order orders by first id and order by last id, reload page and have same order', async() => { - await page.loginAndModule('developer', 'item'); - await page.accessToSection('item.fixedPrice'); - await page.keyboard.press('Enter'); - - await page.waitForTextInField(selectors.itemFixedPrice.firstItemID, '1'); - - await page.waitToClick(selectors.itemFixedPrice.orderColumnId); - await page.reload({ - waitUntil: 'networkidle2' - }); - await page.waitForTextInField(selectors.itemFixedPrice.firstItemID, '3'); - }); -}); diff --git a/e2e/paths/02-client/04_edit_billing_data.spec.js b/e2e/paths/02-client/04_edit_billing_data.spec.js index 10eb85406..ca2c3b953 100644 --- a/e2e/paths/02-client/04_edit_billing_data.spec.js +++ b/e2e/paths/02-client/04_edit_billing_data.spec.js @@ -35,6 +35,14 @@ describe('Client Edit billing data path', () => { it(`should attempt to edit the billing data without an IBAN but fail`, async() => { await page.autocompleteSearch($.payMethod, 'PayMethod with IBAN'); + await page.waitToClick($.saveButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('That payment method requires an IBAN'); + }); + + it(`should edit the billing data and save the form`, async() => { + await page.autocompleteSearch($.payMethod, 'PayMethod five'); await page.autocompleteSearch($.swiftBic, 'BBKKESMMMMM'); await page.clearInput($.dueDay); await page.write($.dueDay, '60'); @@ -45,10 +53,13 @@ describe('Client Edit billing data path', () => { await page.waitToClick($.saveButton); const message = await page.waitForSnackbar(); - expect(message.text).toContain('That payment method requires an IBAN'); + expect(message.text).toContain('Notification sent!'); }); it(`should create a new BIC code`, async() => { + await page.loginAndModule('financial', 'client'); + await page.accessToSearchResult('Bruce Banner'); + await page.accessToSection('client.card.billingData'); await page.waitToClick($.newBankEntityButton); await page.write($.newBankEntityName, 'Gotham City Bank'); await page.write($.newBankEntityBIC, 'GTHMCT'); @@ -66,7 +77,7 @@ describe('Client Edit billing data path', () => { it(`should confirm the IBAN pay method was sucessfully saved`, async() => { const payMethod = await page.waitToGetProperty($.payMethod, 'value'); - expect(payMethod).toEqual('PayMethod with IBAN'); + expect(payMethod).toEqual('PayMethod five'); }); it(`should clear the BIC code field, update the IBAN to see how he BIC code autocompletes`, async() => { @@ -79,14 +90,6 @@ describe('Client Edit billing data path', () => { expect(automaticCode).toEqual('CAIXESBB'); }); - it(`should save the form with all its new data`, async() => { - await page.waitForWatcherData($.watcher); - await page.waitToClick($.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Notification sent!'); - }); - it('should confirm the billing data have been edited', async() => { const dueDate = await page.waitToGetProperty($.dueDay, 'value'); const IBAN = await page.waitToGetProperty($.IBAN, 'value'); @@ -94,7 +97,9 @@ describe('Client Edit billing data path', () => { const receivedCoreLCR = await page.checkboxState($.receivedCoreLCRCheckbox); const receivedCoreVNL = await page.checkboxState($.receivedCoreVNLCheckbox); const receivedB2BVNL = await page.checkboxState($.receivedB2BVNLCheckbox); + const payMethod = await page.waitToGetProperty($.payMethod, 'value'); + expect(payMethod).toEqual('PayMethod five'); expect(dueDate).toEqual('60'); expect(IBAN).toEqual('ES9121000418450200051332'); expect(swiftBic).toEqual('CAIXESBB'); diff --git a/e2e/paths/02-client/05_add_address.spec.js b/e2e/paths/02-client/05_add_address.spec.js index 0581635d0..4f809a716 100644 --- a/e2e/paths/02-client/05_add_address.spec.js +++ b/e2e/paths/02-client/05_add_address.spec.js @@ -51,7 +51,7 @@ describe('Client Add address path', () => { await page.waitToClick(selectors.clientAddresses.saveButton); const message = await page.waitForSnackbar(); - expect(message.text).toContain('Incoterms is required for a non UEE member'); + expect(message.text).toContain('Incoterms and Customs agent are required for a non UEE member'); }); it(`should receive an error after clicking save button as customsAgent is empty`, async() => { @@ -59,7 +59,7 @@ describe('Client Add address path', () => { await page.waitToClick(selectors.clientAddresses.saveButton); const message = await page.waitForSnackbar(); - expect(message.text).toContain('Customs agent is required for a non UEE member'); + expect(message.text).toContain('Incoterms and Customs agent are required for a non UEE member'); }); it(`should create a new custom agent and then save the address`, async() => { diff --git a/e2e/paths/02-client/08_add_notes.spec.js b/e2e/paths/02-client/08_add_notes.spec.js deleted file mode 100644 index d0c483a11..000000000 --- a/e2e/paths/02-client/08_add_notes.spec.js +++ /dev/null @@ -1,42 +0,0 @@ -import selectors from '../../helpers/selectors'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Client Add notes path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'client'); - await page.accessToSearchResult('Bruce Banner'); - await page.accessToSection('client.card.note.index'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should reach the notes index`, async() => { - await page.waitForState('client.card.note.index'); - }); - - it(`should click on the add note button`, async() => { - await page.waitToClick(selectors.clientNotes.addNoteFloatButton); - await page.waitForState('client.card.note.create'); - }); - - it(`should create a note`, async() => { - await page.waitForSelector(selectors.clientNotes.note); - await page.type(`${selectors.clientNotes.note} textarea`, 'Meeting with Black Widow 21st 9am'); - await page.waitToClick(selectors.clientNotes.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should confirm the note was created', async() => { - const result = await page.waitToGetProperty(selectors.clientNotes.firstNoteText, 'innerText'); - - expect(result).toEqual('Meeting with Black Widow 21st 9am'); - }); -}); diff --git a/e2e/paths/02-client/21_defaulter.spec.js b/e2e/paths/02-client/21_defaulter.spec.js index 2bb3d6254..01f394bc8 100644 --- a/e2e/paths/02-client/21_defaulter.spec.js +++ b/e2e/paths/02-client/21_defaulter.spec.js @@ -28,12 +28,12 @@ describe('Client defaulter path', () => { const salesPersonName = await page.waitToGetProperty(selectors.clientDefaulter.firstSalesPersonName, 'innerText'); - expect(clientName).toEqual('Bruce Banner'); - expect(salesPersonName).toEqual('developer'); + expect(clientName).toEqual('Ororo Munroe'); + expect(salesPersonName).toEqual('salesperson'); }); it('should first observation not changed', async() => { - const expectedObservation = 'Meeting with Black Widow 21st 9am'; + const expectedObservation = 'Madness, as you know, is like gravity, all it takes is a little push'; const result = await page.waitToGetProperty(selectors.clientDefaulter.firstObservation, 'value'); expect(result).toContain(expectedObservation); @@ -62,13 +62,4 @@ describe('Client defaulter path', () => { await page.write(selectors.clientDefaulter.observation, 'My new observation'); await page.waitToClick(selectors.clientDefaulter.saveButton); }); - - it('should first observation changed', async() => { - const message = await page.waitForSnackbar(); - await page.waitForSelector(selectors.clientDefaulter.firstObservation); - const result = await page.waitToGetProperty(selectors.clientDefaulter.firstObservation, 'value'); - - expect(message.text).toContain('Observation saved!'); - expect(result).toContain('My new observation'); - }); }); diff --git a/e2e/paths/03-worker/01-department/01_summary.spec.js b/e2e/paths/03-worker/01-department/01_summary.spec.js deleted file mode 100644 index e4bf8fc2d..000000000 --- a/e2e/paths/03-worker/01-department/01_summary.spec.js +++ /dev/null @@ -1,29 +0,0 @@ -import selectors from '../../../helpers/selectors.js'; -import getBrowser from '../../../helpers/puppeteer'; - -describe('department summary path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('hr', 'worker'); - await page.accessToSection('worker.department'); - await page.doSearch('INFORMATICA'); - await page.click(selectors.department.firstDepartment); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the employee summary section and check all properties', async() => { - expect(await page.waitToGetProperty(selectors.departmentSummary.header, 'innerText')).toEqual('INFORMATICA'); - expect(await page.getProperty(selectors.departmentSummary.name, 'innerText')).toEqual('INFORMATICA'); - expect(await page.getProperty(selectors.departmentSummary.code, 'innerText')).toEqual('it'); - expect(await page.getProperty(selectors.departmentSummary.chat, 'innerText')).toEqual('informatica-cau'); - expect(await page.getProperty(selectors.departmentSummary.bossDepartment, 'innerText')).toEqual(''); - expect(await page.getProperty(selectors.departmentSummary.email, 'innerText')).toEqual('-'); - expect(await page.getProperty(selectors.departmentSummary.clientFk, 'innerText')).toEqual('-'); - }); -}); diff --git a/e2e/paths/03-worker/01-department/02-basicData.spec.js b/e2e/paths/03-worker/01-department/02-basicData.spec.js deleted file mode 100644 index 219d1426c..000000000 --- a/e2e/paths/03-worker/01-department/02-basicData.spec.js +++ /dev/null @@ -1,43 +0,0 @@ -import getBrowser from '../../../helpers/puppeteer'; -import selectors from '../../../helpers/selectors.js'; - -const $ = { - form: 'vn-worker-department-basic-data form', -}; - -describe('department summary path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('hr', 'worker'); - await page.accessToSection('worker.department'); - await page.doSearch('INFORMATICA'); - await page.click(selectors.department.firstDepartment); - }); - - beforeEach(async() => { - await page.accessToSection('worker.department.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should edit the department basic data and confirm the department data was edited`, async() => { - const values = { - Name: 'Informatica', - Code: 'IT', - Chat: 'informatica-cau', - Email: 'it@verdnatura.es', - }; - - await page.fillForm($.form, values); - const formValues = await page.fetchForm($.form, Object.keys(values)); - const message = await page.sendForm($.form, values); - - expect(message.isSuccess).toBeTrue(); - expect(formValues).toEqual(values); - }); -}); diff --git a/e2e/paths/03-worker/01_summary.spec.js b/e2e/paths/03-worker/01_summary.spec.js deleted file mode 100644 index 51992b41d..000000000 --- a/e2e/paths/03-worker/01_summary.spec.js +++ /dev/null @@ -1,34 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Worker summary path', () => { - const workerId = 3; - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'worker'); - const httpDataResponse = page.waitForResponse(response => { - return response.status() === 200 && response.url().includes(`Workers/${workerId}`); - }); - await page.accessToSearchResult('agencyNick'); - await httpDataResponse; - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the employee summary section and check all properties', async() => { - expect(await page.getProperty(selectors.workerSummary.header, 'innerText')).toEqual('agency agency'); - expect(await page.getProperty(selectors.workerSummary.id, 'innerText')).toEqual('3'); - expect(await page.getProperty(selectors.workerSummary.email, 'innerText')).toEqual('agency@verdnatura.es'); - expect(await page.getProperty(selectors.workerSummary.department, 'innerText')).toEqual('CAMARA'); - expect(await page.getProperty(selectors.workerSummary.userId, 'innerText')).toEqual('3'); - expect(await page.getProperty(selectors.workerSummary.userName, 'innerText')).toEqual('agency'); - expect(await page.getProperty(selectors.workerSummary.role, 'innerText')).toEqual('agency'); - expect(await page.getProperty(selectors.workerSummary.extension, 'innerText')).toEqual('1101'); - expect(await page.getProperty(selectors.workerSummary.locker, 'innerText')).toEqual('-'); - }); -}); diff --git a/e2e/paths/03-worker/02_basicData.spec.js b/e2e/paths/03-worker/02_basicData.spec.js deleted file mode 100644 index 66a597dd1..000000000 --- a/e2e/paths/03-worker/02_basicData.spec.js +++ /dev/null @@ -1,40 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Worker basic data path', () => { - const workerId = 1106; - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('hr', 'worker'); - const httpDataResponse = page.waitForResponse(response => { - return response.status() === 200 && response.url().includes(`Workers/${workerId}`); - }); - await page.accessToSearchResult('David Charles Haller'); - await httpDataResponse; - await page.accessToSection('worker.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should edit the form and then reload the section and check the data was edited', async() => { - await page.overwrite(selectors.workerBasicData.name, 'David C.'); - await page.overwrite(selectors.workerBasicData.surname, 'H.'); - await page.overwrite(selectors.workerBasicData.phone, '444332211'); - await page.click(selectors.workerBasicData.saveButton); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - - await page.reloadSection('worker.card.basicData'); - - expect(await page.waitToGetProperty(selectors.workerBasicData.name, 'value')).toEqual('David C.'); - expect(await page.waitToGetProperty(selectors.workerBasicData.surname, 'value')).toEqual('H.'); - expect(await page.waitToGetProperty(selectors.workerBasicData.phone, 'value')).toEqual('444332211'); - }); -}); diff --git a/e2e/paths/03-worker/03_pbx.spec.js b/e2e/paths/03-worker/03_pbx.spec.js deleted file mode 100644 index 0e8003c47..000000000 --- a/e2e/paths/03-worker/03_pbx.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Worker pbx path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('hr', 'worker'); - await page.accessToSearchResult('employee'); - await page.accessToSection('worker.card.pbx'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should receive an error when the extension exceeds 4 characters and then sucessfully save the changes', async() => { - await page.write(selectors.workerPbx.extension, '55555'); - await page.click(selectors.workerPbx.saveButton); - let message = await page.waitForSnackbar(); - - expect(message.text).toContain('Extension format is invalid'); - - await page.overwrite(selectors.workerPbx.extension, '4444'); - await page.click(selectors.workerPbx.saveButton); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved! User must access web'); - }); -}); diff --git a/e2e/paths/03-worker/04_time_control.spec.js b/e2e/paths/03-worker/04_time_control.spec.js deleted file mode 100644 index c6589d2e3..000000000 --- a/e2e/paths/03-worker/04_time_control.spec.js +++ /dev/null @@ -1,65 +0,0 @@ -/* eslint max-len: ["error", { "code": 150 }]*/ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Worker time control path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('salesBoss', 'worker'); - await page.accessToSearchResult('HankPym'); - await page.accessToSection('worker.card.timeControl'); - }); - - afterAll(async() => { - await browser.close(); - }); - - const eightAm = '08:00'; - const fourPm = '16:00'; - const hankPymId = 1107; - - it('should go to the next month, go to current month and go 1 month in the past', async() => { - let date = Date.vnNew(); - date.setDate(1); - date.setMonth(date.getMonth() + 1); - let month = date.toLocaleString('default', {month: 'long'}); - - await page.waitToClick(selectors.workerTimeControl.nextMonthButton); - let result = await page.getProperty(selectors.workerTimeControl.monthName, 'innerText'); - - expect(result).toContain(month); - - date = Date.vnNew(); - date.setDate(1); - month = date.toLocaleString('default', {month: 'long'}); - - await page.waitToClick(selectors.workerTimeControl.previousMonthButton); - result = await page.getProperty(selectors.workerTimeControl.monthName, 'innerText'); - - expect(result).toContain(month); - - date = Date.vnNew(); - date.setDate(1); - date.setMonth(date.getMonth() - 1); - const timestamp = Math.round(date.getTime() / 1000); - month = date.toLocaleString('default', {month: 'long'}); - - await page.loginAndModule('salesBoss', 'worker'); - await page.goto(`http://localhost:5000/#!/worker/${hankPymId}/time-control?timestamp=${timestamp}`); - await page.waitToClick(selectors.workerTimeControl.secondWeekDay); - - result = await page.getProperty(selectors.workerTimeControl.monthName, 'innerText'); - - expect(result).toContain(month); - }); - - it('should change week of month', async() => { - await page.click(selectors.workerTimeControl.thrirdWeekDay); - const result = await page.getProperty(selectors.workerTimeControl.mondayWorkedHours, 'innerText'); - - expect(result).toEqual('00:00 h.'); - }); -}); diff --git a/e2e/paths/03-worker/05_calendar.spec.js b/e2e/paths/03-worker/05_calendar.spec.js deleted file mode 100644 index f0af0a053..000000000 --- a/e2e/paths/03-worker/05_calendar.spec.js +++ /dev/null @@ -1,114 +0,0 @@ -/* eslint-disable max-len */ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Worker calendar path', () => { - const reasonableTimeBetweenClicks = 300; - const date = Date.vnNew(); - const lastYear = (date.getFullYear() - 1).toString(); - - let browser; - let page; - - async function accessAs(user) { - await page.loginAndModule(user, 'worker'); - await page.accessToSearchResult('Charles Xavier'); - await page.accessToSection('worker.card.calendar'); - } - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - accessAs('hr'); - }); - - afterAll(async() => { - await browser.close(); - }); - - describe('as hr', () => { - it('should set two days as holidays on the calendar and check the total holidays increased by 1.5', async() => { - await page.waitToClick(selectors.workerCalendar.holidays); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.penultimateMondayOfJanuary); - - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.absence); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.lastMondayOfMarch); - - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.halfHoliday); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.fistMondayOfMay); - - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.furlough); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.secondTuesdayOfMay); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.secondWednesdayOfMay); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.secondThursdayOfMay); - - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.halfFurlough); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.secondFridayOfJun); - - expect(await page.getProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText')).toContain(' 1.5 '); - }); - }); - - describe(`as salesBoss`, () => { - it(`should log in, get to Charles Xavier's calendar, undo what was done here, and check the total holidays used are back to what it was`, async() => { - accessAs('salesBoss'); - - await page.waitToClick(selectors.workerCalendar.holidays); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.penultimateMondayOfJanuary); - - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.absence); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.lastMondayOfMarch); - - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.halfHoliday); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.fistMondayOfMay); - - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.furlough); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.secondTuesdayOfMay); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.secondWednesdayOfMay); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.secondThursdayOfMay); - - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.halfFurlough); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.secondFridayOfJun); - - expect(await page.getProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText')).toContain(' 0 '); - }); - }); - - describe(`as Charles Xavier`, () => { - it('should log in and get to his calendar, make a futile attempt to add holidays, check the total holidays used are now the initial ones and use the year selector to go to the previous year', async() => { - accessAs('CharlesXavier'); - await page.waitToClick(selectors.workerCalendar.holidays); - await page.waitForTimeout(reasonableTimeBetweenClicks); - - await page.click(selectors.workerCalendar.penultimateMondayOfJanuary); - - expect(await page.getProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText')).toContain(' 0 '); - - await page.autocompleteSearch(selectors.workerCalendar.year, lastYear); - - expect(await page.getProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText')).toContain(' 0 '); - }); - }); -}); diff --git a/e2e/paths/03-worker/06_create.spec.js b/e2e/paths/03-worker/06_create.spec.js deleted file mode 100644 index 2accdfc31..000000000 --- a/e2e/paths/03-worker/06_create.spec.js +++ /dev/null @@ -1,73 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Worker create path', () => { - let browser; - let page; - let newWorker; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('hr', 'worker'); - await page.waitToClick(selectors.workerCreate.newWorkerButton); - await page.waitForState('worker.create'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should insert default data', async() => { - await page.write(selectors.workerCreate.firstname, 'Victor'); - await page.write(selectors.workerCreate.lastname, 'Von Doom'); - await page.write(selectors.workerCreate.fi, '78457139E'); - await page.write(selectors.workerCreate.phone, '12356789'); - await page.write(selectors.workerCreate.postcode, '46680'); - await page.write(selectors.workerCreate.street, 'S/ DOOMSTADT'); - await page.write(selectors.workerCreate.email, 'doctorDoom@marvel.com'); - await page.write(selectors.workerCreate.iban, 'ES9121000418450200051332'); - - // should check for autocompleted worker code and worker user name - const workerCode = await page - .waitToGetProperty(selectors.workerCreate.code, 'value'); - - newWorker = await page - .waitToGetProperty(selectors.workerCreate.user, 'value'); - - expect(workerCode).toEqual('VVD'); - expect(newWorker).toContain('victorvd'); - - // should fail if necessary data is void - await page.waitToClick(selectors.workerCreate.createButton); - let message = await page.waitForSnackbar(); - - expect(message.text).toContain('is a required argument'); - - // should create a new worker and go to worker basic data' - await page.pickDate(selectors.workerCreate.birth, new Date(1962, 8, 5)); - await page.autocompleteSearch(selectors.workerCreate.boss, 'deliveryAssistant'); - await page.waitToClick(selectors.workerCreate.createButton); - message = await page.waitForSnackbar(); - await page.waitForState('worker.card.basicData'); - - expect(message.text).toContain('Data saved!'); - - // 'rollback' - await page.loginAndModule('itManagement', 'account'); - await page.accessToSearchResult(newWorker); - - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.deactivateUser); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('User deactivated!'); - - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.disableAccount); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('Account disabled!'); - }); -}); diff --git a/e2e/paths/03-worker/08_add_notes.spec.js b/e2e/paths/03-worker/08_add_notes.spec.js deleted file mode 100644 index bdc475c90..000000000 --- a/e2e/paths/03-worker/08_add_notes.spec.js +++ /dev/null @@ -1,42 +0,0 @@ -import selectors from '../../helpers/selectors'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Worker Add notes path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('hr', 'worker'); - await page.accessToSearchResult('Bruce Banner'); - await page.accessToSection('worker.card.note.index'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should reach the notes index`, async() => { - await page.waitForState('worker.card.note.index'); - }); - - it(`should click on the add note button`, async() => { - await page.waitToClick(selectors.workerNotes.addNoteFloatButton); - await page.waitForState('worker.card.note.create'); - }); - - it(`should create a note`, async() => { - await page.waitForSelector(selectors.workerNotes.note); - await page.type(`${selectors.workerNotes.note} textarea`, 'Meeting with Black Widow 21st 9am'); - await page.waitToClick(selectors.workerNotes.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should confirm the note was created', async() => { - const result = await page.waitToGetProperty(selectors.workerNotes.firstNoteText, 'innerText'); - - expect(result).toEqual('Meeting with Black Widow 21st 9am'); - }); -}); diff --git a/e2e/paths/05-ticket/01-sale/01_list_sales.spec.js b/e2e/paths/05-ticket/01-sale/01_list_sales.spec.js index 5c8eba571..ad0975889 100644 --- a/e2e/paths/05-ticket/01-sale/01_list_sales.spec.js +++ b/e2e/paths/05-ticket/01-sale/01_list_sales.spec.js @@ -57,7 +57,7 @@ describe('Ticket List sale path', () => { let searchValue = 'Melee weapon heavy shield 100cm'; await page.autocompleteSearch(selectors.ticketSales.secondSaleIdAutocomplete, searchValue); await page.waitToClick(selectors.ticketSales.secondSaleQuantityCell); - await page.type(selectors.ticketSales.secondSaleQuantity, '1'); + await page.type(selectors.ticketSales.secondSaleQuantity, '8'); await page.keyboard.press('Enter'); const message = await page.waitForSnackbar(); diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index 4f54ad860..d9689e31a 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -19,7 +19,9 @@ describe('Ticket Edit sale path', () => { it(`should click on the first sale claim icon to navigate over there`, async() => { await page.waitToClick(selectors.ticketSales.firstSaleClaimIcon); - await page.waitForState('claim.card.basicData'); + await page.waitForNavigation(); + await page.goBack(); + await page.goBack(); }); it('should navigate to the tickets index', async() => { @@ -225,7 +227,7 @@ describe('Ticket Edit sale path', () => { }); it('should show error trying to delete a ticket with a refund', async() => { - await page.loginAndModule('production', 'ticket'); + await page.loginAndModule('salesPerson', 'ticket'); await page.accessToSearchResult('8'); await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket); @@ -243,29 +245,13 @@ describe('Ticket Edit sale path', () => { await page.waitToClick(selectors.ticketSales.moreMenu); await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim); await page.waitToClick(selectors.globalItems.acceptButton); - await page.waitForState('claim.card.basicData'); - }); - - it('should click on the Claims button of the top bar menu', async() => { - await page.waitToClick(selectors.globalItems.applicationsMenuButton); - await page.waitForSelector(selectors.globalItems.applicationsMenuVisible); - await page.waitToClick(selectors.globalItems.claimsButton); - await page.waitForState('claim.index'); - }); - - it('should search for the claim with id 4', async() => { - await page.accessToSearchResult('4'); - await page.waitForState('claim.card.summary'); - }); - - it('should click the Tickets button of the top bar menu', async() => { - await page.waitToClick(selectors.globalItems.applicationsMenuButton); - await page.waitForSelector(selectors.globalItems.applicationsMenuVisible); - await page.waitToClick(selectors.globalItems.ticketsButton); - await page.waitForState('ticket.index'); + await page.waitForNavigation(); }); it('should search for a ticket then access to the sales section', async() => { + await page.goBack(); + await page.goBack(); + await page.loginAndModule('salesPerson', 'ticket'); await page.accessToSearchResult('16'); await page.accessToSection('ticket.card.sale'); }); diff --git a/e2e/paths/05-ticket/09_weekly.spec.js b/e2e/paths/05-ticket/09_weekly.spec.js index 1caf91f9c..370d422e6 100644 --- a/e2e/paths/05-ticket/09_weekly.spec.js +++ b/e2e/paths/05-ticket/09_weekly.spec.js @@ -19,7 +19,7 @@ describe('Ticket descriptor path', () => { it('should count the amount of tickets in the turns section', async() => { const result = await page.countElement(selectors.ticketsIndex.weeklyTicket); - expect(result).toEqual(5); + expect(result).toEqual(6); }); it('should go back to the ticket index then search and access a ticket summary', async() => { @@ -106,7 +106,7 @@ describe('Ticket descriptor path', () => { await page.doSearch(); const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult); - expect(nResults).toEqual(5); + expect(nResults).toEqual(6); }); it('should update the agency then remove it afterwards', async() => { diff --git a/e2e/paths/05-ticket/21_future.spec.js b/e2e/paths/05-ticket/21_future.spec.js index 7b7d478f7..60bb9c38d 100644 --- a/e2e/paths/05-ticket/21_future.spec.js +++ b/e2e/paths/05-ticket/21_future.spec.js @@ -30,18 +30,18 @@ describe('Ticket Future path', () => { expect(message.text).toContain('warehouseFk is a required argument'); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.futureDated); + await page.clearInput(selectors.ticketFuture.futureScopeDays); await page.waitToClick(selectors.ticketFuture.submit); message = await page.waitForSnackbar(); - expect(message.text).toContain('futureDated is a required argument'); + expect(message.text).toContain('futureScopeDays is a required argument'); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); - await page.clearInput(selectors.ticketFuture.originDated); + await page.clearInput(selectors.ticketFuture.originScopeDays); await page.waitToClick(selectors.ticketFuture.submit); message = await page.waitForSnackbar(); - expect(message.text).toContain('originDated is a required argument'); + expect(message.text).toContain('originScopeDays is a required argument'); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.waitToClick(selectors.ticketFuture.submit); @@ -71,7 +71,7 @@ describe('Ticket Future path', () => { await page.autocompleteSearch(selectors.ticketFuture.state, 'Free'); await page.waitToClick(selectors.ticketFuture.submit); - expect(httpRequest).toContain('state=FREE'); + expect(httpRequest).toContain('state=0'); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); @@ -80,7 +80,7 @@ describe('Ticket Future path', () => { await page.autocompleteSearch(selectors.ticketFuture.futureState, 'Free'); await page.waitToClick(selectors.ticketFuture.submit); - expect(httpRequest).toContain('futureState=FREE'); + expect(httpRequest).toContain('futureState=0'); await page.waitToClick(selectors.ticketFuture.openAdvancedSearchButton); await page.clearInput(selectors.ticketFuture.state); diff --git a/e2e/paths/06-claim/01_basic_data.spec.js b/e2e/paths/06-claim/01_basic_data.spec.js deleted file mode 100644 index 33c68183f..000000000 --- a/e2e/paths/06-claim/01_basic_data.spec.js +++ /dev/null @@ -1,61 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Claim edit basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should log in as claimManager then reach basic data of the target claim`, async() => { - await page.loginAndModule('claimManager', 'claim'); - await page.accessToSearchResult('1'); - await page.accessToSection('claim.card.basicData'); - }); - - it(`should edit claim state and observation fields`, async() => { - await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Resuelto'); - await page.clearInput(selectors.claimBasicData.packages); - await page.write(selectors.claimBasicData.packages, '2'); - await page.waitToClick(selectors.claimBasicData.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should have been redirected to the next section of claims as the role is claimManager`, async() => { - await page.waitForState('claim.card.detail'); - }); - - it('should confirm the claim state was edited', async() => { - await page.reloadSection('claim.card.basicData'); - await page.waitForSelector(selectors.claimBasicData.claimState); - const result = await page.waitToGetProperty(selectors.claimBasicData.claimState, 'value'); - - expect(result).toEqual('Resuelto'); - }); - - it('should confirm the claim packages was edited', async() => { - const result = await page - .waitToGetProperty(selectors.claimBasicData.packages, 'value'); - - expect(result).toEqual('2'); - }); - - it(`should edit the claim to leave it untainted`, async() => { - await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Pendiente'); - await page.clearInput(selectors.claimBasicData.packages); - await page.write(selectors.claimBasicData.packages, '0'); - await page.waitToClick(selectors.claimBasicData.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); -}); diff --git a/e2e/paths/06-claim/03_claim_action.spec.js b/e2e/paths/06-claim/03_claim_action.spec.js deleted file mode 100644 index ac6f72e37..000000000 --- a/e2e/paths/06-claim/03_claim_action.spec.js +++ /dev/null @@ -1,54 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer.js'; - -describe('Claim action path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('claimManager', 'claim'); - await page.accessToSearchResult('2'); - await page.accessToSection('claim.card.action'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should import the claim', async() => { - await page.waitToClick(selectors.claimAction.importClaimButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should delete the first line', async() => { - await page.waitToClick(selectors.claimAction.firstDeleteLine); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should refresh the view to check not have lines', async() => { - await page.reloadSection('claim.card.action'); - const result = await page.countElement(selectors.claimAction.anyLine); - - expect(result).toEqual(0); - }); - - it('should check the "is paid with mana" checkbox', async() => { - await page.waitToClick(selectors.claimAction.isPaidWithManaCheckbox); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should confirm the "is paid with mana" is checked', async() => { - await page.reloadSection('claim.card.action'); - const isPaidWithManaCheckbox = await page.checkboxState(selectors.claimAction.isPaidWithManaCheckbox); - - expect(isPaidWithManaCheckbox).toBe('checked'); - }); -}); diff --git a/e2e/paths/06-claim/04_summary.spec.js b/e2e/paths/06-claim/04_summary.spec.js deleted file mode 100644 index dda8484a6..000000000 --- a/e2e/paths/06-claim/04_summary.spec.js +++ /dev/null @@ -1,96 +0,0 @@ - -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer.js'; - -describe('Claim summary path', () => { - let browser; - let page; - const claimId = '4'; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should navigate to the target claim summary section', async() => { - await page.loginAndModule('salesPerson', 'claim'); - await page.accessToSearchResult(claimId); - await page.waitForState('claim.card.summary'); - }); - - it(`should display details from the claim and it's client on the top of the header`, async() => { - await page.waitForTextInElement(selectors.claimSummary.header, 'Tony Stark'); - const result = await page.waitToGetProperty(selectors.claimSummary.header, 'innerText'); - - expect(result).toContain('4 -'); - expect(result).toContain('Tony Stark'); - }); - - it('should display the claim state', async() => { - const result = await page.waitToGetProperty(selectors.claimSummary.state, 'innerText'); - - expect(result).toContain('Resuelto'); - }); - - it('should display the observation', async() => { - const result = await page.waitToGetProperty(selectors.claimSummary.observation, 'innerText'); - - expect(result).toContain('Wisi forensibus mnesarchum in cum. Per id impetus abhorreant'); - }); - - it('should display the claimed line(s)', async() => { - const result = await page.waitToGetProperty(selectors.claimSummary.firstSaleItemId, 'innerText'); - - expect(result).toContain('2'); - }); - - it(`should click on the first sale ID making the item descriptor visible`, async() => { - const firstItem = selectors.claimSummary.firstSaleItemId; - await page.evaluate(selectors => { - document.querySelector(selectors).scrollIntoView(); - }, firstItem); - await page.click(firstItem); - await page.waitImgLoad(selectors.claimSummary.firstSaleDescriptorImage); - const visible = await page.isVisible(selectors.claimSummary.itemDescriptorPopover); - - expect(visible).toBeTruthy(); - }); - - it(`should check the url for the item diary link of the descriptor is for the right item id`, async() => { - await page.waitForSelector(selectors.claimSummary.itemDescriptorPopoverItemDiaryButton, {visible: true}); - - await page.closePopup(); - }); - - it('should display the claim development details', async() => { - const result = await page.waitToGetProperty(selectors.claimSummary.firstDevelopmentWorker, 'innerText'); - - expect(result).toContain('salesAssistantNick'); - }); - - it(`should click on the first development worker making the worker descriptor visible`, async() => { - await page.waitToClick(selectors.claimSummary.firstDevelopmentWorker); - - const visible = await page.isVisible(selectors.claimSummary.firstDevelopmentWorkerGoToClientButton); - - expect(visible).toBeTruthy(); - }); - - it(`should check the url for the go to clientlink of the descriptor is for the right client id`, async() => { - await page.waitForSelector(selectors.claimSummary.firstDevelopmentWorkerGoToClientButton, {visible: true}); - - await page.closePopup(); - }); - - it(`should click on the first action ticket ID making the ticket descriptor visible`, async() => { - await page.waitToClick(selectors.claimSummary.firstActionTicketId); - await page.waitForSelector(selectors.claimSummary.firstActionTicketDescriptor); - const visible = await page.isVisible(selectors.claimSummary.firstActionTicketDescriptor); - - expect(visible).toBeTruthy(); - }); -}); diff --git a/e2e/paths/06-claim/05_descriptor.spec.js b/e2e/paths/06-claim/05_descriptor.spec.js deleted file mode 100644 index 49912b26a..000000000 --- a/e2e/paths/06-claim/05_descriptor.spec.js +++ /dev/null @@ -1,58 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer.js'; - -describe('Claim descriptor path', () => { - let browser; - let page; - const claimId = '1'; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should now navigate to the target claim summary section', async() => { - await page.loginAndModule('salesPerson', 'claim'); - await page.accessToSearchResult(claimId); - await page.waitForState('claim.card.summary'); - }); - - it(`should not be able to see the delete claim button of the descriptor more menu`, async() => { - await page.waitToClick(selectors.claimDescriptor.moreMenu); - await page.waitForSelector(selectors.claimDescriptor.moreMenuDeleteClaim, {hidden: true}); - }); - - it(`should log in as claimManager and navigate to the target claim`, async() => { - await page.loginAndModule('claimManager', 'claim'); - await page.accessToSearchResult(claimId); - await page.waitForState('claim.card.summary'); - }); - - it(`should be able to see the delete claim button of the descriptor more menu`, async() => { - await page.waitToClick(selectors.claimDescriptor.moreMenu); - await page.waitForSelector(selectors.claimDescriptor.moreMenuDeleteClaim, {visible: true}); - }); - - it(`should delete the claim`, async() => { - await page.waitToClick(selectors.claimDescriptor.moreMenuDeleteClaim); - await page.waitToClick(selectors.claimDescriptor.acceptDeleteClaim); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Claim deleted!'); - }); - - it(`should have been relocated to the claim index`, async() => { - await page.waitForState('claim.index'); - }); - - it(`should search for the deleted claim to find no results`, async() => { - await page.doSearch(claimId); - const nResults = await page.countElement(selectors.claimsIndex.searchResult); - - expect(nResults).toEqual(0); - }); -}); diff --git a/e2e/paths/06-claim/06_note.spec.js b/e2e/paths/06-claim/06_note.spec.js deleted file mode 100644 index 830f77cbe..000000000 --- a/e2e/paths/06-claim/06_note.spec.js +++ /dev/null @@ -1,46 +0,0 @@ -import selectors from '../../helpers/selectors'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Claim Add note path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('salesPerson', 'claim'); - await page.accessToSearchResult('2'); - await page.accessToSection('claim.card.note.index'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should reach the claim note index`, async() => { - await page.waitForState('claim.card.note.index'); - }); - - it(`should click on the add new note button`, async() => { - await page.waitToClick(selectors.claimNote.addNoteFloatButton); - await page.waitForState('claim.card.note.create'); - }); - - it(`should create a new note`, async() => { - await page.waitForSelector(selectors.claimNote.note); - await page.type(`${selectors.claimNote.note} textarea`, 'The delivery was unsuccessful'); - await page.waitToClick(selectors.claimNote.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should redirect back to the claim notes page`, async() => { - await page.waitForState('claim.card.note.index'); - }); - - it('should confirm the note was created', async() => { - const result = await page.waitToGetProperty(selectors.claimNote.firstNoteText, 'innerText'); - - expect(result).toEqual('The delivery was unsuccessful'); - }); -}); diff --git a/e2e/paths/07-order/01_summary.spec.js b/e2e/paths/07-order/01_summary.spec.js deleted file mode 100644 index 9df481ef6..000000000 --- a/e2e/paths/07-order/01_summary.spec.js +++ /dev/null @@ -1,46 +0,0 @@ -import getBrowser from '../../helpers/puppeteer'; - -const $ = { - id: 'vn-order-summary vn-one:nth-child(1) > vn-label-value:nth-child(1) span', - alias: 'vn-order-summary vn-one:nth-child(1) > vn-label-value:nth-child(2) span', - consignee: 'vn-order-summary vn-one:nth-child(2) > vn-label-value:nth-child(6) span', - subtotal: 'vn-order-summary vn-one.taxes > p:nth-child(1)', - vat: 'vn-order-summary vn-one.taxes > p:nth-child(2)', - total: 'vn-order-summary vn-one.taxes > p:nth-child(3)', - sale: 'vn-order-summary vn-tbody > vn-tr', -}; - -describe('Order summary path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'order'); - await page.accessToSearchResult('16'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the order summary section and check data', async() => { - await page.waitForState('order.card.summary'); - - const id = await page.innerText($.id); - const alias = await page.innerText($.alias); - const consignee = await page.innerText($.consignee); - const subtotal = await page.innerText($.subtotal); - const vat = await page.innerText($.vat); - const total = await page.innerText($.total); - const sale = await page.countElement($.sale); - - expect(id).toEqual('16'); - expect(alias).toEqual('Many places'); - expect(consignee).toEqual('address 26 - Gotham (Province one)'); - expect(subtotal.length).toBeGreaterThan(1); - expect(vat.length).toBeGreaterThan(1); - expect(total.length).toBeGreaterThan(1); - expect(sale).toBeGreaterThan(0); - }); -}); diff --git a/e2e/paths/07-order/02_basic_data.spec.js b/e2e/paths/07-order/02_basic_data.spec.js deleted file mode 100644 index b2c21b071..000000000 --- a/e2e/paths/07-order/02_basic_data.spec.js +++ /dev/null @@ -1,69 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -const $ = { - form: 'vn-order-basic-data form', - observation: 'vn-order-basic-data form [vn-name="note"]', - saveButton: `vn-order-basic-data form button[type=submit]`, - acceptButton: '.vn-confirm.shown button[response="accept"]' -}; - -describe('Order edit basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - - await page.loginAndModule('employee', 'order'); - await page.accessToSearchResult('1'); - await page.accessToSection('order.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - describe('when confirmed order', () => { - it('should not be able to change the client', async() => { - const message = await page.sendForm($.form, { - client: 'Tony Stark', - address: 'Tony Stark', - }); - - expect(message.text).toContain(`You can't make changes on the basic data`); - }); - }); - - describe('when new order', () => { - it('should create an order and edit its basic data', async() => { - await page.waitToClick(selectors.globalItems.returnToModuleIndexButton); - await page.waitToClick($.acceptButton); - await page.waitForContentLoaded(); - await page.waitToClick(selectors.ordersIndex.createOrderButton); - await page.waitForState('order.create'); - - await page.autocompleteSearch(selectors.createOrderView.client, 'Jessica Jones'); - await page.pickDate(selectors.createOrderView.landedDatePicker); - await page.autocompleteSearch(selectors.createOrderView.agency, 'Other agency'); - await page.waitToClick(selectors.createOrderView.createButton); - await page.waitForState('order.card.catalog'); - - await page.accessToSection('order.card.basicData'); - - const values = { - client: 'Tony Stark', - address: 'Tony Stark', - agencyMode: 'Other agency' - }; - - const message = await page.sendForm($.form, values); - await page.reloadSection('order.card.basicData'); - const formValues = await page.fetchForm($.form, Object.keys(values)); - - expect(message.isSuccess).toBeTrue(); - expect(formValues).toEqual(values); - }); - }); -}); diff --git a/e2e/paths/07-order/03_lines.spec.js b/e2e/paths/07-order/03_lines.spec.js deleted file mode 100644 index 718ea5ce5..000000000 --- a/e2e/paths/07-order/03_lines.spec.js +++ /dev/null @@ -1,48 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Order lines', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'order'); - await page.accessToSearchResult('8'); - await page.accessToSection('order.card.line'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should check the order subtotal', async() => { - const result = await page - .waitToGetProperty(selectors.orderLine.orderSubtotal, 'innerText'); - - expect(result).toContain('112.30'); - }); - - it('should delete the first line in the order', async() => { - await page.waitToClick(selectors.orderLine.firstLineDeleteButton); - await page.waitToClick(selectors.orderLine.confirmButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should confirm the order subtotal has changed', async() => { - await page.waitForTextInElement(selectors.orderLine.orderSubtotal, '92.80'); - const result = await page - .waitToGetProperty(selectors.orderLine.orderSubtotal, 'innerText'); - - expect(result).toContain('92.80'); - }); - - it('should confirm the whole order and redirect to ticket index filtered by clientFk', async() => { - await page.waitToClick(selectors.orderLine.confirmOrder); - - await page.expectURL('ticket/index'); - await page.expectURL('clientFk'); - }); -}); diff --git a/e2e/paths/07-order/04_catalog.spec.js b/e2e/paths/07-order/04_catalog.spec.js deleted file mode 100644 index b8a20e938..000000000 --- a/e2e/paths/07-order/04_catalog.spec.js +++ /dev/null @@ -1,97 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Order catalog', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'order'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should open the create new order form', async() => { - await page.waitToClick(selectors.ordersIndex.createOrderButton); - await page.waitForState('order.create'); - }); - - it('should create a new order', async() => { - await page.autocompleteSearch(selectors.createOrderView.client, 'Tony Stark'); - await page.pickDate(selectors.createOrderView.landedDatePicker); - await page.autocompleteSearch(selectors.createOrderView.agency, 'Other agency'); - await page.waitToClick(selectors.createOrderView.createButton); - await page.waitForState('order.card.catalog'); - }); - - it('should add the realm and type filters and obtain results', async() => { - await page.waitToClick(selectors.orderCatalog.plantRealmButton); - await page.autocompleteSearch(selectors.orderCatalog.type, 'Anthurium'); - await page.waitForNumberOfElements('section.product', 4); - const result = await page.countElement('section.product'); - - expect(result).toEqual(4); - }); - - it('should perfom an "OR" search for the item tag colors silver and brown', async() => { - await page.waitToClick(selectors.orderCatalog.openTagSearch); - await page.autocompleteSearch(selectors.orderCatalog.tag, 'Color'); - await page.autocompleteSearch(selectors.orderCatalog.firstTagAutocomplete, 'silver'); - await page.waitToClick(selectors.orderCatalog.addTagButton); - await page.autocompleteSearch(selectors.orderCatalog.secondTagAutocomplete, 'brown'); - await page.waitToClick(selectors.orderCatalog.searchTagButton); - await page.waitForNumberOfElements('section.product', 4); - }); - - it('should perfom an "OR" search for the item tag tallos 2 and 9', async() => { - await page.waitToClick(selectors.orderCatalog.openTagSearch); - await page.autocompleteSearch(selectors.orderCatalog.tag, 'Tallos'); - await page.write(selectors.orderCatalog.firstTagValue, '2'); - await page.waitToClick(selectors.orderCatalog.addTagButton); - await page.write(selectors.orderCatalog.secondTagValue, '9'); - await page.waitToClick(selectors.orderCatalog.searchTagButton); - await page.waitForNumberOfElements('section.product', 2); - }); - - it('should perform a general search for category', async() => { - await page.write(selectors.orderCatalog.itemTagValue, 'concussion'); - await page.keyboard.press('Enter'); - await page.waitForNumberOfElements('section.product', 2); - }); - - it('should perfom an "AND" search for the item tag tallos 2', async() => { - await page.waitToClick(selectors.orderCatalog.openTagSearch); - await page.autocompleteSearch(selectors.orderCatalog.tag, 'Tallos'); - await page.write(selectors.orderCatalog.firstTagValue, '2'); - await page.waitToClick(selectors.orderCatalog.searchTagButton); - await page.waitForNumberOfElements('section.product', 1); - }); - - it('should remove the tag filters and have 4 results', async() => { - await page.waitForContentLoaded(); - await page.waitToClick(selectors.orderCatalog.sixthFilterRemoveButton); - await page.waitForContentLoaded(); - await page.waitToClick(selectors.orderCatalog.fifthFilterRemoveButton); - await page.waitForContentLoaded(); - await page.waitToClick(selectors.orderCatalog.fourthFilterRemoveButton); - await page.waitForContentLoaded(); - await page.waitToClick(selectors.orderCatalog.thirdFilterRemoveButton); - - await page.waitForNumberOfElements('.product', 4); - const result = await page.countElement('section.product'); - - expect(result).toEqual(4); - }); - - it('should search for an item by id', async() => { - await page.accessToSearchResult('2'); - await page.waitForNumberOfElements('section.product', 1); - const result = await page.countElement('section.product'); - - expect(result).toEqual(1); - }); -}); diff --git a/e2e/paths/07-order/05_index.spec.js b/e2e/paths/07-order/05_index.spec.js deleted file mode 100644 index 23769766c..000000000 --- a/e2e/paths/07-order/05_index.spec.js +++ /dev/null @@ -1,34 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Order Index', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'order'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should check the second search result doesn't contain a total of 0€`, async() => { - await page.waitToClick(selectors.globalItems.searchButton); - const result = await page.waitToGetProperty(selectors.ordersIndex.secondSearchResultTotal, 'innerText'); - - expect(result).not.toContain('0.00'); - }); - - it('should search including empty orders', async() => { - await page.waitToClick(selectors.ordersIndex.openAdvancedSearch); - await page.waitToClick(selectors.ordersIndex.advancedSearchShowEmptyCheckbox); - await page.waitToClick(selectors.ordersIndex.advancedSearchButton); - await page.waitForTextInElement(selectors.ordersIndex.secondSearchResultTotal, '0.00'); - const result = await page.waitToGetProperty(selectors.ordersIndex.secondSearchResultTotal, 'innerText'); - - expect(result).toContain('0.00'); - }); -}); diff --git a/e2e/paths/08-route/01_summary.spec.js b/e2e/paths/08-route/01_summary.spec.js deleted file mode 100644 index 44f66ba2d..000000000 --- a/e2e/paths/08-route/01_summary.spec.js +++ /dev/null @@ -1,62 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Route summary path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'route'); - await page.waitToClick(selectors.routeIndex.previewButton); - await page.waitToClick(selectors.routeSummary.goToRouteSummaryButton); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the first route summary section', async() => { - await page.waitForState('route.card.summary'); - }); - - it(`should display details from the route on the header`, async() => { - await page.waitForTextInElement(selectors.routeSummary.header, 'first route'); - const result = await page.waitToGetProperty(selectors.routeSummary.header, 'innerText'); - - expect(result).toContain('first route'); - }); - - it('should display some route details like the cost', async() => { - const result = await page.waitToGetProperty(selectors.routeSummary.cost, 'innerText'); - - expect(result).toContain('€10.00'); - }); - - it('should click on the first ticket ID making the descriptor popover visible', async() => { - await page.waitForState('route.card.summary'); - await page.waitForTimeout(250); - await page.waitToClick(selectors.routeSummary.firstTicketID); - await page.waitForSelector(selectors.routeSummary.firstTicketDescriptor); - const visible = await page.isVisible(selectors.routeSummary.firstTicketDescriptor); - - expect(visible).toBe(true); - }); - - it('should close the ticket descriptor', async() => { - await page.closePopup(); - }); - - it('should click on the first alias making the client descriptor popover visible', async() => { - await page.waitToClick(selectors.routeSummary.firstAlias); - await page.waitForSelector(selectors.routeSummary.firstClientDescriptor); - const visible = await page.isVisible(selectors.routeSummary.firstClientDescriptor); - - expect(visible).toBe(true); - }); - - it('should close the client descriptor', async() => { - await page.closePopup(); - }); -}); diff --git a/e2e/paths/08-route/02_basic_data.spec.js b/e2e/paths/08-route/02_basic_data.spec.js deleted file mode 100644 index 7ab7dda42..000000000 --- a/e2e/paths/08-route/02_basic_data.spec.js +++ /dev/null @@ -1,42 +0,0 @@ -import getBrowser from '../../helpers/puppeteer'; - -describe('Route basic Data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('delivery', 'route'); - await page.accessToSearchResult('1'); - await page.accessToSection('route.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should edit the route basic data and confirm the route was edited', async() => { - const nextMonth = Date.vnNew(); - nextMonth.setMonth(nextMonth.getMonth() + 1); - nextMonth.setUTCHours(0, 0, 0, 0); - - const form = 'vn-route-basic-data form'; - const values = { - worker: 'adminBossNick', - vehicle: '1111-IMK', - created: nextMonth, - kmStart: 1, - kmEnd: 2, - started: '08:00', - finished: '12:30', - }; - - const message = await page.sendForm(form, values); - await page.reloadSection('route.card.basicData'); - const formValues = await page.fetchForm(form, Object.keys(values)); - - expect(message.isSuccess).toBeTrue(); - expect(formValues).toEqual(values); - }); -}); diff --git a/e2e/paths/08-route/03_create_and_clone.spec.js b/e2e/paths/08-route/03_create_and_clone.spec.js deleted file mode 100644 index 31c0cfc18..000000000 --- a/e2e/paths/08-route/03_create_and_clone.spec.js +++ /dev/null @@ -1,91 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Route create path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'route'); - }); - - afterAll(async() => { - await browser.close(); - }); - - describe('as employee', () => { - it('should click on the add new route button and open the creation form', async() => { - await page.waitToClick(selectors.routeIndex.addNewRouteButton); - await page.waitForState('route.create'); - }); - - it(`should attempt to create a new route but fail since employee has no access rights`, async() => { - await page.write(selectors.createRouteView.description, 'faster faster!!'); - await page.waitToClick(selectors.createRouteView.submitButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Access Denied'); - }); - }); - - describe('as delivery', () => { - beforeAll(async() => { - await page.login('delivery'); - await page.selectModule('route'); - }); - - it('should again click on the add new route button and open the creation form', async() => { - await page.waitToClick(selectors.routeIndex.addNewRouteButton); - await page.waitForState('route.create'); - }); - - it(`should create a new route`, async() => { - await page.autocompleteSearch(selectors.createRouteView.worker, 'teamManagerNick'); - await page.pickDate(selectors.createRouteView.createdDatePicker); - await page.autocompleteSearch(selectors.createRouteView.vehicleAuto, '4444-IMK'); - await page.autocompleteSearch(selectors.createRouteView.agency, 'Teleportation device'); - await page.write(selectors.createRouteView.description, 'faster faster!!'); - await page.waitToClick(selectors.createRouteView.submitButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should confirm the redirection to the created route summary`, async() => { - await page.waitForState('route.card.summary'); - }); - - it(`should navigate back to the route index`, async() => { - await page.waitToClick(selectors.globalItems.returnToModuleIndexButton); - await page.waitForState('route.index'); - }); - - let count; - it(`should count the amount of routes before clonation`, async() => { - await page.waitForFunction(selector => { - return document.querySelectorAll(selector).length > 6; - }, {}, selectors.routeIndex.anyResult); - count = await page.countElement(selectors.routeIndex.anyResult); - - expect(count).toBeGreaterThanOrEqual(7); - }); - - it(`should clone the first route`, async() => { - await page.waitToClick(selectors.routeIndex.firstRouteCheckbox); - await page.waitToClick(selectors.routeIndex.cloneButton); - await page.waitToClick(selectors.routeIndex.submitClonationButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should reload the section and count the amount of routes after clonation`, async() => { - await page.waitForNumberOfElements(selectors.routeIndex.anyResult, count + 1); - const result = await page.countElement(selectors.routeIndex.anyResult); - - expect(result).toEqual(count + 1); - }); - }); -}); diff --git a/e2e/paths/08-route/04_tickets.spec.js b/e2e/paths/08-route/04_tickets.spec.js deleted file mode 100644 index c890162a1..000000000 --- a/e2e/paths/08-route/04_tickets.spec.js +++ /dev/null @@ -1,59 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Route tickets path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('delivery', 'route'); - await page.accessToSearchResult('2'); - await page.accessToSection('route.card.tickets'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should modify the first ticket priority', async() => { - await page.writeOnEditableTD(selectors.routeTickets.firstTicketPriority, '9'); - await page.keyboard.press('Enter'); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should confirm the buscaman button is disabled', async() => { - await page.waitForSelector(`${selectors.routeTickets.buscamanButton}.disabled`); - }); - - it('should check the first ticket checkbox and confirm the buscamanButton button is no longer disabled', async() => { - await page.waitForSelector(`${selectors.routeTickets.buscamanButton}.disabled`, {visible: false}); - }); - - it('should check the route volume on the descriptor', async() => { - const result = await page.waitToGetProperty(selectors.routeDescriptor.volume, 'innerText'); - - expect(result).toEqual('0.2 / 50 m³'); - }); - - it('should count how many tickets are in route', async() => { - const result = await page.countElement(selectors.routeTickets.anyTicket); - - expect(result).toEqual(1); - }); - - it('should delete the first ticket in route', async() => { - await page.waitToClick(selectors.routeTickets.firstTicketDeleteButton); - await page.waitToClick(selectors.routeTickets.confirmButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Ticket removed from route'); - }); - - it('should now count how many tickets are in route to find one less', async() => { - await page.waitForNumberOfElements(selectors.routeTickets.anyTicket, 0); - }); -}); diff --git a/e2e/paths/09-invoice-in/01_summary.spec.js b/e2e/paths/09-invoice-in/01_summary.spec.js deleted file mode 100644 index d5932efd0..000000000 --- a/e2e/paths/09-invoice-in/01_summary.spec.js +++ /dev/null @@ -1,28 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('InvoiceIn summary path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'invoiceIn'); - await page.accessToSearchResult('1'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the summary section', async() => { - await page.waitForState('invoiceIn.card.summary'); - }); - - it('should contain some basic data from the invoice', async() => { - const result = await page.waitToGetProperty(selectors.invoiceInSummary.supplierRef, 'innerText'); - - expect(result).toEqual('1234'); - }); -}); diff --git a/e2e/paths/09-invoice-in/02_descriptor.spec.js b/e2e/paths/09-invoice-in/02_descriptor.spec.js deleted file mode 100644 index 02bbce7ac..000000000 --- a/e2e/paths/09-invoice-in/02_descriptor.spec.js +++ /dev/null @@ -1,52 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('InvoiceIn descriptor path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'invoiceIn'); - await page.accessToSearchResult('10'); - await page.accessToSection('invoiceIn.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should clone the invoiceIn using the descriptor more menu', async() => { - await page.waitToClick(selectors.invoiceInDescriptor.moreMenu); - await page.waitToClick(selectors.invoiceInDescriptor.moreMenuCloneInvoiceIn); - await page.waitToClick(selectors.invoiceInDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('InvoiceIn cloned'); - }); - - it('should have been redirected to the created invoiceIn summary', async() => { - await page.waitForState('invoiceIn.card.summary'); - }); - - it('should delete the cloned invoiceIn using the descriptor more menu', async() => { - await page.waitToClick(selectors.invoiceInDescriptor.moreMenu); - await page.waitToClick(selectors.invoiceInDescriptor.moreMenuDeleteInvoiceIn); - await page.waitToClick(selectors.invoiceInDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('InvoiceIn deleted'); - }); - - it('should have been relocated to the invoiceOut index', async() => { - await page.waitForState('invoiceIn.index'); - }); - - it(`should search for the deleted invouceOut to find no results`, async() => { - await page.doSearch('10'); - const nResults = await page.countElement(selectors.invoiceOutIndex.searchResult); - - expect(nResults).toEqual(0); - }); -}); diff --git a/e2e/paths/09-invoice-in/03_basic_data.spec.js b/e2e/paths/09-invoice-in/03_basic_data.spec.js deleted file mode 100644 index 50fe18830..000000000 --- a/e2e/paths/09-invoice-in/03_basic_data.spec.js +++ /dev/null @@ -1,196 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('InvoiceIn basic data path', () => { - let browser; - let page; - let newDms; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'invoiceIn'); - await page.accessToSearchResult('1'); - await page.accessToSection('invoiceIn.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should edit the invoiceIn basic data`, async() => { - const now = Date.vnNew(); - await page.pickDate(selectors.invoiceInBasicData.issued, now); - await page.pickDate(selectors.invoiceInBasicData.operated, now); - await page.autocompleteSearch(selectors.invoiceInBasicData.supplier, 'Verdnatura'); - await page.clearInput(selectors.invoiceInBasicData.supplierRef); - await page.write(selectors.invoiceInBasicData.supplierRef, '9999'); - await page.clearInput(selectors.invoiceInBasicData.dms); - await page.write(selectors.invoiceInBasicData.dms, '2'); - await page.pickDate(selectors.invoiceInBasicData.bookEntried, now); - await page.pickDate(selectors.invoiceInBasicData.booked, now); - await page.autocompleteSearch(selectors.invoiceInBasicData.currency, 'USD'); - await page.autocompleteSearch(selectors.invoiceInBasicData.company, 'ORN'); - await page.waitToClick(selectors.invoiceInBasicData.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should confirm the invoiceIn supplier was edited`, async() => { - await page.reloadSection('invoiceIn.card.basicData'); - const result = await page.waitToGetProperty(selectors.invoiceInBasicData.supplier, 'value'); - - expect(result).toContain('Verdnatura'); - }); - - it(`should confirm the invoiceIn supplierRef was edited`, async() => { - const result = await page - .waitToGetProperty(selectors.invoiceInBasicData.supplierRef, 'value'); - - expect(result).toEqual('9999'); - }); - - it(`should confirm the invoiceIn currency was edited`, async() => { - const result = await page - .waitToGetProperty(selectors.invoiceInBasicData.currency, 'value'); - - expect(result).toEqual('USD'); - }); - - it(`should confirm the invoiceIn company was edited`, async() => { - const result = await page - .waitToGetProperty(selectors.invoiceInBasicData.company, 'value'); - - expect(result).toEqual('ORN'); - }); - - it(`should confirm the invoiceIn dms was edited`, async() => { - const result = await page - .waitToGetProperty(selectors.invoiceInBasicData.dms, 'value'); - - expect(result).toEqual('2'); - }); - - it(`should create a new invoiceIn dms and save the changes`, async() => { - await page.clearInput(selectors.invoiceInBasicData.dms); - await page.waitToClick(selectors.invoiceInBasicData.create); - - await page.clearInput(selectors.invoiceInBasicData.reference); - await page.write(selectors.invoiceInBasicData.reference, 'New Dms'); - - await page.waitToClick(selectors.invoiceInBasicData.confirm); - let message = await page.waitForSnackbar(); - - await page.clearInput(selectors.invoiceInBasicData.companyId); - await page.autocompleteSearch(selectors.invoiceInBasicData.companyId, 'VNL'); - - await page.waitToClick(selectors.invoiceInBasicData.confirm); - message = await page.waitForSnackbar(); - - await page.clearInput(selectors.invoiceInBasicData.warehouseId); - await page.autocompleteSearch(selectors.invoiceInBasicData.warehouseId, 'Warehouse One'); - - await page.waitToClick(selectors.invoiceInBasicData.confirm); - message = await page.waitForSnackbar(); - - await page.clearInput(selectors.invoiceInBasicData.dmsTypeId); - await page.autocompleteSearch(selectors.invoiceInBasicData.dmsTypeId, 'Ticket'); - - await page.waitToClick(selectors.invoiceInBasicData.confirm); - message = await page.waitForSnackbar(); - - await page.waitToClick(selectors.invoiceInBasicData.description); - await page.write(selectors.invoiceInBasicData.description, 'Dms without edition.'); - - await page.waitToClick(selectors.invoiceInBasicData.confirm); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('The files can\'t be empty'); - - let currentDir = process.cwd(); - let filePath = `${currentDir}/e2e/assets/thermograph.jpeg`; - - const [fileChooser] = await Promise.all([ - page.waitForFileChooser(), - page.waitToClick(selectors.invoiceInBasicData.inputFile) - ]); - await fileChooser.accept([filePath]); - - await page.waitToClick(selectors.invoiceInBasicData.confirm); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - - newDms = await page - .waitToGetProperty(selectors.invoiceInBasicData.dms, 'value'); - }); - - it(`should confirm the invoiceIn was edited with the new dms`, async() => { - await page.reloadSection('invoiceIn.card.basicData'); - const result = await page - .waitToGetProperty(selectors.invoiceInBasicData.dms, 'value'); - - expect(result).toEqual(newDms); - }); - - it(`should edit the invoiceIn`, async() => { - await page.waitToClick(selectors.invoiceInBasicData.edit); - - await page.clearInput(selectors.invoiceInBasicData.reference); - await page.write(selectors.invoiceInBasicData.reference, 'Dms Edited'); - await page.clearInput(selectors.invoiceInBasicData.companyId); - await page.autocompleteSearch(selectors.invoiceInBasicData.companyId, 'CCs'); - await page.clearInput(selectors.invoiceInBasicData.warehouseId); - await page.autocompleteSearch(selectors.invoiceInBasicData.warehouseId, 'Algemesi'); - await page.clearInput(selectors.invoiceInBasicData.dmsTypeId); - await page.autocompleteSearch(selectors.invoiceInBasicData.dmsTypeId, 'Basura'); - await page.waitToClick(selectors.invoiceInBasicData.description); - await page.write(selectors.invoiceInBasicData.description, ' Nevermind, now is edited.'); - - await page.waitToClick(selectors.invoiceInBasicData.confirm); - let message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should confirm the new dms has been edited`, async() => { - await page.reloadSection('invoiceIn.card.basicData'); - await page.waitToClick(selectors.invoiceInBasicData.edit); - - const reference = await page - .waitToGetProperty(selectors.invoiceInBasicData.reference, 'value'); - const companyId = await page - .waitToGetProperty(selectors.invoiceInBasicData.companyId, 'value'); - const warehouseId = await page - .waitToGetProperty(selectors.invoiceInBasicData.warehouseId, 'value'); - const dmsTypeId = await page - .waitToGetProperty(selectors.invoiceInBasicData.dmsTypeId, 'value'); - const description = await page - .waitToGetProperty(selectors.invoiceInBasicData.description, 'value'); - - expect(reference).toEqual('Dms Edited'); - expect(companyId).toEqual('CCs'); - expect(warehouseId).toEqual('Algemesi'); - expect(dmsTypeId).toEqual('Basura'); - expect(description).toEqual('Dms without edition. Nevermind, now is edited.'); - - await page.waitToClick(selectors.invoiceInBasicData.confirm); - }); - - it(`should disable edit and download if dms doesn't exists, and set back the original dms`, async() => { - await page.clearInput(selectors.invoiceInBasicData.dms); - await page.write(selectors.invoiceInBasicData.dms, '9999'); - - await page.waitForSelector(`${selectors.invoiceInBasicData.download}.disabled`); - await page.waitForSelector(`${selectors.invoiceInBasicData.edit}.disabled`); - - await page.clearInput(selectors.invoiceInBasicData.dms); - await page.write(selectors.invoiceInBasicData.dms, '1'); - - await page.waitToClick(selectors.invoiceInBasicData.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); -}); diff --git a/e2e/paths/09-invoice-in/04_tax.spec.js b/e2e/paths/09-invoice-in/04_tax.spec.js deleted file mode 100644 index d51c39048..000000000 --- a/e2e/paths/09-invoice-in/04_tax.spec.js +++ /dev/null @@ -1,59 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('InvoiceIn tax path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('developer', 'invoiceIn'); - await page.accessToSearchResult('2'); - await page.accessToSection('invoiceIn.card.tax'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should add a new tax and check it', async() => { - await page.waitToClick(selectors.invoiceInTax.addTaxButton); - await page.autocompleteSearch(selectors.invoiceInTax.thirdExpense, '6210000567'); - await page.write(selectors.invoiceInTax.thirdTaxableBase, '100'); - await page.autocompleteSearch(selectors.invoiceInTax.thirdTaxType, 'H.P. IVA'); - await page.autocompleteSearch(selectors.invoiceInTax.thirdTransactionType, 'Operaciones exentas'); - await page.waitToClick(selectors.invoiceInTax.saveButton); - const message = await page.waitForSnackbar(); - - await page.waitToClick(selectors.invoiceInDescriptor.summaryIcon); - await page.waitForState('invoiceIn.card.summary'); - const total = await page.waitToGetProperty(selectors.invoiceInSummary.totalTaxableBase, 'innerText'); - - await page.accessToSection('invoiceIn.card.tax'); - - const thirdExpense = await page.waitToGetProperty(selectors.invoiceInTax.thirdExpense, 'value'); - const thirdTaxableBase = await page.waitToGetProperty(selectors.invoiceInTax.thirdTaxableBase, 'value'); - const thirdTaxType = await page.waitToGetProperty(selectors.invoiceInTax.thirdTaxType, 'value'); - const thirdTransactionType = await page.waitToGetProperty(selectors.invoiceInTax.thirdTransactionType, 'value'); - const thirdRate = await page.waitToGetProperty(selectors.invoiceInTax.thirdRate, 'value'); - - expect(message.text).toContain('Data saved!'); - - expect(total).toEqual('Taxable base €1,323.16'); - - expect(thirdExpense).toEqual('6210000567'); - expect(thirdTaxableBase).toEqual('100'); - expect(thirdTaxType).toEqual('H.P. IVA 4% CEE'); - expect(thirdTransactionType).toEqual('Operaciones exentas'); - expect(thirdRate).toEqual('€4.00'); - }); - - it('should delete the added line', async() => { - await page.waitToClick(selectors.invoiceInTax.thirdDeleteButton); - await page.waitToClick(selectors.invoiceInTax.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); -}); diff --git a/e2e/paths/09-invoice-in/05_serial.spec.js b/e2e/paths/09-invoice-in/05_serial.spec.js deleted file mode 100644 index 8be5660da..000000000 --- a/e2e/paths/09-invoice-in/05_serial.spec.js +++ /dev/null @@ -1,48 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('InvoiceIn serial path', () => { - let browser; - let page; - let httpRequest; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'invoiceIn'); - await page.accessToSection('invoiceIn.serial'); - page.on('request', req => { - if (req.url().includes(`InvoiceIns/getSerial`)) - httpRequest = req.url(); - }); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should check that passes the correct params to back', async() => { - await page.overwrite(selectors.invoiceInSerial.daysAgo, '30'); - await page.keyboard.press('Enter'); - - expect(httpRequest).toContain('daysAgo=30'); - - await page.overwrite(selectors.invoiceInSerial.serial, 'R'); - await page.keyboard.press('Enter'); - - expect(httpRequest).toContain('serial=R'); - await page.click(selectors.invoiceInSerial.chip); - }); - - it('should go to index and check if the search-panel has the correct params', async() => { - await page.waitToClick(selectors.invoiceInSerial.goToIndex); - const params = await page.$$(selectors.invoiceInIndex.topbarSearchParams); - const serial = await params[0].getProperty('title'); - const isBooked = await params[1].getProperty('title'); - const from = await params[2].getProperty('title'); - - expect(await serial.jsonValue()).toContain('serial'); - expect(await isBooked.jsonValue()).toContain('not isBooked'); - expect(await from.jsonValue()).toContain('from'); - }); -}); diff --git a/e2e/paths/09-invoice-out/01_summary.spec.js b/e2e/paths/09-invoice-out/01_summary.spec.js deleted file mode 100644 index 09ac66ffc..000000000 --- a/e2e/paths/09-invoice-out/01_summary.spec.js +++ /dev/null @@ -1,44 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('InvoiceOut summary path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'invoiceOut'); - await page.accessToSearchResult('T1111111'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the summary section', async() => { - await page.waitForState('invoiceOut.card.summary'); - }); - - it('should contain the company from which the invoice is emited', async() => { - const result = await page.waitToGetProperty(selectors.invoiceOutSummary.company, 'innerText'); - - expect(result).toEqual('Company VNL'); - }); - - it('should contain the tax breakdown', async() => { - const firstTax = await page.waitToGetProperty(selectors.invoiceOutSummary.taxOne, 'innerText'); - const secondTax = await page.waitToGetProperty(selectors.invoiceOutSummary.taxTwo, 'innerText'); - - expect(firstTax).toContain('10%'); - expect(secondTax).toContain('21%'); - }); - - it('should contain the tickets info', async() => { - const firstTicket = await page.waitToGetProperty(selectors.invoiceOutSummary.ticketOne, 'innerText'); - const secondTicket = await page.waitToGetProperty(selectors.invoiceOutSummary.ticketTwo, 'innerText'); - - expect(firstTicket).toContain('Bat cave'); - expect(secondTicket).toContain('Bat cave'); - }); -}); diff --git a/e2e/paths/09-invoice-out/02_descriptor.spec.js b/e2e/paths/09-invoice-out/02_descriptor.spec.js deleted file mode 100644 index 5169345bc..000000000 --- a/e2e/paths/09-invoice-out/02_descriptor.spec.js +++ /dev/null @@ -1,137 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('InvoiceOut descriptor path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'ticket'); - }); - - afterAll(async() => { - await browser.close(); - }); - - describe('as Administrative', () => { - it('should search for tickets with an specific invoiceOut', async() => { - await page.waitToClick(selectors.ticketsIndex.openAdvancedSearchButton); - await page.clearInput(selectors.ticketsIndex.advancedSearchDaysOnward); - await page.write(selectors.ticketsIndex.advancedSearchInvoiceOut, 'T2222222'); - await page.waitToClick(selectors.ticketsIndex.advancedSearchButton); - await page.waitForState('ticket.card.summary'); - }); - - it('should navigate to the invoiceOut index', async() => { - await page.waitToClick(selectors.globalItems.applicationsMenuButton); - await page.waitForSelector(selectors.globalItems.applicationsMenuVisible); - await page.waitToClick(selectors.globalItems.invoiceOutButton); - await page.waitForSelector(selectors.invoiceOutIndex.topbarSearch); - await page.waitForState('invoiceOut.index'); - }); - - it(`should click on the search result to access to the invoiceOut summary`, async() => { - await page.accessToSearchResult('T2222222'); - await page.waitForState('invoiceOut.card.summary'); - }); - - it('should delete the invoiceOut using the descriptor more menu', async() => { - await page.waitToClick(selectors.invoiceOutDescriptor.moreMenu); - await page.waitToClick(selectors.invoiceOutDescriptor.moreMenuDeleteInvoiceOut); - await page.waitToClick(selectors.invoiceOutDescriptor.acceptDeleteButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('InvoiceOut deleted'); - }); - - it('should have been relocated to the invoiceOut index', async() => { - await page.waitForState('invoiceOut.index'); - }); - - it(`should search for the deleted invouceOut to find no results`, async() => { - await page.doSearch('T2222222'); - const nResults = await page.countElement(selectors.invoiceOutIndex.searchResult); - - expect(nResults).toEqual(0); - }); - - it('should navigate to the ticket index', async() => { - await page.waitToClick(selectors.globalItems.applicationsMenuButton); - await page.waitForSelector(selectors.globalItems.applicationsMenuVisible); - await page.waitToClick(selectors.globalItems.ticketsButton); - await page.waitForState('ticket.index'); - }); - - it('should search now for tickets with an specific invoiceOut to find no results', async() => { - await page.doSearch('T2222222'); - const nResults = await page.countElement(selectors.ticketsIndex.searchResult); - - expect(nResults).toEqual(0); - }); - - it('should now navigate to the invoiceOut index', async() => { - await page.waitToClick(selectors.globalItems.applicationsMenuButton); - await page.waitForSelector(selectors.globalItems.applicationsMenuVisible); - await page.waitToClick(selectors.globalItems.invoiceOutButton); - await page.waitForState('invoiceOut.index'); - }); - - it(`should search and access to the invoiceOut summary`, async() => { - await page.accessToSearchResult('T1111111'); - await page.waitForState('invoiceOut.card.summary'); - }); - - it(`should check the invoiceOut is booked in the summary data`, async() => { - await page.waitForTextInElement(selectors.invoiceOutSummary.bookedLabel, '/'); - const result = await page.waitToGetProperty(selectors.invoiceOutSummary.bookedLabel, 'innerText'); - - expect(result.length).toBeGreaterThan(1); - }); - - it('should re-book the invoiceOut using the descriptor more menu', async() => { - await page.waitToClick(selectors.invoiceOutDescriptor.moreMenu); - await page.waitToClick(selectors.invoiceOutDescriptor.moreMenuBookInvoiceOut); - await page.waitToClick(selectors.invoiceOutDescriptor.acceptBookingButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('InvoiceOut booked'); - }); - - it(`should check the invoiceOut booked in the summary data`, async() => { - let today = Date.vnNew(); - - let day = today.getDate(); - if (day < 10) day = `0${day}`; - - let month = (today.getMonth() + 1); - if (month < 10) month = `0${month}`; - - let expectedDate = `${day}/${month}/${today.getFullYear()}`; - - await page.waitForContentLoaded(); - const result = await page - .waitToGetProperty(selectors.invoiceOutSummary.bookedLabel, 'innerText'); - - expect(result).toEqual(expectedDate); - }); - }); - - describe('as salesPerson', () => { - it(`should log in as salesPerson then go to the target invoiceOut summary`, async() => { - await page.loginAndModule('salesPerson', 'invoiceOut'); - await page.accessToSearchResult('A1111111'); - }); - - it(`should check the salesPerson role doens't see the book option in the more menu`, async() => { - await page.waitToClick(selectors.invoiceOutDescriptor.moreMenu); - await page.waitForSelector(selectors.invoiceOutDescriptor.moreMenuShowInvoiceOutPdf); - await page.waitForSelector(selectors.invoiceOutDescriptor.moreMenuBookInvoiceOut, {hidden: true}); - }); - - it(`should check the salesPerson role doens't see the delete option in the more menu`, async() => { - await page.waitForSelector(selectors.invoiceOutDescriptor.moreMenuDeleteInvoiceOut, {hidden: true}); - }); - }); -}); diff --git a/e2e/paths/09-invoice-out/03_manualInvoice.spec.js b/e2e/paths/09-invoice-out/03_manualInvoice.spec.js deleted file mode 100644 index a1856f1b1..000000000 --- a/e2e/paths/09-invoice-out/03_manualInvoice.spec.js +++ /dev/null @@ -1,53 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('InvoiceOut manual invoice path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'invoiceOut'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should create an invoice from a ticket', async() => { - await page.waitToClick(selectors.invoiceOutIndex.createInvoice); - await page.waitForSelector(selectors.invoiceOutIndex.manualInvoiceForm); - - await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTicket, '15'); - await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceSerial, 'Global nacional'); - await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTaxArea, 'national'); - await page.waitToClick(selectors.invoiceOutIndex.saveInvoice); - const message = await page.waitForSnackbar(); - - await page.waitForState('invoiceOut.card.summary'); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should create another invoice from a client`, async() => { - await page.waitToClick(selectors.globalItems.applicationsMenuButton); - await page.waitForSelector(selectors.globalItems.applicationsMenuVisible); - await page.waitToClick(selectors.globalItems.invoiceOutButton); - await page.waitForSelector(selectors.invoiceOutIndex.topbarSearch); - await page.waitForState('invoiceOut.index'); - - await page.waitToClick(selectors.invoiceOutIndex.createInvoice); - await page.waitForSelector(selectors.invoiceOutIndex.manualInvoiceForm); - - await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceClient, 'Petter Parker'); - await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceSerial, 'Global nacional'); - await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTaxArea, 'national'); - await page.waitToClick(selectors.invoiceOutIndex.saveInvoice); - const message = await page.waitForSnackbar(); - - await page.waitForState('invoiceOut.card.summary'); - - expect(message.text).toContain('Data saved!'); - }); -}); diff --git a/e2e/paths/09-invoice-out/04_globalInvoice.spec.js b/e2e/paths/09-invoice-out/04_globalInvoice.spec.js deleted file mode 100644 index 64cddfa25..000000000 --- a/e2e/paths/09-invoice-out/04_globalInvoice.spec.js +++ /dev/null @@ -1,39 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('InvoiceOut global invoice path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'invoiceOut'); - await page.waitToClick('[icon="search"]'); - await page.waitForTimeout(1000); // index search needs time to return results - }); - - afterAll(async() => { - await browser.close(); - }); - - let invoicesBeforeOneClient; - let now = Date.vnNew(); - - it('should count the amount of invoices listed before globla invoces are made', async() => { - invoicesBeforeOneClient = await page.countElement(selectors.invoiceOutIndex.searchResult); - - expect(invoicesBeforeOneClient).toBeGreaterThanOrEqual(4); - }); - - it('should create a global invoice for charles xavier today', async() => { - await page.accessToSection('invoiceOut.global-invoicing'); - await page.waitToClick(selectors.invoiceOutGlobalInvoicing.oneClient); - await page.autocompleteSearch(selectors.invoiceOutGlobalInvoicing.clientId, 'Charles Xavier'); - await page.pickDate(selectors.invoiceOutGlobalInvoicing.invoiceDate, now); - await page.pickDate(selectors.invoiceOutGlobalInvoicing.maxShipped, now); - await page.autocompleteSearch(selectors.invoiceOutGlobalInvoicing.printer, '1'); - await page.waitToClick(selectors.invoiceOutGlobalInvoicing.makeInvoice); - await page.waitForTimeout(1000); - }); -}); diff --git a/e2e/paths/09-invoice-out/05_negative_bases.spec.js b/e2e/paths/09-invoice-out/05_negative_bases.spec.js deleted file mode 100644 index 43ced2115..000000000 --- a/e2e/paths/09-invoice-out/05_negative_bases.spec.js +++ /dev/null @@ -1,29 +0,0 @@ -import getBrowser from '../../helpers/puppeteer'; - -describe('InvoiceOut negative bases path', () => { - let browser; - let page; - const httpRequests = []; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - page.on('request', req => { - if (req.url().includes(`InvoiceOuts/negativeBases`)) - httpRequests.push(req.url()); - }); - await page.loginAndModule('administrative', 'invoiceOut'); - await page.accessToSection('invoiceOut.negative-bases'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should show negative bases in a date range', async() => { - const request = httpRequests.find(req => - req.includes(`from`) && req.includes(`to`)); - - expect(request).toBeDefined(); - }); -}); diff --git a/e2e/paths/10-travel/01_create.spec.js b/e2e/paths/10-travel/01_create.spec.js deleted file mode 100644 index 98ade4852..000000000 --- a/e2e/paths/10-travel/01_create.spec.js +++ /dev/null @@ -1,42 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Travel create path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'travel'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should create a new travel and check it was created with the correct data', async() => { - const date = Date.vnNew(); - date.setDate(15); - date.setUTCHours(0, 0, 0, 0); - - await page.waitToClick(selectors.travelIndex.newTravelButton); - await page.waitForState('travel.create'); - - const values = { - reference: 'Testing reference', - agencyMode: 'inhouse pickup', - shipped: date, - landed: date, - warehouseOut: 'Warehouse One', - warehouseIn: 'Warehouse Five' - }; - - const message = await page.sendForm('vn-travel-create form', values); - await page.waitForState('travel.card.basicData'); - const formValues = await page.fetchForm('vn-travel-basic-data form', Object.keys(values)); - - expect(message.isSuccess).toBeTrue(); - expect(formValues).toEqual(values); - }); -}); diff --git a/e2e/paths/10-travel/02_basic_data_and_log.spec.js b/e2e/paths/10-travel/02_basic_data_and_log.spec.js deleted file mode 100644 index 701e6b1b4..000000000 --- a/e2e/paths/10-travel/02_basic_data_and_log.spec.js +++ /dev/null @@ -1,97 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Travel basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'travel'); - await page.write(selectors.travelIndex.generalSearchFilter, '3'); - await page.keyboard.press('Enter'); - await page.accessToSection('travel.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the thermograph section', async() => { - await page.waitForState('travel.card.basicData'); - }); - - it('should set a wrong delivery date then receive an error on submit', async() => { - await page.loginAndModule('buyer', 'travel'); - await page.write(selectors.travelIndex.generalSearchFilter, '4'); - await page.keyboard.press('Enter'); - await page.accessToSection('travel.card.basicData'); - await page.waitForState('travel.card.basicData'); - - const lastMonth = Date.vnNew(); - lastMonth.setMonth(lastMonth.getMonth() - 2); - - await page.pickDate(selectors.travelBasicData.deliveryDate, lastMonth); - await page.waitToClick(selectors.travelBasicData.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Landing cannot be lesser than shipment'); - }); - - it('should undo the changes', async() => { - await page.clearInput(selectors.travelBasicData.reference); - await page.write(selectors.travelBasicData.reference, 'totally pointless ref'); - await page.waitToClick(selectors.travelBasicData.undoChanges); - const result = await page.waitToGetProperty(selectors.travelBasicData.reference, 'value'); - - expect(result).toEqual('fourth travel'); - }); - - it('should now edit the whole form then save', async() => { - await page.clearInput(selectors.travelBasicData.reference); - await page.write(selectors.travelBasicData.reference, 'new reference!'); - await page.autocompleteSearch(selectors.travelBasicData.agency, 'Entanglement'); - await page.autocompleteSearch(selectors.travelBasicData.outputWarehouse, 'Warehouse Three'); - await page.autocompleteSearch(selectors.travelBasicData.inputWarehouse, 'Warehouse Four'); - await page.waitToClick(selectors.travelBasicData.delivered); - await page.waitToClick(selectors.travelBasicData.received); - await page.waitToClick(selectors.travelBasicData.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reload the section and check the reference was saved', async() => { - await page.reloadSection('travel.card.basicData'); - const result = await page.waitToGetProperty(selectors.travelBasicData.reference, 'value'); - - expect(result).toEqual('new reference!'); - }); - - it('should check the agency was saved', async() => { - const result = await page.waitToGetProperty(selectors.travelBasicData.agency, 'value'); - - expect(result).toEqual('Entanglement'); - }); - - it('should check the output warehouse date was saved', async() => { - const result = await page.waitToGetProperty(selectors.travelBasicData.outputWarehouse, 'value'); - - expect(result).toEqual('Warehouse Three'); - }); - - it('should check the input warehouse date was saved', async() => { - const result = await page.waitToGetProperty(selectors.travelBasicData.inputWarehouse, 'value'); - - expect(result).toEqual('Warehouse Four'); - }); - - it(`should check the delivered checkbox was saved even tho it doesn't make sense`, async() => { - await page.waitForClassPresent(selectors.travelBasicData.delivered, 'checked'); - }); - - it(`should check the received checkbox was saved even tho it doesn't make sense`, async() => { - await page.waitForClassPresent(selectors.travelBasicData.received, 'checked'); - }); -}); diff --git a/e2e/paths/10-travel/03_descriptor.spec.js b/e2e/paths/10-travel/03_descriptor.spec.js deleted file mode 100644 index 4723cc4a3..000000000 --- a/e2e/paths/10-travel/03_descriptor.spec.js +++ /dev/null @@ -1,138 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Travel descriptor path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'travel'); - await page.write(selectors.travelIndex.generalSearchFilter, '3'); - await page.keyboard.press('Enter'); - await page.waitForState('travel.card.summary'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should click the descriptor button to navigate to the travel index showing all travels with current agency', async() => { - await page.waitToClick(selectors.travelDescriptor.filterByAgencyButton); - await page.waitForState('travel.index'); - const result = await page.countElement(selectors.travelIndex.anySearchResult); - - expect(result).toBeGreaterThanOrEqual(1); - }); - - it('should navigate to the first search result', async() => { - await page.waitToClick(selectors.travelIndex.firstSearchResult); - await page.waitForState('travel.card.summary'); - const state = await page.getState(); - - expect(state).toBe('travel.card.summary'); - }); - - it('should be redirected to the create entry view', async() => { - await page.waitToClick(selectors.travelDescriptor.dotMenu); - await page.waitToClick(selectors.travelDescriptor.dotMenuAddEntry); - await page.waitForState('entry.create'); - const state = await page.getState(); - - expect(state).toBe('entry.create'); - }); - - it('should check some data was imported from the travel', async() => { - const travel = await page.waitToGetProperty(selectors.entryCreate.travel, 'value'); - const campany = await page.waitToGetProperty(selectors.entryCreate.company, 'value'); - - expect(travel).toContain('Warehouse'); - expect(campany).toContain('VNL'); - }); - - it('should navigate back to the travel index', async() => { - await page.waitToClick('.cancel'); - await page.waitToClick(selectors.globalItems.homeButton); - await page.selectModule('travel'); - await page.waitForState('travel.index'); - const state = await page.getState(); - - expect(state).toBe('travel.index'); - }); - - it('should click on the add entry button of the third result to be redirected to create entry', async() => { - await page.keyboard.press('Enter'); - await page.waitToClick(selectors.travelIndex.firstTravelAddEntryButton); - await page.waitForState('entry.create'); - const state = await page.getState(); - - expect(state).toBe('entry.create'); - }); - - it('should check again some data was imported from the travel', async() => { - const travel = await page.waitToGetProperty(selectors.entryCreate.travel, 'value'); - const campany = await page.waitToGetProperty(selectors.entryCreate.company, 'value'); - - expect(travel).toContain('Warehouse'); - expect(campany).toContain('VNL'); - }); - - it('should navigate to the travel summary of a given travel', async() => { - await page.waitToClick('.cancel'); - await page.waitToClick(selectors.globalItems.homeButton); - await page.selectModule('travel'); - await page.write(selectors.travelIndex.generalSearchFilter, '3'); - await page.keyboard.press('Enter'); - await page.waitForState('travel.card.summary'); - const state = await page.getState(); - - expect(state).toBe('travel.card.summary'); - }); - - it('should be redirected to the create travel when using the clone option of the dot menu', async() => { - await page.waitToClick(selectors.travelDescriptor.dotMenu); - await page.waitToClick(selectors.travelDescriptor.dotMenuClone); - await page.respondToDialog('accept'); - await page.waitForState('travel.create'); - const state = await page.getState(); - - expect(state).toBe('travel.create'); - }); - - it('should edit the data to clone and then get redirected to the cloned travel basic data', async() => { - await page.clearInput(selectors.travelCreate.reference); - await page.write(selectors.travelCreate.reference, 'reference'); - await page.autocompleteSearch(selectors.travelCreate.agency, 'entanglement'); - await page.pickDate(selectors.travelCreate.shipped); - await page.pickDate(selectors.travelCreate.landed); - await page.autocompleteSearch(selectors.travelCreate.warehouseOut, 'warehouse one'); - await page.autocompleteSearch(selectors.travelCreate.warehouseIn, 'warehouse two'); - await page.waitToClick(selectors.travelCreate.saveButton); - await page.waitForState('travel.card.basicData'); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should update the landed date to a future date to enable cloneWithEntries', async() => { - const nextMonth = Date.vnNew(); - nextMonth.setMonth(nextMonth.getMonth() + 1); - await page.pickDate(selectors.travelBasicData.deliveryDate, nextMonth); - await page.waitToClick(selectors.travelBasicData.save); - await page.waitForState('travel.card.basicData'); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should navigate to the summary and then clone the travel and its entries using the descriptor menu to get redirected to the cloned travel basic data', async() => { - await page.waitToClick('vn-icon[icon="launch"]'); - await page.waitForState('travel.card.summary'); - await page.waitForTimeout(1000); - await page.waitToClick(selectors.travelDescriptor.dotMenu); - await page.waitToClick(selectors.travelDescriptor.dotMenuCloneWithEntries); - await page.waitToClick(selectors.travelDescriptor.acceptClonation); - await page.waitForState('travel.card.basicData'); - }); -}); diff --git a/e2e/paths/10-travel/04_extra_community.spec.js b/e2e/paths/10-travel/04_extra_community.spec.js deleted file mode 100644 index c5975c958..000000000 --- a/e2e/paths/10-travel/04_extra_community.spec.js +++ /dev/null @@ -1,42 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Travel extra community path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'travel'); - await page.accessToSection('travel.extraCommunity'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should edit the travel reference and the locked kilograms', async() => { - await page.waitToClick(selectors.travelExtraCommunity.removeContinentFilter); - await page.waitForSpinnerLoad(); - await page.writeOnEditableTD(selectors.travelExtraCommunity.firstTravelReference, 'edited reference'); - await page.waitForSpinnerLoad(); - await page.writeOnEditableTD(selectors.travelExtraCommunity.firstTravelLockedKg, '1500'); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reload the index and confirm the reference and locked kg were edited', async() => { - await page.accessToSection('travel.index'); - await page.accessToSection('travel.extraCommunity'); - await page.waitToClick(selectors.travelExtraCommunity.removeContinentFilter); - await page.waitForTextInElement(selectors.travelExtraCommunity.firstTravelReference, 'edited reference'); - const reference = await page.getProperty(selectors.travelExtraCommunity.firstTravelReference, 'innerText'); - const lockedKg = await page.getProperty(selectors.travelExtraCommunity.firstTravelLockedKg, 'innerText'); - - expect(reference).toContain('edited reference'); - expect(lockedKg).toContain(1500); - }); -}); diff --git a/e2e/paths/10-travel/05_thermograph.spec.js b/e2e/paths/10-travel/05_thermograph.spec.js deleted file mode 100644 index c9709f2f5..000000000 --- a/e2e/paths/10-travel/05_thermograph.spec.js +++ /dev/null @@ -1,64 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Travel thermograph path', () => { - const thermographName = '7H3-37H3RN4L-FL4M3'; - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'travel'); - await page.write(selectors.travelIndex.generalSearchFilter, '3'); - await page.keyboard.press('Enter'); - await page.accessToSection('travel.card.thermograph.index'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the thermograph section', async() => { - await page.waitForState('travel.card.thermograph.index'); - }); - - it('should click the add thermograph floating button', async() => { - await page.waitToClick(selectors.travelThermograph.add); - await page.waitForState('travel.card.thermograph.create'); - }); - - it('should click on the add thermograph icon of the thermograph autocomplete', async() => { - await page.waitToClick(selectors.travelThermograph.addThermographIcon); - await page.write(selectors.travelThermograph.newThermographId, thermographName); - await page.autocompleteSearch(selectors.travelThermograph.newThermographModel, 'TEMPMATE'); - await page.autocompleteSearch(selectors.travelThermograph.newThermographWarehouse, 'Warehouse Two'); - await page.autocompleteSearch(selectors.travelThermograph.newThermographTemperature, 'Warm'); - await page.waitToClick(selectors.travelThermograph.createThermographButton); - }); - - it('should select the file to upload', async() => { - let currentDir = process.cwd(); - let filePath = `${currentDir}/e2e/assets/thermograph.jpeg`; - - const [fileChooser] = await Promise.all([ - page.waitForFileChooser(), - page.waitToClick(selectors.travelThermograph.uploadIcon) - ]); - await fileChooser.accept([filePath]); - - await page.waitToClick(selectors.travelThermograph.upload); - - const message = await page.waitForSnackbar(); - const state = await page.getState(); - - expect(message.text).toContain('Data saved!'); - expect(state).toBe('travel.card.thermograph.index'); - }); - - it('should check everything was saved correctly', async() => { - const result = await page.waitToGetProperty(selectors.travelThermograph.createdThermograph, 'innerText'); - - expect(result).toContain(thermographName); - }); -}); diff --git a/e2e/paths/10-travel/06_search_panel.spec.js b/e2e/paths/10-travel/06_search_panel.spec.js deleted file mode 100644 index 420ceaf48..000000000 --- a/e2e/paths/10-travel/06_search_panel.spec.js +++ /dev/null @@ -1,62 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Travel search panel path', () => { - let browser; - let page; - let httpRequest; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'travel'); - page.on('request', req => { - if (req.url().includes(`Travels/filter`)) - httpRequest = req.url(); - }); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should filter using all the fields', async() => { - await page.click(selectors.travelIndex.chip); - await page.write(selectors.travelIndex.generalSearchFilter, 'travel'); - await page.keyboard.press('Enter'); - - expect(httpRequest).toContain('search=travel'); - - await page.click(selectors.travelIndex.chip); - await page.autocompleteSearch(selectors.travelIndex.agencyFilter, 'Entanglement'); - - expect(httpRequest).toContain('agencyModeFk'); - - await page.click(selectors.travelIndex.chip); - await page.autocompleteSearch(selectors.travelIndex.warehouseOutFilter, 'Warehouse One'); - - expect(httpRequest).toContain('warehouseOutFk'); - - await page.click(selectors.travelIndex.chip); - await page.autocompleteSearch(selectors.travelIndex.warehouseInFilter, 'Warehouse Two'); - - expect(httpRequest).toContain('warehouseInFk'); - - await page.click(selectors.travelIndex.chip); - await page.overwrite(selectors.travelIndex.scopeDaysFilter, '15'); - await page.keyboard.press('Enter'); - - expect(httpRequest).toContain('scopeDays=15'); - - await page.click(selectors.travelIndex.chip); - await page.autocompleteSearch(selectors.travelIndex.continentFilter, 'Asia'); - - expect(httpRequest).toContain('continent'); - - await page.click(selectors.travelIndex.chip); - await page.write(selectors.travelIndex.totalEntriesFilter, '1'); - await page.keyboard.press('Enter'); - - expect(httpRequest).toContain('totalEntries=1'); - }); -}); diff --git a/e2e/paths/11-zone/01_basic-data.spec.js b/e2e/paths/11-zone/01_basic-data.spec.js deleted file mode 100644 index 34d08c57f..000000000 --- a/e2e/paths/11-zone/01_basic-data.spec.js +++ /dev/null @@ -1,104 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Zone basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - - await page.loginAndModule('deliveryAssistant', - 'zone'); // turns up the zone module name and route aint the same lol - await page.accessToSearchResult('10'); - await page.accessToSection('zone.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the basic data section', async() => { - await page.waitForState('zone.card.basicData'); - }); - - it('should edit de form and then save', async() => { - await page.clearInput(selectors.zoneBasicData.name); - await page.write(selectors.zoneBasicData.name, 'Brimstone teleportation'); - await page.autocompleteSearch(selectors.zoneBasicData.agency, 'Quantum break device'); - await page.clearInput(selectors.zoneBasicData.maxVolume); - await page.write(selectors.zoneBasicData.maxVolume, '10'); - await page.clearInput(selectors.zoneBasicData.travelingDays); - await page.write(selectors.zoneBasicData.travelingDays, '1'); - await page.clearInput(selectors.zoneBasicData.closing); - await page.pickTime(selectors.zoneBasicData.closing, '21:00'); - await page.clearInput(selectors.zoneBasicData.price); - await page.write(selectors.zoneBasicData.price, '999'); - await page.clearInput(selectors.zoneBasicData.bonus); - await page.write(selectors.zoneBasicData.bonus, '100'); - await page.clearInput(selectors.zoneBasicData.inflation); - await page.write(selectors.zoneBasicData.inflation, '200'); - await page.waitToClick(selectors.zoneBasicData.volumetric); - await page.waitToClick(selectors.zoneBasicData.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should now reload the section', async() => { - await page.reloadSection('zone.card.basicData'); - }); - - it('should confirm the name was updated', async() => { - const result = await page.waitToGetProperty(selectors.zoneBasicData.name, 'value'); - - expect(result).toEqual('Brimstone teleportation'); - }); - - it('should confirm the agency was updated', async() => { - const result = await page.waitToGetProperty(selectors.zoneBasicData.agency, 'value'); - - expect(result).toEqual('Quantum break device'); - }); - - it('should confirm the max volume was updated', async() => { - const result = await page.waitToGetProperty(selectors.zoneBasicData.maxVolume, 'value'); - - expect(result).toEqual('10'); - }); - - it('should confirm the traveling days were updated', async() => { - const result = await page.waitToGetProperty(selectors.zoneBasicData.travelingDays, 'value'); - - expect(result).toEqual('1'); - }); - - it('should confirm the closing hour was updated', async() => { - const result = await page.waitToGetProperty(selectors.zoneBasicData.closing, 'value'); - - expect(result).toEqual('21:00'); - }); - - it('should confirm the price was updated', async() => { - const result = await page.waitToGetProperty(selectors.zoneBasicData.price, 'value'); - - expect(result).toEqual('999'); - }); - - it('should confirm the bonus was updated', async() => { - const result = await page.waitToGetProperty(selectors.zoneBasicData.bonus, 'value'); - - expect(result).toEqual('100'); - }); - - it('should confirm the inflation was updated', async() => { - const result = await page.waitToGetProperty(selectors.zoneBasicData.inflation, 'value'); - - expect(result).toEqual('200'); - }); - - it('should confirm the volumetric checkbox was checked', async() => { - await page.waitForClassPresent(selectors.zoneBasicData.volumetric, 'checked'); - }); -}); diff --git a/e2e/paths/11-zone/02_descriptor.spec.js b/e2e/paths/11-zone/02_descriptor.spec.js deleted file mode 100644 index baccc910f..000000000 --- a/e2e/paths/11-zone/02_descriptor.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Zone descriptor path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('deliveryAssistant', 'zone'); - await page.accessToSearchResult('13'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should eliminate the zone using the descriptor option', async() => { - await page.waitToClick(selectors.zoneDescriptor.menu); - await page.waitToClick(selectors.zoneDescriptor.deleteZone); - await page.respondToDialog('accept'); - await page.waitForState('zone.index'); - }); - - it('should search for the deleted zone to find no results', async() => { - await page.doSearch('13'); - const count = await page.countElement(selectors.zoneIndex.searchResult); - - expect(count).toEqual(0); - }); -}); diff --git a/e2e/paths/12-entry/01_summary.spec.js b/e2e/paths/12-entry/01_summary.spec.js deleted file mode 100644 index b846bc4c8..000000000 --- a/e2e/paths/12-entry/01_summary.spec.js +++ /dev/null @@ -1,47 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Entry summary path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'entry'); - await page.accessToSearchResult('4'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the second entry summary section', async() => { - await page.waitForState('entry.card.summary'); - }); - - it(`should display details from the entry on the header`, async() => { - await page.waitForTextInElement(selectors.entrySummary.header, 'The farmer'); - const result = await page.waitToGetProperty(selectors.entrySummary.header, 'innerText'); - - expect(result).toContain('The farmer'); - }); - - it('should display some entry details like the reference', async() => { - const result = await page.waitToGetProperty(selectors.entrySummary.reference, 'innerText'); - - expect(result).toContain('Movement 4'); - }); - - it('should display other entry details like the confirmed', async() => { - const result = await page.checkboxState(selectors.entrySummary.confirmed, 'innerText'); - - expect(result).toContain('unchecked'); - }); - - it('should display all buys for the entry', async() => { - const result = await page.countElement(selectors.entrySummary.anyBuyLine); - - expect(result).toEqual(4); - }); -}); diff --git a/e2e/paths/12-entry/02_descriptor.spec.js b/e2e/paths/12-entry/02_descriptor.spec.js deleted file mode 100644 index 997a6065c..000000000 --- a/e2e/paths/12-entry/02_descriptor.spec.js +++ /dev/null @@ -1,49 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Entry descriptor path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'entry'); - await page.accessToSearchResult('2'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the second entry summary section', async() => { - await page.waitForState('entry.card.summary'); - }); - - it('should show some entry information', async() => { - const result = await page.waitToGetProperty(selectors.entryDescriptor.agency, 'innerText'); - - expect(result).toContain('inhouse pickup'); - }); - - it('should click the travels button to be redirected to the travels index filtered by the current agency', async() => { - await page.waitToClick(selectors.entryDescriptor.travelsQuicklink); - await page.expectURL('/travel/index'); - await page.expectURL('agencyModeFk'); - }); - - it('should go back to the entry summary', async() => { - await page.waitToClick(selectors.globalItems.homeButton); - await page.selectModule('entry'); - await page.accessToSearchResult('2'); - await page.waitForState('entry.card.summary'); - }); - - it('should click the entries button to be redirected to the entries index filtered by the current supplier', async() => { - await page.waitToClick(selectors.entryDescriptor.entriesQuicklink); - await page.expectURL('/entry/index'); - await page.expectURL('supplierFk'); - await page.expectURL('to'); - await page.expectURL('from'); - }); -}); diff --git a/e2e/paths/12-entry/03_latestBuys.spec.js b/e2e/paths/12-entry/03_latestBuys.spec.js deleted file mode 100644 index 9ec072912..000000000 --- a/e2e/paths/12-entry/03_latestBuys.spec.js +++ /dev/null @@ -1,116 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Entry lastest buys path', () => { - let browser; - let page; - const httpRequests = []; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - page.on('request', req => { - if (req.url().includes(`Buys/latestBuysFilter`)) - httpRequests.push(req.url()); - }); - await page.loginAndModule('buyer', 'entry'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should access the latest buys seccion and search not seeing the edit buys button yet', async() => { - await page.waitToClick(selectors.entryLatestBuys.latestBuysSectionButton); - await page.waitForSelector(selectors.entryLatestBuys.editBuysButton, {visible: false}); - }); - - it('should filter by name', async() => { - await page.write(selectors.entryLatestBuys.generalSearchInput, 'Melee'); - await page.keyboard.press('Enter'); - await page.waitToClick(selectors.entryLatestBuys.chip); - - expect(httpRequests.find(req => req.includes(('search=Melee')))).toBeDefined(); - }); - - it('should filter by reign and type', async() => { - await page.click(selectors.entryLatestBuys.firstReignIcon); - await page.autocompleteSearch(selectors.entryLatestBuys.typeInput, 'Alstroemeria'); - await page.click(selectors.entryLatestBuys.chip); - - expect(httpRequests.find(req => req.includes(('categoryFk')))).toBeDefined(); - expect(httpRequests.find(req => req.includes(('typeFk')))).toBeDefined(); - }); - - it('should filter by sales person', async() => { - await page.autocompleteSearch(selectors.entryLatestBuys.salesPersonInput, 'buyerNick'); - await page.waitToClick(selectors.entryLatestBuys.chip); - - expect(httpRequests.find(req => req.includes(('salesPersonFk')))).toBeDefined(); - }); - - it('should filter by supplier', async() => { - await page.autocompleteSearch(selectors.entryLatestBuys.supplierInput, 'Farmer King'); - await page.waitToClick(selectors.entryLatestBuys.chip); - - expect(httpRequests.find(req => req.includes(('supplierFk')))).toBeDefined(); - }); - - it('should filter by active', async() => { - await page.waitToClick(selectors.entryLatestBuys.activeCheck); - await page.waitToClick(selectors.entryLatestBuys.activeCheck); - await page.waitToClick(selectors.entryLatestBuys.chip); - - expect(httpRequests.find(req => req.includes(('active=true')))).toBeDefined(); - expect(httpRequests.find(req => req.includes(('active=false')))).toBeDefined(); - }); - - it('should filter by visible', async() => { - await page.waitToClick(selectors.entryLatestBuys.visibleCheck); - await page.waitToClick(selectors.entryLatestBuys.visibleCheck); - await page.waitToClick(selectors.entryLatestBuys.chip); - - expect(httpRequests.find(req => req.includes(('visible=true')))).toBeDefined(); - expect(httpRequests.find(req => req.includes(('visible=false')))).toBeDefined(); - }); - - it('should filter by floramondo', async() => { - await page.waitToClick(selectors.entryLatestBuys.floramondoCheck); - await page.waitToClick(selectors.entryLatestBuys.floramondoCheck); - await page.waitToClick(selectors.entryLatestBuys.chip); - - expect(httpRequests.find(req => req.includes(('floramondo=true')))).toBeDefined(); - expect(httpRequests.find(req => req.includes(('floramondo=false')))).toBeDefined(); - }); - - it('should filter by tag Color', async() => { - await page.waitToClick(selectors.entryLatestBuys.addTagButton); - await page.autocompleteSearch(selectors.entryLatestBuys.itemTagInput, 'Color'); - await page.autocompleteSearch(selectors.entryLatestBuys.itemTagValueInput, 'Brown'); - await page.waitToClick(selectors.entryLatestBuys.chip); - - expect(httpRequests.find(req => req.includes(('tags')))).toBeDefined(); - }); - - it('should select all lines but one and then check the edit buys button appears', async() => { - await page.waitToClick(selectors.entryLatestBuys.allBuysCheckBox); - await page.waitToClick(selectors.entryLatestBuys.secondBuyCheckBox); - await page.waitForSelector(selectors.entryLatestBuys.editBuysButton, {visible: true}); - }); - - it('should open the edit dialog', async() => { - await page.waitToClick(selectors.entryLatestBuys.editBuysButton); - await page.waitForSelector(selectors.entryLatestBuys.fieldAutocomplete, {visible: true}); - }); - - it('should search for the "Description" and type a new one for the items in each selected buy', async() => { - await page.autocompleteSearch(selectors.entryLatestBuys.fieldAutocomplete, 'Description'); - await page.write(selectors.entryLatestBuys.newValueInput, 'Crafted item'); - await page.waitToClick(selectors.entryLatestBuys.acceptEditBuysDialog); - }); - - it('should navigate to the entry.buy section by clicking one of the buys', async() => { - await page.waitToClick(selectors.entryLatestBuys.firstBuy); - await page.waitForState('entry.card.buy.index'); - }); -}); diff --git a/e2e/paths/12-entry/04_create.spec.js b/e2e/paths/12-entry/04_create.spec.js deleted file mode 100644 index 537637671..000000000 --- a/e2e/paths/12-entry/04_create.spec.js +++ /dev/null @@ -1,34 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Entry create path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'entry'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should click the create entry button to open the form', async() => { - await page.waitToClick(selectors.entryIndex.createEntryButton); - await page.waitForState('entry.create'); - }); - - it('should fill the form to create a valid entry then redirect to basic Data', async() => { - await page.autocompleteSearch(selectors.entryIndex.newEntrySupplier, 'The farmer'); - await page.autocompleteSearch(selectors.entryIndex.newEntryTravel, 'Warehouse'); - await page.autocompleteSearch(selectors.entryIndex.newEntryCompany, 'ORN'); - - await page.waitToClick(selectors.entryIndex.saveNewEntry); - await page.waitForNavigation({ - waitUntil: 'load', - }); - await page.waitForState('entry.card.basicData'); - }); -}); diff --git a/e2e/paths/12-entry/05_basicData.spec.js b/e2e/paths/12-entry/05_basicData.spec.js deleted file mode 100644 index f1f14f8da..000000000 --- a/e2e/paths/12-entry/05_basicData.spec.js +++ /dev/null @@ -1,81 +0,0 @@ -import getBrowser from '../../helpers/puppeteer'; - -const $ = { - reference: 'vn-entry-basic-data vn-textfield[ng-model="$ctrl.entry.reference"]', - invoiceNumber: 'vn-entry-basic-data vn-textfield[ng-model="$ctrl.entry.invoiceNumber"]', - notes: 'vn-entry-basic-data vn-textfield[ng-model="$ctrl.entry.notes"]', - observations: 'vn-entry-basic-data vn-textarea[ng-model="$ctrl.entry.observation"]', - supplier: 'vn-entry-basic-data vn-autocomplete[ng-model="$ctrl.entry.supplierFk"]', - currency: 'vn-entry-basic-data vn-autocomplete[ng-model="$ctrl.entry.currencyFk"]', - commission: 'vn-entry-basic-data vn-input-number[ng-model="$ctrl.entry.commission"]', - company: 'vn-entry-basic-data vn-autocomplete[ng-model="$ctrl.entry.companyFk"]', - ordered: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isOrdered"]', - confirmed: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isConfirmed"]', - inventory: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isExcludedFromAvailable"]', - raid: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isRaid"]', - booked: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isBooked"]', - save: 'vn-entry-basic-data button[type=submit]', -}; - -describe('Entry basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'entry'); - await page.accessToSearchResult('2'); - await page.accessToSection('entry.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should edit the basic data and confirm the reference was edited', async() => { - await page.write($.reference, 'new movement 8'); - await page.write($.invoiceNumber, 'new movement 8'); - await page.write($.observations, ' edited'); - await page.autocompleteSearch($.supplier, 'Plants nick'); - await page.autocompleteSearch($.currency, 'eur'); - await page.clearInput($.commission); - await page.write($.commission, '100'); - await page.autocompleteSearch($.company, 'CCs'); - await page.waitToClick($.ordered); - await page.waitToClick($.confirmed); - await page.waitToClick($.inventory); - await page.waitToClick($.raid); - await page.waitToClick($.booked); - await page.waitToClick($.save); - const message = await page.waitForSnackbar(); - - await page.reloadSection('entry.card.basicData'); - const reference = await page.waitToGetProperty($.reference, 'value'); - const supplier = await page.waitToGetProperty($.supplier, 'value'); - const invoiceNumber = await page.waitToGetProperty($.invoiceNumber, 'value'); - const observations = await page.waitToGetProperty($.observations, 'value'); - const currency = await page.waitToGetProperty($.currency, 'value'); - const commission = await page.waitToGetProperty($.commission, 'value'); - const company = await page.waitToGetProperty($.company, 'value'); - const ordered = await page.checkboxState($.ordered); - const confirmed = await page.checkboxState($.confirmed); - const inventory = await page.checkboxState($.inventory); - const raid = await page.checkboxState($.raid); - const booked = await page.checkboxState($.booked); - - expect(message.text).toContain('Data saved!'); - expect(reference).toEqual('new movement 8'); - expect(supplier).toEqual('Plants nick'); - expect(invoiceNumber).toEqual('new movement 8'); - expect(observations).toEqual('observation two edited'); - expect(currency).toEqual('EUR'); - expect(commission).toEqual('100'); - expect(company).toEqual('CCs'); - expect(ordered).toBe('checked'); - expect(confirmed).toBe('checked'); - expect(inventory).toBe('checked'); - expect(raid).toBe('checked'); - expect(booked).toBe('unchecked'); - }); -}); diff --git a/e2e/paths/12-entry/06_observations.spec.js b/e2e/paths/12-entry/06_observations.spec.js deleted file mode 100644 index dcad44fb0..000000000 --- a/e2e/paths/12-entry/06_observations.spec.js +++ /dev/null @@ -1,65 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Entry observations path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'entry'); - await page.accessToSearchResult('2'); - await page.accessToSection('entry.card.observation'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should add two new observations of the same type then fail to save as they can't be repeated`, async() => { - await page.waitToClick(selectors.entryObservations.addNewObservation); - await page.waitToClick(selectors.entryObservations.addNewObservation); - await page.autocompleteSearch(selectors.entryObservations.firstObservationType, 'SalesPerson'); - await page.autocompleteSearch(selectors.entryObservations.secondObservationType, 'SalesPerson'); - await page.write(selectors.entryObservations.firstObservationDescription, 'first observation'); - await page.write(selectors.entryObservations.secondObservationDescription, 'second observation'); - await page.waitToClick(selectors.entryObservations.saveObservationsButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`The observation type can't be repeated`); - }); - - it('should set the 2nd observation of a different one and successfully save both', async() => { - await page.autocompleteSearch(selectors.entryObservations.secondObservationType, 'Delivery'); - await page.waitToClick(selectors.entryObservations.saveObservationsButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reload the section and make sure the first observation type was saved correctly', async() => { - await page.reloadSection('entry.card.observation'); - const result = await page.waitToGetProperty(selectors.entryObservations.firstObservationType, 'value'); - - expect(result).toEqual('SalesPerson'); - }); - - it('should make sure the first observation description was saved correctly', async() => { - const result = await page.waitToGetProperty(selectors.entryObservations.firstObservationDescription, 'value'); - - expect(result).toEqual('first observation'); - }); - - it('should make sure the second observation type was saved correctly', async() => { - const result = await page.waitToGetProperty(selectors.entryObservations.secondObservationType, 'value'); - - expect(result).toEqual('Delivery'); - }); - - it('should make sure the second observation description was saved correctly', async() => { - const result = await page.waitToGetProperty(selectors.entryObservations.secondObservationDescription, 'value'); - - expect(result).toEqual('second observation'); - }); -}); diff --git a/e2e/paths/12-entry/07_buys.spec.js b/e2e/paths/12-entry/07_buys.spec.js deleted file mode 100644 index b960673ec..000000000 --- a/e2e/paths/12-entry/07_buys.spec.js +++ /dev/null @@ -1,69 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Entry import, create and edit buys path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'entry'); - await page.accessToSearchResult('3'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should count the summary buys and find there only one at this point', async() => { - const buysCount = await page.countElement(selectors.entrySummary.anyBuyLine); - - expect(buysCount).toEqual(2); - }); - - it('should navigate to the buy section and then click the import button opening the import form', async() => { - await page.accessToSection('entry.card.buy.index'); - await page.waitToClick(selectors.entryBuys.importButton); - await page.waitForState('entry.card.buy.import'); - }); - - it('should fill the form, import the a JSON file and select items for each import and confirm import', async() => { - let currentDir = process.cwd(); - let filePath = `${currentDir}/e2e/assets/07_import_buys.json`; - - const [fileChooser] = await Promise.all([ - page.waitForFileChooser(), - page.waitToClick(selectors.entryBuys.file) - ]); - await fileChooser.accept([filePath]); - - await page.waitForTextInField(selectors.entryBuys.ref, '200573095, 200573106, 200573117, 200573506'); - await page.waitForTextInField(selectors.entryBuys.observation, '729-6340 2846'); - - await page.autocompleteSearch(selectors.entryBuys.firstImportedItem, 'Ranged weapon longbow 200cm'); - await page.autocompleteSearch(selectors.entryBuys.secondImportedItem, 'Ranged weapon longbow 200cm'); - await page.autocompleteSearch(selectors.entryBuys.thirdImportedItem, 'Ranged weapon sniper rifle 113cm'); - await page.autocompleteSearch(selectors.entryBuys.fourthImportedItem, 'Melee weapon heavy shield 100cm'); - - await page.waitToClick(selectors.entryBuys.importBuysButton); - - const message = await page.waitForSnackbar(); - const state = await page.getState(); - - expect(message.text).toContain('Data saved!'); - expect(state).toBe('entry.card.buy.index'); - }); - - it('should count the buys to find 4 buys have been added', async() => { - await page.waitForNumberOfElements(selectors.entryBuys.anyBuyLine, 6); - }); - - it('should delete the four buys that were just added', async() => { - await page.waitToClick(selectors.entryBuys.allBuyCheckbox); - await page.waitToClick(selectors.entryBuys.firstBuyCheckbox); - await page.waitToClick(selectors.entryBuys.deleteBuysButton); - await page.waitToClick(selectors.globalItems.acceptButton); - await page.waitForNumberOfElements(selectors.entryBuys.anyBuyLine, 1); - }); -}); diff --git a/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js b/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js deleted file mode 100644 index e82f851ea..000000000 --- a/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js +++ /dev/null @@ -1,84 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Supplier summary & descriptor path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'supplier'); - await page.accessToSearchResult('1'); - }); - - afterAll(async() => { - await browser.close(); - }); - - // summary - it('should reach the second entry summary section', async() => { - await page.waitForState('supplier.card.summary'); - }); - - it(`should confirm there's data on the summary header`, async() => { - const result = await page.waitToGetProperty(selectors.supplierSummary.header, 'innerText'); - - expect(result).toContain('PLANTS SL - 1'); - }); - - it(`should confirm there's data on the summary basic data`, async() => { - const result = await page.waitToGetProperty(selectors.supplierSummary.basicDataId, 'innerText'); - - expect(result).toContain('Id 1'); - }); - - it(`should confirm there's data on the summary fiscal address`, async() => { - const result = await page.waitToGetProperty(selectors.supplierSummary.fiscalAddressTaxNumber, 'innerText'); - - expect(result).toContain('Tax number 06089160W'); - }); - - it(`should confirm there's data on the summary fiscal pay method`, async() => { - const result = await page.waitToGetProperty(selectors.supplierSummary.billingDataPayMethod, 'innerText'); - - expect(result).toContain('Pay method PayMethod one'); - }); - - // descriptor - it(`should confirm there's data on the descriptor`, async() => { - const result = await page.waitToGetProperty(selectors.supplierDescriptor.alias, 'innerText'); - - expect(result).toContain('Plants nick'); - }); - - it(`should navigate to the supplier's client summary using the icon client button`, async() => { - await page.waitToClick(selectors.supplierDescriptor.clientButton); - await page.waitForState('client.card.summary'); - }); - - it(`should navigate back to the supplier`, async() => { - await page.waitToClick(selectors.globalItems.homeButton); - await page.waitForState('home'); - await page.selectModule('supplier'); - await page.accessToSearchResult('1'); - await page.waitForState('supplier.card.summary'); - }); - - it(`should navigate to the supplier's entries`, async() => { - await page.waitToClick(selectors.supplierDescriptor.entriesButton); - await page.waitForState('entry.index'); - }); - - it(`should navigate back to suppliers but a different one this time`, async() => { - await page.waitToClick(selectors.globalItems.homeButton); - await page.waitForState('home'); - await page.selectModule('supplier'); - await page.accessToSearchResult('2'); - await page.waitForState('supplier.card.summary'); - }); - - it(`should check the client button isn't present since this supplier should not be a client`, async() => { - await page.waitForSelector(selectors.supplierDescriptor.clientButton, {visible: false}); - }); -}); diff --git a/e2e/paths/13-supplier/02_basic_data.spec.js b/e2e/paths/13-supplier/02_basic_data.spec.js deleted file mode 100644 index 710ebd8df..000000000 --- a/e2e/paths/13-supplier/02_basic_data.spec.js +++ /dev/null @@ -1,67 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Supplier basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('financial', 'supplier'); - await page.accessToSearchResult('1'); - await page.accessToSection('supplier.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should edit the basic data', async() => { - await page.clearInput(selectors.supplierBasicData.alias); - await page.write(selectors.supplierBasicData.alias, 'Plants Nick SL'); - await page.waitToClick(selectors.supplierBasicData.isReal); - await page.waitToClick(selectors.supplierBasicData.isActive); - await page.waitToClick(selectors.supplierBasicData.isPayMethodChecked); - await page.write(selectors.supplierBasicData.notes, 'Some notes'); - - await page.waitToClick(selectors.supplierBasicData.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reload the section', async() => { - await page.reloadSection('supplier.card.basicData'); - }); - - it('should check the alias was edited', async() => { - const result = await page.waitToGetProperty(selectors.supplierBasicData.alias, 'value'); - - expect(result).toEqual('Plants Nick SL'); - }); - - it('should check the isReal checkbox is now checked', async() => { - const result = await page.checkboxState(selectors.supplierBasicData.isReal); - - expect(result).toBe('checked'); - }); - - it('should check the isActive checkbox is now unchecked', async() => { - const result = await page.checkboxState(selectors.supplierBasicData.isActive); - - expect(result).toBe('unchecked'); - }); - - it('should check the isPayMethodChecked checkbox is now unchecked', async() => { - const result = await page.checkboxState(selectors.supplierBasicData.isPayMethodChecked); - - expect(result).toBe('unchecked'); - }); - - it('should check the notes were edited', async() => { - const result = await page.waitToGetProperty(selectors.supplierBasicData.notes, 'value'); - - expect(result).toEqual('Some notes'); - }); -}); diff --git a/e2e/paths/13-supplier/03_fiscal_data.spec.js b/e2e/paths/13-supplier/03_fiscal_data.spec.js deleted file mode 100644 index ccd9d7809..000000000 --- a/e2e/paths/13-supplier/03_fiscal_data.spec.js +++ /dev/null @@ -1,56 +0,0 @@ -import getBrowser from '../../helpers/puppeteer'; - -describe('Supplier fiscal data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'supplier'); - await page.accessToSearchResult('2'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should attempt to edit the fiscal data and check data iss saved', async() => { - await page.accessToSection('supplier.card.fiscalData'); - - const form = 'vn-supplier-fiscal-data form'; - const values = { - province: null, - country: null, - postcode: null, - city: 'Valencia', - socialName: 'FARMER KING SL', - taxNumber: '12345678Z', - account: '0123456789', - sageWithholding: 'retencion estimacion objetiva', - sageTaxType: 'operaciones no sujetas' - }; - - const errorMessage = await page.sendForm(form, { - taxNumber: 'Wrong tax number' - }); - const message = await page.sendForm(form, values); - - await page.reloadSection('supplier.card.fiscalData'); - const formValues = await page.fetchForm(form, Object.keys(values)); - - expect(errorMessage.text).toContain('Invalid Tax number'); - expect(message.isSuccess).toBeTrue(); - expect(formValues).toEqual({ - province: 'Province one', - country: 'España', - postcode: '46000', - city: 'Valencia', - socialName: 'FARMER KING SL', - taxNumber: '12345678Z', - account: '0123456789', - sageWithholding: 'RETENCION ESTIMACION OBJETIVA', - sageTaxType: 'Operaciones no sujetas' - }); - }); -}); diff --git a/e2e/paths/13-supplier/04_billing_data.spec.js b/e2e/paths/13-supplier/04_billing_data.spec.js deleted file mode 100644 index d3cb6dcab..000000000 --- a/e2e/paths/13-supplier/04_billing_data.spec.js +++ /dev/null @@ -1,52 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Supplier billing data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'supplier'); - await page.accessToSearchResult('442'); - await page.accessToSection('supplier.card.billingData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should edit the billing data', async() => { - await page.autocompleteSearch(selectors.supplierBillingData.payMethod, 'PayMethod with IBAN'); - await page.autocompleteSearch(selectors.supplierBillingData.payDem, '10'); - await page.clearInput(selectors.supplierBillingData.payDay); - await page.write(selectors.supplierBillingData.payDay, '19'); - await page.waitToClick(selectors.supplierBillingData.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reload the section', async() => { - await page.reloadSection('supplier.card.billingData'); - }); - - it('should check the pay method was edited', async() => { - const result = await page.waitToGetProperty(selectors.supplierBillingData.payMethod, 'value'); - - expect(result).toEqual('PayMethod with IBAN'); - }); - - it('should check the payDem was edited', async() => { - const result = await page.waitToGetProperty(selectors.supplierBillingData.payDem, 'value'); - - expect(result).toEqual('10'); - }); - - it('should check the pay day was edited', async() => { - const result = await page.waitToGetProperty(selectors.supplierBillingData.payDay, 'value'); - - expect(result).toEqual('19'); - }); -}); diff --git a/e2e/paths/13-supplier/05_address.spec.js b/e2e/paths/13-supplier/05_address.spec.js deleted file mode 100644 index 5bccba3ee..000000000 --- a/e2e/paths/13-supplier/05_address.spec.js +++ /dev/null @@ -1,79 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Supplier address path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'supplier'); - await page.accessToSearchResult('1'); - await page.accessToSection('supplier.card.address.index'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should count the addresses before creating one', async() => { - const count = await page.countElement(selectors.supplierAddress.anyAddress); - - expect(count).toEqual(2); - }); - - it('should open the new address form by clicking the add button', async() => { - await page.waitToClick(selectors.supplierAddress.newAddress); - await page.waitForState('supplier.card.address.create'); - }); - - it('should create a new address', async() => { - await page.write(selectors.supplierAddress.newNickname, 'Darkest dungeon'); - await page.write(selectors.supplierAddress.newStreet, 'Wayne manor'); - await page.write(selectors.supplierAddress.newPostcode, '46000'); - await page.write(selectors.supplierAddress.newCity, 'Valencia'); - await page.autocompleteSearch(selectors.supplierAddress.newProvince, 'Province one'); - await page.write(selectors.supplierAddress.newPhone, '888888888'); - await page.write(selectors.supplierAddress.newMobile, '444444444'); - await page.waitToClick(selectors.supplierAddress.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should have been redirected to the addresses index', async() => { - await page.waitForState('supplier.card.address.index'); - }); - - it('should count the addresses and find one more now', async() => { - const count = await page.countElement(selectors.supplierAddress.anyAddress); - - expect(count).toEqual(3); - }); - - it('should open the edit address form by clicking the new address', async() => { - await page.waitToClick(selectors.supplierAddress.thirdAddress); - await page.waitForState('supplier.card.address.edit'); - }); - - it('should edit the address', async() => { - await page.overwrite(selectors.supplierAddress.editNickname, 'Wayne manor'); - await page.overwrite(selectors.supplierAddress.editStreet, '1007 Mountain Drive'); - await page.overwrite(selectors.supplierAddress.editPostcode, '46000'); - await page.overwrite(selectors.supplierAddress.editCity, 'Valencia'); - await page.autocompleteSearch(selectors.supplierAddress.editProvince, 'Province one'); - await page.overwrite(selectors.supplierAddress.editPhone, '777777777'); - await page.overwrite(selectors.supplierAddress.editMobile, '555555555'); - await page.waitToClick(selectors.supplierAddress.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should check the address has now the expected data', async() => { - let thirdAddress = await page.waitToGetProperty(selectors.supplierAddress.thirdAddress, 'innerText'); - - expect(thirdAddress).toContain('Wayne manor'); - }); -}); diff --git a/e2e/paths/13-supplier/06_contact.spec.js b/e2e/paths/13-supplier/06_contact.spec.js deleted file mode 100644 index 60fd28f9c..000000000 --- a/e2e/paths/13-supplier/06_contact.spec.js +++ /dev/null @@ -1,89 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Supplier contact path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'supplier'); - await page.accessToSearchResult('1'); - await page.accessToSection('supplier.card.contact'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should create a new contact', async() => { - await page.waitToClick(selectors.supplierContact.addNewContact); - await page.write(selectors.supplierContact.thirdContactName, 'The tester'); - await page.write(selectors.supplierContact.thirdContactPhone, '99 999 99 99'); - await page.write(selectors.supplierContact.thirdContactMobile, '555 55 55 55'); - await page.write(selectors.supplierContact.thirdContactEmail, 'testing@puppeteer.com'); - await page.write(selectors.supplierContact.thirdContactNotes, 'the end to end integration tester'); - await page.waitToClick(selectors.supplierContact.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should reload the section and count the contacts`, async() => { - await page.reloadSection('supplier.card.contact'); - const result = await page.countElement(selectors.supplierContact.anyContact); - - expect(result).toEqual(3); - }); - - it(`should check the new contact name was saved correctly`, async() => { - const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactName, 'value'); - - expect(result).toContain('The tester'); - }); - - it(`should check the new contact phone was saved correctly`, async() => { - const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactPhone, 'value'); - - expect(result).toContain('99 999 99 99'); - }); - - it(`should check the new contact mobile was saved correctly`, async() => { - const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactMobile, 'value'); - - expect(result).toContain('555 55 55 55'); - }); - - it(`should check the new contact email was saved correctly`, async() => { - const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactEmail, 'value'); - - expect(result).toContain('testing@puppeteer.com'); - }); - - it(`should check the new contact note was saved correctly`, async() => { - await page.waitForTextInField(selectors.supplierContact.thirdContactNotes, 'the end to end integration tester'); - const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactNotes, 'value'); - - expect(result).toContain('the end to end integration tester'); - }); - - it(`should remove the created contact`, async() => { - await page.waitToClick(selectors.supplierContact.thirdContactDeleteButton, 'value'); - const result = await page.countElement(selectors.supplierContact.anyContact); - - expect(result).toEqual(2); - - await page.waitToClick(selectors.supplierContact.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should reload the section and count the amount of contacts went back to 2`, async() => { - await page.reloadSection('supplier.card.contact'); - const result = await page.countElement(selectors.supplierContact.anyContact); - - expect(result).toEqual(2); - }); -}); diff --git a/e2e/paths/14-account/01_create_and_basic_data.spec.js b/e2e/paths/14-account/01_create_and_basic_data.spec.js deleted file mode 100644 index e2c069d80..000000000 --- a/e2e/paths/14-account/01_create_and_basic_data.spec.js +++ /dev/null @@ -1,164 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account create and basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('itManagement', 'account'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should open the new account form by clicking the add button', async() => { - await page.waitToClick(selectors.accountIndex.addAccount); - await page.waitForState('account.create'); - }); - - it('should fill the form and then save it by clicking the create button', async() => { - await page.write(selectors.accountIndex.newName, 'remy'); - await page.write(selectors.accountIndex.newNickname, 'Gambit'); - await page.write(selectors.accountIndex.newEmail, 'RemyEtienneLeBeau@verdnatura.es'); - await page.autocompleteSearch(selectors.accountIndex.newRole, 'Trainee'); - await page.write(selectors.accountIndex.newPassword, 'cestlavie'); - await page.waitToClick(selectors.accountIndex.createAccountButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should redirect the user to the created account basic data section', async() => { - await page.waitForState('account.card.basicData'); - }); - - it('should check the name is as expected', async() => { - const result = await page.waitToGetProperty(selectors.accountBasicData.name, 'value'); - - expect(result).toEqual('remy'); - }); - - it('should check the nickname is as expected', async() => { - const result = await page.waitToGetProperty(selectors.accountBasicData.nickname, 'value'); - - expect(result).toEqual('Gambit'); - }); - - it('should check the email is as expected', async() => { - const result = await page.waitToGetProperty(selectors.accountBasicData.email, 'value'); - - expect(result).toEqual('RemyEtienneLeBeau@verdnatura.es'); - }); - - it('should navigate to the roles section to check the roles are correct', async() => { - await page.accessToSection('account.card.roles'); - const rolesCount = await page.countElement(selectors.accountRoles.anyResult); - - expect(rolesCount).toEqual(3); - }); - - describe('Descriptor option', () => { - describe('activate account', () => { - it(`should check the active account icon isn't present in the descriptor`, async() => { - await page.waitForNumberOfElements(selectors.accountDescriptor.activeAccountIcon, 0); - }); - - it('should activate the account using the descriptor menu', async() => { - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.activateAccount); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Account enabled!'); - }); - - it('should check the active account icon is now present in the descriptor', async() => { - await page.waitForSelector(selectors.accountDescriptor.activeAccountIcon, {visible: false}); - }); - }); - - describe('deactivate user', () => { - it(`should check the inactive user icon isn't present in the descriptor just yet`, async() => { - await page.waitForNumberOfElements(selectors.accountDescriptor.activeUserIcon, 0); - }); - - it('should deactivate the user using the descriptor menu', async() => { - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.deactivateUser); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('User deactivated!'); - }); - - it('should check the inactive user icon is now present', async() => { - await page.waitForNumberOfElements(selectors.accountDescriptor.activeUserIcon, 1); - }); - }); - - describe('activate user', () => { - it('should activate the user using the descriptor menu', async() => { - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.activateUser); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('User activated!'); - }); - - it('should check the inactive user icon is not present anymore', async() => { - await page.waitForNumberOfElements(selectors.accountDescriptor.activeUserIcon, 0); - }); - }); - - describe('mail forwarding', () => { - it('should activate the mail forwarding and set the recipent email', async() => { - await page.accessToSection('account.card.mailForwarding'); - await page.waitToClick(selectors.accountMailForwarding.mailForwardingCheckbox); - await page.write(selectors.accountMailForwarding.email, 'someEmail@someDomain.es'); - await page.waitToClick(selectors.accountMailForwarding.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - }); - - describe('Set password', () => { - it('should set the password using the descriptor menu', async() => { - const newPassword = 'quantum.12345'; - - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.setPassword); - await page.write(selectors.accountDescriptor.newPassword, newPassword); - await page.write(selectors.accountDescriptor.repeatPassword, newPassword); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Password changed succesfully!'); - }); - - // cant log into created account for unknown reasons - // it('should login into the created account with the new password', async() => { - // await page.loginAndModule('Remy', 'quantum.crypt0graphy'); - // }); - }); - - describe('delete account', () => { - // it('should navigate to the account basic data section', async() => { - // }); - - it('should delete the account using the descriptor menu', async() => { - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.deleteAccount); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('User removed'); - }); - }); - }); -}); diff --git a/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js b/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js deleted file mode 100644 index 840fb8afe..000000000 --- a/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js +++ /dev/null @@ -1,66 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account Alias create and basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('itManagement', 'account'); - await page.accessToSection('account.alias'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should open the new account alias form by clicking the add button', async() => { - await page.waitToClick(selectors.accountAliasIndex.addAlias); - await page.waitForState('account.alias.create'); - }); - - it('should fill the form and then save it by clicking the create alias button', async() => { - await page.write(selectors.accountAliasIndex.newName, 'Boring alias'); - await page.write(selectors.accountAliasIndex.newDescription, 'Boring description'); - await page.waitToClick(selectors.accountAliasIndex.createAliasButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should redirect the user to the created account alias basic data section', async() => { - await page.waitForState('account.alias.card.basicData'); - }); - - it('should edit the alias basic data', async() => { - await page.overwrite(selectors.accountAliasBasicData.name, 'Psykers'); - await page.overwrite(selectors.accountAliasBasicData.description, 'Email group for psykers'); - await page.waitToClick(selectors.accountAliasBasicData.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reload the basicData section and check the name was edited successfully', async() => { - await page.reloadSection('account.alias.card.basicData'); - const result = await page.waitToGetProperty(selectors.accountAliasBasicData.name, 'value'); - - expect(result).toEqual('Psykers'); - }); - - it('should check the alias description was edited successfully', async() => { - const result = await page.waitToGetProperty(selectors.accountAliasBasicData.description, 'value'); - - expect(result).toContain('psykers'); - }); - - it('should search IT alias then access the user section to check the role listed is the expected one', async() => { - await page.accessToSearchResult('IT'); - await page.accessToSection('account.alias.card.users'); - const rolesCount = await page.countElement(selectors.accountAliasUsers.anyResult); - - expect(rolesCount).toEqual(1); - }); -}); diff --git a/e2e/paths/14-account/03_role_create_and_basic_data.spec.js b/e2e/paths/14-account/03_role_create_and_basic_data.spec.js deleted file mode 100644 index 6acf82318..000000000 --- a/e2e/paths/14-account/03_role_create_and_basic_data.spec.js +++ /dev/null @@ -1,86 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account Role create and basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('it', 'account'); - await page.accessToSection('account.role'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should open the new account role form by clicking the add button', async() => { - await page.waitToClick(selectors.accountRoleIndex.addRole); - await page.waitForState('account.role.create'); - }); - - it('should fill the form and then save it by clicking the create role button', async() => { - await page.write(selectors.accountRoleIndex.newName, 'boringRole'); - await page.write(selectors.accountRoleIndex.newDescription, 'Boring description'); - await page.waitToClick(selectors.accountRoleIndex.createRoleButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should redirect the user to the created role basic data section', async() => { - await page.waitForState('account.role.card.basicData'); - }); - - it('should edit the role basic data', async() => { - await page.overwrite(selectors.accountRoleBasicData.name, 'psyker'); - await page.overwrite(selectors.accountRoleBasicData.description, 'A role just for psykers'); - await page.waitToClick(selectors.accountRoleBasicData.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reload the role basicData section and check the name was edited successfully', async() => { - await page.reloadSection('account.role.card.basicData'); - const result = await page.waitToGetProperty(selectors.accountRoleBasicData.name, 'value'); - - expect(result).toEqual('psyker'); - }); - - it('should check the role description was edited successfully', async() => { - const result = await page.waitToGetProperty(selectors.accountRoleBasicData.description, 'value'); - - expect(result).toContain('psykers'); - }); - - it('should navigate to the subroles section', async() => { - await page.accessToSection('account.role.card.subroles'); - }); - - it('should asign a subrole', async() => { - await page.waitToClick(selectors.accountSubroles.addSubrole); - await page.autocompleteSearch(selectors.accountSubroles.role, 'teamManager'); - await page.waitToClick(selectors.accountSubroles.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Role added!'); - }); - - it('should reload the subroles section and check a role was added', async() => { - await page.reloadSection('account.role.card.subroles'); - const subrolesCount = await page.countElement(selectors.accountSubroles.anyResult); - - expect(subrolesCount).toEqual(1); - }); - - it('should access the employee roles inheritance then check the roles listed are the expected ones', async() => { - await page.accessToSearchResult('employee'); - await page.accessToSection('account.role.card.inherited'); - const rolesCount = await page.countElement(selectors.accountRoleInheritance.anyResult); - - expect(rolesCount).toEqual(7); - }); -}); diff --git a/e2e/paths/14-account/04_acl.spec.js b/e2e/paths/14-account/04_acl.spec.js deleted file mode 100644 index ce2a63b14..000000000 --- a/e2e/paths/14-account/04_acl.spec.js +++ /dev/null @@ -1,60 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account ACL path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('developer', 'account'); - await page.accessToSection('account.acl'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should go to create new acl', async() => { - await page.waitToClick(selectors.accountAcl.addAcl); - await page.waitForState('account.acl.create'); - }); - - it('should create new acl', async() => { - await page.autocompleteSearch(selectors.accountAcl.role, 'sysadmin'); - await page.autocompleteSearch(selectors.accountAcl.model, 'Account'); - await page.autocompleteSearch(selectors.accountAcl.accessType, '*'); - await page.autocompleteSearch(selectors.accountAcl.permission, 'ALLOW'); - await page.waitToClick(selectors.accountAcl.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should navigate to edit', async() => { - await page.doSearch(); - await page.waitToClick(selectors.accountAcl.thirdAcl); - await page.waitForState('account.acl.edit'); - }); - - it('should edit the third acl', async() => { - await page.autocompleteSearch(selectors.accountAcl.model, 'Supplier'); - await page.autocompleteSearch(selectors.accountAcl.accessType, 'READ'); - await page.waitToClick(selectors.accountAcl.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should delete the third result', async() => { - const result = await page.waitToGetProperty(selectors.accountAcl.thirdAcl, 'innerText'); - await page.waitToClick(selectors.accountAcl.deleteThirdAcl); - await page.waitToClick(selectors.globalItems.acceptButton); - const message = await page.waitForSnackbar(); - const newResult = await page.waitToGetProperty(selectors.accountAcl.thirdAcl, 'innerText'); - - expect(message.text).toContain('ACL removed'); - expect(result).not.toEqual(newResult); - }); -}); diff --git a/e2e/paths/14-account/05_connections.spec.js b/e2e/paths/14-account/05_connections.spec.js deleted file mode 100644 index 49d5f612d..000000000 --- a/e2e/paths/14-account/05_connections.spec.js +++ /dev/null @@ -1,25 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account Connections path', () => { - let browser; - let page; - const account = 'sysadmin'; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule(account, 'account'); - await page.accessToSection('account.connections'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should check this is the last connection', async() => { - const firstResult = await page.waitToGetProperty(selectors.accountConnections.firstConnection, 'innerText'); - - expect(firstResult).toContain(account); - }); -}); diff --git a/e2e/paths/14-account/06_accounts.spec.js b/e2e/paths/14-account/06_accounts.spec.js deleted file mode 100644 index 8bd6ea7d5..000000000 --- a/e2e/paths/14-account/06_accounts.spec.js +++ /dev/null @@ -1,37 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account Accounts path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('sysadmin', 'account'); - await page.accessToSection('account.accounts'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should sync roles', async() => { - await page.waitToClick(selectors.accountAccounts.syncRoles); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Roles synchronized!'); - }); - - it('should relogin', async() => { - await page.loginAndModule('sysadmin', 'account'); - await page.accessToSection('account.accounts'); - }); - - it('should sync all', async() => { - await page.waitToClick(selectors.accountAccounts.syncAll); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Synchronizing in the background'); - }); -}); diff --git a/e2e/paths/14-account/07_ldap.spec.js b/e2e/paths/14-account/07_ldap.spec.js deleted file mode 100644 index eb22f695c..000000000 --- a/e2e/paths/14-account/07_ldap.spec.js +++ /dev/null @@ -1,41 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account LDAP path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('sysadmin', 'account'); - await page.accessToSection('account.ldap'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should set data and save', async() => { - await page.waitToClick(selectors.accountLdap.checkEnable); - await page.write(selectors.accountLdap.server, '1234'); - await page.write(selectors.accountLdap.rdn, '1234'); - await page.write(selectors.accountLdap.password, 'nightmare'); - await page.write(selectors.accountLdap.userDn, 'sysadmin'); - await page.write(selectors.accountLdap.groupDn, '1234'); - await page.waitToClick(selectors.accountLdap.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reset data', async() => { - await page.waitToClick(selectors.accountLdap.checkEnable); - await page.waitToClick(selectors.accountLdap.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); -}); diff --git a/e2e/paths/14-account/08_samba.spec.js b/e2e/paths/14-account/08_samba.spec.js deleted file mode 100644 index a92344acb..000000000 --- a/e2e/paths/14-account/08_samba.spec.js +++ /dev/null @@ -1,42 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account Samba path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('sysadmin', 'account'); - await page.accessToSection('account.samba'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should set data and save', async() => { - await page.waitToClick(selectors.accountSamba.checkEnable); - await page.write(selectors.accountSamba.adDomain, '1234'); - await page.write(selectors.accountSamba.adController, '1234'); - await page.write(selectors.accountSamba.adUser, 'sysadmin'); - await page.write(selectors.accountSamba.adPassword, 'nightmare'); - await page.write(selectors.accountSamba.userDn, 'testDn'); - await page.waitToClick(selectors.accountSamba.verifyCert); - await page.waitToClick(selectors.accountSamba.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reset data', async() => { - await page.waitToClick(selectors.accountSamba.checkEnable); - await page.waitToClick(selectors.accountSamba.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); -}); diff --git a/e2e/paths/14-account/09_privileges.spec.js b/e2e/paths/14-account/09_privileges.spec.js deleted file mode 100644 index e4b8fb24c..000000000 --- a/e2e/paths/14-account/09_privileges.spec.js +++ /dev/null @@ -1,112 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account privileges path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('developer', 'account'); - await page.accessToSearchResult('1101'); - await page.accessToSection('account.card.privileges'); - }); - - afterAll(async() => { - await browser.close(); - }); - - describe('as developer', () => { - it('should throw error when give privileges', async() => { - await page.waitToClick(selectors.accountPrivileges.checkHasGrant); - await page.waitToClick(selectors.accountPrivileges.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`You don't have grant privilege`); - }); - - it('should throw error when change role', async() => { - await page.autocompleteSearch(selectors.accountPrivileges.role, 'employee'); - await page.waitToClick(selectors.accountPrivileges.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`You don't have grant privilege`); - }); - }); - - describe('as sysadmin', () => { - beforeAll(async() => { - await page.loginAndModule('sysadmin', 'account'); - await page.accessToSearchResult('9'); - await page.accessToSection('account.card.privileges'); - }); - - it('should give privileges', async() => { - await page.waitToClick(selectors.accountPrivileges.checkHasGrant); - await page.waitToClick(selectors.accountPrivileges.save); - const message = await page.waitForSnackbar(); - - await page.reloadSection('account.card.privileges'); - const result = await page.checkboxState(selectors.accountPrivileges.checkHasGrant); - - expect(message.text).toContain(`Data saved!`); - expect(result).toBe('checked'); - }); - - it('should throw error when change role and not own role', async() => { - await page.autocompleteSearch(selectors.accountPrivileges.role, 'itBoss'); - await page.waitToClick(selectors.accountPrivileges.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`You don't own the role and you can't assign it to another user`); - }); - - it('should change role to employee', async() => { - await page.autocompleteSearch(selectors.accountPrivileges.role, 'employee'); - await page.waitToClick(selectors.accountPrivileges.save); - const message = await page.waitForSnackbar(); - - await page.reloadSection('account.card.privileges'); - const result = await page.waitToGetProperty(selectors.accountPrivileges.role, 'value'); - - expect(message.text).toContain(`Data saved!`); - expect(result).toContain('employee'); - }); - - it('should return role to developer', async() => { - await page.autocompleteSearch(selectors.accountPrivileges.role, 'developer'); - await page.waitToClick(selectors.accountPrivileges.save); - const message = await page.waitForSnackbar(); - - await page.reloadSection('account.card.privileges'); - const result = await page.waitToGetProperty(selectors.accountPrivileges.role, 'value'); - - expect(message.text).toContain(`Data saved!`); - expect(result).toContain('developer'); - }); - }); - - describe('as developer again', () => { - it('should remove privileges', async() => { - await page.accessToSearchResult('9'); - await page.accessToSection('account.card.privileges'); - - await page.waitToClick(selectors.accountPrivileges.checkHasGrant); - await page.waitToClick(selectors.accountPrivileges.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`Data saved!`); - }); - - it('should logIn in developer', async() => { - await page.reloadSection('account.card.privileges'); - const result = await page.checkboxState(selectors.accountPrivileges.checkHasGrant); - - expect(result).toBe('unchecked'); - }); - }); -}); diff --git a/e2e/tests.js b/e2e/tests.js index 829056f4c..a9c662dc4 100644 --- a/e2e/tests.js +++ b/e2e/tests.js @@ -41,7 +41,6 @@ async function test() { `./e2e/paths/03*/*[sS]pec.js`, `./e2e/paths/04*/*[sS]pec.js`, `./e2e/paths/05*/*[sS]pec.js`, - `./e2e/paths/06*/*[sS]pec.js`, `./e2e/paths/07*/*[sS]pec.js`, `./e2e/paths/08*/*[sS]pec.js`, `./e2e/paths/09*/*[sS]pec.js`, diff --git a/front/core/locale/es.yml b/front/core/locale/es.yml index 17e955ff5..7fcb8c16b 100644 --- a/front/core/locale/es.yml +++ b/front/core/locale/es.yml @@ -69,3 +69,4 @@ Send cau: Enviar cau By sending this ticket, all the data related to the error, the section, the user, etc., are already sent.: Al enviar este cau ya se envían todos los datos relacionados con el error, la sección, el usuario, etc ExplainReason: Explique el motivo por el que no deberia aparecer este fallo You already have the mailAlias: Ya tienes este alias de correo +Error loading ACLs: Error al cargar los ACLs diff --git a/front/core/services/app.js b/front/core/services/app.js index 8cee66ef0..dba6e70bf 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -56,6 +56,8 @@ export default class App { } getUrl(route, appName = 'lilium') { + const index = window.location.hash.indexOf(route.toLowerCase()); + let newRoute = index < 0 ? route : window.location.hash.substring(index); const env = process.env.NODE_ENV; const filter = { where: {and: [ @@ -64,10 +66,21 @@ export default class App { ]} }; + const hasId = !isNaN(parseInt(route.split('/')[1])); + + if (this.logger.$params.q) { + let tableValue = this.logger.$params.q; + const q = JSON.parse(tableValue); + if (typeof q === 'number') + tableValue = JSON.stringify({id: tableValue}); + newRoute = newRoute.concat(`?table=${tableValue}`); + } else if (!hasId && this.logger.$params.id && newRoute.indexOf(this.logger.$params.id) < 0) + newRoute = newRoute.concat(`${this.logger.$params.id}`); + return this.logger.$http.get('Urls/findOne', {filter}) .then(res => { if (res && res.data) - return res.data.url + route; + return res.data.url + newRoute; }) .catch(() => { this.showError('Direction not found'); diff --git a/front/core/services/auth.js b/front/core/services/auth.js index 753bc3fba..0cae4bae8 100644 --- a/front/core/services/auth.js +++ b/front/core/services/auth.js @@ -7,16 +7,17 @@ import UserError from 'core/lib/user-error'; * @property {Boolean} loggedIn Whether the user is currently logged */ export default class Auth { - constructor($http, $q, $state, $transitions, $window, vnToken, vnModules, aclService) { + constructor($http, $q, vnApp, $translate, $state, $transitions, $window, vnToken, vnModules) { Object.assign(this, { $http, $q, + vnApp, + $translate, $state, $transitions, $window, vnToken, vnModules, - aclService, loggedIn: false }); } @@ -39,9 +40,26 @@ export default class Auth { }; if (this.vnToken.token) { - return this.loadAcls() - .then(() => true) - .catch(redirectToLogin); + const loadWithRetry = () => { + return this.validateToken() + .then(() => true) + .catch(err => { + switch (err.status) { + case 400: + case 401: + return redirectToLogin(); + default: + return new Promise(resolve => { + setTimeout(() => { + this.vnApp.showMessage(this.$translate.instant('Loading...')); + + resolve(loadWithRetry()); + }, 2000); + }); + } + }); + }; + return loadWithRetry(); } else return redirectToLogin(); }); @@ -87,13 +105,11 @@ export default class Auth { headers: {Authorization: json.data.token} }).then(({data}) => { 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) - this.$window.location = continueHash; - else - this.$state.go('home'); - }); + let continueHash = this.$state.params.continue; + if (continueHash) + this.$window.location = continueHash; + else + this.$state.go('home'); }).catch(() => {}); } @@ -107,24 +123,25 @@ export default class Auth { this.vnToken.unset(); this.loggedIn = false; this.vnModules.reset(); - this.aclService.reset(); + this.vnModules.aclService.reset(); this.$state.go('login'); return promise; } - loadAcls() { - return this.aclService.load() + validateToken() { + return this.$http.get('VnUsers/validateToken') .then(() => { this.loggedIn = true; this.vnModules.reset(); }) .catch(err => { - this.vnToken.unset(); throw err; }); } } -Auth.$inject = ['$http', '$q', '$state', '$transitions', '$window', 'vnToken', 'vnModules', 'aclService']; +Auth.$inject = [ + '$http', '$q', 'vnApp', '$translate', '$state', + '$transitions', '$window', 'vnToken', 'vnModules']; ngModule.service('vnAuth', Auth); diff --git a/front/module-import.js b/front/module-import.js index bc547deeb..22a2747d2 100755 --- a/front/module-import.js +++ b/front/module-import.js @@ -1,27 +1,27 @@ export default function moduleImport(moduleName) { // TODO: Webpack watches module backend files when using dynamic import - //return import( + // return import( // /* webpackInclude: /modules\/[a-z0-9-]+\/front\/index.js$/ */ // '../modules/'+ moduleName +'/front/index.js' - //); + // ); - switch(moduleName) { - case 'client' : return import('client/front'); - case 'item' : return import('item/front'); - case 'ticket' : return import('ticket/front'); - case 'order' : return import('order/front'); - case 'claim' : return import('claim/front'); - case 'zone' : return import('zone/front'); - case 'travel' : return import('travel/front'); - case 'worker' : return import('worker/front'); - case 'invoiceOut' : return import('invoiceOut/front'); - case 'invoiceIn' : return import('invoiceIn/front'); - case 'route' : return import('route/front'); - case 'entry' : return import('entry/front'); - case 'account' : return import('account/front'); - case 'supplier' : return import('supplier/front'); - case 'shelving' : return import('shelving/front'); - case 'monitor' : return import('monitor/front'); + switch (moduleName) { + case 'client': return import('client/front'); + case 'item': return import('item/front'); + case 'ticket': return import('ticket/front'); + case 'order': return import('order/front'); + case 'claim': return import('claim/front'); + case 'zone': return import('zone/front'); + case 'travel': return import('travel/front'); + case 'worker': return import('worker/front'); + case 'invoiceOut': return import('invoiceOut/front'); + case 'invoiceIn': return import('invoiceIn/front'); + case 'route': return import('route/front'); + case 'account': return import('account/front'); + case 'supplier': return import('supplier/front'); + case 'shelving': return import('shelving/front'); + case 'monitor': return import('monitor/front'); + case 'entry': return import('entry/front'); } } diff --git a/front/salix/components/bank-entity/index.html b/front/salix/components/bank-entity/index.html index 6ce073f1a..915294671 100644 --- a/front/salix/components/bank-entity/index.html +++ b/front/salix/components/bank-entity/index.html @@ -27,7 +27,7 @@ vn-id="country" ng-model="$ctrl.data.countryFk" url="Countries" - fields="['id', 'country', 'code']" + fields="['id', 'name', 'code']" show-field="name" value-field="id" label="Country"> diff --git a/front/salix/components/upload-photo/index.js b/front/salix/components/upload-photo/index.js index c9774d037..7779c81e1 100644 --- a/front/salix/components/upload-photo/index.js +++ b/front/salix/components/upload-photo/index.js @@ -164,6 +164,7 @@ export default class UploadPhoto extends Component { const options = { type: 'blob', + size: 'original' }; return this.editor.result(options) .then(blob => this.newPhoto.blob = blob) diff --git a/front/salix/components/user-popover/index.html b/front/salix/components/user-popover/index.html index 06a4af1e0..cedb3383b 100644 --- a/front/salix/components/user-popover/index.html +++ b/front/salix/components/user-popover/index.html @@ -38,7 +38,7 @@ My account diff --git a/front/salix/components/user-popover/index.js b/front/salix/components/user-popover/index.js index 1d88137ff..72cb734e9 100644 --- a/front/salix/components/user-popover/index.js +++ b/front/salix/components/user-popover/index.js @@ -82,6 +82,9 @@ class Controller { ? {id: $search} : {bank: {like: '%' + $search + '%'}}; } + async redirect(id) { + window.location.href = await this.vnConfig.vnApp.getUrl(`worker/${id}`); + } } Controller.$inject = ['$scope', '$translate', 'vnConfig', 'vnAuth', 'vnToken']; diff --git a/front/salix/routes.js b/front/salix/routes.js index 8621f83c7..2c6f1b848 100644 --- a/front/salix/routes.js +++ b/front/salix/routes.js @@ -4,7 +4,17 @@ import getMainRoute from 'core/lib/get-main-route'; config.$inject = ['$stateProvider', '$urlRouterProvider']; function config($stateProvider, $urlRouterProvider) { $urlRouterProvider - .otherwise('/'); + .otherwise(async($injector, {$location}) => { + const prefix = '#!'; + if (!$location.$$path) return window.location.href = `/${prefix}/`; + + const url = $location.$$absUrl + .replace('5000', '9000') + .replace('salix', 'lilium') + .replace(prefix, '#') + .replace('client', 'customer'); + window.location.href = url; + }); $stateProvider .state('layout', { @@ -12,7 +22,8 @@ function config($stateProvider, $urlRouterProvider) { template: '', resolve: { config: ['vnConfig', vnConfig => vnConfig.initialize()], - token: ['vnToken', vnToken => vnToken.fetchConfig()] + token: ['vnToken', vnToken => vnToken.fetchConfig()], + acl: ['aclService', aclService => aclService.load()] } }) .state('outLayout', { diff --git a/loopback/common/methods/application/spec/execute.spec.js b/loopback/common/methods/application/spec/execute.spec.js index 1a0a8ace9..ca4efd9cc 100644 --- a/loopback/common/methods/application/spec/execute.spec.js +++ b/loopback/common/methods/application/spec/execute.spec.js @@ -2,18 +2,9 @@ const models = require('vn-loopback/server/server').models; describe('Application execute()/executeProc()/executeFunc()', () => { const userWithoutPrivileges = 1; - const userWithPrivileges = 9; const userWithInheritedPrivileges = 120; let tx; - - function getCtx(userId) { - return { - req: { - accessToken: {userId}, - headers: {origin: 'http://localhost'} - } - }; - } + const ctx = beforeAll.getCtx(); beforeEach(async() => { tx = await models.Application.beginTransaction({}); @@ -42,7 +33,7 @@ describe('Application execute()/executeProc()/executeFunc()', () => { }); it('should throw error when execute procedure and not have privileges', async() => { - const ctx = getCtx(userWithoutPrivileges); + const ctx = {req: {accessToken: {userId: userWithoutPrivileges}}}; let error; try { @@ -66,7 +57,6 @@ describe('Application execute()/executeProc()/executeFunc()', () => { }); it('should execute procedure and get data', async() => { - const ctx = getCtx(userWithPrivileges); try { const options = {transaction: tx}; @@ -90,7 +80,6 @@ describe('Application execute()/executeProc()/executeFunc()', () => { describe('Application executeProc()', () => { it('should execute procedure and get data (executeProc)', async() => { - const ctx = getCtx(userWithPrivileges); try { const options = {transaction: tx}; @@ -115,7 +104,6 @@ describe('Application execute()/executeProc()/executeFunc()', () => { describe('Application executeFunc()', () => { it('should execute function and get data', async() => { - const ctx = getCtx(userWithPrivileges); try { const options = {transaction: tx}; @@ -137,7 +125,7 @@ describe('Application execute()/executeProc()/executeFunc()', () => { }); it('should execute function and get data with user with inherited privileges', async() => { - const ctx = getCtx(userWithInheritedPrivileges); + const ctx = {req: {accessToken: {userId: userWithInheritedPrivileges}}}; try { const options = {transaction: tx}; diff --git a/loopback/common/methods/schema/model-info.js b/loopback/common/methods/schema/model-info.js index 0648deb80..74d764475 100644 --- a/loopback/common/methods/schema/model-info.js +++ b/loopback/common/methods/schema/model-info.js @@ -92,6 +92,7 @@ module.exports = Self => { const locale = modelLocale && modelLocale.get(lang); json[modelName] = { + http: model.sharedClass.http.path, properties: model.definition.rawProperties, validations: jsonValidations, locale diff --git a/loopback/common/methods/vn-model/specs/crud.spec.js b/loopback/common/methods/vn-model/specs/crud.spec.js index 56af72bd9..28b256ad8 100644 --- a/loopback/common/methods/vn-model/specs/crud.spec.js +++ b/loopback/common/methods/vn-model/specs/crud.spec.js @@ -1,20 +1,7 @@ const app = require('vn-loopback/server/server'); -const LoopBackContext = require('loopback-context'); describe('Model crud()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); let insertId; const barcodeModel = app.models.ItemBarcode; diff --git a/loopback/common/methods/vn-model/specs/rewriteDbError.spec.js b/loopback/common/methods/vn-model/specs/rewriteDbError.spec.js index a3dba14d7..84c0784c9 100644 --- a/loopback/common/methods/vn-model/specs/rewriteDbError.spec.js +++ b/loopback/common/methods/vn-model/specs/rewriteDbError.spec.js @@ -1,20 +1,7 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('Model rewriteDbError()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); it('should extend rewriteDbError properties to any model passed', () => { const exampleModel = models.ItemTag; diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 22b535f62..e24653d13 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -13,7 +13,6 @@ module.exports = function(Self) { Object.assign(Self, { setup() { Self.super_.setup.call(this); - /** * Setting a global transaction timeout to find out if the service * is blocked because the connection pool is empty. @@ -28,6 +27,26 @@ module.exports = function(Self) { }; }); + this.beforeRemote('**', async ctx => { + if (!this.hasFilter(ctx)) return; + + const defaultLimit = this.app.orm.selectLimit; + const filter = ctx.args.filter || {limit: defaultLimit}; + + if (!filter.limit || filter.limit > defaultLimit) { + filter.limit = defaultLimit; + ctx.args.filter = filter; + } + }); + + this.afterRemote('**', async ctx => { + if (!this.hasFilter(ctx)) return; + + const {result} = ctx; + const length = Array.isArray(result) ? result.length : result ? 1 : 0; + if (length >= this.app.orm.selectLimit) throw new UserError('Too many records'); + }); + // Register field ACL validation /* this.beforeRemote('prototype.patchAttributes', ctx => this.checkUpdateAcls(ctx)); @@ -327,6 +346,13 @@ module.exports = function(Self) { checkInsertAcls(ctx) { return this.checkAcls(ctx, 'insert'); - } + }, + + hasFilter(ctx) { + const {method, req} = ctx; + if (method.noLimit) return false; + return req.method.toUpperCase() === 'GET' && + method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object'); + }, }); }; diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 601a26f5b..ea84cb6eb 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -61,7 +61,8 @@ "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 quantity": "I have changed {{changes}} of the ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changes in sales": "the quantity of [{{itemId}} {{concept}}]({{{itemUrl}}}) from {{oldQuantity}} ➔ *{{newQuantity}}*", "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}} €*", @@ -149,7 +150,7 @@ "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", + "Tickets with associated refunds": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº %s", "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", @@ -226,5 +227,18 @@ "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", - "This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency" -} \ No newline at end of file + "This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency", + "You can only have one PDA": "You can only have one PDA", + "Incoterms and Customs agent are required for a non UEE member": "Incoterms and Customs agent are required for a non UEE member", + "The invoices have been created but the PDFs could not be generated": "The invoices have been created but the PDFs could not be generated", + "It has been invoiced but the PDF of refund not be generated": "It has been invoiced but the PDF of refund not be generated", + "Cannot add holidays on this day": "Cannot add holidays on this day", + "Cannot send mail": "Cannot send mail", + "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`": "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`", + "This postcode already exists": "This postcode already exists", + "Original invoice not found": "Original invoice not found", + "There is already a tray with the same height": "There is already a tray with the same height", + "The height must be greater than 50cm": "The height must be greater than 50cm", + "The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm", + "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line" +} diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 77e707590..9308fd4ec 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -124,7 +124,8 @@ "Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale quantity": "He cambiado la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* del ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale quantity": "He cambiado {{changes}} del ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changes in sales": "la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}*", "State": "Estado", "regular": "normal", "reserved": "reservado", @@ -271,7 +272,7 @@ "Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite", "Warehouse inventory not set": "El almacén inventario no está establecido", "This locker has already been assigned": "Esta taquilla ya ha sido asignada", - "Tickets with associated refunds": "No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº %d", + "Tickets with associated refunds": "No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº %s", "Not exist this branch": "La rama no existe", "This ticket cannot be signed because it has not been boxed": "Este ticket no puede firmarse porque no ha sido encajado", "Collection does not exist": "La colección no existe", @@ -350,13 +351,36 @@ "You are not allowed to modify the alias": "No estás autorizado a modificar el alias", "The address of the customer must have information about Incoterms and Customs Agent": "El consignatario del cliente debe tener informado Incoterms y Agente de aduanas", "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", + "Through this procedure, it is not possible to modify the password of users with verified email": "Mediante este procedimiento, no es posible modificar la contraseña de usuarios con correo verificado", "They're not your subordinate": "No es tu subordinado/a.", "No results found": "No se han encontrado resultados", "InvoiceIn is already booked": "La factura recibida está contabilizada", "This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia", "Select ticket or client": "Elija un ticket o un client", "It was not able to create the invoice": "No se pudo crear la factura", - "This PDA is already assigned to another user": "This PDA is already assigned to another user", - "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)" + "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)", + "Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE", + "You can not use the same password": "No puedes usar la misma contraseña", + "This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario", + "You can only have one PDA": "Solo puedes tener un PDA", + "The invoices have been created but the PDFs could not be generated": "Se ha facturado pero no se ha podido generar el PDF", + "It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono", + "Payment method is required": "El método de pago es obligatorio", + "Cannot send mail": "Não é possível enviar o email", + "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos", + "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo", + "The entry not have stickers": "La entrada no tiene etiquetas", + "Too many records": "Demasiados registros", + "Original invoice not found": "Factura original no encontrada", + "The entry has no lines or does not exist": "La entrada no tiene lineas o no existe", + "Weight already set": "El peso ya está establecido", + "This ticket is not allocated to your department": "Este ticket no está asignado a tu departamento", + "There is already a tray with the same height": "Ya existe una bandeja con la misma altura", + "The height must be greater than 50cm": "La altura debe ser superior a 50cm", + "The maximum height of the wagon is 200cm": "La altura máxima es 200cm", + "The entry does not have stickers": "La entrada no tiene etiquetas", + "This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha", + "No valid travel thermograph found": "No se encontró un termógrafo válido", + "The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea", + "type cannot be blank": "Se debe rellenar el tipo" } \ No newline at end of file diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index 44f5e35d3..a6648b186 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -123,8 +123,9 @@ "Added sale to ticket": "J'ai ajouté la ligne suivante au ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", "Changed sale discount": "J'ai changé le rabais des lignes suivantes du ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Created claim": "J'ai créé la réclamation [{{claimId}}]({{{claimUrl}}}) des lignes suivantes du ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Changed sale price": "J'ai changé le prix de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* du ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale quantity": "J'ai changé la quantité de {{itemId}} {{concept}} de {{oldQuantity}} ➔ {{newQuantity}} du ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale price": " le prix de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* du ticket [{{ticketId}}]({{{ticketUrl}}})",, + "Changed sale quantity": "J'ai changé {{changes}} du ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changes in sales": "la quantité de {{itemId}} {{concept}} de {{oldQuantity}} ➔ {{newQuantity}}", "State": "État", "regular": "normal", "reserved": "réservé", @@ -271,7 +272,7 @@ "Invoice date can't be less than max date": "La date de la facture ne peut pas être inférieure à la date limite", "Warehouse inventory not set": "L'inventaire de l'entrepôt n'est pas établi", "This locker has already been assigned": "Ce casier a déjà été assigné", - "Tickets with associated refunds": "Vous ne pouvez pas supprimer des tickets avec des remboursements associés. Ce ticket est associé au remboursement Nº %d", + "Tickets with associated refunds": "Vous ne pouvez pas supprimer des tickets avec des remboursements associés. Ce ticket est associé au remboursement Nº %s", "Not exist this branch": "La branche n'existe pas", "This ticket cannot be signed because it has not been boxed": "Ce ticket ne peut pas être signé car il n'a pas été emballé", "Collection does not exist": "La collection n'existe pas", @@ -356,5 +357,10 @@ "InvoiceIn is already booked": "La facture reçue est déjà comptabilisée", "This workCenter is already assigned to this agency": "Ce centre de travail est déjà assigné à cette agence", "Select ticket or client": "Choisissez un ticket ou un client", - "It was not able to create the invoice": "Il n'a pas été possible de créer la facture" -} \ No newline at end of file + "It was not able to create the invoice": "Il n'a pas été possible de créer la facture", + "The invoices have been created but the PDFs could not be generated": "La facture a été émise mais le PDF n'a pas pu être généré", + "It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré", + "Cannot send mail": "Impossible d'envoyer le mail", + "Original invoice not found": "Facture originale introuvable", + "The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne" +} diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index b11eeefc6..a43f0e780 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -124,7 +124,8 @@ "Changed sale discount": "Desconto da venda alterado no ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Created claim": "Reclamação criada [{{claimId}}]({{{claimUrl}}}) no ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", "Changed sale price": "Preço da venda alterado para [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* no ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale quantity": "Quantidade da venda alterada para [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* no ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale quantity": "Quantidade da venda alterada para {{changes}} no ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changes in sales": " [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* ", "State": "Estado", "regular": "normal", "reserved": "reservado", @@ -356,5 +357,10 @@ "InvoiceIn is already booked": "InvoiceIn já está reservado", "This workCenter is already assigned to this agency": "Este centro de trabalho já está atribuído a esta agência", "Select ticket or client": "Selecione um ticket ou cliente", - "It was not able to create the invoice": "Não foi possível criar a fatura" -} \ No newline at end of file + "It was not able to create the invoice": "Não foi possível criar a fatura", + "The invoices have been created but the PDFs could not be generated": "Foi faturado, mas o PDF não pôde ser gerado", + "It has been invoiced but the PDF of refund not be generated": "Foi faturado mas não foi gerado o PDF do reembolso", + "Original invoice not found": "Fatura original não encontrada", + "Cannot send mail": "Não é possível enviar o email", + "The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha" +} diff --git a/loopback/server/boot/orm.js b/loopback/server/boot/orm.js new file mode 100644 index 000000000..8bbd969e1 --- /dev/null +++ b/loopback/server/boot/orm.js @@ -0,0 +1,6 @@ +module.exports = async function(app) { + if (!app.orm) { + const ormConfig = await app.models.OrmConfig.findOne(); + app.orm = ormConfig; + } +}; diff --git a/loopback/server/boot/role-resolver.js b/loopback/server/boot/role-resolver.js new file mode 100644 index 000000000..183d64de1 --- /dev/null +++ b/loopback/server/boot/role-resolver.js @@ -0,0 +1,9 @@ +module.exports = async function(app) { + const models = app.models; + + models.VnRole.registerResolver('$subordinate', async(role, ctx) => { + if (!ctx.accessToken) return false; + const httpCtx = {req: {accessToken: {userId: ctx.accessToken.userId}}}; + return models.Worker.isSubordinate(httpCtx, +ctx.modelId); + }); +}; diff --git a/loopback/server/connectors/vn-mysql.js b/loopback/server/connectors/vn-mysql.js index 5edef4395..2012caf37 100644 --- a/loopback/server/connectors/vn-mysql.js +++ b/loopback/server/connectors/vn-mysql.js @@ -342,6 +342,9 @@ exports.initialize = function initialize(dataSource, callback) { } }; +// Code extracted from original Loopback MySQL connector +// since it cannot be reused, please try not to alter it. +// https://github.com/loopbackio/loopback-connector-mysql/blob/v6.2.0/lib/mysql.js MySQL.prototype.connect = function(callback) { const self = this; const options = generateOptions(this.settings); diff --git a/loopback/server/datasources.json b/loopback/server/datasources.json index 341d5d578..f1643e522 100644 --- a/loopback/server/datasources.json +++ b/loopback/server/datasources.json @@ -11,12 +11,16 @@ "port": "3306", "username": "root", "password": "root", + "connectionLimit": 100, + "queueLimit": 100, "multipleStatements": true, "legacyUtcDateProcessing": false, "timezone": "local", "connectTimeout": 40000, "acquireTimeout": 90000, - "waitForConnections": true + "waitForConnections": true, + "maxIdleTime": 60000, + "idleTimeout": 60000 }, "osticket": { "connector": "memory", diff --git a/loopback/server/middleware/error-handler.js b/loopback/server/middleware/error-handler.js index cc7b81618..beeff95ae 100644 --- a/loopback/server/middleware/error-handler.js +++ b/loopback/server/middleware/error-handler.js @@ -22,7 +22,7 @@ module.exports = function() { } // MySQL user-defined exceptions - if (err.sqlState == '45000') + if (err.sqlState == '45000' || err?.errno == 4025) return next(new UserError(req.__(err.sqlMessage))); // Logs error to console diff --git a/loopback/util/flatten.js b/loopback/util/flatten.js new file mode 100644 index 000000000..18d682d1f --- /dev/null +++ b/loopback/util/flatten.js @@ -0,0 +1,42 @@ +/** + * Flattens an array of objects by converting each object into a flat structure. + * + * @param {Array} dataArray Array of objects to be flattened + * @return {Array} Array of flattened objects + */ +function flatten(dataArray) { + return dataArray.map(item => flattenObj(item.__data)); +} + +/** + * Recursively flattens an object, converting nested properties into a single level object + * with keys representing the original nested structure. + * + * @param {Object} data The object to be flattened + * @param {String} [prefix=''] Optional prefix for nested keys + * @return {Object} Flattened object + */ +function flattenObj(data, prefix = '') { + let result = {}; + try { + for (let key in data) { + if (!data[key]) continue; + + const newKey = prefix ? `${prefix}_${key}` : key; + const value = data[key]; + + if (typeof value === 'object' && value !== null && !Array.isArray(value)) + Object.assign(result, flattenObj(value.__data, newKey)); + else + result[newKey] = value; + } + } catch (error) { + console.error(error); + } + + return result; +} +module.exports = { + flatten, + flattenObj, +}; diff --git a/loopback/util/log.js b/loopback/util/log.js index 76e87781d..d2b78ce70 100644 --- a/loopback/util/log.js +++ b/loopback/util/log.js @@ -85,8 +85,12 @@ exports.translateValues = async(instance, changes, options = {}) => { exports.getChanges = (original, changes) => { const oldChanges = {}; const newChanges = {}; + const dateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/; for (let property in changes) { + if (dateRegex.test(original[property])) + original[property] = new Date(Date.parse(original[property])); + const firstChar = property.substring(0, 1); const isPrivate = firstChar == '$'; if (isPrivate) return; diff --git a/modules/account/back/model-config.json b/modules/account/back/model-config.json index 0cd43d0ce..cfec1fbe4 100644 --- a/modules/account/back/model-config.json +++ b/modules/account/back/model-config.json @@ -1,4 +1,7 @@ { + "Account": { + "dataSource": "vn" + }, "AccountConfig": { "dataSource": "vn" }, @@ -47,9 +50,6 @@ "SipConfig": { "dataSource": "vn" }, - "Account": { - "dataSource": "vn" - }, "UserLog": { "dataSource": "vn" }, diff --git a/modules/account/back/models/account.js b/modules/account/back/models/account.js index ceb26053c..7800d3e44 100644 --- a/modules/account/back/models/account.js +++ b/modules/account/back/models/account.js @@ -13,7 +13,11 @@ module.exports = Self => { Self.setUnverifiedPassword = async(id, pass, options) => { const {emailVerified} = await models.VnUser.findById(id, {fields: ['emailVerified']}, options); - if (emailVerified) throw new ForbiddenError('This password can only be changed by the user themselves'); + if (emailVerified) { + throw new ForbiddenError( + 'Through this procedure, it is not possible to modify the password of users with verified email' + ); + } await models.VnUser.setPassword(id, pass, options); }; diff --git a/modules/account/back/models/account.json b/modules/account/back/models/account.json index 6c2784696..fc1bbeb3d 100644 --- a/modules/account/back/models/account.json +++ b/modules/account/back/models/account.json @@ -46,4 +46,4 @@ "permission": "ALLOW" } ] -} +} \ No newline at end of file diff --git a/modules/account/back/models/mail-alias-account.json b/modules/account/back/models/mail-alias-account.json index 54e986ef7..46d4793e6 100644 --- a/modules/account/back/models/mail-alias-account.json +++ b/modules/account/back/models/mail-alias-account.json @@ -6,6 +6,9 @@ "table": "account.mailAliasAccount" } }, + "mixins": { + "Loggable": true + }, "properties": { "id": { "type": "number", diff --git a/modules/account/back/models/role-inherit.json b/modules/account/back/models/role-inherit.json index a89f47b77..30d526471 100644 --- a/modules/account/back/models/role-inherit.json +++ b/modules/account/back/models/role-inherit.json @@ -1,6 +1,9 @@ { "name": "RoleInherit", "base": "VnModel", + "mixins": { + "Loggable": true + }, "options": { "mysql": { "table": "account.roleInherit" diff --git a/modules/account/back/models/sip.json b/modules/account/back/models/sip.json index f2e2221b5..dbcef3b9e 100644 --- a/modules/account/back/models/sip.json +++ b/modules/account/back/models/sip.json @@ -25,7 +25,12 @@ "type": "belongsTo", "model": "VnUser", "foreignKey": "user_id" + }, + "queueMember": { + "type": "belongsTo", + "model": "QueueMember", + "foreignKey": "extension", + "primaryKey": "extension" } } -} - \ No newline at end of file +} \ No newline at end of file diff --git a/modules/account/front/accounts/index.html b/modules/account/front/accounts/index.html deleted file mode 100644 index 6847e68d1..000000000 --- a/modules/account/front/accounts/index.html +++ /dev/null @@ -1,75 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/account/front/accounts/index.js b/modules/account/front/accounts/index.js deleted file mode 100644 index ab19126a1..000000000 --- a/modules/account/front/accounts/index.js +++ /dev/null @@ -1,19 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onSynchronizeAll() { - this.vnApp.showSuccess(this.$t('Synchronizing in the background')); - this.$http.patch(`Accounts/syncAll`); - } - - onSynchronizeRoles() { - this.$http.patch(`RoleInherits/sync`) - .then(() => this.vnApp.showSuccess(this.$t('Roles synchronized!'))); - } -} - -ngModule.component('vnAccountAccounts', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/accounts/locale/es.yml b/modules/account/front/accounts/locale/es.yml deleted file mode 100644 index 614ade3eb..000000000 --- a/modules/account/front/accounts/locale/es.yml +++ /dev/null @@ -1,14 +0,0 @@ -Accounts: Cuentas -Homedir base: Directorio base para carpetas de usuario -Shell: Intérprete de línea de comandos -User and role base id: Id base usuarios y roles -Synchronize all: Sincronizar todo -Synchronize roles: Sincronizar roles -If password is not specified, just user attributes are synchronized: >- - Si la contraseña no se especifica solo se sincronizarán lo atributos del usuario -Synchronizing in the background: Sincronizando en segundo plano -Users synchronized!: ¡Usuarios sincronizados! -Username: Nombre de usuario -Synchronize: Sincronizar -Please enter the username: Por favor introduce el nombre de usuario -Roles synchronized!: ¡Roles sincronizados! diff --git a/modules/account/front/acl/create/index.html b/modules/account/front/acl/create/index.html deleted file mode 100644 index 14332f737..000000000 --- a/modules/account/front/acl/create/index.html +++ /dev/null @@ -1,70 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/account/front/acl/create/index.js b/modules/account/front/acl/create/index.js deleted file mode 100644 index fea71991f..000000000 --- a/modules/account/front/acl/create/index.js +++ /dev/null @@ -1,33 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor(...args) { - super(...args); - this.accessTypes = [ - {name: '*'}, - {name: 'READ'}, - {name: 'WRITE'} - ]; - this.permissions = [ - {name: 'ALLOW'}, - {name: 'DENY'} - ]; - - this.models = []; - for (let model in window.validations) - this.models.push({name: model}); - - this.acl = { - property: '*', - principalType: 'ROLE', - accessType: 'READ', - permission: 'ALLOW' - }; - } -} - -ngModule.component('vnAclCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/acl/index.js b/modules/account/front/acl/index.js deleted file mode 100644 index 8393859a5..000000000 --- a/modules/account/front/acl/index.js +++ /dev/null @@ -1,4 +0,0 @@ -import './main'; -import './index/'; -import './create'; -import './search-panel'; diff --git a/modules/account/front/acl/index/index.html b/modules/account/front/acl/index/index.html deleted file mode 100644 index af06ec481..000000000 --- a/modules/account/front/acl/index/index.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - -
- -
{{::row.model}}.{{::row.property}}
- - - - - - -
- - - - -
- - - - - - - - \ No newline at end of file diff --git a/modules/account/front/acl/index/index.js b/modules/account/front/acl/index/index.js deleted file mode 100644 index a2aec534a..000000000 --- a/modules/account/front/acl/index/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onDelete(row) { - return this.$http.delete(`ACLs/${row.id}`) - .then(() => this.$.model.refresh()) - .then(() => this.vnApp.showSuccess(this.$t('ACL removed'))); - } -} - -ngModule.component('vnAclIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/acl/index/locale/es.yml b/modules/account/front/acl/index/locale/es.yml deleted file mode 100644 index 8024f804c..000000000 --- a/modules/account/front/acl/index/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -New ACL: Nuevo ACL -Edit ACL: Editar ACL -ACL will be removed: El ACL será eliminado -ACL removed: ACL eliminado diff --git a/modules/account/front/acl/locale/es.yml b/modules/account/front/acl/locale/es.yml deleted file mode 100644 index ff6a1b41c..000000000 --- a/modules/account/front/acl/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -Model: Modelo -Property: Propiedad -Access type: Tipo de acceso -Permission: Permiso \ No newline at end of file diff --git a/modules/account/front/acl/main/index.html b/modules/account/front/acl/main/index.html deleted file mode 100644 index 7767768d9..000000000 --- a/modules/account/front/acl/main/index.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/modules/account/front/acl/main/index.js b/modules/account/front/acl/main/index.js deleted file mode 100644 index a91a71cb7..000000000 --- a/modules/account/front/acl/main/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import ngModule from '../../module'; -import ModuleMain from 'salix/components/module-main'; - -export default class ACL extends ModuleMain { - exprBuilder(param, value) { - switch (param) { - case 'search': - return {model: {like: `%${value}%`}}; - default: - return {[param]: value}; - } - } -} - -ngModule.vnComponent('vnAclComponent', { - controller: ACL, - template: require('./index.html') -}); diff --git a/modules/account/front/acl/search-panel/index.html b/modules/account/front/acl/search-panel/index.html deleted file mode 100644 index a3efab440..000000000 --- a/modules/account/front/acl/search-panel/index.html +++ /dev/null @@ -1,39 +0,0 @@ -
-
- - - - - - - - - - - - - - - -
diff --git a/modules/account/front/acl/search-panel/index.js b/modules/account/front/acl/search-panel/index.js deleted file mode 100644 index 4f571059e..000000000 --- a/modules/account/front/acl/search-panel/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import ngModule from '../../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -export default class Controller extends SearchPanel { - constructor(...args) { - super(...args); - this.accessTypes = [ - {name: '*'}, - {name: 'READ'}, - {name: 'WRITE'} - ]; - this.permissions = [ - {name: 'ALLOW'}, - {name: 'DENY'} - ]; - - this.models = []; - for (let model in window.validations) - this.models.push({name: model}); - } -} - -ngModule.component('vnAclSearchPanel', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/alias/basic-data/index.html b/modules/account/front/alias/basic-data/index.html deleted file mode 100644 index 523c9297a..000000000 --- a/modules/account/front/alias/basic-data/index.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/account/front/alias/basic-data/index.js b/modules/account/front/alias/basic-data/index.js deleted file mode 100644 index b7c2db089..000000000 --- a/modules/account/front/alias/basic-data/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section {} - -ngModule.component('vnAliasBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - alias: '<' - } -}); diff --git a/modules/account/front/alias/card/index.html b/modules/account/front/alias/card/index.html deleted file mode 100644 index 712147a24..000000000 --- a/modules/account/front/alias/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/account/front/alias/card/index.js b/modules/account/front/alias/card/index.js deleted file mode 100644 index fd1a18f6a..000000000 --- a/modules/account/front/alias/card/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - this.$http.get(`MailAliases/${this.$params.id}`) - .then(res => this.alias = res.data); - } -} - -ngModule.vnComponent('vnAliasCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/alias/create/index.html b/modules/account/front/alias/create/index.html deleted file mode 100644 index 4dad1b870..000000000 --- a/modules/account/front/alias/create/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/modules/account/front/alias/create/index.js b/modules/account/front/alias/create/index.js deleted file mode 100644 index c058c3adf..000000000 --- a/modules/account/front/alias/create/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onSubmit() { - return this.$.watcher.submit().then(res => - this.$state.go('account.alias.card.basicData', {id: res.data.id}) - ); - } -} - -ngModule.component('vnAliasCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/alias/descriptor/index.html b/modules/account/front/alias/descriptor/index.html deleted file mode 100644 index 71b98c6a3..000000000 --- a/modules/account/front/alias/descriptor/index.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - Delete - - - -
- - -
-
-
- - \ No newline at end of file diff --git a/modules/account/front/alias/descriptor/index.js b/modules/account/front/alias/descriptor/index.js deleted file mode 100644 index a21baae5a..000000000 --- a/modules/account/front/alias/descriptor/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import ngModule from '../../module'; -import Descriptor from 'salix/components/descriptor'; - -class Controller extends Descriptor { - get alias() { - return this.entity; - } - - set alias(value) { - this.entity = value; - } - - onDelete() { - return this.$http.delete(`MailAliases/${this.id}`) - .then(() => this.$state.go('account.alias')) - .then(() => this.vnApp.showSuccess(this.$t('Alias removed'))); - } -} - -ngModule.component('vnAliasDescriptor', { - template: require('./index.html'), - controller: Controller, - bindings: { - alias: '<' - } -}); diff --git a/modules/account/front/alias/descriptor/locale/es.yml b/modules/account/front/alias/descriptor/locale/es.yml deleted file mode 100644 index 9c6fa0e73..000000000 --- a/modules/account/front/alias/descriptor/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Alias will be removed: El alias será eliminado -Alias removed: Alias eliminado \ No newline at end of file diff --git a/modules/account/front/alias/index.js b/modules/account/front/alias/index.js deleted file mode 100644 index 8eed3a3d3..000000000 --- a/modules/account/front/alias/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import './main'; -import './index/'; -import './create'; -import './summary'; -import './card'; -import './descriptor'; -import './create'; -import './basic-data'; -import './users'; diff --git a/modules/account/front/alias/index/index.html b/modules/account/front/alias/index/index.html deleted file mode 100644 index 7343cb9bd..000000000 --- a/modules/account/front/alias/index/index.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - -
{{::alias.alias}}
-
{{::alias.description}}
-
- - - - -
-
-
-
- - - - - - \ No newline at end of file diff --git a/modules/account/front/alias/index/index.js b/modules/account/front/alias/index/index.js deleted file mode 100644 index 44e146fb4..000000000 --- a/modules/account/front/alias/index/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - preview(alias) { - this.selectedAlias = alias; - this.$.summary.show(); - } -} - -ngModule.component('vnAliasIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/alias/index/locale/es.yml b/modules/account/front/alias/index/locale/es.yml deleted file mode 100644 index 4df41c0be..000000000 --- a/modules/account/front/alias/index/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -New alias: Nuevo alias -View alias: Ver alias \ No newline at end of file diff --git a/modules/account/front/alias/locale/es.yml b/modules/account/front/alias/locale/es.yml deleted file mode 100644 index ecc856fcf..000000000 --- a/modules/account/front/alias/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Public: Público \ No newline at end of file diff --git a/modules/account/front/alias/main/index.html b/modules/account/front/alias/main/index.html deleted file mode 100644 index 43f6e2f51..000000000 --- a/modules/account/front/alias/main/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/modules/account/front/alias/main/index.js b/modules/account/front/alias/main/index.js deleted file mode 100644 index 21eed3d85..000000000 --- a/modules/account/front/alias/main/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import ngModule from '../../module'; -import ModuleMain from 'salix/components/module-main'; - -export default class Alias extends ModuleMain { - exprBuilder(param, value) { - switch (param) { - case 'search': - return /^\d+$/.test(value) - ? {id: value} - : {alias: {like: `%${value}%`}}; - } - } -} - -ngModule.vnComponent('vnAlias', { - controller: Alias, - template: require('./index.html') -}); diff --git a/modules/account/front/alias/summary/index.html b/modules/account/front/alias/summary/index.html deleted file mode 100644 index 52ee2813d..000000000 --- a/modules/account/front/alias/summary/index.html +++ /dev/null @@ -1,16 +0,0 @@ - -
{{summary.alias}}
- - -

Basic data

- - - - -
-
-
\ No newline at end of file diff --git a/modules/account/front/alias/summary/index.js b/modules/account/front/alias/summary/index.js deleted file mode 100644 index 21bc8d9ba..000000000 --- a/modules/account/front/alias/summary/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import ngModule from '../../module'; -import Component from 'core/lib/component'; - -class Controller extends Component { - set alias(value) { - this._alias = value; - this.$.summary = null; - if (!value) return; - - this.$http.get(`MailAliases/${value.id}`) - .then(res => this.$.summary = res.data); - } - - get alias() { - return this._alias; - } -} - -ngModule.component('vnAliasSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - alias: '<' - } -}); diff --git a/modules/account/front/alias/users/index.html b/modules/account/front/alias/users/index.html deleted file mode 100644 index 048a702ea..000000000 --- a/modules/account/front/alias/users/index.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - {{::row.user.name}} - - - - - - - - - - - diff --git a/modules/account/front/alias/users/index.js b/modules/account/front/alias/users/index.js deleted file mode 100644 index b2446d71b..000000000 --- a/modules/account/front/alias/users/index.js +++ /dev/null @@ -1,31 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - let filter = { - include: { - relation: 'user', - scope: { - fields: ['id', 'name'] - } - } - }; - this.$http.get(`MailAliases/${this.$params.id}/accounts`, {filter}) - .then(res => this.$.data = res.data); - } - - onRemove(row) { - return this.$http.delete(`MailAliases/${this.$params.id}/accounts/${row.id}`) - .then(() => { - let index = this.$.data.indexOf(row); - if (index !== -1) this.$.data.splice(index, 1); - this.vnApp.showSuccess(this.$t('User removed')); - }); - } -} - -ngModule.component('vnAliasUsers', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/alias/users/index.spec.js b/modules/account/front/alias/users/index.spec.js deleted file mode 100644 index d618f1de1..000000000 --- a/modules/account/front/alias/users/index.spec.js +++ /dev/null @@ -1,42 +0,0 @@ -import './index'; - -describe('component vnAliasUsers', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnAliasUsers', {$element: null}); - controller.$params.id = 1; - })); - - describe('$onInit()', () => { - it('should delete entity and go to index', () => { - $httpBackend.expectGET('MailAliases/1/accounts').respond('foo'); - controller.$onInit(); - $httpBackend.flush(); - - expect(controller.$.data).toBe('foo'); - }); - }); - - describe('onRemove()', () => { - it('should call backend method to change role', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - - controller.$.data = [ - {id: 1, alias: 'foo'}, - {id: 2, alias: 'bar'} - ]; - - $httpBackend.expectDELETE('MailAliases/1/accounts/1').respond(); - controller.onRemove(controller.$.data[0]); - $httpBackend.flush(); - - expect(controller.$.data).toEqual([{id: 2, alias: 'bar'}]); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); -}); diff --git a/modules/account/front/alias/users/locale/es.yml b/modules/account/front/alias/users/locale/es.yml deleted file mode 100644 index dc24eb318..000000000 --- a/modules/account/front/alias/users/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -User will be removed from alias: El usuario será borrado del alias -User removed: Usuario borrado \ No newline at end of file diff --git a/modules/account/front/aliases/index.html b/modules/account/front/aliases/index.html deleted file mode 100644 index 4a73ec873..000000000 --- a/modules/account/front/aliases/index.html +++ /dev/null @@ -1,64 +0,0 @@ -
- - - - - -
- {{::row.alias.alias}} -
-
- {{::row.alias.description}} -
-
- - - - -
-
- -
-
- - - - - - - - - - - - - - -
-
- Account not enabled -
diff --git a/modules/account/front/aliases/index.js b/modules/account/front/aliases/index.js deleted file mode 100644 index 0fc806a71..000000000 --- a/modules/account/front/aliases/index.js +++ /dev/null @@ -1,51 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - this.refresh(); - } - - refresh() { - let filter = { - where: {account: this.$params.id}, - include: { - relation: 'alias', - scope: { - fields: ['id', 'alias', 'description'] - } - } - }; - return this.$http.get(`MailAliasAccounts`, {filter}) - .then(res => this.$.data = res.data); - } - - onAddClick() { - this.addData = {account: this.$params.id}; - this.$.dialog.show(); - } - - onAddSave() { - return this.$http.post(`MailAliasAccounts`, this.addData) - .then(() => this.refresh()) - .then(() => this.vnApp.showSuccess( - this.$t('Subscribed to alias!')) - ); - } - - onRemove(row) { - return this.$http.delete(`MailAliasAccounts/${row.id}`) - .then(() => { - this.$.data.splice(this.$.data.indexOf(row), 1); - this.vnApp.showSuccess(this.$t('Unsubscribed from alias!')); - }); - } -} - -ngModule.component('vnUserAliases', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnUserCard' - } -}); diff --git a/modules/account/front/aliases/index.spec.js b/modules/account/front/aliases/index.spec.js deleted file mode 100644 index 466f1e1e9..000000000 --- a/modules/account/front/aliases/index.spec.js +++ /dev/null @@ -1,53 +0,0 @@ -import './index'; - -describe('component vnUserAliases', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnUserAliases', {$element: null}); - jest.spyOn(controller.vnApp, 'showSuccess'); - })); - - describe('refresh()', () => { - it('should refresh the controller data', () => { - $httpBackend.expectGET('MailAliasAccounts').respond('foo'); - controller.refresh(); - $httpBackend.flush(); - - expect(controller.$.data).toBe('foo'); - }); - }); - - describe('onAddSave()', () => { - it('should add the new row', () => { - controller.addData = {account: 1}; - - $httpBackend.expectPOST('MailAliasAccounts').respond(); - $httpBackend.expectGET('MailAliasAccounts').respond('foo'); - controller.onAddSave(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('onRemove()', () => { - it('shoud remove the passed row remote and locally', () => { - controller.$.data = [ - {id: 1, alias: 'foo'}, - {id: 2, alias: 'bar'} - ]; - - $httpBackend.expectDELETE('MailAliasAccounts/1').respond(); - controller.onRemove(controller.$.data[0]); - $httpBackend.flush(); - - expect(controller.$.data).toEqual([{id: 2, alias: 'bar'}]); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); -}); diff --git a/modules/account/front/aliases/locale/es.yml b/modules/account/front/aliases/locale/es.yml deleted file mode 100644 index 4d1ad76a7..000000000 --- a/modules/account/front/aliases/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Unsubscribe: Desuscribir -Subscribed to alias!: ¡Suscrito al alias! -Unsubscribed from alias!: ¡Desuscrito del alias! \ No newline at end of file diff --git a/modules/account/front/basic-data/index.html b/modules/account/front/basic-data/index.html deleted file mode 100644 index 9fd3506fe..000000000 --- a/modules/account/front/basic-data/index.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/account/front/basic-data/index.js b/modules/account/front/basic-data/index.js deleted file mode 100644 index f6b266bbc..000000000 --- a/modules/account/front/basic-data/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - if (this.$params.emailConfirmed) - this.vnApp.showSuccess(this.$t('Email verified successfully!')); - } - - onSubmit() { - this.$.watcher.submit() - .then(() => this.card.reload()); - } -} - -ngModule.component('vnUserBasicData', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnUserCard' - }, - bindings: { - user: '<' - } -}); diff --git a/modules/account/front/basic-data/locale/es.yml b/modules/account/front/basic-data/locale/es.yml deleted file mode 100644 index 2ca7bf698..000000000 --- a/modules/account/front/basic-data/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Email verified successfully!: Correo verificado correctamente! diff --git a/modules/account/front/card/index.html b/modules/account/front/card/index.html deleted file mode 100644 index cba6b93c6..000000000 --- a/modules/account/front/card/index.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - diff --git a/modules/account/front/card/index.js b/modules/account/front/card/index.js deleted file mode 100644 index 2c8cc7637..000000000 --- a/modules/account/front/card/index.js +++ /dev/null @@ -1,32 +0,0 @@ -import ngModule from '../module'; -import ModuleCard from 'salix/components/module-card'; -import './style.scss'; - -class Controller extends ModuleCard { - reload() { - const filter = { - where: {id: this.$params.id}, - include: { - relation: 'role', - scope: { - fields: ['id', 'name'] - } - } - }; - - return Promise.all([ - this.$http.get(`VnUsers/preview`, {filter}) - .then(res => { - const [user] = res.data; - this.user = user; - }), - this.$http.get(`Accounts/${this.$params.id}/exists`) - .then(res => this.hasAccount = res.data.exists) - ]); - } -} - -ngModule.vnComponent('vnUserCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/card/index.spec.js b/modules/account/front/card/index.spec.js deleted file mode 100644 index 712d3c1d8..000000000 --- a/modules/account/front/card/index.spec.js +++ /dev/null @@ -1,27 +0,0 @@ -import './index'; - -describe('component vnUserCard', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnUserCard', {$element: null}); - })); - - describe('reload()', () => { - it('should reload the controller data', () => { - controller.$params.id = 1; - - $httpBackend.expectGET('VnUsers/preview').respond('foo'); - $httpBackend.expectGET('Accounts/1/exists').respond({exists: true}); - controller.reload(); - $httpBackend.flush(); - - expect(controller.user).toBe('f'); - expect(controller.hasAccount).toBeTruthy(); - }); - }); -}); diff --git a/modules/account/front/card/style.scss b/modules/account/front/card/style.scss deleted file mode 100644 index 4d9d108a0..000000000 --- a/modules/account/front/card/style.scss +++ /dev/null @@ -1,10 +0,0 @@ -@import "variables"; - -.bg-title { - display: block; - text-align: center; - padding: 24px; - box-sizing: border-box; - color: $color-font-secondary; - font-size: 1.375rem; -} diff --git a/modules/account/front/connections/index.html b/modules/account/front/connections/index.html deleted file mode 100644 index d634b7a9f..000000000 --- a/modules/account/front/connections/index.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - -
{{::row.user.username}}
-
{{::row.created | date:'dd/MM HH:mm'}}
-
- - - - -
-
-
-
- - - - \ No newline at end of file diff --git a/modules/account/front/connections/index.js b/modules/account/front/connections/index.js deleted file mode 100644 index c4ddd5615..000000000 --- a/modules/account/front/connections/index.js +++ /dev/null @@ -1,29 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor(...args) { - super(...args); - this.filter = { - fields: ['id', 'created', 'userId'], - include: { - relation: 'user', - scope: { - fields: ['username'] - } - }, - order: 'created DESC' - }; - } - - onDisconnect(row) { - return this.$http.delete(`AccessTokens/${row.id}`) - .then(() => this.$.model.refresh()) - .then(() => this.vnApp.showSuccess(this.$t('Session killed'))); - } -} - -ngModule.component('vnConnections', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/connections/locale/es.yml b/modules/account/front/connections/locale/es.yml deleted file mode 100644 index 41ef18b45..000000000 --- a/modules/account/front/connections/locale/es.yml +++ /dev/null @@ -1,5 +0,0 @@ -Go to user: Ir al usuario -Refresh: Actualizar -Session will be killed: Se va a matar la sesión -Kill session: Matar sesión -Session killed: Sesión matada \ No newline at end of file diff --git a/modules/account/front/create/index.html b/modules/account/front/create/index.html deleted file mode 100644 index 70a518885..000000000 --- a/modules/account/front/create/index.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/account/front/create/index.js b/modules/account/front/create/index.js deleted file mode 100644 index 01ba7905b..000000000 --- a/modules/account/front/create/index.js +++ /dev/null @@ -1,20 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.user = {active: true}; - } - - onSubmit() { - return this.$.watcher.submit().then(res => { - this.$state.go('account.card.basicData', {id: res.data.id}); - }); - } -} - -ngModule.component('vnUserCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/descriptor/__snapshots__/index.spec.js.snap b/modules/account/front/descriptor/__snapshots__/index.spec.js.snap deleted file mode 100644 index de5f8e8c2..000000000 --- a/modules/account/front/descriptor/__snapshots__/index.spec.js.snap +++ /dev/null @@ -1,5 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`component vnUserDescriptor onPassChange() should throw an error when password is empty 1`] = `"You must enter a new password"`; - -exports[`component vnUserDescriptor onPassChange() should throw an error when repeat password not matches new password 1`] = `"Passwords don't match"`; diff --git a/modules/account/front/descriptor/index.spec.js b/modules/account/front/descriptor/index.spec.js deleted file mode 100644 index 46c7e376c..000000000 --- a/modules/account/front/descriptor/index.spec.js +++ /dev/null @@ -1,97 +0,0 @@ -import './index'; - -describe('component vnUserDescriptor', () => { - let controller; - let $httpBackend; - - let user = {id: 1, name: 'foo'}; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $httpBackend.whenGET('Accounts/1/exists').respond({exists: true}); - - controller = $componentController('vnUserDescriptor', {$element: null}, {user}); - jest.spyOn(controller, 'emit'); - jest.spyOn(controller.vnApp, 'showSuccess'); - })); - - describe('onDelete()', () => { - it('should delete entity and go to index', () => { - controller.$state.go = jest.fn(); - - $httpBackend.expectDELETE('VnUsers/1').respond(); - controller.onDelete(); - $httpBackend.flush(); - - expect(controller.$state.go).toHaveBeenCalledWith('account.index'); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('onPassChange()', () => { - it('should throw an error when password is empty', () => { - expect(() => { - controller.onPassChange(); - }).toThrowErrorMatchingSnapshot(); - }); - - it('should throw an error when repeat password not matches new password', () => { - controller.newPassword = 'foo'; - controller.repeatPassword = 'bar'; - - expect(() => { - controller.onPassChange(); - }).toThrowErrorMatchingSnapshot(); - }); - - it('should make a request when password checks passes', () => { - controller.newPassword = 'foo'; - controller.repeatPassword = 'foo'; - - $httpBackend.expectPATCH('Accounts/1/setPassword').respond(); - controller.onPassChange(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.emit).toHaveBeenCalledWith('change'); - }); - }); - - describe('onEnableAccount()', () => { - it('should make request to enable account', () => { - $httpBackend.expectPOST('Accounts', {id: 1}).respond(); - controller.onEnableAccount(); - $httpBackend.flush(); - - expect(controller.hasAccount).toBeTruthy(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.emit).toHaveBeenCalledWith('change'); - }); - }); - - describe('onDisableAccount()', () => { - it('should make request to disable account', () => { - $httpBackend.expectDELETE('Accounts/1').respond(); - controller.onDisableAccount(); - $httpBackend.flush(); - - expect(controller.hasAccount).toBeFalsy(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.emit).toHaveBeenCalledWith('change'); - }); - }); - - describe('onSetActive()', () => { - it('should make request to activate/deactivate the user', () => { - $httpBackend.expectPATCH('VnUsers/1', {active: true}).respond(); - controller.onSetActive(true); - $httpBackend.flush(); - - expect(controller.user.active).toBeTruthy(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.emit).toHaveBeenCalledWith('change'); - }); - }); -}); diff --git a/modules/account/front/index.js b/modules/account/front/index.js index 4d6aedcae..0f2208862 100644 --- a/modules/account/front/index.js +++ b/modules/account/front/index.js @@ -1,24 +1,6 @@ export * from './module'; import './main'; -import './index/'; -import './role'; -import './alias'; -import './connections'; -import './acl'; -import './summary'; -import './card'; import './descriptor'; import './descriptor-popover'; -import './search-panel'; -import './create'; -import './basic-data'; -import './mail-forwarding'; -import './aliases'; -import './roles'; -import './ldap'; -import './samba'; -import './accounts'; -import './privileges'; -import './user-log'; -import './role-log'; +import './summary'; diff --git a/modules/account/front/index/index.html b/modules/account/front/index/index.html deleted file mode 100644 index 7502c8b3d..000000000 --- a/modules/account/front/index/index.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - diff --git a/modules/account/front/index/index.js b/modules/account/front/index/index.js deleted file mode 100644 index 9324ca740..000000000 --- a/modules/account/front/index/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - preview(user) { - this.selectedUser = user; - this.$.summary.show(); - } -} - -ngModule.component('vnUserIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/index/locale/es.yml b/modules/account/front/index/locale/es.yml deleted file mode 100644 index 074fb054e..000000000 --- a/modules/account/front/index/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -New user: Nuevo usuario -View user: Ver usuario \ No newline at end of file diff --git a/modules/account/front/ldap/index.html b/modules/account/front/ldap/index.html deleted file mode 100644 index 23356452a..000000000 --- a/modules/account/front/ldap/index.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/account/front/ldap/index.js b/modules/account/front/ldap/index.js deleted file mode 100644 index 40e1e8db1..000000000 --- a/modules/account/front/ldap/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onTestConection() { - this.$http.get(`LdapConfigs/test`) - .then(() => this.vnApp.showSuccess(this.$t('LDAP connection established!'))); - } -} - -ngModule.component('vnAccountLdap', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/ldap/locale/es.yml b/modules/account/front/ldap/locale/es.yml deleted file mode 100644 index 0353d6b72..000000000 --- a/modules/account/front/ldap/locale/es.yml +++ /dev/null @@ -1,8 +0,0 @@ -Enable synchronization: Habilitar sincronización -Server: Servidor -RDN: RDN -User DN: DN usuarios -Filter: Filtro -Group DN: DN grupos -Test connection: Probar conexión -LDAP connection established!: ¡Conexión con LDAP establecida! diff --git a/modules/account/front/mail-forwarding/index.html b/modules/account/front/mail-forwarding/index.html deleted file mode 100644 index df5cd80bf..000000000 --- a/modules/account/front/mail-forwarding/index.html +++ /dev/null @@ -1,49 +0,0 @@ -
- - -
- - - - - - - - - - - - - - - -
-
- Account not enabled -
diff --git a/modules/account/front/mail-forwarding/index.js b/modules/account/front/mail-forwarding/index.js deleted file mode 100644 index 5118e8eab..000000000 --- a/modules/account/front/mail-forwarding/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section {} - -ngModule.component('vnUserMailForwarding', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnUserCard' - }, -}); diff --git a/modules/account/front/mail-forwarding/locale/es.yml b/modules/account/front/mail-forwarding/locale/es.yml deleted file mode 100644 index 688ace6b5..000000000 --- a/modules/account/front/mail-forwarding/locale/es.yml +++ /dev/null @@ -1,7 +0,0 @@ -Mail forwarding: Reenvío de correo -Forward email: Dirección de reenvío -Enable mail forwarding: Habilitar redirección de correo -All emails will be forwarded to the specified address.: > - Todos los correos serán reenviados a la dirección especificada, no se - mantendrá copia de los mismos en el buzón del usuario. -You don't have enough privileges: No tienes suficientes permisos diff --git a/modules/account/front/main/index.html b/modules/account/front/main/index.html index 36b493ec4..e69de29bb 100644 --- a/modules/account/front/main/index.html +++ b/modules/account/front/main/index.html @@ -1,19 +0,0 @@ - - - - - - - - - - diff --git a/modules/account/front/main/index.js b/modules/account/front/main/index.js index a43ffb76b..335d71b42 100644 --- a/modules/account/front/main/index.js +++ b/modules/account/front/main/index.js @@ -4,32 +4,10 @@ import ModuleMain from 'salix/components/module-main'; export default class User extends ModuleMain { constructor($element, $) { super($element, $); - this.filter = { - fields: ['id', 'nickname', 'name', 'role'], - include: { - relation: 'role', - scope: { - fields: ['id', 'name'] - } - } - }; } - - exprBuilder(param, value) { - switch (param) { - case 'search': - return /^\d+$/.test(value) - ? {id: value} - : {or: [ - {name: {like: `%${value}%`}}, - {nickname: {like: `%${value}%`}} - ]}; - case 'name': - case 'nickname': - return {[param]: {like: `%${value}%`}}; - case 'roleFk': - return {[param]: value}; - } + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`account/`); } } diff --git a/modules/account/front/main/index.spec.js b/modules/account/front/main/index.spec.js deleted file mode 100644 index c232aa849..000000000 --- a/modules/account/front/main/index.spec.js +++ /dev/null @@ -1,28 +0,0 @@ -import './index'; - -describe('component vnUser', () => { - let controller; - - beforeEach(ngModule('account')); - - beforeEach(inject($componentController => { - controller = $componentController('vnUser', {$element: null}); - })); - - describe('exprBuilder()', () => { - it('should search by id when only digits string is passed', () => { - let expr = controller.exprBuilder('search', '1'); - - expect(expr).toEqual({id: '1'}); - }); - - it('should search by name when non-only digits string is passed', () => { - let expr = controller.exprBuilder('search', '1foo'); - - expect(expr).toEqual({or: [ - {name: {like: '%1foo%'}}, - {nickname: {like: '%1foo%'}} - ]}); - }); - }); -}); diff --git a/modules/account/front/privileges/index.html b/modules/account/front/privileges/index.html deleted file mode 100644 index 343c179e3..000000000 --- a/modules/account/front/privileges/index.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/account/front/privileges/index.js b/modules/account/front/privileges/index.js deleted file mode 100644 index f69428666..000000000 --- a/modules/account/front/privileges/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - get user() { - return this._user; - } - - set user(value) { - this._user = value; - if (!value) return; - } -} - -ngModule.component('vnUserPrivileges', { - template: require('./index.html'), - controller: Controller, - bindings: { - user: '<' - } -}); diff --git a/modules/account/front/privileges/locale/es.yml b/modules/account/front/privileges/locale/es.yml deleted file mode 100644 index d66a7a6cf..000000000 --- a/modules/account/front/privileges/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Privileges: Privilegios -Has grant: Puede delegar privilegios diff --git a/modules/account/front/role-log/index.html b/modules/account/front/role-log/index.html deleted file mode 100644 index 9e2b151b5..000000000 --- a/modules/account/front/role-log/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/modules/account/front/role-log/index.js b/modules/account/front/role-log/index.js deleted file mode 100644 index 02448ccaa..000000000 --- a/modules/account/front/role-log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnRoleLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/account/front/role/basic-data/index.html b/modules/account/front/role/basic-data/index.html deleted file mode 100644 index 846f8b455..000000000 --- a/modules/account/front/role/basic-data/index.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/modules/account/front/role/basic-data/index.js b/modules/account/front/role/basic-data/index.js deleted file mode 100644 index 4e26906ee..000000000 --- a/modules/account/front/role/basic-data/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section {} - -ngModule.component('vnRoleBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - role: '<' - } -}); diff --git a/modules/account/front/role/card/index.html b/modules/account/front/role/card/index.html deleted file mode 100644 index 2f51f88b5..000000000 --- a/modules/account/front/role/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/account/front/role/card/index.js b/modules/account/front/role/card/index.js deleted file mode 100644 index 3c7c758ef..000000000 --- a/modules/account/front/role/card/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - this.$http.get(`VnRoles/${this.$params.id}`) - .then(res => this.role = res.data); - } -} - -ngModule.vnComponent('vnRoleCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/role/card/index.spec.js b/modules/account/front/role/card/index.spec.js deleted file mode 100644 index 569fe487d..000000000 --- a/modules/account/front/role/card/index.spec.js +++ /dev/null @@ -1,25 +0,0 @@ -import './index'; - -describe('component vnRoleCard', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnRoleCard', {$element: null}); - })); - - describe('reload()', () => { - it('should reload the controller data', () => { - controller.$params.id = 1; - - $httpBackend.expectGET('VnRoles/1').respond('foo'); - controller.reload(); - $httpBackend.flush(); - - expect(controller.role).toBe('foo'); - }); - }); -}); diff --git a/modules/account/front/role/create/index.html b/modules/account/front/role/create/index.html deleted file mode 100644 index 77d6fc2c1..000000000 --- a/modules/account/front/role/create/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/modules/account/front/role/create/index.js b/modules/account/front/role/create/index.js deleted file mode 100644 index 3f7fcc9cf..000000000 --- a/modules/account/front/role/create/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onSubmit() { - return this.$.watcher.submit().then(res => - this.$state.go('account.role.card.basicData', {id: res.data.id}) - ); - } -} - -ngModule.component('vnRoleCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/role/descriptor/index.html b/modules/account/front/role/descriptor/index.html deleted file mode 100644 index d8bf4857a..000000000 --- a/modules/account/front/role/descriptor/index.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - Delete - - - -
- - -
-
-
- - diff --git a/modules/account/front/role/descriptor/index.js b/modules/account/front/role/descriptor/index.js deleted file mode 100644 index 17b585cb7..000000000 --- a/modules/account/front/role/descriptor/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import ngModule from '../../module'; -import Descriptor from 'salix/components/descriptor'; - -class Controller extends Descriptor { - get role() { - return this.entity; - } - - set role(value) { - this.entity = value; - } - - onDelete() { - return this.$http.delete(`VnRoles/${this.id}`) - .then(() => this.$state.go('account.role')) - .then(() => this.vnApp.showSuccess(this.$t('Role removed'))); - } -} - -ngModule.component('vnRoleDescriptor', { - template: require('./index.html'), - controller: Controller, - bindings: { - role: '<' - } -}); diff --git a/modules/account/front/role/descriptor/index.spec.js b/modules/account/front/role/descriptor/index.spec.js deleted file mode 100644 index f3b2e4763..000000000 --- a/modules/account/front/role/descriptor/index.spec.js +++ /dev/null @@ -1,29 +0,0 @@ -import './index'; - -describe('component vnRoleDescriptor', () => { - let controller; - let $httpBackend; - - let role = {id: 1, name: 'foo'}; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnRoleDescriptor', {$element: null}, {role}); - })); - - describe('onDelete()', () => { - it('should delete entity and go to index', () => { - controller.$state.go = jest.fn(); - jest.spyOn(controller.vnApp, 'showSuccess'); - - $httpBackend.expectDELETE('VnRoles/1').respond(); - controller.onDelete(); - $httpBackend.flush(); - - expect(controller.$state.go).toHaveBeenCalledWith('account.role'); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); -}); diff --git a/modules/account/front/role/descriptor/locale/es.yml b/modules/account/front/role/descriptor/locale/es.yml deleted file mode 100644 index 1ca512e4f..000000000 --- a/modules/account/front/role/descriptor/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Role will be removed: El rol va a ser eliminado -Role removed: Rol eliminado \ No newline at end of file diff --git a/modules/account/front/role/index.js b/modules/account/front/role/index.js deleted file mode 100644 index 97a20d3bc..000000000 --- a/modules/account/front/role/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import './main'; -import './index/'; -import './summary'; -import './card'; -import './descriptor'; -import './search-panel'; -import './create'; -import './basic-data'; -import './subroles'; -import './inherited'; diff --git a/modules/account/front/role/index/index.html b/modules/account/front/role/index/index.html deleted file mode 100644 index 4c4c6b0ad..000000000 --- a/modules/account/front/role/index/index.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/account/front/role/index/index.js b/modules/account/front/role/index/index.js deleted file mode 100644 index 40773b23b..000000000 --- a/modules/account/front/role/index/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - preview(role) { - this.selectedRole = role; - this.$.summary.show(); - } -} - -ngModule.component('vnRoleIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/role/index/locale/es.yml b/modules/account/front/role/index/locale/es.yml deleted file mode 100644 index 70932e983..000000000 --- a/modules/account/front/role/index/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -New role: Nuevo rol -View role: Ver rol \ No newline at end of file diff --git a/modules/account/front/role/inherited/index.html b/modules/account/front/role/inherited/index.html deleted file mode 100644 index 83ecbbff4..000000000 --- a/modules/account/front/role/inherited/index.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - -
- {{::row.inherits.name}} -
-
- {{::row.inherits.description}} -
-
-
-
-
-
diff --git a/modules/account/front/role/inherited/index.js b/modules/account/front/role/inherited/index.js deleted file mode 100644 index 5927493ee..000000000 --- a/modules/account/front/role/inherited/index.js +++ /dev/null @@ -1,23 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - let filter = { - where: {role: this.$params.id}, - include: { - relation: 'inherits', - scope: { - fields: ['id', 'name', 'description'] - } - } - }; - this.$http.get('RoleRoles', {filter}) - .then(res => this.$.data = res.data); - } -} - -ngModule.component('vnRoleInherited', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/role/inherited/index.spec.js b/modules/account/front/role/inherited/index.spec.js deleted file mode 100644 index 16b0c53b2..000000000 --- a/modules/account/front/role/inherited/index.spec.js +++ /dev/null @@ -1,23 +0,0 @@ -import './index'; - -describe('component vnRoleInherited', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnRoleInherited', {$element: null}); - })); - - describe('$onInit()', () => { - it('should delete entity and go to index', () => { - $httpBackend.expectGET('RoleRoles').respond('foo'); - controller.$onInit(); - $httpBackend.flush(); - - expect(controller.$.data).toBe('foo'); - }); - }); -}); diff --git a/modules/account/front/role/locale/es.yml b/modules/account/front/role/locale/es.yml deleted file mode 100644 index 159fc7f16..000000000 --- a/modules/account/front/role/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Subroles: Subroles diff --git a/modules/account/front/role/main/index.html b/modules/account/front/role/main/index.html deleted file mode 100644 index cfef28e57..000000000 --- a/modules/account/front/role/main/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - diff --git a/modules/account/front/role/main/index.js b/modules/account/front/role/main/index.js deleted file mode 100644 index 77d15cf17..000000000 --- a/modules/account/front/role/main/index.js +++ /dev/null @@ -1,24 +0,0 @@ -import ngModule from '../../module'; -import ModuleMain from 'salix/components/module-main'; - -export default class Role extends ModuleMain { - exprBuilder(param, value) { - switch (param) { - case 'search': - return /^\d+$/.test(value) - ? {id: value} - : {or: [ - {name: {like: `%${value}%`}}, - {nickname: {like: `%${value}%`}} - ]}; - case 'name': - case 'description': - return {[param]: {like: `%${value}%`}}; - } - } -} - -ngModule.vnComponent('vnRole', { - controller: Role, - template: require('./index.html') -}); diff --git a/modules/account/front/role/search-panel/index.html b/modules/account/front/role/search-panel/index.html deleted file mode 100644 index dfea9f01c..000000000 --- a/modules/account/front/role/search-panel/index.html +++ /dev/null @@ -1,21 +0,0 @@ -
-
- - - - - - - - - - - - -
\ No newline at end of file diff --git a/modules/account/front/role/search-panel/index.js b/modules/account/front/role/search-panel/index.js deleted file mode 100644 index 35da591ad..000000000 --- a/modules/account/front/role/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.component('vnRoleSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/account/front/role/subroles/index.html b/modules/account/front/role/subroles/index.html deleted file mode 100644 index eba1002b0..000000000 --- a/modules/account/front/role/subroles/index.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - -
- {{::row.inherits.name}} -
-
- {{::row.inherits.description}} -
-
- - - - -
-
-
-
- - - - - - - - - - - - - - diff --git a/modules/account/front/role/subroles/index.js b/modules/account/front/role/subroles/index.js deleted file mode 100644 index b7e1caaa4..000000000 --- a/modules/account/front/role/subroles/index.js +++ /dev/null @@ -1,51 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - this.refresh(); - } - - get path() { - return `RoleInherits`; - } - - refresh() { - let filter = { - where: {role: this.$params.id}, - include: { - relation: 'inherits', - scope: { - fields: ['id', 'name', 'description'] - } - } - }; - this.$http.get(this.path, {filter}) - .then(res => this.$.data = res.data); - } - - onAddClick() { - this.addData = {role: this.$params.id}; - this.$.dialog.show(); - } - - onAddSave() { - return this.$http.post(this.path, this.addData) - .then(() => this.refresh()) - .then(() => this.vnApp.showSuccess(this.$t('Role added! Changes will take a while to fully propagate.'))); - } - - onRemove(row) { - return this.$http.delete(`${this.path}/${row.id}`) - .then(() => { - let index = this.$.data.indexOf(row); - if (index !== -1) this.$.data.splice(index, 1); - this.vnApp.showSuccess(this.$t('Role removed. Changes will take a while to fully propagate.')); - }); - } -} - -ngModule.component('vnRoleSubroles', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/role/subroles/index.spec.js b/modules/account/front/role/subroles/index.spec.js deleted file mode 100644 index e7d9a4d0e..000000000 --- a/modules/account/front/role/subroles/index.spec.js +++ /dev/null @@ -1,53 +0,0 @@ -import './index'; - -describe('component vnRoleSubroles', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnRoleSubroles', {$element: null}); - jest.spyOn(controller.vnApp, 'showSuccess'); - })); - - describe('refresh()', () => { - it('should delete entity and go to index', () => { - $httpBackend.expectGET('RoleInherits').respond('foo'); - controller.refresh(); - $httpBackend.flush(); - - expect(controller.$.data).toBe('foo'); - }); - }); - - describe('onAddSave()', () => { - it('should add a subrole', () => { - controller.addData = {role: 'foo'}; - - $httpBackend.expectPOST('RoleInherits', {role: 'foo'}).respond(); - $httpBackend.expectGET('RoleInherits').respond(); - controller.onAddSave(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('onRemove()', () => { - it('should remove a subrole', () => { - controller.$.data = [ - {id: 1, name: 'foo'}, - {id: 2, name: 'bar'} - ]; - - $httpBackend.expectDELETE('RoleInherits/1').respond(); - controller.onRemove(controller.$.data[0]); - $httpBackend.flush(); - - expect(controller.$.data).toEqual([{id: 2, name: 'bar'}]); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); -}); diff --git a/modules/account/front/role/subroles/locale/es.yml b/modules/account/front/role/subroles/locale/es.yml deleted file mode 100644 index 170882405..000000000 --- a/modules/account/front/role/subroles/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -Role added! Changes will take a while to fully propagate.: > - ¡Rol añadido! Los cambios tardaran un tiempo en propagarse completamente. -Role removed. Changes will take a while to fully propagate.: > - Rol eliminado. Los cambios tardaran un tiempo en propagarse completamente. diff --git a/modules/account/front/role/summary/index.html b/modules/account/front/role/summary/index.html deleted file mode 100644 index f7971190c..000000000 --- a/modules/account/front/role/summary/index.html +++ /dev/null @@ -1,20 +0,0 @@ - -
{{summary.name}}
- - -

Basic data

- - - - - - -
-
-
\ No newline at end of file diff --git a/modules/account/front/role/summary/index.js b/modules/account/front/role/summary/index.js deleted file mode 100644 index 6c649a68f..000000000 --- a/modules/account/front/role/summary/index.js +++ /dev/null @@ -1,24 +0,0 @@ -import ngModule from '../../module'; -import Component from 'core/lib/component'; - -class Controller extends Component { - set role(value) { - this._role = value; - this.$.summary = null; - if (!value) return; - this.$http.get(`VnRoles/${value.id}`) - .then(res => this.$.summary = res.data); - } - - get role() { - return this._role; - } -} - -ngModule.component('vnRoleSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - role: '<' - } -}); diff --git a/modules/account/front/roles/index.html b/modules/account/front/roles/index.html deleted file mode 100644 index 8c8583929..000000000 --- a/modules/account/front/roles/index.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - -
- {{::row.role.name}} -
-
- {{::row.role.description}} -
-
-
-
-
-
diff --git a/modules/account/front/roles/index.js b/modules/account/front/roles/index.js deleted file mode 100644 index 0982dcf10..000000000 --- a/modules/account/front/roles/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - let filter = { - where: { - prindicpalType: 'USER', - principalId: this.$params.id - }, - include: { - relation: 'role', - scope: { - fields: ['id', 'name', 'description'] - } - } - }; - this.$http.get('RoleMappings', {filter}) - .then(res => this.$.data = res.data); - } -} - -ngModule.component('vnUserRoles', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/routes.json b/modules/account/front/routes.json index d7845090b..9eadf2af2 100644 --- a/modules/account/front/routes.json +++ b/modules/account/front/routes.json @@ -7,31 +7,6 @@ "menus": { "main": [ {"state": "account.index", "icon": "face"}, - {"state": "account.role", "icon": "group"}, - {"state": "account.alias", "icon": "email"}, - {"state": "account.accounts", "icon": "accessibility"}, - {"state": "account.ldap", "icon": "account_tree"}, - {"state": "account.samba", "icon": "preview"}, - {"state": "account.acl", "icon": "check"}, - {"state": "account.connections", "icon": "share"} - ], - "card": [ - {"state": "account.card.basicData", "icon": "settings"}, - {"state": "account.card.roles", "icon": "group"}, - {"state": "account.card.mailForwarding", "icon": "forward"}, - {"state": "account.card.aliases", "icon": "email"}, - {"state": "account.card.privileges", "icon": "badge"}, - {"state": "account.card.log", "icon": "history"} - ], - "role": [ - {"state": "account.role.card.basicData", "icon": "settings"}, - {"state": "account.role.card.subroles", "icon": "groups"}, - {"state": "account.role.card.inherited", "icon": "account_tree"}, - {"state": "account.role.card.log", "icon": "history"} - ], - "alias": [ - {"state": "account.alias.card.basicData", "icon": "settings"}, - {"state": "account.alias.card.users", "icon": "groups"} ] }, "keybindings": [ @@ -50,224 +25,6 @@ "state": "account.index", "component": "vn-user-index", "description": "Users" - }, - { - "url": "/create", - "state": "account.create", - "component": "vn-user-create", - "description": "New user" - }, - { - "url": "/:id", - "state": "account.card", - "component": "vn-user-card", - "abstract": true, - "description": "Detail" - }, - { - "url": "/summary", - "state": "account.card.summary", - "component": "vn-user-summary", - "description": "Summary", - "params": { - "user": "$ctrl.user" - } - }, - { - "url": "/basic-data?emailConfirmed", - "state": "account.card.basicData", - "component": "vn-user-basic-data", - "description": "Basic data", - "params": { - "user": "$ctrl.user" - } - }, - { - "url" : "/log", - "state": "account.card.log", - "component": "vn-user-log", - "description": "Log" - }, - { - "url" : "/log", - "state": "account.role.card.log", - "component": "vn-role-log", - "description": "Log" - }, - { - "url": "/roles", - "state": "account.card.roles", - "component": "vn-user-roles", - "description": "Inherited roles" - }, - { - "url": "/mail-forwarding", - "state": "account.card.mailForwarding", - "component": "vn-user-mail-forwarding", - "description": "Mail forwarding" - }, - { - "url": "/aliases", - "state": "account.card.aliases", - "component": "vn-user-aliases", - "description": "Mail aliases" - }, - { - "url": "/privileges", - "state": "account.card.privileges", - "component": "vn-user-privileges", - "description": "Privileges", - "params": { - "user": "$ctrl.user" - } - }, - { - "url": "/role?q", - "state": "account.role", - "component": "vn-role", - "description": "Roles", - "acl": ["it"] - }, - { - "url": "/create", - "state": "account.role.create", - "component": "vn-role-create", - "description": "New role", - "acl": ["it"] - }, - { - "url": "/:id", - "state": "account.role.card", - "component": "vn-role-card", - "abstract": true, - "description": "Detail" - }, - { - "url": "/summary", - "state": "account.role.card.summary", - "component": "vn-role-summary", - "description": "Summary", - "params": { - "role": "$ctrl.role" - }, - "acl": ["it"] - }, - { - "url": "/basic-data", - "state": "account.role.card.basicData", - "component": "vn-role-basic-data", - "description": "Basic data", - "params": { - "role": "$ctrl.role" - }, - "acl": ["it"] - }, - { - "url": "/subroles", - "state": "account.role.card.subroles", - "component": "vn-role-subroles", - "description": "Subroles", - "acl": ["it"] - }, - { - "url": "/inherited", - "state": "account.role.card.inherited", - "component": "vn-role-inherited", - "description": "Inherited roles", - "acl": ["it"] - }, - { - "url": "/alias?q", - "state": "account.alias", - "component": "vn-alias", - "description": "Mail aliases" - }, - { - "url": "/create", - "state": "account.alias.create", - "component": "vn-alias-create", - "description": "New alias" - }, - { - "url": "/:id", - "state": "account.alias.card", - "component": "vn-alias-card", - "abstract": true, - "description": "Detail" - }, - { - "url": "/summary", - "state": "account.alias.card.summary", - "component": "vn-alias-summary", - "description": "Summary", - "params": { - "alias": "$ctrl.alias" - } - }, - { - "url": "/basic-data", - "state": "account.alias.card.basicData", - "component": "vn-alias-basic-data", - "description": "Basic data", - "params": { - "alias": "$ctrl.alias" - } - }, - { - "url": "/users", - "state": "account.alias.card.users", - "component": "vn-alias-users", - "description": "Users", - "acl": ["it"] - }, - { - "url": "/accounts", - "state": "account.accounts", - "component": "vn-account-accounts", - "description": "Accounts", - "acl": ["sysadmin"] - }, - { - "url": "/ldap", - "state": "account.ldap", - "component": "vn-account-ldap", - "description": "LDAP", - "acl": ["sysadmin"] - }, - { - "url": "/samba", - "state": "account.samba", - "component": "vn-account-samba", - "description": "Samba", - "acl": ["sysadmin"] - }, - { - "url": "/acl?q", - "state": "account.acl", - "component": "vn-acl-component", - "description": "ACLs", - "acl": ["developer"] - }, - { - "url": "/create", - "state": "account.acl.create", - "component": "vn-acl-create", - "description": "New ACL", - "acl": ["developer"] - }, - { - "url": "/:id/edit", - "state": "account.acl.edit", - "component": "vn-acl-create", - "description": "Edit ACL", - "acl": ["developer"] - }, - { - "url": "/connections", - "state": "account.connections", - "component": "vn-connections", - "description": "Connections", - "acl": ["developer"] } ] } diff --git a/modules/account/front/samba/index.html b/modules/account/front/samba/index.html deleted file mode 100644 index 0186cac7c..000000000 --- a/modules/account/front/samba/index.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/account/front/samba/index.js b/modules/account/front/samba/index.js deleted file mode 100644 index 6a4969893..000000000 --- a/modules/account/front/samba/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onTestConection() { - this.$http.get(`SambaConfigs/test`) - .then(() => this.vnApp.showSuccess(this.$t('Samba connection established!'))); - } -} - -ngModule.component('vnAccountSamba', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/samba/locale/es.yml b/modules/account/front/samba/locale/es.yml deleted file mode 100644 index efa3b1597..000000000 --- a/modules/account/front/samba/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Enable synchronization: Habilitar sincronización -Domain controller: Controlador de dominio -AD domain: Dominio AD -AD user: Usuario AD -AD password: Contraseña AD -User DN (without domain part): DN usuarios (sin la parte del dominio) -Verify certificate: Verificar certificado -Test connection: Probar conexión -Samba connection established!: ¡Conexión con Samba establecida! diff --git a/modules/account/front/search-panel/index.html b/modules/account/front/search-panel/index.html deleted file mode 100644 index a539d9657..000000000 --- a/modules/account/front/search-panel/index.html +++ /dev/null @@ -1,31 +0,0 @@ -
-
- - - - - - - - - - - - - - - - -
diff --git a/modules/account/front/search-panel/index.js b/modules/account/front/search-panel/index.js deleted file mode 100644 index fff3bf7b9..000000000 --- a/modules/account/front/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.component('vnUserSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/account/front/summary/index.html b/modules/account/front/summary/index.html index 41632aef6..f3c11f25f 100644 --- a/modules/account/front/summary/index.html +++ b/modules/account/front/summary/index.html @@ -1,6 +1,6 @@
-

- Basic Data

Basic Data

-
\ No newline at end of file + diff --git a/modules/account/front/user-log/index.html b/modules/account/front/user-log/index.html deleted file mode 100644 index 5a77ed7b9..000000000 --- a/modules/account/front/user-log/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/modules/account/front/user-log/index.js b/modules/account/front/user-log/index.js deleted file mode 100644 index 7cd0bb378..000000000 --- a/modules/account/front/user-log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnUserLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js index b05b2ac15..156caaeec 100644 --- a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js +++ b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js @@ -6,6 +6,7 @@ describe('claimBeginning', () => { const claimManagerId = 72; const activeCtx = { accessToken: {userId: claimManagerId}, + __: value => value }; const ctx = {req: activeCtx}; diff --git a/modules/claim/back/methods/claim-beginning/specs/claim-beginning.spec.js b/modules/claim/back/methods/claim-beginning/specs/claim-beginning.spec.js new file mode 100644 index 000000000..b7974ad23 --- /dev/null +++ b/modules/claim/back/methods/claim-beginning/specs/claim-beginning.spec.js @@ -0,0 +1,55 @@ +const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); + +describe('ClaimBeginning model()', () => { + const claimFk = 1; + const activeCtx = { + accessToken: {userId: 18}, + headers: {origin: 'localhost:5000'}, + __: () => {} + }; + + beforeEach(() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + + it('should change quantity claimed', async() => { + const tx = await models.ClaimBeginning.beginTransaction({}); + + let error; + try { + const options = {transaction: tx}; + const claim = await models.ClaimBeginning.findOne({where: {claimFk}}, options); + const sale = await models.Sale.findById(claim.saleFk, {}, options); + await claim.updateAttribute('quantity', sale.quantity - 1, options); + + await tx.rollback(); + } catch (e) { + error = e; + await tx.rollback(); + } + + expect(error).toBeUndefined(); + }); + + it('should throw error when quantity claimed is greater than quantity of the sale', async() => { + const tx = await models.ClaimBeginning.beginTransaction({}); + + let error; + try { + const options = {transaction: tx}; + const claim = await models.ClaimBeginning.findOne({where: {claimFk}}, options); + const sale = await models.Sale.findById(claim.saleFk, {}, options); + await claim.updateAttribute('quantity', sale.quantity + 1, options); + + await tx.rollback(); + } catch (e) { + error = e; + await tx.rollback(); + } + + expect(error.toString()).toContain('The quantity claimed cannot be greater than the quantity of the line'); + }); +}); diff --git a/modules/claim/back/methods/claim/specs/filter.spec.js b/modules/claim/back/methods/claim/specs/filter.spec.js index 872f49aa3..1ef808e9d 100644 --- a/modules/claim/back/methods/claim/specs/filter.spec.js +++ b/modules/claim/back/methods/claim/specs/filter.spec.js @@ -2,15 +2,7 @@ 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'} - } - }; - }); + const ctx = beforeAll.getCtx(); it('should return 1 result filtering by id', async() => { const tx = await app.models.Claim.beginTransaction({}); diff --git a/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js b/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js index 95c356374..55d76ed7a 100644 --- a/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js +++ b/modules/claim/back/methods/claim/specs/regularizeClaim.spec.js @@ -1,18 +1,11 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('claim regularizeClaim()', () => { const userId = 18; - const ctx = { - req: { - accessToken: {userId: userId}, - headers: {origin: 'http://localhost'} - } - }; + const ctx = beforeAll.mockLoopBackContext(userId); ctx.req.__ = (value, params) => { return params.nickname; }; - const chatModel = models.Chat; const claimId = 1; const ticketId = 1; @@ -40,20 +33,6 @@ describe('claim regularizeClaim()', () => { return await models.ClaimEnd.create(claimEnds, options); } - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); - it('should send a chat message with value "Trash" and then change claim state to resolved', async() => { const tx = await models.Claim.beginTransaction({}); diff --git a/modules/claim/back/methods/claim/specs/updateClaim.spec.js b/modules/claim/back/methods/claim/specs/updateClaim.spec.js index b7725e7f8..e1eec59d1 100644 --- a/modules/claim/back/methods/claim/specs/updateClaim.spec.js +++ b/modules/claim/back/methods/claim/specs/updateClaim.spec.js @@ -1,22 +1,10 @@ const app = require('vn-loopback/server/server'); -const LoopBackContext = require('loopback-context'); const i18n = require('i18n'); describe('Update Claim', () => { let url; let claimStatesMap = {}; + beforeAll.mockLoopBackContext(); beforeAll(async() => { - url = await app.models.Url.getUrl(); - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); const claimStates = await app.models.ClaimState.find(); claimStatesMap = claimStates.reduce((acc, state) => ({...acc, [state.code]: state.id}), {}); }); diff --git a/modules/claim/back/methods/claim/specs/updateClaimAction.spec.js b/modules/claim/back/methods/claim/specs/updateClaimAction.spec.js index 99436fed6..bc081ed08 100644 --- a/modules/claim/back/methods/claim/specs/updateClaimAction.spec.js +++ b/modules/claim/back/methods/claim/specs/updateClaimAction.spec.js @@ -1,20 +1,7 @@ const app = require('vn-loopback/server/server'); -const LoopBackContext = require('loopback-context'); describe('Update Claim', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); const newDate = Date.vnNew(); const original = { ticketFk: 3, diff --git a/modules/claim/back/methods/claim/updateClaim.js b/modules/claim/back/methods/claim/updateClaim.js index a206d7f3e..326192385 100644 --- a/modules/claim/back/methods/claim/updateClaim.js +++ b/modules/claim/back/methods/claim/updateClaim.js @@ -69,34 +69,32 @@ module.exports = Self => { } } }, myOptions); - // Get sales person from claim client - const salesPerson = claim.client().salesPersonUser(); - const changedPickup = args.pickup != claim.pickup; + const changedPickup = args.pickup && args.pickup != claim.pickup; - // Validate when claimState has been changed if (args.claimStateFk) { const canEditOldState = await models.ClaimState.isEditable(ctx, claim.claimStateFk, myOptions); const canEditNewState = await models.ClaimState.isEditable(ctx, args.claimStateFk, myOptions); - const canEditState = await models.ACL.checkAccessAcl(ctx, 'Claim', 'editState', 'WRITE'); + const canEditPickup = await models.ACL.checkAccessAcl(ctx, 'Claim', 'editPickup', 'WRITE'); - if (!canEditOldState || !canEditNewState || changedPickup && !canEditState) + if (!canEditOldState || !canEditNewState || (changedPickup && !canEditPickup)) throw new UserError(`You don't have enough privileges to change that field`); } delete args.ctx; const updatedClaim = await claim.updateAttributes(args, myOptions); - // When pickup has been changed - if (salesPerson && changedPickup && updatedClaim.pickup) - await notifyPickUp(ctx, salesPerson.id, claim); + const salesPerson = claim.client().salesPersonUser(); + if (salesPerson) { + if (changedPickup && updatedClaim.pickup) + await notifyPickUp(ctx, salesPerson.id, claim); - // When claimState has been changed - if (args.claimStateFk) { - const newState = await models.ClaimState.findById(args.claimStateFk, null, myOptions); - await notifyStateChange(ctx, salesPerson.id, claim, newState.description); - if (newState.code == 'canceled') - await notifyStateChange(ctx, claim.workerFk, claim, newState.description); + if (args.claimStateFk) { + const newState = await models.ClaimState.findById(args.claimStateFk, null, myOptions); + await notifyStateChange(ctx, salesPerson.id, claim, newState.description); + if (newState.code == 'canceled') + await notifyStateChange(ctx, claim.workerFk, claim, newState.description); + } } if (tx) await tx.commit(); @@ -111,7 +109,7 @@ module.exports = Self => { async function notifyStateChange(ctx, workerId, claim, newState) { const models = Self.app.models; const url = await models.Url.getUrl(); - const $t = ctx.req.__; // $translate + const $t = ctx.req.__; const message = $t(`Claim state has changed to`, { claimId: claim.id, diff --git a/modules/claim/back/models/claim-beginning.js b/modules/claim/back/models/claim-beginning.js index d269b2285..3dc9261c3 100644 --- a/modules/claim/back/models/claim-beginning.js +++ b/modules/claim/back/models/claim-beginning.js @@ -10,16 +10,21 @@ module.exports = Self => { }); Self.observe('before save', async ctx => { + const options = ctx.options; + const models = Self.app.models; + const saleFk = ctx?.currentInstance?.saleFk || ctx?.instance?.saleFk; + const sale = await models.Sale.findById(saleFk, {fields: ['ticketFk', 'quantity']}, options); + if (ctx.isNewInstance) { - const models = Self.app.models; - const options = ctx.options; - const instance = ctx.instance; - const ticket = await models.Sale.findById(instance.saleFk, {fields: ['ticketFk']}, options); - const claim = await models.Claim.findById(instance.claimFk, {fields: ['ticketFk']}, options); - if (ticket.ticketFk != claim.ticketFk) + const claim = await models.Claim.findById(ctx.instance.claimFk, {fields: ['ticketFk']}, options); + if (sale.ticketFk != claim.ticketFk) throw new UserError(`Cannot create a new claimBeginning from a different ticket`); } + await claimIsEditable(ctx); + + if (sale?.quantity && ctx.data?.quantity && ctx.data.quantity > sale?.quantity) + throw new UserError('The quantity claimed cannot be greater than the quantity of the line'); }); Self.observe('before delete', async ctx => { diff --git a/modules/claim/front/action/index.html b/modules/claim/front/action/index.html deleted file mode 100644 index 9da51b8de..000000000 --- a/modules/claim/front/action/index.html +++ /dev/null @@ -1,188 +0,0 @@ - - - - - - - - - - - -
- - - - - - - - - - -
-
- -
Id ColaRuta ImpresoraInformeEstadoTrabajadorError
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - IdTicket - Destination - - Landed - - Quantity - - Description - - Price - - Disc. - Total
- - - - - {{::saleClaimed.itemFk}} - - - - {{::saleClaimed.ticketFk}} - - - - - {{::saleClaimed.landed | date: 'dd/MM/yyyy'}}{{::saleClaimed.quantity}}{{::saleClaimed.concept}}{{::saleClaimed.price | currency: 'EUR':2}}{{::saleClaimed.discount}} %{{saleClaimed.total | currency: 'EUR':2}} - - -
- - - - - - - - - - - - - - - - - -
-
{{$ctrl.$t('Change destination to all selected rows', {total: $ctrl.checked.length})}}
- - - - -
-
- - - - -
diff --git a/modules/claim/front/action/index.js b/modules/claim/front/action/index.js deleted file mode 100644 index 10b629f27..000000000 --- a/modules/claim/front/action/index.js +++ /dev/null @@ -1,233 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.newDestination; - this.filter = { - include: [ - {relation: 'sale', - scope: { - fields: ['concept', 'ticketFk', 'price', 'quantity', 'discount', 'itemFk'], - include: { - relation: 'ticket' - } - } - }, - {relation: 'claimBeggining'}, - {relation: 'claimDestination'} - ] - }; - this.getResolvedState(); - this.maxResponsibility = 5; - this.smartTableOptions = { - activeButtons: { - search: true - }, - columns: [ - { - field: 'claimDestinationFk', - autocomplete: { - url: 'ClaimDestinations', - showField: 'description', - valueField: 'id' - } - }, - { - field: 'landed', - searchable: false - } - ] - }; - } - - exprBuilder(param, value) { - switch (param) { - case 'itemFk': - case 'ticketFk': - case 'claimDestinationFk': - case 'quantity': - case 'price': - case 'discount': - case 'total': - return {[param]: value}; - case 'concept': - return {[param]: {like: `%${value}%`}}; - case 'landed': - return {[param]: {between: this.dateRange(value)}}; - } - } - - dateRange(value) { - const minHour = new Date(value); - minHour.setHours(0, 0, 0, 0); - const maxHour = new Date(value); - maxHour.setHours(23, 59, 59, 59); - - return [minHour, maxHour]; - } - - get checked() { - const salesClaimed = this.$.model.data || []; - - const checkedSalesClaimed = []; - for (let saleClaimed of salesClaimed) { - if (saleClaimed.$checked) - checkedSalesClaimed.push(saleClaimed); - } - - return checkedSalesClaimed; - } - - updateDestination(saleClaimed, claimDestinationFk) { - const data = {rows: [saleClaimed], claimDestinationFk: claimDestinationFk}; - this.$http.post(`Claims/updateClaimDestination`, data).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - }).catch(e => { - this.$.model.refresh(); - throw e; - }); - } - - removeSales(saleClaimed) { - const params = {sales: [saleClaimed]}; - this.$http.post(`ClaimEnds/deleteClamedSales`, params).then(() => { - this.$.model.refresh(); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - getResolvedState() { - const query = `ClaimStates/findOne`; - const params = { - filter: { - where: { - code: 'resolved' - } - } - }; - this.$http.get(query, params).then(res => - this.resolvedStateId = res.data.id - ); - } - - importToNewRefundTicket() { - let query = `ClaimBeginnings/${this.$params.id}/importToNewRefundTicket`; - return this.$http.post(query).then(() => { - this.$.model.refresh(); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - focusLastInput() { - let inputs = document.querySelectorAll('#claimDestinationFk'); - inputs[inputs.length - 1].querySelector('input').focus(); - this.calculateTotals(); - } - - calculateTotals() { - this.claimedTotal = 0; - this.salesClaimed.forEach(sale => { - const price = sale.quantity * sale.price; - const discount = (sale.discount * (sale.quantity * sale.price)) / 100; - this.claimedTotal += price - discount; - }); - } - - regularize() { - const query = `Claims/${this.$params.id}/regularizeClaim`; - return this.$http.post(query).then(() => { - if (this.claim.responsibility >= Math.ceil(this.maxResponsibility) / 2) - this.$.updateGreuge.show(); - else - this.vnApp.showSuccess(this.$t('Data saved!')); - - this.card.reload(); - }); - } - - getGreugeTypeId() { - const params = {filter: {where: {code: 'freightPickUp'}}}; - const query = `GreugeTypes/findOne`; - return this.$http.get(query, {params}).then(res => { - this.greugeTypeFreightId = res.data.id; - - return res; - }); - } - - getGreugeConfig() { - const query = `GreugeConfigs/findOne`; - return this.$http.get(query).then(res => { - this.freightPickUpPrice = res.data.freightPickUpPrice; - - return res; - }); - } - - onUpdateGreugeAccept() { - const promises = []; - promises.push(this.getGreugeTypeId()); - promises.push(this.getGreugeConfig()); - - return Promise.all(promises).then(() => { - return this.updateGreuge({ - clientFk: this.claim.clientFk, - description: this.$t('ClaimGreugeDescription', { - claimId: this.claim.id - }).toUpperCase(), - amount: this.freightPickUpPrice, - greugeTypeFk: this.greugeTypeFreightId, - ticketFk: this.claim.ticketFk - }); - }); - } - - updateGreuge(data) { - return this.$http.post(`Greuges`, data).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.vnApp.showMessage(this.$t('Greuge added')); - }); - } - - save(data) { - const query = `Claims/${this.$params.id}/updateClaimAction`; - this.$http.patch(query, data) - .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); - } - - onSave() { - this.vnApp.showSuccess(this.$t('Data saved!')); - } - - onResponse() { - const rowsToEdit = []; - for (let row of this.checked) - rowsToEdit.push({id: row.id}); - - const data = { - rows: rowsToEdit, - claimDestinationFk: this.newDestination - }; - - const query = `Claims/updateClaimDestination`; - this.$http.post(query, data) - .then(() => { - this.$.model.refresh(); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } -} - -ngModule.vnComponent('vnClaimAction', { - template: require('./index.html'), - controller: Controller, - bindings: { - claim: '<' - }, - require: { - card: '^vnClaimCard' - } -}); diff --git a/modules/claim/front/action/index.spec.js b/modules/claim/front/action/index.spec.js deleted file mode 100644 index e773511bf..000000000 --- a/modules/claim/front/action/index.spec.js +++ /dev/null @@ -1,167 +0,0 @@ -import './index.js'; -import crudModel from 'core/mocks/crud-model'; - -describe('claim', () => { - describe('Component vnClaimAction', () => { - let controller; - let $httpBackend; - let $state; - - beforeEach(ngModule('claim')); - - beforeEach(inject(($componentController, _$state_, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $state = _$state_; - $state.params.id = 1; - - controller = $componentController('vnClaimAction', {$element: null}); - controller.claim = {ticketFk: 1}; - controller.$.model = {refresh: () => {}}; - controller.$.addSales = { - hide: () => {}, - show: () => {} - }; - controller.$.lastTicketsModel = crudModel; - controller.$.lastTicketsPopover = { - hide: () => {}, - show: () => {} - }; - controller.card = {reload: () => {}}; - $httpBackend.expectGET(`ClaimStates/findOne`).respond({}); - })); - - describe('getResolvedState()', () => { - it('should return the resolved state id', () => { - $httpBackend.expectGET(`ClaimStates/findOne`).respond({id: 1}); - controller.getResolvedState(); - $httpBackend.flush(); - - expect(controller.resolvedStateId).toEqual(1); - }); - }); - - describe('calculateTotals()', () => { - it('should calculate the total price of the items claimed', () => { - controller.salesClaimed = [ - {quantity: 5, price: 2, discount: 0}, - {quantity: 10, price: 2, discount: 0}, - {quantity: 10, price: 2, discount: 0} - ]; - controller.calculateTotals(); - - expect(controller.claimedTotal).toEqual(50); - }); - }); - - describe('importToNewRefundTicket()', () => { - it('should perform a post query and add lines from a new ticket', () => { - jest.spyOn(controller.$.model, 'refresh'); - jest.spyOn(controller.vnApp, 'showSuccess'); - - $httpBackend.expect('POST', `ClaimBeginnings/1/importToNewRefundTicket`).respond({}); - controller.importToNewRefundTicket(); - $httpBackend.flush(); - - expect(controller.$.model.refresh).toHaveBeenCalled(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('regularize()', () => { - it('should perform a post query and reload the claim card', () => { - jest.spyOn(controller.card, 'reload'); - jest.spyOn(controller.vnApp, 'showSuccess'); - - $httpBackend.expect('POST', `Claims/1/regularizeClaim`).respond({}); - controller.regularize(); - $httpBackend.flush(); - - expect(controller.card.reload).toHaveBeenCalledWith(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('save()', () => { - it('should perform a patch query and show a success message', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - - const data = {pickup: 'agency'}; - $httpBackend.expect('PATCH', `Claims/1/updateClaimAction`, data).respond({}); - controller.save(data); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('onUpdateGreugeAccept()', () => { - const greugeTypeId = 7; - const freightPickUpPrice = 11; - - it('should make a query and get the greugeTypeId and greuge config', () => { - $httpBackend.expectRoute('GET', `GreugeTypes/findOne`).respond({id: greugeTypeId}); - $httpBackend.expectGET(`GreugeConfigs/findOne`).respond({freightPickUpPrice}); - controller.onUpdateGreugeAccept(); - $httpBackend.flush(); - - expect(controller.greugeTypeFreightId).toEqual(greugeTypeId); - expect(controller.freightPickUpPrice).toEqual(freightPickUpPrice); - }); - - it('should perform a insert into greuges', done => { - jest.spyOn(controller, 'getGreugeTypeId').mockReturnValue(new Promise(resolve => { - return resolve({id: greugeTypeId}); - })); - jest.spyOn(controller, 'getGreugeConfig').mockReturnValue(new Promise(resolve => { - return resolve({freightPickUpPrice}); - })); - jest.spyOn(controller, 'updateGreuge').mockReturnValue(new Promise(resolve => { - return resolve(true); - })); - - controller.claim.clientFk = 1101; - controller.claim.id = 11; - - controller.onUpdateGreugeAccept().then(() => { - expect(controller.updateGreuge).toHaveBeenCalledWith(jasmine.any(Object)); - done(); - }).catch(done.fail); - }); - }); - - describe('updateGreuge()', () => { - it('should make a query and then call to showSuccess() and showMessage() methods', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - jest.spyOn(controller.vnApp, 'showMessage'); - - const freightPickUpPrice = 11; - const greugeTypeId = 7; - const expectedData = { - clientFk: 1101, - description: `claim: ${controller.claim.id}`, - amount: freightPickUpPrice, - greugeTypeFk: greugeTypeId, - ticketFk: controller.claim.ticketFk - }; - $httpBackend.expect('POST', `Greuges`, expectedData).respond(200); - controller.updateGreuge(expectedData); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Greuge added'); - }); - }); - - describe('onResponse()', () => { - it('should perform a post query and show a success message', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - - $httpBackend.expect('POST', `Claims/updateClaimDestination`).respond({}); - controller.onResponse(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - }); -}); diff --git a/modules/claim/front/action/locale/en.yml b/modules/claim/front/action/locale/en.yml deleted file mode 100644 index faab67c06..000000000 --- a/modules/claim/front/action/locale/en.yml +++ /dev/null @@ -1 +0,0 @@ -ClaimGreugeDescription: Claim id {{claimId}} \ No newline at end of file diff --git a/modules/claim/front/action/locale/es.yml b/modules/claim/front/action/locale/es.yml deleted file mode 100644 index 97640d9dc..000000000 --- a/modules/claim/front/action/locale/es.yml +++ /dev/null @@ -1,13 +0,0 @@ -Destination: Destino -Action: Actuaciones -Total claimed: Total Reclamado -Import claim: Importar reclamacion -Imports claim details: Importa detalles de la reclamacion -Regularize: Regularizar -Do you want to insert greuges?: Desea insertar greuges? -Insert greuges on client card: Insertar greuges en la ficha del cliente -Greuge added: Greuge añadido -ClaimGreugeDescription: Reclamación id {{claimId}} -Change destination: Cambiar destino -Change destination to all selected rows: Cambiar destino a {{total}} fila(s) seleccionada(s) -Add observation to all selected clients: Añadir observación a {{total}} cliente(s) seleccionado(s) diff --git a/modules/claim/front/action/style.scss b/modules/claim/front/action/style.scss deleted file mode 100644 index cda6779c8..000000000 --- a/modules/claim/front/action/style.scss +++ /dev/null @@ -1,46 +0,0 @@ -vn-claim-action { - .header { - display: flex; - justify-content: space-between; - align-items: center; - align-content: center; - - vn-tool-bar { - flex: none - } - - .vn-check { - flex: none; - } - } - - vn-dialog[vn-id=addSales] { - tpl-body { - width: 950px; - div { - div.buttons { - display: none; - } - vn-table{ - min-width: 950px; - } - } - } - } - - vn-popover.lastTicketsPopover { - vn-table { - min-width: 650px; - overflow: auto - } - - div.ticketList { - overflow: auto; - max-height: 350px; - } - } - - .right { - margin-left: 370px; - } -} \ No newline at end of file diff --git a/modules/claim/front/basic-data/index.html b/modules/claim/front/basic-data/index.html deleted file mode 100644 index 45bc1823d..000000000 --- a/modules/claim/front/basic-data/index.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/claim/front/basic-data/index.js b/modules/claim/front/basic-data/index.js deleted file mode 100644 index 818012bb9..000000000 --- a/modules/claim/front/basic-data/index.js +++ /dev/null @@ -1,20 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - onSubmit() { - this.$.watcher.submit().then(() => { - if (this.aclService.hasAny(['claimManager'])) - this.$state.go('claim.card.detail'); - }); - } -} - -ngModule.vnComponent('vnClaimBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - claim: '<' - } -}); diff --git a/modules/claim/front/basic-data/index.spec.js b/modules/claim/front/basic-data/index.spec.js deleted file mode 100644 index 638f88418..000000000 --- a/modules/claim/front/basic-data/index.spec.js +++ /dev/null @@ -1,28 +0,0 @@ -import './index.js'; -import watcher from 'core/mocks/watcher'; - -describe('Claim', () => { - describe('Component vnClaimBasicData', () => { - let controller; - let $scope; - - beforeEach(ngModule('claim')); - - beforeEach(inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - $scope.watcher = watcher; - const $element = angular.element(''); - controller = $componentController('vnClaimBasicData', {$element, $scope}); - })); - - describe('onSubmit()', () => { - it(`should redirect to 'claim.card.detail' state`, () => { - jest.spyOn(controller.aclService, 'hasAny').mockReturnValue(true); - jest.spyOn(controller.$state, 'go'); - controller.onSubmit(); - - expect(controller.$state.go).toHaveBeenCalledWith('claim.card.detail'); - }); - }); - }); -}); diff --git a/modules/claim/front/basic-data/locale/es.yml b/modules/claim/front/basic-data/locale/es.yml deleted file mode 100644 index 5250d266c..000000000 --- a/modules/claim/front/basic-data/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Contact: Contacto -Claim state: Estado de la reclamación -Is paid with mana: Cargado al maná -Responsability: Responsabilidad -Company: Empresa -Sales/Client: Comercial/Cliente -Pick up: Recoger -When checked will notify to the salesPerson: Cuando se marque enviará una notificación de recogida al comercial -Packages received: Bultos recibidos diff --git a/modules/claim/front/basic-data/style.scss b/modules/claim/front/basic-data/style.scss deleted file mode 100644 index e80361ca8..000000000 --- a/modules/claim/front/basic-data/style.scss +++ /dev/null @@ -1,3 +0,0 @@ -vn-claim-basic-data vn-date-picker { - padding-left: 80px; -} diff --git a/modules/claim/front/card/index.html b/modules/claim/front/card/index.html deleted file mode 100644 index 1db6b38db..000000000 --- a/modules/claim/front/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/claim/front/card/index.js b/modules/claim/front/card/index.js deleted file mode 100644 index 5dad0dfc2..000000000 --- a/modules/claim/front/card/index.js +++ /dev/null @@ -1,68 +0,0 @@ -import ngModule from '../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - let filter = { - include: [ - { - relation: 'worker', - scope: { - fields: ['id'], - include: { - relation: 'user', - scope: { - fields: ['name'] - } - } - } - }, { - relation: 'ticket', - scope: { - fields: ['zoneFk', 'addressFk'], - include: [ - { - relation: 'zone', - scope: { - fields: ['name'] - } - }, - { - relation: 'address', - scope: { - fields: ['provinceFk'], - include: { - relation: 'province', - scope: { - fields: ['name'] - } - } - } - }] - } - }, { - relation: 'claimState', - scope: { - fields: ['id', 'description'] - } - }, { - relation: 'client', - scope: { - fields: ['salesPersonFk', 'name', 'email'], - include: { - relation: 'salesPersonUser' - } - } - } - ] - }; - - this.$http.get(`Claims/${this.$params.id}`, {filter}) - .then(res => this.claim = res.data); - } -} - -ngModule.vnComponent('vnClaimCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/claim/front/card/index.spec.js b/modules/claim/front/card/index.spec.js deleted file mode 100644 index aa796c1e3..000000000 --- a/modules/claim/front/card/index.spec.js +++ /dev/null @@ -1,29 +0,0 @@ -import './index.js'; - -describe('Claim', () => { - describe('Component vnClaimCard', () => { - let controller; - let $httpBackend; - let data = {id: 1, name: 'fooName'}; - - beforeEach(ngModule('claim')); - - beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => { - $httpBackend = _$httpBackend_; - - let $element = angular.element('
'); - controller = $componentController('vnClaimCard', {$element}); - - $stateParams.id = data.id; - $httpBackend.whenRoute('GET', 'Claims/:id').respond(data); - })); - - it('should request data and set it on the controller', () => { - controller.reload(); - $httpBackend.flush(); - - expect(controller.claim).toEqual(data); - }); - }); -}); - diff --git a/modules/claim/front/descriptor/index.js b/modules/claim/front/descriptor/index.js index 5e9ea5140..337233059 100644 --- a/modules/claim/front/descriptor/index.js +++ b/modules/claim/front/descriptor/index.js @@ -29,9 +29,9 @@ class Controller extends Descriptor { deleteClaim() { return this.$http.delete(`Claims/${this.claim.id}`) - .then(() => { + .then(async() => { this.vnApp.showSuccess(this.$t('Claim deleted!')); - this.$state.go('claim.index'); + window.location.href = await this.vnApp.getUrl(`claim/`); }); } } diff --git a/modules/claim/front/descriptor/index.spec.js b/modules/claim/front/descriptor/index.spec.js index e6785d3d8..03710b479 100644 --- a/modules/claim/front/descriptor/index.spec.js +++ b/modules/claim/front/descriptor/index.spec.js @@ -53,14 +53,12 @@ describe('Item Component vnClaimDescriptor', () => { describe('deleteClaim()', () => { it('should perform a query and call showSuccess if the response is accept', () => { jest.spyOn(controller.vnApp, 'showSuccess'); - jest.spyOn(controller.$state, 'go'); $httpBackend.expectDELETE(`Claims/${claim.id}`).respond(); controller.deleteClaim(); $httpBackend.flush(); expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.$state.go).toHaveBeenCalledWith('claim.index'); }); }); }); diff --git a/modules/claim/front/detail/index.html b/modules/claim/front/detail/index.html deleted file mode 100644 index a2a08a5db..000000000 --- a/modules/claim/front/detail/index.html +++ /dev/null @@ -1,178 +0,0 @@ - - - - - - - - - - - - - - Landed - Quantity - Claimed - Description - Price - Disc. - Total - - - - - - {{::saleClaimed.sale.ticket.landed | date:'dd/MM/yyyy'}} - {{::saleClaimed.sale.quantity}} - - - - - - - {{::saleClaimed.sale.concept}} - - - {{::saleClaimed.sale.price | currency: 'EUR':2}} - - - {{saleClaimed.sale.discount}} % - - - - {{$ctrl.getSaleTotal(saleClaimed.sale) | currency: 'EUR':2}} - - - - - - - - - - - - - - - - - - Claimable sales from ticket {{$ctrl.claim.ticketFk}} - - - - - - - Landed - Quantity - Description - Price - Disc. - Total - - - - - {{sale.landed | date: 'dd/MM/yyyy'}} - {{sale.quantity}} - - - {{sale.itemFk}} - {{sale.concept}} - - - {{sale.price | currency: 'EUR':2}} - {{sale.discount}} % - - {{(sale.quantity * sale.price) - ((sale.discount * (sale.quantity * sale.price))/100) | currency: 'EUR':2}} - - - - - - - - - - -
- - -
- -
MANÁ: {{$ctrl.mana | currency: 'EUR':0}}
-
-
- - -
-

Total claimed price

-

{{$ctrl.newPrice | currency: 'EUR':2}} -

-
-
-
-
-
- - \ No newline at end of file diff --git a/modules/claim/front/detail/index.js b/modules/claim/front/detail/index.js deleted file mode 100644 index 56f39e074..000000000 --- a/modules/claim/front/detail/index.js +++ /dev/null @@ -1,203 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.edit = {}; - this.filter = { - where: {claimFk: this.$params.id}, - include: [ - { - relation: 'sale', - scope: { - fields: ['concept', 'ticketFk', 'price', 'quantity', 'discount', 'itemFk'], - include: { - relation: 'ticket' - } - } - } - ] - }; - } - - get claim() { - return this._claim; - } - - set claim(value) { - this._claim = value; - - if (value) { - this.isClaimEditable(); - this.isTicketEditable(); - } - } - - set salesClaimed(value) { - this._salesClaimed = value; - - if (value) this.calculateTotals(); - } - - get salesClaimed() { - return this._salesClaimed; - } - - get newDiscount() { - return this._newDiscount; - } - - set newDiscount(value) { - this._newDiscount = value; - this.updateNewPrice(); - } - - get isClaimManager() { - return this.aclService.hasAny(['claimManager']); - } - - openAddSalesDialog() { - this.getClaimableFromTicket(); - this.$.addSales.show(); - } - - getClaimableFromTicket() { - let config = {params: {ticketFk: this.claim.ticketFk}}; - let query = `Sales/getClaimableFromTicket`; - this.$http.get(query, config).then(res => { - if (res.data) - this.salesToClaim = res.data; - }); - } - - addClaimedSale(index) { - let sale = this.salesToClaim[index]; - let saleToAdd = {saleFk: sale.saleFk, claimFk: this.claim.id, quantity: sale.quantity}; - let query = `ClaimBeginnings/`; - this.$http.post(query, saleToAdd).then(() => { - this.$.addSales.hide(); - this.$.model.refresh(); - this.vnApp.showSuccess(this.$t('Data saved!')); - - if (this.aclService.hasAny(['claimManager'])) - this.$state.go('claim.card.development'); - }); - } - - showDeleteConfirm($index) { - this.claimedIndex = $index; - this.$.confirm.show(); - } - - deleteClaimedSale() { - this.$.model.remove(this.claimedIndex); - this.$.model.save().then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.calculateTotals(); - }); - } - - setClaimedQuantity(id, claimedQuantity) { - let params = {quantity: claimedQuantity}; - let query = `ClaimBeginnings/${id}`; - this.$http.patch(query, params).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.calculateTotals(); - }); - } - - calculateTotals() { - this.paidTotal = 0.0; - this.claimedTotal = 0.0; - if (!this._salesClaimed) return; - - this._salesClaimed.forEach(sale => { - let orgSale = sale.sale; - this.paidTotal += this.getSaleTotal(orgSale); - - const price = sale.quantity * orgSale.price; - const discount = ((orgSale.discount * price) / 100); - - this.claimedTotal += price - discount; - }); - } - - getSaleTotal(sale) { - let total = 0.0; - - const price = sale.quantity * sale.price; - const discount = ((sale.discount * price) / 100); - - total += price - discount; - return total; - } - - getSalespersonMana() { - this.$http.get(`Tickets/${this.claim.ticketFk}/getSalesPersonMana`).then(res => { - this.mana = res.data; - }); - } - - isTicketEditable() { - if (!this.claim) return; - - this.$http.get(`Tickets/${this.claim.ticketFk}/isEditable`).then(res => { - this.isEditable = res.data; - }); - } - - isClaimEditable() { - if (!this.claim) return; - - this.$http.get(`ClaimStates/${this.claim.claimStateFk}/isEditable`).then(res => { - this.isRewritable = res.data; - }); - } - - showEditPopover(event, saleClaimed) { - if (this.aclService.hasAny(['claimManager'])) { - this.saleClaimed = saleClaimed; - this.$.editPopover.parent = event.target; - this.$.editPopover.show(); - } - } - - updateDiscount() { - const claimedSale = this.saleClaimed.sale; - if (this.newDiscount != claimedSale.discount) { - const params = {salesIds: [claimedSale.id], newDiscount: this.newDiscount}; - const query = `Tickets/${claimedSale.ticketFk}/updateDiscount`; - - this.$http.post(query, params).then(() => { - claimedSale.discount = this.newDiscount; - this.calculateTotals(); - this.clearDiscount(); - - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - this.$.editPopover.hide(); - } - - updateNewPrice() { - this.newPrice = (this.saleClaimed.quantity * this.saleClaimed.sale.price) - - ((this.newDiscount * (this.saleClaimed.quantity * this.saleClaimed.sale.price)) / 100); - } - - clearDiscount() { - this.newDiscount = null; - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnClaimDetail', { - template: require('./index.html'), - controller: Controller, - bindings: { - claim: '<' - } -}); diff --git a/modules/claim/front/detail/index.spec.js b/modules/claim/front/detail/index.spec.js deleted file mode 100644 index 1ef779fd7..000000000 --- a/modules/claim/front/detail/index.spec.js +++ /dev/null @@ -1,150 +0,0 @@ -import './index.js'; -import crudModel from 'core/mocks/crud-model'; - -describe('claim', () => { - describe('Component vnClaimDetail', () => { - let $scope; - let controller; - let $httpBackend; - - beforeEach(ngModule('claim')); - - beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { - $scope = $rootScope.$new(); - $scope.descriptor = { - show: () => {} - }; - $httpBackend = _$httpBackend_; - $httpBackend.whenGET('Claims/ClaimBeginnings').respond({}); - $httpBackend.whenGET(`Tickets/1/isEditable`).respond(true); - $httpBackend.whenGET(`ClaimStates/2/isEditable`).respond(true); - const $element = angular.element(''); - controller = $componentController('vnClaimDetail', {$element, $scope}); - controller.claim = { - ticketFk: 1, - id: 2, - claimStateFk: 2} - ; - controller.salesToClaim = [{saleFk: 1}, {saleFk: 2}]; - controller.salesClaimed = [{id: 1, sale: {}}]; - controller.$.model = crudModel; - controller.$.addSales = { - hide: () => {}, - show: () => {} - }; - controller.$.editPopover = { - hide: () => {} - }; - jest.spyOn(controller.aclService, 'hasAny').mockReturnValue(true); - })); - - describe('openAddSalesDialog()', () => { - it('should call getClaimableFromTicket and $.addSales.show', () => { - jest.spyOn(controller, 'getClaimableFromTicket'); - jest.spyOn(controller.$.addSales, 'show'); - controller.openAddSalesDialog(); - - expect(controller.getClaimableFromTicket).toHaveBeenCalledWith(); - expect(controller.$.addSales.show).toHaveBeenCalledWith(); - }); - }); - - describe('getClaimableFromTicket()', () => { - it('should make a query and set salesToClaim', () => { - $httpBackend.expectGET(`Sales/getClaimableFromTicket?ticketFk=1`).respond(200, 1); - controller.getClaimableFromTicket(); - $httpBackend.flush(); - - expect(controller.salesToClaim).toEqual(1); - }); - }); - - describe('addClaimedSale(index)', () => { - it('should make a post and call refresh, hide and showSuccess', () => { - jest.spyOn(controller.$.addSales, 'hide'); - jest.spyOn(controller.$state, 'go'); - $httpBackend.expectPOST(`ClaimBeginnings/`).respond({}); - controller.addClaimedSale(1); - $httpBackend.flush(); - - expect(controller.$.addSales.hide).toHaveBeenCalledWith(); - expect(controller.$state.go).toHaveBeenCalledWith('claim.card.development'); - }); - }); - - describe('deleteClaimedSale()', () => { - it('should make a delete and call refresh and showSuccess', () => { - const claimedIndex = 1; - controller.claimedIndex = claimedIndex; - jest.spyOn(controller.$.model, 'remove'); - jest.spyOn(controller.$.model, 'save'); - jest.spyOn(controller.vnApp, 'showSuccess'); - - controller.deleteClaimedSale(); - - expect(controller.$.model.remove).toHaveBeenCalledWith(claimedIndex); - expect(controller.$.model.save).toHaveBeenCalledWith(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('setClaimedQuantity(id, claimedQuantity)', () => { - it('should make a patch and call refresh and showSuccess', () => { - const id = 1; - const claimedQuantity = 1; - - jest.spyOn(controller.vnApp, 'showSuccess'); - $httpBackend.expectPATCH(`ClaimBeginnings/${id}`).respond({}); - controller.setClaimedQuantity(id, claimedQuantity); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('calculateTotals()', () => { - it('should set paidTotal and claimedTotal to 0 if salesClaimed has no data', () => { - controller.salesClaimed = []; - controller.calculateTotals(); - - expect(controller.paidTotal).toEqual(0); - expect(controller.claimedTotal).toEqual(0); - }); - }); - - describe('updateDiscount()', () => { - it('should perform a query if the new discount differs from the claim discount', () => { - controller.saleClaimed = {sale: { - discount: 5, - id: 7, - ticketFk: 1, - price: 2, - quantity: 10}}; - controller.newDiscount = 10; - - jest.spyOn(controller.vnApp, 'showSuccess'); - jest.spyOn(controller, 'calculateTotals'); - jest.spyOn(controller, 'clearDiscount'); - jest.spyOn(controller.$.editPopover, 'hide'); - - $httpBackend.when('POST', 'Tickets/1/updateDiscount').respond({}); - controller.updateDiscount(); - $httpBackend.flush(); - - expect(controller.calculateTotals).toHaveBeenCalledWith(); - expect(controller.clearDiscount).toHaveBeenCalledWith(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.$.editPopover.hide).toHaveBeenCalledWith(); - }); - }); - - describe('isTicketEditable()', () => { - it('should check if the ticket assigned to the claim is editable', () => { - controller.isTicketEditable(); - $httpBackend.flush(); - - expect(controller.isEditable).toBeTruthy(); - }); - }); - }); -}); diff --git a/modules/claim/front/detail/locale/es.yml b/modules/claim/front/detail/locale/es.yml deleted file mode 100644 index 53f9e9b1d..000000000 --- a/modules/claim/front/detail/locale/es.yml +++ /dev/null @@ -1,11 +0,0 @@ -Claimed: Reclamados -Disc.: Dto. -Attended by: Atendida por -Landed: F. entrega -Price: Precio -Claimable sales from ticket: Lineas reclamables del ticket -Detail: Detalles -Add sale item: Añadir artículo -Insuficient permisos: Permisos insuficientes -Total claimed price: Precio total reclamado -Delete sale from claim?: ¿Borrar la linea de la reclamación? \ No newline at end of file diff --git a/modules/claim/front/detail/style.scss b/modules/claim/front/detail/style.scss deleted file mode 100644 index 470c83034..000000000 --- a/modules/claim/front/detail/style.scss +++ /dev/null @@ -1,30 +0,0 @@ -@import "variables"; - -.vn-popover .discount-popover { - width: 256px; - - .header { - background-color: $color-main; - color: $color-font-dark; - - h5 { - color: inherit; - margin: 0 auto; - } - } - .simulatorTitle { - margin-bottom: 0; - font-size: .75rem; - color: $color-main; - } - vn-label-value { - padding-bottom: 20px; - } - .simulator{ - text-align: center; - } -} - -.next{ - float: right; -} diff --git a/modules/claim/front/development/index.html b/modules/claim/front/development/index.html deleted file mode 100644 index 7fb3b870e..000000000 --- a/modules/claim/front/development/index.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/modules/claim/front/development/index.js b/modules/claim/front/development/index.js deleted file mode 100644 index 7b31bd17f..000000000 --- a/modules/claim/front/development/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - } - - async $onInit() { - this.$state.go('claim.card.summary', {id: this.$params.id}); - window.location.href = await this.vnApp.getUrl(`claim/${this.$params.id}/development`); - } -} - -ngModule.vnComponent('vnClaimDevelopment', { - template: require('./index.html'), - controller: Controller, - bindings: { - claim: '<' - } -}); diff --git a/modules/claim/front/index.js b/modules/claim/front/index.js index 473f6a4d3..16397df28 100644 --- a/modules/claim/front/index.js +++ b/modules/claim/front/index.js @@ -1,16 +1,4 @@ export * from './module'; import './main'; -import './index/'; -import './action'; -import './basic-data'; -import './card'; -import './detail'; import './descriptor'; -import './development'; -import './search-panel'; -import './summary'; -import './photos'; -import './log'; -import './note/index'; -import './note/create'; diff --git a/modules/claim/front/index/index.html b/modules/claim/front/index/index.html deleted file mode 100644 index 6b2481429..000000000 --- a/modules/claim/front/index/index.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Id - - Client - - Created - - Worker - - State -
{{::claim.id}} - - {{::claim.clientName}} - - {{::claim.created | date:'dd/MM/yyyy'}} - - {{::claim.workerName}} - - - - {{::claim.stateDescription}} - - - - -
-
-
-
- - - - - - - - diff --git a/modules/claim/front/index/index.js b/modules/claim/front/index/index.js deleted file mode 100644 index e3fdabf79..000000000 --- a/modules/claim/front/index/index.js +++ /dev/null @@ -1,82 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - - this.smartTableOptions = { - activeButtons: { - search: true - }, - columns: [ - { - field: 'clientName', - autocomplete: { - url: 'Clients', - showField: 'name', - valueField: 'name' - } - }, - { - field: 'workerFk', - autocomplete: { - url: 'Workers/activeWithInheritedRole', - where: `{role: 'salesPerson'}`, - searchFunction: '{firstName: $search}', - showField: 'name', - valueField: 'id', - } - }, - { - field: 'claimStateFk', - autocomplete: { - url: 'ClaimStates', - showField: 'description', - valueField: 'id', - } - }, - { - field: 'created', - searchable: false - } - ] - }; - } - - exprBuilder(param, value) { - switch (param) { - case 'clientName': - return {'cl.clientName': {like: `%${value}%`}}; - case 'clientFk': - case 'claimStateFk': - case 'workerFk': - return {[`cl.${param}`]: value}; - } - } - - stateColor(code) { - switch (code) { - case 'pending': - return 'warning'; - case 'managed': - return 'notice'; - case 'resolved': - return 'success'; - } - } - - preview(claim) { - this.claimSelected = claim; - this.$.summary.show(); - } - - reload() { - this.$.model.refresh(); - } -} - -ngModule.vnComponent('vnClaimIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/claim/front/log/index.html b/modules/claim/front/log/index.html deleted file mode 100644 index 500a626d6..000000000 --- a/modules/claim/front/log/index.html +++ /dev/null @@ -1,4 +0,0 @@ - - \ No newline at end of file diff --git a/modules/claim/front/log/index.js b/modules/claim/front/log/index.js deleted file mode 100644 index 0143a612b..000000000 --- a/modules/claim/front/log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnClaimLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/claim/front/main/index.html b/modules/claim/front/main/index.html index f38cc573f..e69de29bb 100644 --- a/modules/claim/front/main/index.html +++ b/modules/claim/front/main/index.html @@ -1,19 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/modules/claim/front/main/index.js b/modules/claim/front/main/index.js index 0c5c7d728..c921d5a12 100644 --- a/modules/claim/front/main/index.js +++ b/modules/claim/front/main/index.js @@ -1,7 +1,18 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; +export default class Claim extends ModuleMain { + constructor($element, $) { + super($element, $); + } + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`claim/`); + } +} + ngModule.vnComponent('vnClaim', { - controller: ModuleMain, + controller: Claim, template: require('./index.html') }); + diff --git a/modules/claim/front/note/create/index.html b/modules/claim/front/note/create/index.html deleted file mode 100644 index 8a882a4f5..000000000 --- a/modules/claim/front/note/create/index.html +++ /dev/null @@ -1,30 +0,0 @@ - - -
- - - - - - - - - - - - -
diff --git a/modules/claim/front/note/create/index.js b/modules/claim/front/note/create/index.js deleted file mode 100644 index 40ae9309b..000000000 --- a/modules/claim/front/note/create/index.js +++ /dev/null @@ -1,22 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.note = { - claimFk: parseInt(this.$params.id), - workerFk: window.localStorage.currentUserWorkerId, - text: null - }; - } - - cancel() { - this.$state.go('claim.card.note.index', {id: this.$params.id}); - } -} - -ngModule.vnComponent('vnClaimNoteCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/claim/front/note/index/index.html b/modules/claim/front/note/index/index.html deleted file mode 100644 index 8ffe19c2b..000000000 --- a/modules/claim/front/note/index/index.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - -
- - {{::note.worker.firstName}} {{::note.worker.lastName}} - {{::note.created | date:'dd/MM/yyyy HH:mm'}} - - - {{::note.text}} - -
-
-
- - - \ No newline at end of file diff --git a/modules/claim/front/note/index/index.js b/modules/claim/front/note/index/index.js deleted file mode 100644 index 5a2fd96d3..000000000 --- a/modules/claim/front/note/index/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.filter = { - order: 'created DESC', - }; - this.include = { - relation: 'worker', - scope: { - fields: ['id', 'firstName', 'lastName'] - } - }; - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnClaimNote', { - template: require('./index.html'), - controller: Controller, -}); diff --git a/modules/claim/front/note/index/style.scss b/modules/claim/front/note/index/style.scss deleted file mode 100644 index 44ae2cee7..000000000 --- a/modules/claim/front/note/index/style.scss +++ /dev/null @@ -1,5 +0,0 @@ -vn-client-note { - .note:last-child { - margin-bottom: 0; - } -} \ No newline at end of file diff --git a/modules/claim/front/photos/index.html b/modules/claim/front/photos/index.html deleted file mode 100644 index 8b1378917..000000000 --- a/modules/claim/front/photos/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/modules/claim/front/photos/index.js b/modules/claim/front/photos/index.js deleted file mode 100644 index c9fada9a4..000000000 --- a/modules/claim/front/photos/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - } - - async $onInit() { - const url = await this.vnApp.getUrl(`claim/${this.$params.id}/photos`); - window.location.href = url; - } -} - -ngModule.vnComponent('vnClaimPhotos', { - template: require('./index.html'), - controller: Controller, - bindings: { - claim: '<' - } -}); diff --git a/modules/claim/front/search-panel/index.html b/modules/claim/front/search-panel/index.html deleted file mode 100644 index 260f86801..000000000 --- a/modules/claim/front/search-panel/index.html +++ /dev/null @@ -1,84 +0,0 @@ -
-
- - - - - - - - - - - - - - - - - - - {{description}} - - - - - - - {{::id}} - {{::name}} - - - - - - - - - - -
-
diff --git a/modules/claim/front/search-panel/index.js b/modules/claim/front/search-panel/index.js deleted file mode 100644 index 2400b8ede..000000000 --- a/modules/claim/front/search-panel/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -class Controller extends SearchPanel { - itemSearchFunc($search) { - return /^\d+$/.test($search) - ? {id: $search} - : {name: {like: '%' + $search + '%'}}; - } -} -ngModule.vnComponent('vnClaimSearchPanel', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/claim/front/search-panel/locale/es.yml b/modules/claim/front/search-panel/locale/es.yml deleted file mode 100644 index 1f892a742..000000000 --- a/modules/claim/front/search-panel/locale/es.yml +++ /dev/null @@ -1,7 +0,0 @@ -Ticket id: Id ticket -Client id: Id cliente -Nickname: Alias -From: Desde -To: Hasta -Agency: Agencia -Warehouse: Almacén \ No newline at end of file diff --git a/modules/claim/front/summary/index.html b/modules/claim/front/summary/index.html deleted file mode 100644 index b5225e6f4..000000000 --- a/modules/claim/front/summary/index.html +++ /dev/null @@ -1,273 +0,0 @@ - - - -
- - - - {{::$ctrl.summary.claim.id}} - {{::$ctrl.summary.claim.client.name}} - - -
- - -

- - Basic data - -

- - - - - - - - -
- -

- - Observations - -

-

- Observations -

-
- - {{::note.worker.firstName}} {{::note.worker.lastName}} - {{::note.created | date:'dd/MM/yyyy HH:mm'}} - - - {{::note.text}} - -
-
- -

- - Detail - -

-

- Detail -

- - - - - Item - Landed - Quantity - Claimed - Description - Price - Disc. - Total - - - - - - - {{::saleClaimed.sale.itemFk}} - - - {{::saleClaimed.sale.ticket.landed | date: 'dd/MM/yyyy'}} - {{::saleClaimed.sale.quantity}} - {{::saleClaimed.quantity}} - {{::saleClaimed.sale.concept}} - {{::saleClaimed.sale.price | currency: 'EUR':2}} - {{::saleClaimed.sale.discount}} % - - {{saleClaimed.sale.quantity * saleClaimed.sale.price * - ((100 - saleClaimed.sale.discount) / 100) | currency: 'EUR':2}} - - - - - -
- -

Photos

- -
-
-
- -
-
-
- -

- - Development - -

-

- Development -

- - - - - Reason - Result - Responsible - Worker - Redelivery - - - - - {{::development.claimReason.description}} - {{::development.claimResult.description}} - {{::development.claimResponsible.description}} - - - {{::development.worker.user.nickname}} - - - {{::development.claimRedelivery.description}} - - - - -
- -

- - Action - -

-

- Action -

- - - - - - - - - - - Item - Ticket - Destination - Landed - Quantity - Description - Price - Disc. - Total - - - - - - - {{::action.sale.itemFk}} - - - - - {{::action.sale.ticket.id}} - - - {{::action.claimBeggining.description}} - {{::action.sale.ticket.landed | date: 'dd/MM/yyyy'}} - {{::action.sale.quantity}} - {{::action.sale.concept}} - {{::action.sale.price}} - {{::action.sale.discount}} % - - {{action.sale.quantity * action.sale.price * - ((100 - action.sale.discount) / 100) | currency: 'EUR':2}} - - - - - -
-
-
- - - - - - diff --git a/modules/claim/front/summary/index.js b/modules/claim/front/summary/index.js deleted file mode 100644 index 7cd4805e9..000000000 --- a/modules/claim/front/summary/index.js +++ /dev/null @@ -1,103 +0,0 @@ -import ngModule from '../module'; -import Summary from 'salix/components/summary'; -import './style.scss'; - -class Controller extends Summary { - constructor($element, $, vnFile) { - super($element, $); - this.vnFile = vnFile; - this.filter = { - include: [ - { - relation: 'dms' - } - ] - }; - } - - $onChanges() { - if (this.claim && this.claim.id) - this.loadData(); - } - - loadData() { - return this.$http.get(`Claims/${this.claim.id}/getSummary`).then(res => { - if (res && res.data) - this.summary = res.data; - }); - } - - reload() { - this.loadData() - .then(() => { - if (this.card) - this.card.reload(); - - if (this.parentReload) - this.parentReload(); - }); - } - - get isSalesPerson() { - return this.aclService.hasAny(['salesPerson']); - } - - get isClaimManager() { - return this.aclService.hasAny(['claimManager']); - } - - get claim() { - return this._claim; - } - - set claim(value) { - this._claim = value; - - // Get DMS on summary load - if (value) { - this.$.$applyAsync(() => this.loadDms()); - this.loadData(); - } - } - - loadDms() { - this.$.model.where = { - claimFk: this.claim.id - }; - this.$.model.refresh(); - } - - getImagePath(dmsId) { - return this.vnFile.getPath(`/api/dms/${dmsId}/downloadFile`); - } - - changeState(value) { - const params = { - id: this.claim.id, - claimStateFk: value - }; - - this.$http.patch(`Claims/updateClaim/${this.claim.id}`, params) - .then(() => { - this.reload(); - }) - .then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } -} - -Controller.$inject = ['$element', '$scope', 'vnFile']; - -ngModule.vnComponent('vnClaimSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - claim: '<', - model: ' { - describe('Component summary', () => { - let controller; - let $httpBackend; - let $scope; - - beforeEach(ngModule('claim')); - - beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { - $scope = $rootScope.$new(); - $httpBackend = _$httpBackend_; - const $element = angular.element(''); - controller = $componentController('vnClaimSummary', {$element, $scope}); - controller.claim = {id: 1}; - controller.$.model = crudModel; - })); - - describe('loadData()', () => { - it('should perform a query to set summary', () => { - $httpBackend.when('GET', `Claims/1/getSummary`).respond(200, 24); - controller.loadData(); - $httpBackend.flush(); - - expect(controller.summary).toEqual(24); - }); - }); - - describe('changeState()', () => { - it('should make an HTTP post query, then call the showSuccess()', () => { - jest.spyOn(controller.vnApp, 'showSuccess').mockReturnThis(); - - const expectedParams = {id: 1, claimStateFk: 1}; - $httpBackend.when('GET', `Claims/1/getSummary`).respond(200, 24); - $httpBackend.expect('PATCH', `Claims/updateClaim/1`, expectedParams).respond(200); - controller.changeState(1); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('$onChanges()', () => { - it('should call loadData when $onChanges is called', () => { - jest.spyOn(controller, 'loadData'); - - controller.$onChanges(); - - expect(controller.loadData).toHaveBeenCalledWith(); - }); - }); - }); -}); diff --git a/modules/claim/front/summary/style.scss b/modules/claim/front/summary/style.scss deleted file mode 100644 index 5b4e32f7a..000000000 --- a/modules/claim/front/summary/style.scss +++ /dev/null @@ -1,28 +0,0 @@ -@import "./variables"; - -vn-claim-summary { - section.photo { - height: 248px; - } - .photo .image { - border-radius: 3px; - } - vn-textarea *{ - height: 80px; - } - - .video { - width: 100%; - height: 100%; - object-fit: cover; - cursor: pointer; - box-shadow: 0 2px 2px 0 rgba(0,0,0,.14), - 0 3px 1px -2px rgba(0,0,0,.2), - 0 1px 5px 0 rgba(0,0,0,.12); - border: 2px solid transparent; - - } - .video:hover { - border: 2px solid $color-primary - } -} \ No newline at end of file diff --git a/modules/client/back/locale/client-unpaid/en.yml b/modules/client/back/locale/client-unpaid/en.yml new file mode 100644 index 000000000..10f797c97 --- /dev/null +++ b/modules/client/back/locale/client-unpaid/en.yml @@ -0,0 +1,5 @@ +name: unpaid +columns: + clientFk: client + dated: date + amount: amount diff --git a/modules/client/back/locale/client-unpaid/es.yml b/modules/client/back/locale/client-unpaid/es.yml new file mode 100644 index 000000000..e24236109 --- /dev/null +++ b/modules/client/back/locale/client-unpaid/es.yml @@ -0,0 +1,5 @@ +name: impagado +columns: + clientFk: cliente + dated: fecha + amount: cantidad diff --git a/modules/client/back/methods/client/createAddress.js b/modules/client/back/methods/client/createAddress.js index 8e6db2a22..2709632cb 100644 --- a/modules/client/back/methods/client/createAddress.js +++ b/modules/client/back/methods/client/createAddress.js @@ -92,11 +92,8 @@ module.exports = function(Self) { }, myOptions); const isUeeMember = province.country().isUeeMember; - if (!isUeeMember && !args.incotermsFk) - throw new UserError(`Incoterms is required for a non UEE member`); - - if (!isUeeMember && !args.customsAgentFk) - throw new UserError(`Customs agent is required for a non UEE member`); + if (!isUeeMember && (!args.incotermsFk || !args.customsAgentFk)) + throw new UserError(`Incoterms and Customs agent are required for a non UEE member`); delete args.ctx; // Remove unwanted properties const newAddress = await models.Address.create(args, myOptions); diff --git a/modules/client/back/methods/client/createReceipt.js b/modules/client/back/methods/client/createReceipt.js index e2a57272b..23570baf2 100644 --- a/modules/client/back/methods/client/createReceipt.js +++ b/modules/client/back/methods/client/createReceipt.js @@ -95,9 +95,11 @@ module.exports = function(Self) { myOptions ); } else if (accountingType.isAutoConciliated == true) { - const description = `${originalClient.id} : ${originalClient.socialName} - ${accountingType.receiptDescription}`; - const [xdiarioNew] = await Self.rawSql( - `SELECT xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ledger;`, + const description = + `${originalClient.id} : ${originalClient.socialName} - ${accountingType.receiptDescription}`; + const [, [xdiarioNew]] = await Self.rawSql( + `CALL xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, @xdiarioNew); + SELECT @xdiarioNew ledger;`, [ null, date, @@ -118,7 +120,7 @@ module.exports = function(Self) { ); await Self.rawSql( - `SELECT xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`, + `CALL xdiario_new(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, @xdiarioNew);`, [ xdiarioNew.ledger, date, diff --git a/modules/client/back/methods/client/getCard.js b/modules/client/back/methods/client/getCard.js index 10e6f7adf..c15c260bc 100644 --- a/modules/client/back/methods/client/getCard.js +++ b/modules/client/back/methods/client/getCard.js @@ -50,7 +50,7 @@ module.exports = function(Self) { { relation: 'country', scope: { - fields: ['id', 'country'] + fields: ['id', 'name'] } }, { diff --git a/modules/client/back/methods/client/hasCustomerRole.js b/modules/client/back/methods/client/hasCustomerRole.js index e790d6e3a..08e90077e 100644 --- a/modules/client/back/methods/client/hasCustomerRole.js +++ b/modules/client/back/methods/client/hasCustomerRole.js @@ -29,7 +29,7 @@ module.exports = Self => { SELECT COUNT(*) > 0 isCustomer FROM salix.Account A JOIN salix.Role r ON r.id = A.roleFK - WHERE r.name = 'customer' + WHERE r.name IN ('customer', 'supplier') AND A.id IN (?)`; const [result] = await Self.rawSql(query, [id], myOptions); const {isCustomer} = result; diff --git a/modules/client/back/methods/client/specs/addressesPropagateRe.spec.js b/modules/client/back/methods/client/specs/addressesPropagateRe.spec.js index 74d80b964..1a186f93c 100644 --- a/modules/client/back/methods/client/specs/addressesPropagateRe.spec.js +++ b/modules/client/back/methods/client/specs/addressesPropagateRe.spec.js @@ -1,23 +1,10 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('Client addressesPropagateRe', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; + beforeAll.mockLoopBackContext(); - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); - - it('should propagate the isEqualizated on both addresses of Mr Wayne and set hasToInvoiceByAddress to false', async() => { + it('should propagate the isEqualizated on both addresses of Mr Wayne' + + ' and set hasToInvoiceByAddress to false', async() => { const tx = await models.Client.beginTransaction({}); try { diff --git a/modules/client/back/methods/client/specs/createAddress.spec.js b/modules/client/back/methods/client/specs/createAddress.spec.js index 0841ad98c..f4901ff93 100644 --- a/modules/client/back/methods/client/specs/createAddress.spec.js +++ b/modules/client/back/methods/client/specs/createAddress.spec.js @@ -1,5 +1,4 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('Address createAddress', () => { const clientFk = 1101; @@ -7,20 +6,7 @@ describe('Address createAddress', () => { const incotermsFk = 'FAS'; const customAgentOneId = 1; - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); it('should throw a non uee member error if no incoterms is defined', async() => { const tx = await models.Client.beginTransaction({}); @@ -50,7 +36,7 @@ describe('Address createAddress', () => { } expect(error).toBeDefined(); - expect(error.message).toEqual('Incoterms is required for a non UEE member'); + expect(error.message).toEqual('Incoterms and Customs agent are required for a non UEE member'); }); it('should throw a non uee member error if no customsAgent is defined', async() => { @@ -81,7 +67,7 @@ describe('Address createAddress', () => { } expect(error).toBeDefined(); - expect(error.message).toEqual('Customs agent is required for a non UEE member'); + expect(error.message).toEqual('Incoterms and Customs agent are required for a non UEE member'); }); it('should create a new address and set as a client default address', async() => { diff --git a/modules/client/back/methods/client/specs/createWithUser.spec.js b/modules/client/back/methods/client/specs/createWithUser.spec.js index 04fc51a26..5b1ff5da9 100644 --- a/modules/client/back/methods/client/specs/createWithUser.spec.js +++ b/modules/client/back/methods/client/specs/createWithUser.spec.js @@ -1,6 +1,4 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); - describe('Client Create', () => { const newAccount = { userName: 'deadpool', @@ -16,20 +14,7 @@ describe('Client Create', () => { const newAccountWithoutEmail = JSON.parse(JSON.stringify(newAccount)); delete newAccountWithoutEmail.email; - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); it(`should not find deadpool as he's not created yet`, async() => { const tx = await models.Client.beginTransaction({}); diff --git a/modules/client/back/methods/client/specs/getCard.spec.js b/modules/client/back/methods/client/specs/getCard.spec.js index 962e0a2d4..49e5ed5a4 100644 --- a/modules/client/back/methods/client/specs/getCard.spec.js +++ b/modules/client/back/methods/client/specs/getCard.spec.js @@ -1,11 +1,11 @@ const models = require('vn-loopback/server/server').models; describe('Client getCard()', () => { + const ctx = beforeAll.getCtx(); it('should receive a formated card of Bruce Wayne', async() => { const tx = await models.Client.beginTransaction({}); try { - const ctx = {req: {accessToken: {userId: 9}}}; const options = {transaction: tx}; const id = 1101; diff --git a/modules/client/back/methods/client/specs/getDebt.spec.js b/modules/client/back/methods/client/specs/getDebt.spec.js index b3b5286c0..d89d671a3 100644 --- a/modules/client/back/methods/client/specs/getDebt.spec.js +++ b/modules/client/back/methods/client/specs/getDebt.spec.js @@ -1,9 +1,9 @@ const models = require('vn-loopback/server/server').models; describe('client getDebt()', () => { + const ctx = beforeAll.getCtx(); it('should return the client debt', async() => { const tx = await models.Client.beginTransaction({}); - const ctx = {req: {accessToken: {userId: 9}}}; try { const options = {transaction: tx}; diff --git a/modules/client/back/methods/client/specs/sendSms.spec.js b/modules/client/back/methods/client/specs/sendSms.spec.js index df680c55f..bba9f83ce 100644 --- a/modules/client/back/methods/client/specs/sendSms.spec.js +++ b/modules/client/back/methods/client/specs/sendSms.spec.js @@ -1,12 +1,12 @@ const models = require('vn-loopback/server/server').models; describe('client sendSms()', () => { + const ctx = beforeAll.getCtx(); it('should now send a message and log it', async() => { const tx = await models.Client.beginTransaction({}); try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}}; const id = 1101; const destination = 222222222; const message = 'this is the message created in a test'; diff --git a/modules/client/back/methods/client/specs/summary.spec.js b/modules/client/back/methods/client/specs/summary.spec.js index 227f4c398..fe2af8028 100644 --- a/modules/client/back/methods/client/specs/summary.spec.js +++ b/modules/client/back/methods/client/specs/summary.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('client summary()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; + const ctx = beforeAll.getCtx(); it('should return a summary object containing data', async() => { const clientId = 1101; const tx = await models.Client.beginTransaction({}); diff --git a/modules/client/back/methods/client/specs/updateAddress.spec.js b/modules/client/back/methods/client/specs/updateAddress.spec.js index 6f02323c5..68981f8b7 100644 --- a/modules/client/back/methods/client/specs/updateAddress.spec.js +++ b/modules/client/back/methods/client/specs/updateAddress.spec.js @@ -1,6 +1,4 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); - describe('Address updateAddress', () => { const clientId = 1101; const addressId = 1; @@ -14,20 +12,7 @@ describe('Address updateAddress', () => { } }; - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); it('should throw the non uee member error if no incoterms is defined', async() => { const tx = await models.Client.beginTransaction({}); diff --git a/modules/client/back/methods/client/summary.js b/modules/client/back/methods/client/summary.js index 8de887b47..8162096f0 100644 --- a/modules/client/back/methods/client/summary.js +++ b/modules/client/back/methods/client/summary.js @@ -54,7 +54,7 @@ module.exports = Self => { { relation: 'country', scope: { - fields: ['country'] + fields: ['name'] } }, { diff --git a/modules/client/back/methods/client/updateFiscalData.js b/modules/client/back/methods/client/updateFiscalData.js index 9a6255215..8ed55b856 100644 --- a/modules/client/back/methods/client/updateFiscalData.js +++ b/modules/client/back/methods/client/updateFiscalData.js @@ -97,11 +97,11 @@ module.exports = Self => { type: 'any' }, { - arg: 'hasIncoterms', + arg: 'hasElectronicInvoice', type: 'boolean' }, { - arg: 'hasElectronicInvoice', + arg: 'hasDailyInvoice', type: 'boolean' } ], @@ -121,8 +121,6 @@ module.exports = Self => { const myOptions = {}; const models = Self.app.models; const args = ctx.args; - const userId = ctx.req.accessToken.userId; - const $t = ctx.req.__; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/client/back/methods/defaulter/filter.js b/modules/client/back/methods/defaulter/filter.js index ac9504ec2..9f19dee0a 100644 --- a/modules/client/back/methods/defaulter/filter.js +++ b/modules/client/back/methods/defaulter/filter.js @@ -60,7 +60,7 @@ module.exports = Self => { DISTINCT c.id clientFk, c.name clientName, c.salesPersonFk, - c.businessTypeFk, + c.businessTypeFk = 'worker' isWorker, u.name salesPersonName, d.amount, co.created, @@ -71,14 +71,29 @@ module.exports = Self => { d.defaulterSinced, cn.name country, c.countryFk, - pm.name payMethod - FROM vn.defaulter d - JOIN vn.client c ON c.id = d.clientFk - JOIN vn.country cn ON cn.id = c.countryFk - JOIN vn.payMethod pm ON pm.id = c.payMethodFk - LEFT JOIN vn.clientObservation co ON co.clientFk = c.id + pm.name payMethod, + r.finished IS NULL hasRecovery, + dp.id departmentFk, + dp.name departmentName + FROM defaulter d + JOIN client c ON c.id = d.clientFk + JOIN country cn ON cn.id = c.countryFk + JOIN payMethod pm ON pm.id = c.payMethodFk + LEFT JOIN clientObservation co ON co.clientFk = c.id LEFT JOIN account.user u ON u.id = c.salesPersonFk LEFT JOIN account.user uw ON uw.id = co.workerFk + LEFT JOIN ( + SELECT r1.started, r1.clientFk, r1.finished + FROM recovery r1 + JOIN ( + SELECT MAX(started) AS maxStarted, clientFk + FROM recovery + GROUP BY clientFk + ) r2 ON r1.clientFk = r2.clientFk + AND r1.started = r2.maxStarted + ) r ON r.clientFk = c.id + LEFT JOIN workerDepartment wd ON wd.workerFk = u.id + JOIN department dp ON dp.id = wd.departmentFk WHERE d.created = ? AND d.amount > 0 diff --git a/modules/client/back/model-config.json b/modules/client/back/model-config.json index fc1254dd8..e6690ee5f 100644 --- a/modules/client/back/model-config.json +++ b/modules/client/back/model-config.json @@ -5,7 +5,7 @@ "AddressObservation": { "dataSource": "vn" }, - "AddressShortage": { + "AddressWaste": { "dataSource": "vn" }, "BankEntity": { diff --git a/modules/client/back/models/XDiario.json b/modules/client/back/models/XDiario.json index be543393d..5c277783a 100644 --- a/modules/client/back/models/XDiario.json +++ b/modules/client/back/models/XDiario.json @@ -76,7 +76,16 @@ }, "enlazadoSage": { "type": "boolean" - } + }, + "enlazado": { + "type": "boolean" + }, + "key": { + "type": "number", + "mysql": { + "columnName": "CLAVE" + } + } }, "relations": { "company": { diff --git a/modules/client/back/models/addressShortage.json b/modules/client/back/models/address-waste.json similarity index 70% rename from modules/client/back/models/addressShortage.json rename to modules/client/back/models/address-waste.json index 1ae8d986c..2d7126eae 100644 --- a/modules/client/back/models/addressShortage.json +++ b/modules/client/back/models/address-waste.json @@ -1,15 +1,19 @@ { - "name": "AddressShortage", + "name": "AddressWaste", "base": "VnModel", "options": { "mysql": { - "table": "addressShortage" + "table": "addressWaste" } }, "properties": { "addressFk": { "type": "number", "id": true + }, + "type": { + "type": "string", + "id": true } }, "relations": { diff --git a/modules/client/back/models/address.js b/modules/client/back/models/address.js index 4a93b5d5c..7011008a4 100644 --- a/modules/client/back/models/address.js +++ b/modules/client/back/models/address.js @@ -43,8 +43,14 @@ module.exports = Self => { include: [{ relation: 'province', scope: { - fields: ['id', 'name'] - } + fields: ['id', 'name', 'countryFk'], + include: [ + { + relation: 'country', + scope: {fields: ['id', 'name']}, + }, + ], + }, }, { relation: 'agencyMode', scope: { diff --git a/modules/client/back/models/client-observation.js b/modules/client/back/models/client-observation.js index e34eedca9..d022a440a 100644 --- a/modules/client/back/models/client-observation.js +++ b/modules/client/back/models/client-observation.js @@ -1,8 +1,11 @@ module.exports = function(Self) { - Self.validate('text', isEnabled, {message: 'Description cannot be blank'}); - function isEnabled(err) { + Self.validate('text', function(err) { if (!this.text) err(); - } + }, {message: 'Description cannot be blank'}); + + Self.validate('observationTypeFk', function(err) { + if (!this.observationTypeFk) err(); + }, {message: 'type cannot be blank'}); Self.observe('before save', function(ctx, next) { ctx.instance.created = Date(); diff --git a/modules/client/back/models/client-observation.json b/modules/client/back/models/client-observation.json index b204ebeb4..86351862d 100644 --- a/modules/client/back/models/client-observation.json +++ b/modules/client/back/models/client-observation.json @@ -1,10 +1,10 @@ { - "name": "ClientObservation", + "name": "ClientObservation", "description": "Client notes", "base": "VnModel", - "mixins": { - "Loggable": true - }, + "mixins": { + "Loggable": true + }, "options": { "mysql": { "table": "clientObservation" @@ -26,6 +26,10 @@ "created": { "type": "date", "description": "Creation date and time" + }, + "observationTypeFk": { + "type": "number", + "description": "Type of observation" } }, "relations": { @@ -44,14 +48,18 @@ "include": { "relation": "worker", "scope": { - "fields": ["id"], + "fields": [ + "id" + ], "include": { "relation": "user", "scope": { - "fields": ["nickname"] + "fields": [ + "nickname" + ] } } } } } -} +} \ No newline at end of file diff --git a/modules/client/back/models/client-sample.js b/modules/client/back/models/client-sample.js index 5e4393042..b8ab6cff4 100644 --- a/modules/client/back/models/client-sample.js +++ b/modules/client/back/models/client-sample.js @@ -27,7 +27,7 @@ module.exports = Self => { // Renew mandate if (mandate) { const mandateType = await models.MandateType.findOne({ - where: {name: mandate.type} + where: {code: mandate.type} }); const oldMandate = await models.Mandate.findOne({ diff --git a/modules/client/back/models/client-unpaid.json b/modules/client/back/models/client-unpaid.json index 0fc3a9195..6637c3940 100644 --- a/modules/client/back/models/client-unpaid.json +++ b/modules/client/back/models/client-unpaid.json @@ -1,6 +1,9 @@ { "name": "ClientUnpaid", "base": "VnModel", + "mixins": { + "Loggable": true + }, "options": { "mysql": { "table": "clientUnpaid" @@ -25,4 +28,4 @@ "foreignKey": "clientFk" } } -} \ No newline at end of file +} diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 0a8ebcae5..dc19c5d81 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -320,7 +320,8 @@ module.exports = Self => { // Credit management changes - if (changes?.rating >= 0 || changes?.recommendedCredit >= 0) + if ((changes?.rating != null && changes.rating >= 0) + || (changes?.recommendedCredit != null && changes.recommendedCredit >= 0)) await Self.changeCreditManagement(ctx, finalState, changes); const oldInstance = {}; diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json index 510857595..f24f69ae7 100644 --- a/modules/client/back/models/client.json +++ b/modules/client/back/models/client.json @@ -97,9 +97,6 @@ "hasCoreVnh": { "type": "boolean" }, - "hasIncoterms": { - "type": "boolean" - }, "isTaxDataChecked":{ "type": "boolean" }, @@ -147,6 +144,9 @@ }, "recommendedCredit": { "type": "number" + }, + "hasDailyInvoice": { + "type": "boolean" } }, diff --git a/modules/client/back/models/mandate-type.json b/modules/client/back/models/mandate-type.json index ec189f089..b481e7c72 100644 --- a/modules/client/back/models/mandate-type.json +++ b/modules/client/back/models/mandate-type.json @@ -12,7 +12,7 @@ "type": "number", "description": "Identifier" }, - "name": { + "code": { "type": "string" } } diff --git a/modules/client/back/models/specs/address.spec.js b/modules/client/back/models/specs/address.spec.js index f0b421d35..3eae1b1bf 100644 --- a/modules/client/back/models/specs/address.spec.js +++ b/modules/client/back/models/specs/address.spec.js @@ -1,24 +1,10 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('loopback model address', () => { let createdAddressId; const clientId = 1101; - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - - beforeAll(() => { - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); afterAll(async() => { const client = await models.Client.findById(clientId); diff --git a/modules/client/front/address/index/index.js b/modules/client/front/address/index/index.js index 4bad9d4c8..f47d079b2 100644 --- a/modules/client/front/address/index/index.js +++ b/modules/client/front/address/index/index.js @@ -37,7 +37,7 @@ class Controller extends Section { include: { relation: 'country', scope: { - fields: ['id', 'country'] + fields: ['id', 'name'] } } } diff --git a/modules/client/front/balance/create/index.js b/modules/client/front/balance/create/index.js index 9113d7605..f1474e10c 100644 --- a/modules/client/front/balance/create/index.js +++ b/modules/client/front/balance/create/index.js @@ -23,6 +23,7 @@ class Controller extends Dialog { } set clientFk(value) { + if (!value) return; this.receipt.clientFk = value; const filter = { @@ -152,7 +153,7 @@ class Controller extends Dialog { getAmountPaid() { const filter = { where: { - clientFk: this.$params.id, + clientFk: this.$params.id ?? this.clientFk, companyFk: this.receipt.companyFk } }; @@ -210,8 +211,8 @@ ngModule.vnComponent('vnClientBalanceCreate', { payed: ' Client - + Es trabajador diff --git a/modules/client/front/defaulter/index.js b/modules/client/front/defaulter/index.js index bc8686c10..2ec53d380 100644 --- a/modules/client/front/defaulter/index.js +++ b/modules/client/front/defaulter/index.js @@ -57,6 +57,11 @@ export default class Controller extends Section { field: 'observation', searchable: false }, + { + field: 'isWorker', + checkbox: true, + + }, { field: 'created', datepicker: true @@ -73,9 +78,6 @@ export default class Controller extends Section { set defaulters(value) { if (!value || !value.length) return; - for (let defaulter of value) - defaulter.isWorker = defaulter.businessTypeFk === 'worker'; - this._defaulters = value; } @@ -164,6 +166,8 @@ export default class Controller extends Section { exprBuilder(param, value) { switch (param) { + case 'isWorker': + return {isWorker: value}; case 'creditInsurance': case 'amount': case 'clientFk': diff --git a/modules/client/front/extended-list/index.js b/modules/client/front/extended-list/index.js index 8eed48d01..208d77539 100644 --- a/modules/client/front/extended-list/index.js +++ b/modules/client/front/extended-list/index.js @@ -28,7 +28,7 @@ class Controller extends Section { field: 'countryFk', autocomplete: { url: 'Countries', - showField: 'country', + showField: 'name', } }, { diff --git a/modules/client/front/fiscal-data/index.html b/modules/client/front/fiscal-data/index.html index c366c8ca3..979f45fcc 100644 --- a/modules/client/front/fiscal-data/index.html +++ b/modules/client/front/fiscal-data/index.html @@ -184,11 +184,6 @@ - - {{::mandate.id}} {{::mandate.company.code}} - {{::mandate.mandateType.name}} + {{::mandate.mandateType.code}} {{::mandate.created | date:'dd/MM/yyyy HH:mm' | dashIfEmpty}} {{::mandate.finished | date:'dd/MM/yyyy HH:mm' | dashIfEmpty}} diff --git a/modules/client/front/mandate/index.js b/modules/client/front/mandate/index.js index 114e2b570..605ae08cc 100644 --- a/modules/client/front/mandate/index.js +++ b/modules/client/front/mandate/index.js @@ -9,7 +9,7 @@ class Controller extends Section { { relation: 'mandateType', scope: { - fields: ['id', 'name'] + fields: ['id', 'code'] } }, { relation: 'company', diff --git a/modules/client/front/note/index/index.html b/modules/client/front/note/index/index.html index 634a9c3ce..e69de29bb 100644 --- a/modules/client/front/note/index/index.html +++ b/modules/client/front/note/index/index.html @@ -1,31 +0,0 @@ - - - - -
- - {{::note.worker.user.nickname}} - {{::note.created | date:'dd/MM/yyyy HH:mm'}} - - - {{::note.text}} - -
-
-
- - - diff --git a/modules/client/front/note/index/index.js b/modules/client/front/note/index/index.js index ed15db671..1610bdaab 100644 --- a/modules/client/front/note/index/index.js +++ b/modules/client/front/note/index/index.js @@ -5,9 +5,10 @@ import './style.scss'; export default class Controller extends Section { constructor($element, $) { super($element, $); - this.filter = { - order: 'created DESC', - }; + } + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`customer/${this.$params.id}/notes`); } } diff --git a/modules/client/front/postcode/index.html b/modules/client/front/postcode/index.html index b3dbb74d8..fa0b7870f 100644 --- a/modules/client/front/postcode/index.html +++ b/modules/client/front/postcode/index.html @@ -53,7 +53,7 @@ diff --git a/modules/entry/back/methods/entry/addFromBuy.js b/modules/entry/back/methods/entry/addFromBuy.js index e5cc427a8..c75c1935a 100644 --- a/modules/entry/back/methods/entry/addFromBuy.js +++ b/modules/entry/back/methods/entry/addFromBuy.js @@ -52,8 +52,8 @@ module.exports = Self => { else { const userConfig = await models.UserConfig.findById(userId, {fields: ['warehouseFk']}, myOptions); await Self.rawSql( - 'CALL vn.buyUltimate(?,?)', - [userConfig.warehouseFk, null], + 'CALL buy_getUltimate(?, ?, ?)', + [args.item, userConfig.warehouseFk, null], myOptions ); let buyUltimate = await Self.rawSql( diff --git a/modules/entry/back/methods/entry/buyLabel.js b/modules/entry/back/methods/entry/buyLabel.js new file mode 100644 index 000000000..919f7c4d7 --- /dev/null +++ b/modules/entry/back/methods/entry/buyLabel.js @@ -0,0 +1,37 @@ +module.exports = Self => { + Self.remoteMethodCtx('buyLabel', { + description: 'Returns the entry buy labels', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The entry id', + http: {source: 'path'} + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: '/:id/buy-label', + verb: 'GET' + }, + accessScopes: ['DEFAULT', 'read:multimedia'] + }); + + Self.buyLabel = (ctx, id) => Self.printReport(ctx, id, 'buy-label'); +}; diff --git a/modules/entry/back/methods/entry/filter.js b/modules/entry/back/methods/entry/filter.js index 1cd12b737..f4703245c 100644 --- a/modules/entry/back/methods/entry/filter.js +++ b/modules/entry/back/methods/entry/filter.js @@ -1,4 +1,3 @@ - const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; @@ -95,6 +94,31 @@ module.exports = Self => { arg: 'to', type: 'date', description: `The to date filter` + }, + { + arg: 'fromShipped', + type: 'date', + description: `The from shipped date filter` + }, + { + arg: 'toShipped', + type: 'date', + description: `The to shipped date filter` + }, + { + arg: 'daysOnward', + type: 'number', + description: `N days interval` + }, + { + arg: 'daysAgo', + type: 'number', + description: `N days ago interval` + }, + { + arg: 'invoiceAmount', + type: 'number', + description: `The invoice amount` } ], returns: { @@ -112,7 +136,6 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const conn = Self.dataSource.connector; const where = buildFilter(ctx.args, (param, value) => { switch (param) { @@ -130,8 +153,12 @@ module.exports = Self => { return {'e.created': {gte: value}}; case 'from': return {'t.landed': {gte: value}}; + case 'fromShipped': + return {'t.shipped': {gte: value}}; case 'to': return {'t.landed': {lte: value}}; + case 'toShipped': + return {'t.shipped': {lte: value}}; case 'id': case 'isBooked': case 'isConfirmed': @@ -146,7 +173,13 @@ module.exports = Self => { } }); filter = mergeFilters(ctx.args.filter, {where}); - + const userId = ctx.req.accessToken.userId; + const client = await Self.app.models.Client.findById(userId, myOptions); + const supplier = await Self.app.models.Supplier.findOne({where: {nif: client.fi}}, myOptions); + if (supplier) { + if (!filter.where) filter.where = {}; + filter.where[`e.supplierFk`] = supplier.id; + } const stmts = []; let stmt; stmt = new ParameterizedSQL( @@ -158,7 +191,7 @@ module.exports = Self => { e.invoiceNumber, e.isBooked, e.isExcludedFromAvailable, - e.evaNotes AS observation, + e.evaNotes observation, e.isConfirmed, e.isOrdered, e.isRaid, @@ -169,19 +202,48 @@ module.exports = Self => { e.companyFk, e.gestDocFk, e.invoiceInFk, + e.invoiceAmount, t.landed, - s.name AS supplierName, - s.nickname AS supplierAlias, - co.code AS companyCode, - cu.code AS currencyCode + s.name supplierName, + s.nickname supplierAlias, + co.code companyCode, + cu.code currencyCode, + t.shipped, + t.landed, + t.ref AS travelRef, + t.warehouseInFk, + w.name warehouseInName FROM vn.entry e JOIN vn.supplier s ON s.id = e.supplierFk JOIN vn.travel t ON t.id = e.travelFk + JOIN vn.warehouse w ON w.id = t.warehouseInFk JOIN vn.company co ON co.id = e.companyFk JOIN vn.currency cu ON cu.id = e.currencyFk` ); - stmt.merge(conn.makeSuffix(filter)); + stmt.merge(conn.makeWhere(filter.where)); + + const {daysAgo, daysOnward} = ctx.args; + if (daysOnward || daysAgo) { + const params = []; + let today = 'util.VN_CURDATE()'; + let from = today; + let to = today; + + if (daysAgo) { + from += ' - INTERVAL ? DAY'; + params.push(daysAgo); + } + if (daysOnward) { + to += ' + INTERVAL ? DAY'; + params.push(daysOnward); + } + + const whereDays = (filter.where ? 'AND' : 'WHERE') + ` t.shipped BETWEEN ${from} AND ${to}`; + stmt.merge({sql: whereDays, params}); + } + + stmt.merge(conn.makePagination(filter)); const itemsIndex = stmts.push(stmt) - 1; const sql = ParameterizedSQL.join(stmts, ';'); diff --git a/modules/entry/back/methods/entry/getBuys.js b/modules/entry/back/methods/entry/getBuys.js index 90c1bb9d0..245dada09 100644 --- a/modules/entry/back/methods/entry/getBuys.js +++ b/modules/entry/back/methods/entry/getBuys.js @@ -1,7 +1,8 @@ +const UserError = require('vn-loopback/util/user-error'); const mergeFilters = require('vn-loopback/util/filter').mergeFilters; module.exports = Self => { - Self.remoteMethod('getBuys', { + Self.remoteMethodCtx('getBuys', { description: 'Returns buys for one entry', accessType: 'READ', accepts: [{ @@ -27,13 +28,20 @@ module.exports = Self => { } }); - Self.getBuys = async(id, filter, options) => { + Self.getBuys = async(ctx, id, filter, options) => { + const userId = ctx.req.accessToken.userId; const models = Self.app.models; const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); + const client = await Self.app.models.Client.findById(userId, myOptions); + const supplier = await Self.app.models.Supplier.findOne({where: {nif: client.fi}}, myOptions); + if (supplier) { + const isEntryOwner = (await Self.findById(id)).supplierFk === supplier.id; + if (!isEntryOwner) throw new UserError('Access Denied'); + } let defaultFilter = { where: {entryFk: id}, fields: [ @@ -42,21 +50,39 @@ module.exports = Self => { 'stickers', 'packing', 'grouping', + 'packing', 'groupingMode', 'quantity', 'packagingFk', 'weight', 'buyingValue', 'price2', - 'price3' + 'price3', + 'printedStickers', + 'entryFk' ], - include: { + include: [{ + relation: 'entry', + scope: { + fields: [ + 'id', 'supplierFk' + ], + include: { + relation: 'supplier', scope: { + fields: ['id'] + } + } + } + }, + { relation: 'item', scope: { fields: [ 'id', 'typeFk', + 'stems', 'name', + 'category', 'subName', 'size', 'minPrice', @@ -72,18 +98,35 @@ module.exports = Self => { 'value9', 'tag10', 'value10', - 'groupingMode' + 'groupingMode', + 'inkFk', + 'originFk', + 'producerFk', + 'comment' ], - include: { - relation: 'itemType', - scope: { - fields: ['code', 'description'] + include: [ + { + relation: 'itemType', + scope: { + fields: ['code', 'description'] + } + }, + { + relation: 'origin', + scope: { + fields: ['code'] + } + }, + { + relation: 'producer', + scope: { + fields: ['name'] + } } - } + ] } - } + }] }; - defaultFilter = mergeFilters(defaultFilter, filter); return models.Buy.find(defaultFilter, myOptions); diff --git a/modules/entry/back/methods/entry/getBuysCsv.js b/modules/entry/back/methods/entry/getBuysCsv.js new file mode 100644 index 000000000..4bd246fa0 --- /dev/null +++ b/modules/entry/back/methods/entry/getBuysCsv.js @@ -0,0 +1,44 @@ +const {toCSV} = require('vn-loopback/util/csv'); +const {flatten} = require('vn-loopback/util/flatten'); +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('getBuysCsv', { + description: 'Returns buys for one entry in CSV file format', + accessType: 'READ', + accepts: [{ + arg: 'id', + type: 'number', + required: true, + description: 'The entry id', + http: {source: 'path'} + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: `/:id/getBuysCsv`, + verb: 'GET' + } + }); + + Self.getBuysCsv = async(ctx, id, options) => { + const data = await Self.getBuys(ctx, id, null, options); + if (!data.length) throw new UserError('The entry has no lines or does not exist'); + const dataFlatted = flatten(data); + return [toCSV(dataFlatted), 'text/csv', `inline; filename="buys-${id}.csv"`]; + }; +}; diff --git a/modules/entry/back/methods/entry/importBuys.js b/modules/entry/back/methods/entry/importBuys.js index 812775a1b..e3fd653bb 100644 --- a/modules/entry/back/methods/entry/importBuys.js +++ b/modules/entry/back/methods/entry/importBuys.js @@ -73,7 +73,8 @@ module.exports = Self => { }, myOptions); const travel = entry.travel(); - await Self.rawSql('CALL buyUltimate(?, ?)', [ + await Self.rawSql('CALL buy_getUltimate(?, ?, ?)', [ + null, travel.warehouseInFk, travel.landed ], myOptions); diff --git a/modules/entry/back/methods/entry/lastItemBuys.js b/modules/entry/back/methods/entry/lastItemBuys.js index 63e6d38f2..012b99d17 100644 --- a/modules/entry/back/methods/entry/lastItemBuys.js +++ b/modules/entry/back/methods/entry/lastItemBuys.js @@ -50,7 +50,8 @@ module.exports = Self => { const stmts = []; let stmt; - stmt = new ParameterizedSQL(`CALL buyUltimate(?, ?)`, [ + stmt = new ParameterizedSQL(`CALL buy_getUltimate(?, ?, ?)`, [ + null, travel.warehouseInFk, travel.landed ]); diff --git a/modules/entry/back/methods/entry/print.js b/modules/entry/back/methods/entry/print.js new file mode 100644 index 000000000..5b9de9a69 --- /dev/null +++ b/modules/entry/back/methods/entry/print.js @@ -0,0 +1,65 @@ +const UserError = require('vn-loopback/util/user-error'); +module.exports = Self => { + Self.remoteMethodCtx('print', { + description: 'Print stickers of all entries', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The entry id', + http: {source: 'path'} + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: '/:id/print', + verb: 'GET' + }, + accessScopes: ['DEFAULT', 'read:multimedia'] + }); + + Self.print = async function(ctx, id, options) { + const models = Self.app.models; + const myOptions = {}; + if (typeof options == 'object') + Object.assign(myOptions, options); + + // Importación dinámica porque no admite commonjs + const PDFMerger = ((await import('pdf-merger-js')).default); + const merger = new PDFMerger(); + const buys = await models.Buy.find({where: {entryFk: id}}, myOptions); + + for (const buy of buys) { + if (buy.stickers < 1) continue; + ctx.args.id = buy.id; + const pdfBuffer = await models.Entry.buyLabel(ctx, myOptions); + await merger.add(new Uint8Array(pdfBuffer[0])); + } + + if (!merger._doc) throw new UserError('The entry not have stickers'); + + await Self.rawSql(` + UPDATE buy + SET printedStickers = stickers + WHERE entryFk = ? + `, [id], myOptions); + + return [await merger.saveAsBuffer(), 'application/pdf', `filename="entry-${id}.pdf"`]; + }; +}; diff --git a/modules/entry/back/methods/entry/specs/addFromPackaging.spec.js b/modules/entry/back/methods/entry/specs/addFromPackaging.spec.js index 1b0d4656f..0c8d2729b 100644 --- a/modules/entry/back/methods/entry/specs/addFromPackaging.spec.js +++ b/modules/entry/back/methods/entry/specs/addFromPackaging.spec.js @@ -1,5 +1,4 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('entry addFromPackaging()', () => { const supplier = 442; @@ -7,22 +6,10 @@ describe('entry addFromPackaging()', () => { const yesterday = new Date(today); yesterday.setDate(today.getDate() - 1); - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 49}, - http: { - req: { - headers: {origin: 'http://localhost'}, - }, - }, - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx, - }); - }); + beforeAll.mockLoopBackContext(); it('should create an incoming travel', async() => { - const ctx = {args: {isTravelReception: true, supplier}}; + const ctx = {accessToken: {userId: 49}, args: {isTravelReception: true, supplier}}; const tx = await models.Entry.beginTransaction({}); const options = {transaction: tx}; diff --git a/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js b/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js index 885171ed5..f319c112a 100644 --- a/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js +++ b/modules/entry/back/methods/entry/specs/editLatestBuys.spec.js @@ -1,21 +1,7 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('Buy editLatestsBuys()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); it('should change the value of a given column for the selected buys', async() => { const tx = await models.Buy.beginTransaction({}); diff --git a/modules/entry/back/methods/entry/specs/filter.spec.js b/modules/entry/back/methods/entry/specs/filter.spec.js index 28763bc81..4bf5127b0 100644 --- a/modules/entry/back/methods/entry/specs/filter.spec.js +++ b/modules/entry/back/methods/entry/specs/filter.spec.js @@ -9,7 +9,8 @@ describe('Entry filter()', () => { const ctx = { args: { search: 1 - } + }, + req: {accessToken: {userId: 9}} }; const result = await models.Entry.filter(ctx, options); @@ -32,12 +33,13 @@ describe('Entry filter()', () => { const ctx = { args: { currencyFk: 1 - } + }, + req: {accessToken: {userId: 9}} }; const result = await models.Entry.filter(ctx, options); - expect(result.length).toEqual(9); + expect(result.length).toEqual(12); await tx.rollback(); } catch (e) { @@ -46,26 +48,94 @@ describe('Entry filter()', () => { } }); - it('should return the entry matching the supplier', async() => { - const tx = await models.Entry.beginTransaction({}); - const options = {transaction: tx}; + describe('should return the entry matching the supplier', () => { + it('when userId is supplier and searching days onward', async() => { + const tx = await models.Entry.beginTransaction({}); + const options = {transaction: tx}; - try { - const ctx = { - args: { - supplierFk: 2 - } - }; + try { + const ctx = { + args: {daysOnward: 6}, + req: {accessToken: {userId: 1102}} + }; - const result = await models.Entry.filter(ctx, options); + const result = await models.Entry.filter(ctx, options); - expect(result.length).toEqual(6); + expect(result.length).toEqual(2); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('when userId is supplier and searching days ago', async() => { + const tx = await models.Entry.beginTransaction({}); + const options = {transaction: tx}; + + try { + const ctx = { + args: {daysAgo: 31}, + req: {accessToken: {userId: 1102}} + }; + + const result = await models.Entry.filter(ctx, options); + + expect(result.length).toEqual(6); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('when userId is supplier fetching other supplier', async() => { + const tx = await models.Entry.beginTransaction({}); + const options = {transaction: tx}; + + try { + const ctx = { + args: { + supplierFk: 1 + }, + req: {accessToken: {userId: 1102}} + }; + + const result = await models.Entry.filter(ctx, options); + + expect(result.length).toEqual(8); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('when userId is not supplier', async() => { + const tx = await models.Entry.beginTransaction({}); + const options = {transaction: tx}; + + try { + const ctx = { + args: { + supplierFk: 2 + }, + req: {accessToken: {userId: 9}} + }; + + const result = await models.Entry.filter(ctx, options); + + expect(result.length).toEqual(8); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); it('should return the entry matching the company', async() => { @@ -76,12 +146,13 @@ describe('Entry filter()', () => { const ctx = { args: { companyFk: 442 - } + }, + req: {accessToken: {userId: 9}} }; const result = await models.Entry.filter(ctx, options); - expect(result.length).toEqual(8); + expect(result.length).toEqual(11); await tx.rollback(); } catch (e) { @@ -98,7 +169,8 @@ describe('Entry filter()', () => { const ctx = { args: { isBooked: true, - } + }, + req: {accessToken: {userId: 9}} }; const result = await models.Entry.filter(ctx, options); @@ -121,7 +193,8 @@ describe('Entry filter()', () => { args: { reference: 'movement', travelFk: '2' - } + }, + req: {accessToken: {userId: 9}} }; const result = await models.Entry.filter(ctx, options); diff --git a/modules/entry/back/methods/entry/specs/getBuys.spec.js b/modules/entry/back/methods/entry/specs/getBuys.spec.js index cf4462e48..2d3531249 100644 --- a/modules/entry/back/methods/entry/specs/getBuys.spec.js +++ b/modules/entry/back/methods/entry/specs/getBuys.spec.js @@ -1,24 +1,82 @@ +const UserError = require('vn-loopback/util/user-error'); const models = require('vn-loopback/server/server').models; describe('entry getBuys()', () => { const entryId = 4; - it('should get the buys and items of an entry', async() => { - const tx = await models.Entry.beginTransaction({}); - const options = {transaction: tx}; + describe('should get the buys and items of an entry ', () => { + it('when is supplier and entry owner', async() => { + const tx = await models.Entry.beginTransaction({}); + const options = {transaction: tx}; - try { - const result = await models.Entry.getBuys(entryId, options); + try { + const ctx = { + args: { + search: 1 + }, + req: {accessToken: {userId: 2}} + }; - const length = result.length; - const anyResult = result[Math.floor(Math.random() * Math.floor(length))]; + const result = await models.Entry.getBuys(ctx, entryId, options); - expect(result.length).toEqual(4); - expect(anyResult.item).toBeDefined(); + const length = result.length; + const anyResult = result[Math.floor(Math.random() * Math.floor(length))]; - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(result.length).toEqual(4); + expect(anyResult.item).toBeDefined(); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('when is supplier but not entry owner', async() => { + const tx = await models.Entry.beginTransaction({}); + const options = {transaction: tx}; + const entryId = 1; + try { + const ctx = { + args: { + search: 1 + }, + req: {accessToken: {userId: 1102}} + }; + + const result = await models.Entry.getBuys(ctx, entryId, options); + + expect(result).toBeUndefined(); + } catch (error) { + expect(error).toBeInstanceOf(UserError); + expect(error.message).toBe('Access Denied'); + } + }); + + it('when is not supplier', async() => { + const tx = await models.Entry.beginTransaction({}); + const options = {transaction: tx}; + + try { + const ctx = { + args: { + search: 1 + }, + req: {accessToken: {userId: 9}} + }; + + const result = await models.Entry.getBuys(ctx, entryId, options); + + const length = result.length; + const anyResult = result[Math.floor(Math.random() * Math.floor(length))]; + + expect(result.length).toEqual(4); + expect(anyResult.item).toBeDefined(); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); }); diff --git a/modules/entry/back/methods/entry/specs/importBuysPreview.spec.js b/modules/entry/back/methods/entry/specs/importBuysPreview.spec.js index c860e228e..fb3268901 100644 --- a/modules/entry/back/methods/entry/specs/importBuysPreview.spec.js +++ b/modules/entry/back/methods/entry/specs/importBuysPreview.spec.js @@ -1,14 +1,8 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); -const activeCtx = {accessToken: {userId: 9}}; describe('entry importBuysPreview()', () => { const entryId = 1; - beforeAll(async() => { - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); it('should return the buys with the calculated packagingFk', async() => { const tx = await models.Entry.beginTransaction({}); diff --git a/modules/entry/back/methods/stock-bought/getStockBought.js b/modules/entry/back/methods/stock-bought/getStockBought.js new file mode 100644 index 000000000..c1f99c496 --- /dev/null +++ b/modules/entry/back/methods/stock-bought/getStockBought.js @@ -0,0 +1,58 @@ +module.exports = Self => { + Self.remoteMethod('getStockBought', { + description: 'Returns the stock bought for a given date', + accessType: 'READ', + accepts: [{ + arg: 'workerFk', + type: 'number', + description: 'The id for a buyer', + }, + { + arg: 'dated', + type: 'date', + description: 'The date to filter', + } + ], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/getStockBought`, + verb: 'GET' + } + }); + + Self.getStockBought = async(workerFk, dated = Date.vnNew()) => { + const models = Self.app.models; + const today = Date.vnNew(); + dated.setHours(0, 0, 0, 0); + today.setHours(0, 0, 0, 0); + + await models.StockBought.rawSql(`CALL vn.stockBought_calculate(?)`, [dated]); + + const filter = { + where: {dated}, + include: [ + { + fields: ['workerFk', 'reserve', 'bought'], + relation: 'worker', + scope: { + include: [ + { + relation: 'user', + scope: { + fields: ['id', 'name'] + } + } + ] + } + } + ] + }; + + if (workerFk) filter.where.workerFk = workerFk; + + return models.StockBought.find(filter); + }; +}; diff --git a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js new file mode 100644 index 000000000..d5f712edf --- /dev/null +++ b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js @@ -0,0 +1,74 @@ +module.exports = Self => { + Self.remoteMethod('getStockBoughtDetail', { + description: 'Returns the detail of stock bought for a given date and a worker', + accessType: 'READ', + accepts: [{ + arg: 'workerFk', + type: 'number', + description: 'The worker to filter', + required: true, + }, { + arg: 'dated', + type: 'string', + description: 'The date to filter', + required: true, + } + ], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/getStockBoughtDetail`, + verb: 'GET' + } + }); + + Self.getStockBoughtDetail = async(workerFk, dated) => { + const models = Self.app.models; + const myOptions = {}; + let tx; + let result; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + await models.StockBought.rawSql(`CALL vn.item_calculateStock(?)`, [dated], myOptions); + result = await Self.rawSql( + `SELECT b.entryFk entryFk, + i.id itemFk, + i.name itemName, + ti.quantity, + ROUND((ac.conversionCoefficient * (ti.quantity / b.packing) * buy_getVolume(b.id)) + / (vc.trolleyM3 * 1000000),1) volume, + b.packagingFk packagingFk, + b.packing + FROM tmp.item ti + JOIN item i ON i.id = ti.itemFk + JOIN itemType it ON i.typeFk = it.id + JOIN itemCategory ic ON ic.id = it.categoryFk + JOIN worker w ON w.id = it.workerFk + JOIN auctionConfig ac + JOIN tmp.buyUltimate bu ON bu.itemFk = i.id + AND bu.warehouseFk = ac.warehouseFk + JOIN buy b ON b.id = bu.buyFk + JOIN volumeConfig vc + WHERE ic.display + AND w.id = ?`, + [workerFk], myOptions + ); + await Self.rawSql(`DROP TEMPORARY TABLE tmp.item, tmp.buyUltimate;`, [], myOptions); + if (tx) await tx.commit(); + return result; + } catch (e) { + await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/entry/back/model-config.json b/modules/entry/back/model-config.json index 7b6e23685..5c45b6e07 100644 --- a/modules/entry/back/model-config.json +++ b/modules/entry/back/model-config.json @@ -22,5 +22,11 @@ }, "EntryObservation": { "dataSource": "vn" + }, + "EntryType": { + "dataSource": "vn" + }, + "StockBought": { + "dataSource": "vn" } } diff --git a/modules/entry/back/models/entry-type.json b/modules/entry/back/models/entry-type.json new file mode 100644 index 000000000..989aa3a8a --- /dev/null +++ b/modules/entry/back/models/entry-type.json @@ -0,0 +1,25 @@ +{ + "name": "EntryType", + "base": "VnModel", + "mixins": { + "Loggable": true + }, + "options": { + "mysql": { + "table": "entryType" + } + }, + "properties": { + "code": { + "type": "string", + "id": true, + "description": "Identifier" + }, + "description": { + "type": "string" + }, + "isInformal": { + "type": "boolean" + } + } +} \ No newline at end of file diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 6148ae559..8ca79f531 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -3,12 +3,15 @@ module.exports = Self => { require('../methods/entry/filter')(Self); require('../methods/entry/getEntry')(Self); require('../methods/entry/getBuys')(Self); + require('../methods/entry/getBuysCsv')(Self); require('../methods/entry/importBuys')(Self); require('../methods/entry/importBuysPreview')(Self); require('../methods/entry/lastItemBuys')(Self); require('../methods/entry/entryOrderPdf')(Self); require('../methods/entry/addFromPackaging')(Self); require('../methods/entry/addFromBuy')(Self); + require('../methods/entry/buyLabel')(Self); + require('../methods/entry/print')(Self); Self.observe('before save', async function(ctx, options) { if (ctx.isNewInstance) return; diff --git a/modules/entry/back/models/entry.json b/modules/entry/back/models/entry.json index ab451219e..383585fce 100644 --- a/modules/entry/back/models/entry.json +++ b/modules/entry/back/models/entry.json @@ -35,9 +35,9 @@ }, "isVirtual": { "type": "boolean", - "mysql": { - "columnName": "isRaid" - } + "mysql": { + "columnName": "isRaid" + } }, "isRaid": { "type": "boolean" @@ -53,9 +53,9 @@ }, "observation": { "type": "string", - "mysql": { - "columnName": "evaNotes" - } + "mysql": { + "columnName": "evaNotes" + } }, "loadPriority": { "type": "number" @@ -74,6 +74,9 @@ }, "observationEditorFk": { "type": "number" + }, + "invoiceAmount": { + "type": "number" } }, "relations": { @@ -101,6 +104,11 @@ "type": "belongsTo", "model": "Account", "foreignKey": "observationEditorFk" + }, + "entryType": { + "type": "belongsTo", + "model": "EntryType", + "foreignKey": "typeFk" } } } diff --git a/modules/entry/back/models/stock-bought.js b/modules/entry/back/models/stock-bought.js new file mode 100644 index 000000000..ae52e7654 --- /dev/null +++ b/modules/entry/back/models/stock-bought.js @@ -0,0 +1,10 @@ +const UserError = require('vn-loopback/util/user-error'); +module.exports = Self => { + require('../methods/stock-bought/getStockBought')(Self); + require('../methods/stock-bought/getStockBoughtDetail')(Self); + Self.rewriteDbError(function(err) { + if (err.code === 'ER_DUP_ENTRY') + return new UserError(`This buyer has already made a reservation for this date`); + return err; + }); +}; diff --git a/modules/entry/back/models/stock-bought.json b/modules/entry/back/models/stock-bought.json new file mode 100644 index 000000000..18c9f0347 --- /dev/null +++ b/modules/entry/back/models/stock-bought.json @@ -0,0 +1,34 @@ +{ + "name": "StockBought", + "base": "VnModel", + "options": { + "mysql": { + "table": "stockBought" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "workerFk": { + "type": "number" + }, + "bought": { + "type": "number" + }, + "reserve": { + "type": "number" + }, + "dated": { + "type": "date" + } + }, + "relations": { + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + } + } +} diff --git a/modules/entry/front/basic-data/index.html b/modules/entry/front/basic-data/index.html deleted file mode 100644 index 57de1c5f7..000000000 --- a/modules/entry/front/basic-data/index.html +++ /dev/null @@ -1,234 +0,0 @@ - - - - - -
- - - - -
#{{::nickname}}
-
#{{::id}}
-
-
- - -
- {{::agencyModeName}} - {{::warehouseInName}} ({{::shipped | date: 'dd/MM/yyyy'}}) → - {{::warehouseOutName}} ({{::landed | date: 'dd/MM/yyyy'}}) -
-
#{{::id}}
-
- - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - ID - Agency - Warehouse Out - Warehouse In - Shipped - Landed - - - - - - - {{::travel.id}} - - - {{::travel.agency.name}} - {{::travel.warehouseOut.name}} - {{::travel.warehouseIn.name}} - {{::travel.shipped | date: 'dd/MM/yyyy'}} - {{::travel.landed | date: 'dd/MM/yyyy'}} - - - - - - - - diff --git a/modules/entry/front/basic-data/index.js b/modules/entry/front/basic-data/index.js deleted file mode 100644 index 564a3df5c..000000000 --- a/modules/entry/front/basic-data/index.js +++ /dev/null @@ -1,68 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - showFilterDialog(travel) { - this.activeTravel = travel; - this.travelFilterParams = {}; - this.travelFilter = { - include: [ - { - relation: 'agency', - scope: { - fields: ['name'] - } - }, - { - relation: 'warehouseIn', - scope: { - fields: ['name'] - } - }, - { - relation: 'warehouseOut', - scope: { - fields: ['name'] - } - } - ] - }; - - this.$.filterDialog.show(); - } - - selectTravel(id) { - this.entry.travelFk = id; - this.$.filterDialog.hide(); - } - - filter() { - const filter = this.travelFilter; - const params = this.travelFilterParams; - const where = {}; - for (let key in params) { - const value = params[key]; - if (!value) continue; - - switch (key) { - case 'agencyModeFk': - case 'warehouseInFk': - case 'warehouseOutFk': - case 'shipped': - case 'landed': - where[key] = value; - } - } - - filter.where = where; - this.$.travelsModel.applyFilter(filter); - } -} -ngModule.vnComponent('vnEntryBasicData', { - template: require('./index.html'), - bindings: { - entry: '<' - }, - controller: Controller -}); diff --git a/modules/entry/front/basic-data/style.scss b/modules/entry/front/basic-data/style.scss deleted file mode 100644 index 508aa9091..000000000 --- a/modules/entry/front/basic-data/style.scss +++ /dev/null @@ -1,3 +0,0 @@ -.travelFilter{ - width: 950px; -} diff --git a/modules/entry/front/buy/import/index.html b/modules/entry/front/buy/import/index.html deleted file mode 100644 index 28396434c..000000000 --- a/modules/entry/front/buy/import/index.html +++ /dev/null @@ -1,205 +0,0 @@ - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ItemDescriptionSizePackingGroupingBuying valueBox
- - - {{::id}} - {{::name}} - - - - - - - {{::buy.description | dashIfEmpty}}{{::buy.size | dashIfEmpty}}{{::buy.packing | dashIfEmpty}}{{::buy.grouping | dashIfEmpty}}{{::buy.buyingValue | currency: 'EUR':2}} - - -
-
-
- - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - ID - Item - Size - Producer - Color - - - - - - - {{::item.id}} - - - {{::item.name}} - {{::item.size}} - {{::item.producerName}} - {{::item.inkName}} - - - - - - - - \ No newline at end of file diff --git a/modules/entry/front/buy/import/index.js b/modules/entry/front/buy/import/index.js deleted file mode 100644 index ba0a98e62..000000000 --- a/modules/entry/front/buy/import/index.js +++ /dev/null @@ -1,159 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.import = { - file: '', - invoice: null, - buys: [] - }; - } - - onFileChange($event) { - const input = $event.target; - const file = input.files[0]; - - const reader = new FileReader(); - reader.onload = event => - this.fillData(event.target.result); - reader.readAsText(file, 'UTF-8'); - } - - fillData(raw) { - const data = JSON.parse(raw); - const [invoice] = data.invoices; - - this.$.$applyAsync(() => { - this.import.observation = invoice.tx_awb; - - const companyName = invoice.tx_company; - const boxes = invoice.boxes; - const buys = []; - for (let box of boxes) { - const boxVolume = box.nu_length * box.nu_width * box.nu_height; - for (let product of box.products) { - const packing = product.nu_stems_bunch * product.nu_bunches; - buys.push({ - description: product.nm_product, - companyName: companyName, - size: product.nu_length, - packing: packing, - grouping: product.nu_stems_bunch, - buyingValue: parseFloat(product.mny_rate_stem), - volume: boxVolume, - }); - } - } - - const boxesId = boxes.map(box => box.id_box); - this.import.ref = boxesId.join(', '); - - this.fetchBuys(buys); - }); - } - - fetchBuys(buys) { - const params = {buys}; - const query = `Entries/${this.$params.id}/importBuysPreview`; - this.$http.post(query, params).then(res => { - this.import.buys = res.data; - }); - } - - onSubmit() { - try { - const params = this.import; - const hasAnyEmptyRow = params.buys.some(buy => { - return buy.itemFk == null; - }); - - if (hasAnyEmptyRow) - throw new Error(`Some of the imported buys doesn't have an item`); - - const query = `Entries/${this.$params.id}/importBuys`; - return this.$http.post(query, params) - .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))) - .then(() => this.$state.go('entry.card.buy.index')); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } - } - - itemSearchFunc($search) { - return /^\d+$/.test($search) - ? {id: $search} - : {name: {like: '%' + $search + '%'}}; - } - - showFilterDialog(buy) { - this.activeBuy = buy; - this.itemFilterParams = {}; - this.itemFilter = { - include: [ - { - relation: 'producer', - scope: { - fields: ['name'] - } - }, - { - relation: 'ink', - scope: { - fields: ['name'] - } - } - ] - }; - - this.$.filterDialog.show(); - } - - selectItem(id) { - this.activeBuy['itemFk'] = id; - this.$.filterDialog.hide(); - } - - filter() { - const filter = this.itemFilter; - const params = this.itemFilterParams; - const where = {}; - - for (let key in params) { - const value = params[key]; - if (!value) continue; - - switch (key) { - case 'name': - where[key] = {like: `%${value}%`}; - break; - case 'producerFk': - case 'typeFk': - case 'size': - case 'inkFk': - where[key] = value; - } - } - - filter.where = where; - this.$.itemsModel.applyFilter(filter); - } - - onKeyPress($event) { - if ($event.key === 'Enter') - this.filter(); - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnEntryBuyImport', { - template: require('./index.html'), - controller: Controller, - bindings: { - worker: '<' - } -}); diff --git a/modules/entry/front/buy/import/index.spec.js b/modules/entry/front/buy/import/index.spec.js deleted file mode 100644 index 036f52074..000000000 --- a/modules/entry/front/buy/import/index.spec.js +++ /dev/null @@ -1,199 +0,0 @@ -import './index.js'; - -describe('Entry', () => { - describe('Component vnEntryBuyImport', () => { - let controller; - let $httpParamSerializer; - let $httpBackend; - - beforeEach(ngModule('entry')); - - beforeEach(angular.mock.inject(($componentController, $compile, $rootScope, _$httpParamSerializer_, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - let $element = $compile(' { - it(`should call to the fillData() method`, () => { - controller.fetchBuys = jest.fn(); - - const rawData = `{ - "invoices": [ - { - "tx_awb": "123456", - "boxes": [ - { - "id_box": 1, - "nu_length": 1, - "nu_width": 15, - "nu_height": 80, - "products": [ - { - "nm_product": "Bow", - "nu_length": 1, - "nu_stems_bunch": 1, - "nu_bunches": 1, - "mny_rate_stem": 5.77 - } - - ] - }, - { - "id_box": 2, - "nu_length": 25, - "nu_width": 1, - "nu_height": 45, - "products": [ - { - "nm_product": "Arrow", - "nu_length": 25, - "nu_stems_bunch": 1, - "nu_bunches": 1, - "mny_rate_stem": 2.16 - } - ] - } - ] - } - ]}`; - const expectedBuys = [ - { - 'buyingValue': 5.77, - 'description': 'Bow', - 'grouping': 1, - 'packing': 1, - 'size': 1, - 'volume': 1200}, - - { - 'buyingValue': 2.16, - 'description': 'Arrow', - 'grouping': 1, - 'packing': 1, - 'size': 25, - 'volume': 1125} - ]; - controller.fillData(rawData); - controller.$.$apply(); - - const importData = controller.import; - - expect(importData.observation).toEqual('123456'); - expect(importData.ref).toEqual('1, 2'); - - expect(controller.fetchBuys).toHaveBeenCalledWith(expectedBuys); - }); - }); - - describe('fetchBuys()', () => { - it(`should perform a query to fetch the buys data`, () => { - const buys = [ - { - 'buyingValue': 5.77, - 'description': 'Bow', - 'grouping': 1, - 'packing': 1, - 'size': 1, - 'volume': 1200}, - - { - 'buyingValue': 2.16, - 'description': 'Arrow', - 'grouping': 1, - 'packing': 1, - 'size': 25, - 'volume': 1125} - ]; - - const query = `Entries/1/importBuysPreview`; - $httpBackend.expectPOST(query).respond(200, buys); - controller.fetchBuys(buys); - $httpBackend.flush(); - - const importData = controller.import; - - expect(importData.buys.length).toEqual(2); - }); - }); - - describe('onSubmit()', () => { - it(`should throw an error when some of the rows doesn't have an item`, () => { - jest.spyOn(controller.vnApp, 'showError'); - - controller.import = { - observation: '123456', - ref: '1, 2', - buys: [ - { - 'buyingValue': 5.77, - 'description': 'Bow', - 'grouping': 1, - 'packing': 1, - 'size': 1, - 'volume': 1200}, - { - 'buyingValue': 2.16, - 'description': 'Arrow', - 'grouping': 1, - 'packing': 1, - 'size': 25, - 'volume': 1125} - ] - }; - - controller.onSubmit(); - - const message = `Some of the imported buys doesn't have an item`; - - expect(controller.vnApp.showError).toHaveBeenCalledWith(message); - }); - - it(`should now perform a query to update columns`, () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - controller.$state.go = jest.fn(); - - controller.import = { - observation: '123456', - ref: '1, 2', - buys: [ - { - 'itemFk': 10, - 'buyingValue': 5.77, - 'description': 'Bow', - 'grouping': 1, - 'packing': 1, - 'size': 1, - 'volume': 1200}, - { - 'itemFk': 11, - 'buyingValue': 2.16, - 'description': 'Arrow', - 'grouping': 1, - 'packing': 1, - 'size': 25, - 'volume': 1125} - ] - }; - const params = controller.import; - - const query = `Entries/1/importBuys`; - $httpBackend.expectPOST(query, params).respond(200, params.buys); - controller.onSubmit(); - $httpBackend.flush(); - - const importData = controller.import; - - expect(importData.buys.length).toEqual(2); - - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); - expect(controller.$state.go).toHaveBeenCalledWith('entry.card.buy.index'); - }); - }); - }); -}); diff --git a/modules/entry/front/buy/import/style.scss b/modules/entry/front/buy/import/style.scss deleted file mode 100644 index 9b2fb7688..000000000 --- a/modules/entry/front/buy/import/style.scss +++ /dev/null @@ -1,5 +0,0 @@ -.itemFilter { - vn-table.scrollable { - height: 500px - } -} \ No newline at end of file diff --git a/modules/entry/front/buy/index/index.html b/modules/entry/front/buy/index/index.html deleted file mode 100644 index 0e0c69788..000000000 --- a/modules/entry/front/buy/index/index.html +++ /dev/null @@ -1,243 +0,0 @@ - - - - - - -
- - - - - - -

Subtotal {{$ctrl.ticket.totalWithoutVat | currency: 'EUR':2}}

-

VAT {{$ctrl.ticket.totalWithVat - $ctrl.ticket.totalWithoutVat | currency: 'EUR':2}}

-

Total {{$ctrl.ticket.totalWithVat | currency: 'EUR':2}}

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - ItemQuantityPackageStickersWeightPackingGroupingBuying valueGrouping pricePacking priceImport
- - - - - {{::buy.item.id}} - - - -
{{::name}}
-
#{{::id}}
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{buy.quantity * buy.buyingValue | currency: 'EUR':2}} - -
- - - {{::buy.item.itemType.code}} - - - - {{::buy.item.size}} - - - - {{::buy.item.minPrice | currency: 'EUR':2}} - - -
- {{::buy.item.name}} - -

{{::buy.item.subName}}

-
-
- - -
-
-
-
-
- - - - - - -
- - - - diff --git a/modules/entry/front/buy/index/index.js b/modules/entry/front/buy/index/index.js deleted file mode 100644 index 9131c31f6..000000000 --- a/modules/entry/front/buy/index/index.js +++ /dev/null @@ -1,81 +0,0 @@ -import ngModule from '../../module'; -import './style.scss'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - saveBuy(buy) { - const missingData = !buy.itemFk || !buy.quantity || !buy.packagingFk; - if (missingData) return; - - let options; - if (buy.id) { - options = { - query: `Buys/${buy.id}`, - method: 'patch' - }; - } - this.$http[options.method](options.query, buy).then(res => { - if (!res.data) return; - - buy = Object.assign(buy, res.data); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - /** - * Returns checked instances - * - * @return {Array} Checked instances - */ - selectedBuys() { - if (!this.buys) return; - - return this.buys.filter(buy => { - return buy.checked; - }); - } - - deleteBuys() { - const buys = this.selectedBuys(); - const actualInstances = buys.filter(buy => buy.id); - - const params = {buys: actualInstances}; - - if (actualInstances.length) { - this.$http.post(`Buys/deleteBuys`, params).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - buys.forEach(buy => { - const index = this.buys.indexOf(buy); - this.buys.splice(index, 1); - }); - } - - toggleGroupingMode(buy, mode) { - const groupingMode = mode === 'grouping' ? mode : 'packing'; - const newGroupingMode = buy.groupingMode === groupingMode ? null : groupingMode; - const params = { - groupingMode: newGroupingMode - }; - - this.$http.patch(`Buys/${buy.id}`, params).then(() => { - buy.groupingMode = newGroupingMode; - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - itemSearchFunc($search) { - return /^\d+$/.test($search) - ? {id: $search} - : {name: {like: '%' + $search + '%'}}; - } -} - -ngModule.vnComponent('vnEntryBuyIndex', { - template: require('./index.html'), - controller: Controller, - bindings: { - entry: '<' - } -}); diff --git a/modules/entry/front/buy/index/index.spec.js b/modules/entry/front/buy/index/index.spec.js deleted file mode 100644 index f5c6d1bdb..000000000 --- a/modules/entry/front/buy/index/index.spec.js +++ /dev/null @@ -1,92 +0,0 @@ -/* eslint max-len: ["error", { "code": 150 }]*/ -import './index.js'; - -describe('Entry buy', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('entry')); - - beforeEach(angular.mock.inject(($componentController, $compile, $rootScope, _$httpParamSerializer_, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - let $element = $compile(' { - it(`should call the buys patch route if the received buy has an ID`, () => { - const buy = {id: 1, itemFk: 1, quantity: 1, packagingFk: 1}; - - const query = `Buys/${buy.id}`; - - $httpBackend.expectPATCH(query).respond(200); - controller.saveBuy(buy); - $httpBackend.flush(); - }); - }); - - describe('deleteBuys()', () => { - it(`should perform no queries if all buys to delete were not actual instances`, () => { - controller.buys = [ - {checked: true}, - {checked: true}, - {checked: false}]; - - controller.deleteBuys(); - - expect(controller.buys.length).toEqual(1); - }); - - it(`should perform a query to delete as there's an actual instance at least`, () => { - controller.buys = [ - {checked: true, id: 1}, - {checked: true}, - {checked: false}]; - - const query = 'Buys/deleteBuys'; - - $httpBackend.expectPOST(query).respond(200); - controller.deleteBuys(); - $httpBackend.flush(); - - expect(controller.buys.length).toEqual(1); - }); - }); - - describe('toggleGroupingMode()', () => { - it(`should toggle grouping mode from grouping to packing`, () => { - const buy = {id: 999, groupingMode: 'grouping'}; - - const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: 'packing'}).respond(200); - controller.toggleGroupingMode(buy, 'packing'); - $httpBackend.flush(); - }); - - it(`should toggle grouping mode from packing to grouping`, () => { - const buy = {id: 999, groupingMode: 'packing'}; - const query = `Buys/${buy.id}`; - $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 buy = {id: 999, groupingMode: 'packing'}; - const query = `Buys/${buy.id}`; - $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 buy = {id: 999, groupingMode: 'grouping'}; - const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: null}).respond(200); - controller.toggleGroupingMode(buy, 'grouping'); - $httpBackend.flush(); - }); - }); -}); diff --git a/modules/entry/front/buy/index/locale/es.yml b/modules/entry/front/buy/index/locale/es.yml deleted file mode 100644 index 0a1ecf5b1..000000000 --- a/modules/entry/front/buy/index/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Buys: Compras -Delete buy(s): Eliminar compra(s) -Add buy: Añadir compra \ No newline at end of file diff --git a/modules/entry/front/buy/index/style.scss b/modules/entry/front/buy/index/style.scss deleted file mode 100644 index 3fad252df..000000000 --- a/modules/entry/front/buy/index/style.scss +++ /dev/null @@ -1,42 +0,0 @@ -@import "variables"; - - -vn-entry-buy-index vn-card { - max-width: $width-xl; - - .dark-row { - background-color: lighten($color-marginal, 10%); - } - - thead tr { - border: 1px solid white;; - } - - tbody tr:nth-child(1), - tbody tr:nth-child(2) { - border-left: 1px solid $color-spacer; - border-right: 1px solid $color-spacer; - } - - tbody tr:nth-child(2) { - border-bottom: 1px solid $color-spacer; - } - - tbody{ - border-bottom: 1px solid $color-spacer; - } - - tbody:last-child { - border-bottom: 0; - } - - tbody tr:nth-child(3) { - height: inherit - } - - tr { - margin-bottom: 10px; - } -} - -$color-font-link-medium: lighten($color-font-link, 20%) diff --git a/modules/entry/front/buy/locale/es.yml b/modules/entry/front/buy/locale/es.yml deleted file mode 100644 index 55828a3c6..000000000 --- a/modules/entry/front/buy/locale/es.yml +++ /dev/null @@ -1,8 +0,0 @@ -reference: Referencia -Observation: Observación -Box: Embalaje -Import buys: Importar compras -Some of the imported buys doesn't have an item: Algunas de las compras importadas no tienen un artículo -JSON files only: Solo ficheros JSON -Filter item: Filtrar artículo -Filter...: Filtrar... \ No newline at end of file diff --git a/modules/entry/front/card/index.html b/modules/entry/front/card/index.html deleted file mode 100644 index d386a9ebf..000000000 --- a/modules/entry/front/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/entry/front/card/index.js b/modules/entry/front/card/index.js deleted file mode 100644 index 96f4702e2..000000000 --- a/modules/entry/front/card/index.js +++ /dev/null @@ -1,59 +0,0 @@ -import ngModule from '../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - let filter = { - include: [ - { - relation: 'company', - scope: { - fields: ['id', 'code'] - } - }, - { - relation: 'travel', - scope: { - fields: ['id', 'landed', 'agencyModeFk', 'warehouseOutFk'], - include: [ - { - relation: 'agency', - scope: { - fields: ['name'] - } - }, - { - relation: 'warehouseOut', - scope: { - fields: ['name'] - } - }, - { - relation: 'warehouseIn', - scope: { - fields: ['name'] - } - } - ] - } - }, - { - relation: 'supplier', - scope: { - fields: ['id', 'nickname'] - } - }, - { - relation: 'currency' - } - ] - }; - this.$http.get(`Entries/${this.$params.id}`, {filter}) - .then(response => this.entry = response.data); - } -} - -ngModule.vnComponent('vnEntryCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/entry/front/create/index.html b/modules/entry/front/create/index.html deleted file mode 100644 index e1e4dc064..000000000 --- a/modules/entry/front/create/index.html +++ /dev/null @@ -1,69 +0,0 @@ - - -
- - - - - - -
{{::nickname}}
-
#{{::id}}
-
-
-
- - - -
- {{::agencyModeName}} - - {{::warehouseInName}} ({{::shipped | date: 'dd/MM/yyyy'}}) - → {{::warehouseOutName}} ({{::landed | date: 'dd/MM/yyyy'}}) -
-
#{{::id}}
-
-
-
- - - - -
- - - - - - -
diff --git a/modules/entry/front/create/index.js b/modules/entry/front/create/index.js deleted file mode 100644 index 5c61730f9..000000000 --- a/modules/entry/front/create/index.js +++ /dev/null @@ -1,43 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - - this.entry = { - companyFk: this.vnConfig.companyFk - }; - - if (this.$params && this.$params.supplierFk) - this.entry.supplierFk = parseInt(this.$params.supplierFk); - if (this.$params && this.$params.travelFk) - this.entry.travelFk = parseInt(this.$params.travelFk); - if (this.$params && this.$params.companyFk) - this.entry.companyFk = parseInt(this.$params.companyFk); - } - - onSubmit() { - this.$.watcher.submit().then( - res => this.$state.go('entry.card.basicData', {id: res.data.id}) - ); - } - - searchFunction($search) { - return {or: [ - {'agencyModeName': {like: `%${$search}%`}}, - {'warehouseInName': {like: `%${$search}%`}}, - {'warehouseOutName': {like: `%${$search}%`}}, - {'shipped': new Date($search)}, - {'landed': new Date($search)} - ]}; - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnEntryCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/entry/front/create/locale/es.yml b/modules/entry/front/create/locale/es.yml deleted file mode 100644 index aa269ed15..000000000 --- a/modules/entry/front/create/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -New entry: Nueva entrada -Required fields (*): Campos requeridos (*) \ No newline at end of file diff --git a/modules/entry/front/create/style.scss b/modules/entry/front/create/style.scss deleted file mode 100644 index 2dc52b1ff..000000000 --- a/modules/entry/front/create/style.scss +++ /dev/null @@ -1,10 +0,0 @@ -vn-entry-create { - vn-card { - position: relative - } - vn-icon[icon="info"] { - position: absolute; - top: 16px; - right: 16px - } -} \ No newline at end of file diff --git a/modules/entry/front/descriptor-popover/index.html b/modules/entry/front/descriptor-popover/index.html index 465a9bf51..23f641632 100644 --- a/modules/entry/front/descriptor-popover/index.html +++ b/modules/entry/front/descriptor-popover/index.html @@ -1,3 +1,3 @@ - - + + \ No newline at end of file diff --git a/modules/entry/front/descriptor/index.html b/modules/entry/front/descriptor/index.html index 7b61a0cf5..3354d4155 100644 --- a/modules/entry/front/descriptor/index.html +++ b/modules/entry/front/descriptor/index.html @@ -1,65 +1,65 @@ - - - - Show entry report - - - -
- - - - - - -
-
- - - - -
- -
-
- - + + + + Show entry report + + + +
+ + + + + + +
+
+ + + + +
+ +
+
+ + \ No newline at end of file diff --git a/modules/entry/front/descriptor/index.spec.js b/modules/entry/front/descriptor/index.spec.js deleted file mode 100644 index 714bb9f3c..000000000 --- a/modules/entry/front/descriptor/index.spec.js +++ /dev/null @@ -1,40 +0,0 @@ -import './index.js'; - -describe('Entry Component vnEntryDescriptor', () => { - let $httpBackend; - let controller; - const entry = {id: 2}; - - beforeEach(ngModule('entry')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnEntryDescriptor', {$element: null}, {entry}); - })); - - describe('showEntryReport()', () => { - it('should open a new window showing a delivery note PDF document', () => { - jest.spyOn(controller.vnReport, 'show'); - - window.open = jasmine.createSpy('open'); - controller.showEntryReport(); - const expectedPath = `Entries/${entry.id}/entry-order-pdf`; - - expect(controller.vnReport.show).toHaveBeenCalledWith(expectedPath); - }); - }); - - describe('loadData()', () => { - it('should perform ask for the entry', () => { - let query = `Entries/${entry.id}`; - jest.spyOn(controller, 'getData'); - - $httpBackend.expectGET(query).respond(); - controller.loadData(); - $httpBackend.flush(); - - expect(controller.getData).toHaveBeenCalledTimes(1); - expect(controller.getData).toHaveBeenCalledWith(query, jasmine.any(Object)); - }); - }); -}); diff --git a/modules/entry/front/descriptor/locale/es.yml b/modules/entry/front/descriptor/locale/es.yml deleted file mode 100644 index ad2fef6f3..000000000 --- a/modules/entry/front/descriptor/locale/es.yml +++ /dev/null @@ -1,7 +0,0 @@ -Reference: Referencia -Supplier card: Ficha del proveedor -All travels with current agency: Todos los envios con la agencia actual -All entries with current supplier: Todas las entradas con el proveedor actual -Show entry report: Ver informe del pedido -Is inventory entry: Es una entrada de inventario -Is virtual entry: Es una redada \ No newline at end of file diff --git a/modules/entry/front/index.js b/modules/entry/front/index.js index 88700b166..0f2208862 100644 --- a/modules/entry/front/index.js +++ b/modules/entry/front/index.js @@ -1,18 +1,6 @@ export * from './module'; import './main'; -import './index/'; -import './create'; -import './basic-data'; -import './latest-buys'; -import './search-panel'; -import './latest-buys-search-panel'; import './descriptor'; import './descriptor-popover'; -import './card'; -import './note'; import './summary'; -import './log'; -import './buy/index'; -import './buy/import'; - diff --git a/modules/entry/front/index/index.html b/modules/entry/front/index/index.html deleted file mode 100644 index 42177be21..000000000 --- a/modules/entry/front/index/index.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - Id - Landed - Reference - Invoice number - Supplier - Booked - Confirmed - Ordered - - - - - - - - - - - - {{::entry.id}} - - - {{::entry.landed | date:'dd/MM/yyyy'}} - - - {{::entry.reference}} - {{::entry.invoiceNumber}} - {{::entry.supplierName}} - - - - - - - - - - - - - - - - - - -
- - - - - - -
\ No newline at end of file diff --git a/modules/entry/front/index/index.js b/modules/entry/front/index/index.js deleted file mode 100644 index 8635d3fb4..000000000 --- a/modules/entry/front/index/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - preview(entry) { - this.entrySelected = entry; - this.$.summary.show(); - } -} - -ngModule.vnComponent('vnEntryIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/entry/front/index/locale/es.yml b/modules/entry/front/index/locale/es.yml deleted file mode 100644 index cebe57a42..000000000 --- a/modules/entry/front/index/locale/es.yml +++ /dev/null @@ -1,17 +0,0 @@ -Inventory entry: Es inventario -Virtual entry: Es una redada -Supplier: Proveedor -Currency: Moneda -Company: Empresa -Confirmed: Confirmada -Ordered: Pedida -Is raid: Redada -Commission: Comisión -Landed: F. entrega -Reference: Referencia -Created: Creado -Booked: Contabilizada -Is inventory: Inventario -Status: Estado -Selection: Selección -Invoice number: Núm. factura \ No newline at end of file diff --git a/modules/entry/front/latest-buys-search-panel/index.html b/modules/entry/front/latest-buys-search-panel/index.html deleted file mode 100644 index c73bf7365..000000000 --- a/modules/entry/front/latest-buys-search-panel/index.html +++ /dev/null @@ -1,242 +0,0 @@ - - - - - - - - - - - - - - - - - - -
{{name}}
-
- {{category.name}} -
> -
-
- - - - - {{name}}: {{nickname}} - - - - - - - - - - - - - - - - - - Tags - - - - - - - - - - - - - -
- - Id/Name: {{$ctrl.filter.search}} - - - {{category.selection.name}} - - - {{type.selection.name}} - - - Sales person: {{salesPerson.selection.nickname}} - - - Supplier: {{supplier.selection.name}} - - - From: {{$ctrl.filter.from | date:'dd/MM/yyyy'}} - - - To: {{$ctrl.filter.to | date:'dd/MM/yyyy'}} - - - Active: {{$ctrl.filter.active ? '✓' : '✗'}} - - - Floramondo: {{$ctrl.filter.floramondo ? '✓' : '✗'}} - - - Visible: {{$ctrl.filter.visible ? '✓' : '✗'}} - - - {{$ctrl.showTagInfo(chipTag)}} - - -
-
diff --git a/modules/entry/front/latest-buys-search-panel/index.js b/modules/entry/front/latest-buys-search-panel/index.js deleted file mode 100644 index 4078580ea..000000000 --- a/modules/entry/front/latest-buys-search-panel/index.js +++ /dev/null @@ -1,61 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; -import './style.scss'; - -class Controller extends SearchPanel { - constructor($element, $) { - super($element, $); - } - - $onInit() { - this.filter = { - isActive: true, - tags: [] - }; - } - - changeCategory(id) { - if (this.filter.categoryFk != id) { - this.filter.categoryFk = id; - this.addFilters(); - } - } - - removeItemFilter(param) { - this.filter[param] = null; - if (param == 'categoryFk') this.filter['typeFk'] = null; - this.addFilters(); - } - - removeTag(tag) { - const index = this.filter.tags.indexOf(tag); - if (index > -1) this.filter.tags.splice(index, 1); - this.addFilters(); - } - - onKeyPress($event) { - if ($event.key === 'Enter') - this.addFilters(); - } - - addFilters() { - for (let i = 0; i < this.filter.tags.length; i++) { - if (!this.filter.tags[i].value) - this.filter.tags.splice(i, 1); - } - return this.model.addFilter({}, this.filter); - } - - showTagInfo(itemTag) { - if (!itemTag.tagFk) return itemTag.value; - return `${this.tags.find(tag => tag.id == itemTag.tagFk).name}: ${itemTag.value}`; - } -} - -ngModule.component('vnLatestBuysSearchPanel', { - template: require('./index.html'), - controller: Controller, - bindings: { - model: '<' - } -}); diff --git a/modules/entry/front/latest-buys-search-panel/index.spec.js b/modules/entry/front/latest-buys-search-panel/index.spec.js deleted file mode 100644 index c3c5acbfb..000000000 --- a/modules/entry/front/latest-buys-search-panel/index.spec.js +++ /dev/null @@ -1,56 +0,0 @@ -import './index.js'; - -describe('Entry', () => { - describe('Component vnLatestBuysSearchPanel', () => { - let $element; - let controller; - - beforeEach(ngModule('entry')); - - beforeEach(angular.mock.inject($componentController => { - $element = angular.element(``); - controller = $componentController('vnLatestBuysSearchPanel', {$element}); - controller.model = {addFilter: () => {}}; - })); - - describe('removeItemFilter()', () => { - it(`should remove param from filter`, () => { - controller.filter = {tags: [], categoryFk: 1, typeFk: 1}; - const expectFilter = {tags: [], categoryFk: null, typeFk: null}; - - controller.removeItemFilter('categoryFk'); - - expect(controller.filter).toEqual(expectFilter); - }); - }); - - describe('removeTag()', () => { - it(`should remove tag from filter`, () => { - const tag = {tagFk: 1, value: 'Value'}; - controller.filter = {tags: [tag]}; - const expectFilter = {tags: []}; - - controller.removeTag(tag); - - expect(controller.filter).toEqual(expectFilter); - }); - }); - - describe('showTagInfo()', () => { - it(`should show tag value`, () => { - const tag = {value: 'Value'}; - const result = controller.showTagInfo(tag); - - expect(result).toEqual('Value'); - }); - - it(`should show tag name and value`, () => { - const tag = {tagFk: 1, value: 'Value'}; - controller.tags = [{id: 1, name: 'tagName'}]; - const result = controller.showTagInfo(tag); - - expect(result).toEqual('tagName: Value'); - }); - }); - }); -}); diff --git a/modules/entry/front/latest-buys-search-panel/style.scss b/modules/entry/front/latest-buys-search-panel/style.scss deleted file mode 100644 index ec189c7e4..000000000 --- a/modules/entry/front/latest-buys-search-panel/style.scss +++ /dev/null @@ -1,70 +0,0 @@ -@import "variables"; - -vn-latest-buys-search-panel vn-side-menu div { - & > .input { - padding-left: $spacing-md; - padding-right: $spacing-md; - border-color: $color-spacer; - border-bottom: $border-thin; - } - & > .horizontal { - grid-auto-flow: column; - grid-column-gap: $spacing-sm; - align-items: center; - } - & > .checks { - padding: $spacing-md; - flex-wrap: wrap; - border-color: $color-spacer; - border-bottom: $border-thin; - } - & > .tags { - padding: $spacing-md; - padding-bottom: 0%; - padding-top: 0%; - align-items: center; - } - & > .chips { - display: flex; - flex-wrap: wrap; - padding: $spacing-md; - overflow: hidden; - max-width: 100%; - border-color: $color-spacer; - border-top: $border-thin; - } - & > .item-category { - padding: $spacing-sm; - justify-content: flex-start; - align-items: flex-start; - flex-wrap: wrap; - - vn-autocomplete[vn-id="category"] { - display: none; - } - - & > vn-one { - padding: $spacing-sm; - min-width: 33.33%; - text-align: center; - box-sizing: border-box; - - & > vn-icon { - padding: $spacing-sm; - background-color: $color-font-secondary; - border-radius: 50%; - cursor: pointer; - - &.active { - background-color: $color-main; - color: #fff; - } - & > i:before { - font-size: 2.6rem; - width: 16px; - height: 16px; - } - } - } - } -} diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html deleted file mode 100644 index 2e6de83b9..000000000 --- a/modules/entry/front/latest-buys/index.html +++ /dev/null @@ -1,267 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - Picture - Item ID - - Packing - - Grouping - - Quantity - - Description - - Size - - Tags - - Type - - Intrastat - - Origin - - Weight/Piece - - Active - - Family - - Entry - - Buying value - - Freight value - - Commission value - - Package value - - Is ignored - - Grouping - - Packing - - Min - - Ekt - - Weight - - Package - - Package out - - Landing -
- - - - - - - {{::buy.itemFk}} - - - - {{::buy.packing | dashIfEmpty}} - - - - {{::buy.grouping | dashIfEmpty}} - - {{::buy.quantity}} - {{::buy.description | dashIfEmpty}} - {{::buy.size}} -
- {{::buy.name}} - -

{{::buy.subName}}

-
-
- - -
- {{::buy.code}} - - {{::buy.intrastat}} - {{::buy.origin}}{{::buy.weightByPiece}} - - - {{::buy.family}} - - {{::buy.entryFk}} - - {{::buy.buyingValue | currency: 'EUR':3}}{{::buy.freightValue | currency: 'EUR':3}}{{::buy.comissionValue | currency: 'EUR':3}}{{::buy.packageValue | currency: 'EUR':3}} - - - {{::buy.price2 | currency: 'EUR':3}}{{::buy.price3 | currency: 'EUR':3}}{{::buy.minPrice | currency: 'EUR':3}}{{::buy.ektFk | dashIfEmpty}}{{::buy.weight}}{{::buy.packagingFk}}{{::buy.packingOut}}{{::buy.landing | date: 'dd/MM/yyyy'}}
-
-
-
-
- - - - -
- - - Edit - - {{::$ctrl.totalChecked}} - - buy(s) - - - - - - - - - - - - - - - - diff --git a/modules/entry/front/latest-buys/index.js b/modules/entry/front/latest-buys/index.js deleted file mode 100644 index 292c5b805..000000000 --- a/modules/entry/front/latest-buys/index.js +++ /dev/null @@ -1,209 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.editedColumn; - this.checkAll = false; - this.checkedBuys = []; - - this.smartTableOptions = { - activeButtons: { - search: true, - shownColumns: true, - }, - columns: [ - { - field: 'code', - autocomplete: { - url: 'ItemTypes', - showField: 'code', - valueField: 'code', - } - }, - { - field: 'origin', - autocomplete: { - url: 'Origins', - showField: 'code', - valueField: 'code' - } - }, - { - field: 'family', - autocomplete: { - url: 'ItemFamilies', - valueField: 'code', - showField: 'code' - } - }, - { - field: 'intrastat', - autocomplete: { - url: 'Intrastats', - showField: 'description', - valueField: 'description' - } - }, - { - field: 'packagingFk', - autocomplete: { - url: 'Packagings', - showField: 'id' - } - }, - { - field: 'isActive', - searchable: false - }, - { - field: 'isIgnored', - searchable: false - }, - { - field: 'landing', - searchable: false - } - ] - }; - } - - get columns() { - if (this._columns) return this._columns; - - this._columns = [ - {field: 'packing', displayName: this.$t('Packing')}, - {field: 'grouping', displayName: this.$t('Grouping')}, - {field: 'packageValue', displayName: this.$t('Package value')}, - {field: 'weight', displayName: this.$t('Weight')}, - {field: 'description', displayName: this.$t('Description')}, - {field: 'size', displayName: this.$t('Size')}, - {field: 'weightByPiece', displayName: this.$t('weight/Piece')}, - {field: 'packingOut', displayName: this.$t('PackingOut')}, - {field: 'landing', displayName: this.$t('Landing')} - ]; - - return this._columns; - } - - get checked() { - const buys = this.$.model.data || []; - const checkedBuys = []; - for (let buy of buys) { - if (buy.checked) - checkedBuys.push(buy); - } - - return checkedBuys; - } - - exprBuilder(param, value) { - switch (param) { - case 'id': - case 'size': - case 'weightByPiece': - case 'isActive': - case 'family': - case 'minPrice': - case 'packingOut': - return {[`i.${param}`]: value}; - case 'name': - case 'description': - return {[`i.${param}`]: {like: `%${value}%`}}; - case 'code': - return {'it.code': value}; - case 'intrastat': - return {'intr.description': value}; - case 'origin': - return {'ori.code': value}; - case 'landing': - return {[`lb.${param}`]: value}; - case 'packing': - case 'grouping': - case 'quantity': - case 'entryFk': - case 'buyingValue': - case 'freightValue': - case 'comissionValue': - case 'packageValue': - case 'isIgnored': - case 'price2': - case 'price3': - case 'ektFk': - case 'weight': - case 'packagingFk': - return {[`b.${param}`]: value}; - } - } - - uncheck() { - this.checkAll = false; - this.checkedBuys = []; - } - - get totalChecked() { - if (this.checkedDummyCount) - return this.checkedDummyCount; - - return this.checked.length; - } - - saveChecked(buyId) { - const index = this.checkedBuys.indexOf(buyId); - if (index !== -1) - return this.checkedBuys.splice(index, 1); - return this.checkedBuys.push(buyId); - } - - reCheck() { - if (!this.$.model.data) return; - if (!this.checkedBuys.length) return; - - this.$.model.data.forEach(buy => { - if (this.checkedBuys.includes(buy.id)) - buy.checked = true; - }); - } - - onEditAccept() { - const rowsToEdit = []; - for (let row of this.checked) - rowsToEdit.push({id: row.id, itemFk: row.itemFk}); - - const data = { - field: this.editedColumn.field, - newValue: this.editedColumn.newValue, - lines: rowsToEdit - }; - - if (this.checkedDummyCount && this.checkedDummyCount > 0) { - const params = {}; - if (this.$.model.userParams) { - const userParams = this.$.model.userParams; - for (let param in userParams) { - let newParam = this.exprBuilder(param, userParams[param]); - if (!newParam) - newParam = {[param]: userParams[param]}; - Object.assign(params, newParam); - } - } - if (this.$.model.userFilter) - Object.assign(params, this.$.model.userFilter.where); - - data.filter = params; - } - - return this.$http.post('Buys/editLatestBuys', data) - .then(() => { - this.uncheck(); - this.$.model.refresh(); - }); - } -} - -ngModule.component('vnEntryLatestBuys', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/entry/front/latest-buys/index.spec.js b/modules/entry/front/latest-buys/index.spec.js deleted file mode 100644 index 6574303fc..000000000 --- a/modules/entry/front/latest-buys/index.spec.js +++ /dev/null @@ -1,100 +0,0 @@ -import './index.js'; - -describe('Entry', () => { - describe('Component vnEntryLatestBuys', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('entry')); - - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - const $element = angular.element(' {}}, - edit: {hide: () => {}} - }; - })); - - describe('get columns', () => { - it(`should return a set of columns`, () => { - let result = controller.columns; - - let length = result.length; - let anyColumn = Object.keys(result[Math.floor(Math.random() * Math.floor(length))]); - - expect(anyColumn).toContain('field', 'displayName'); - }); - }); - - describe('get checked', () => { - it(`should return a set of checked lines`, () => { - controller.$.model.data = [ - {checked: true, id: 1}, - {checked: true, id: 2}, - {checked: true, id: 3}, - {checked: false, id: 4}, - ]; - - let result = controller.checked; - - expect(result.length).toEqual(3); - }); - }); - - describe('onEditAccept()', () => { - it(`should perform a query to update columns`, () => { - controller.editedColumn = {field: 'my field', newValue: 'the new value'}; - const query = 'Buys/editLatestBuys'; - - $httpBackend.expectPOST(query).respond(); - controller.onEditAccept(); - $httpBackend.flush(); - - const result = controller.checked; - - expect(result.length).toEqual(0); - }); - }); - - describe('reCheck()', () => { - it(`should recheck buys`, () => { - controller.$.model.data = [ - {checked: false, id: 1}, - {checked: false, id: 2}, - {checked: false, id: 3}, - {checked: false, id: 4}, - ]; - controller.checkedBuys = [1, 2]; - - controller.reCheck(); - - expect(controller.$.model.data[0].checked).toEqual(true); - expect(controller.$.model.data[1].checked).toEqual(true); - expect(controller.$.model.data[2].checked).toEqual(false); - expect(controller.$.model.data[3].checked).toEqual(false); - }); - }); - - describe('saveChecked()', () => { - it(`should check buy`, () => { - const buyCheck = 3; - controller.checkedBuys = [1, 2]; - - controller.saveChecked(buyCheck); - - expect(controller.checkedBuys[2]).toEqual(buyCheck); - }); - - it(`should uncheck buy`, () => { - const buyUncheck = 3; - controller.checkedBuys = [1, 2, 3]; - - controller.saveChecked(buyUncheck); - - expect(controller.checkedBuys[2]).toEqual(undefined); - }); - }); - }); -}); diff --git a/modules/entry/front/latest-buys/locale/en.yml b/modules/entry/front/latest-buys/locale/en.yml deleted file mode 100644 index 48dda861b..000000000 --- a/modules/entry/front/latest-buys/locale/en.yml +++ /dev/null @@ -1,2 +0,0 @@ -Minimun amount: Minimun purchase quantity -PackageName: Package \ No newline at end of file diff --git a/modules/entry/front/latest-buys/locale/es.yml b/modules/entry/front/latest-buys/locale/es.yml deleted file mode 100644 index 795e3f5f4..000000000 --- a/modules/entry/front/latest-buys/locale/es.yml +++ /dev/null @@ -1,19 +0,0 @@ -Edit buy(s): Editar compra(s) -Buying value: Coste -Freight value: Porte -Commission value: Comisión -Package value: Embalaje -Is ignored: Ignorado -Is visible: Visible -Is floramondo: Floramondo -Grouping price: Precio grouping -Packing price: Precio packing -Min price: Precio min -Ekt: Ekt -Weight: Peso -Minimun amount: Cantidad mínima de compra -Field to edit: Campo a editar -PackageName: Cubo -Edit: Editar -buy(s): compra(s) -Package out: Embalaje envíos diff --git a/modules/entry/front/latest-buys/style.scss b/modules/entry/front/latest-buys/style.scss deleted file mode 100644 index a3c399edc..000000000 --- a/modules/entry/front/latest-buys/style.scss +++ /dev/null @@ -1,7 +0,0 @@ -.countLines { - flex: 0.15; - font-size: 24px; - color: orangered; - font-weight: bold; - max-width: 30px; -} diff --git a/modules/entry/front/locale/es.yml b/modules/entry/front/locale/es.yml deleted file mode 100644 index b28cbe735..000000000 --- a/modules/entry/front/locale/es.yml +++ /dev/null @@ -1,6 +0,0 @@ -#Ordenar alfabeticamente - -entry: entrada -Latest buys: Últimas compras - -# Sections diff --git a/modules/entry/front/log/index.html b/modules/entry/front/log/index.html deleted file mode 100644 index fd8ae7c2a..000000000 --- a/modules/entry/front/log/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/modules/entry/front/log/index.js b/modules/entry/front/log/index.js deleted file mode 100644 index 73218f4de..000000000 --- a/modules/entry/front/log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnEntryLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/entry/front/log/locale/es.yml b/modules/entry/front/log/locale/es.yml deleted file mode 100644 index 094615b47..000000000 --- a/modules/entry/front/log/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Date: Fecha \ No newline at end of file diff --git a/modules/entry/front/main/index.html b/modules/entry/front/main/index.html index f6a4c61fc..e69de29bb 100644 --- a/modules/entry/front/main/index.html +++ b/modules/entry/front/main/index.html @@ -1,22 +0,0 @@ - - - - - - - - - - - - - diff --git a/modules/entry/front/main/index.js b/modules/entry/front/main/index.js index 75f1d098a..de0beced4 100644 --- a/modules/entry/front/main/index.js +++ b/modules/entry/front/main/index.js @@ -1,7 +1,15 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; -export default class Entry extends ModuleMain {} +export default class Entry extends ModuleMain { + constructor($element, $) { + super($element, $); + } + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`entry/`); + } +} ngModule.vnComponent('vnEntry', { controller: Entry, diff --git a/modules/entry/front/main/locale/es.yml b/modules/entry/front/main/locale/es.yml new file mode 100644 index 000000000..de408b311 --- /dev/null +++ b/modules/entry/front/main/locale/es.yml @@ -0,0 +1 @@ +entry: entry diff --git a/modules/entry/front/note/index.html b/modules/entry/front/note/index.html deleted file mode 100644 index 5f3c7f77e..000000000 --- a/modules/entry/front/note/index.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/modules/entry/front/note/index.js b/modules/entry/front/note/index.js deleted file mode 100644 index fccd60913..000000000 --- a/modules/entry/front/note/index.js +++ /dev/null @@ -1,20 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - onSubmit() { - this.$.watcher.check(); - this.$.model.save().then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - }); - } -} - -ngModule.vnComponent('vnEntryObservation', { - template: require('./index.html'), - controller: Controller, - bindings: { - entry: '<' - } -}); diff --git a/modules/entry/front/routes.json b/modules/entry/front/routes.json index 3934a96ee..a2e70e37d 100644 --- a/modules/entry/front/routes.json +++ b/modules/entry/front/routes.json @@ -8,11 +8,11 @@ "main": [ {"state": "entry.index", "icon": "icon-entry"}, {"state": "entry.latestBuys", "icon": "contact_support"} - ], - "card": [ - {"state": "entry.card.basicData", "icon": "settings"}, - {"state": "entry.card.buy.index", "icon": "icon-lines"}, - {"state": "entry.card.observation", "icon": "insert_drive_file"}, + ], + "card": [ + {"state": "entry.card.basicData", "icon": "settings"}, + {"state": "entry.card.buy.index", "icon": "icon-lines"}, + {"state": "entry.card.observation", "icon": "insert_drive_file"}, {"state": "entry.card.log", "icon": "history"} ] }, @@ -34,89 +34,89 @@ "description": "Entries", "acl": ["buyer", "administrative"] }, - { - "url": "/latest-buys?q", - "state": "entry.latestBuys", - "component": "vn-entry-latest-buys", - "description": "Latest buys", - "acl": ["buyer", "administrative"] - }, - { - "url": "/create?supplierFk&travelFk&companyFk", - "state": "entry.create", - "component": "vn-entry-create", - "description": "New entry", - "acl": ["buyer", "administrative"] - }, - { - "url": "/:id", - "state": "entry.card", - "abstract": true, - "component": "vn-entry-card" - }, - { - "url": "/summary", - "state": "entry.card.summary", - "component": "vn-entry-summary", - "description": "Summary", - "params": { - "entry": "$ctrl.entry" - }, - "acl": ["buyer", "administrative"] - }, - { - "url": "/basic-data", - "state": "entry.card.basicData", - "component": "vn-entry-basic-data", - "description": "Basic data", - "params": { - "entry": "$ctrl.entry" - }, - "acl": ["buyer", "administrative"] - }, { - "url": "/observation", - "state": "entry.card.observation", - "component": "vn-entry-observation", - "description": "Notes", + "url": "/latest-buys?q", + "state": "entry.latestBuys", + "component": "vn-entry-latest-buys", + "description": "Latest buys", + "acl": ["buyer", "administrative"] + }, + { + "url": "/create?supplierFk&travelFk&companyFk", + "state": "entry.create", + "component": "vn-entry-create", + "description": "New entry", + "acl": ["buyer", "administrative"] + }, + { + "url": "/:id", + "state": "entry.card", + "abstract": true, + "component": "vn-entry-card" + }, + { + "url": "/summary", + "state": "entry.card.summary", + "component": "vn-entry-summary", + "description": "Summary", "params": { "entry": "$ctrl.entry" }, "acl": ["buyer", "administrative"] - }, - { - "url" : "/log", - "state": "entry.card.log", - "component": "vn-entry-log", - "description": "Log", - "acl": ["buyer", "administrative"] - }, - { - "url": "/buy", - "state": "entry.card.buy", - "abstract": true, - "component": "ui-view", - "acl": ["buyer"] - }, - { - "url" : "/index", - "state": "entry.card.buy.index", - "component": "vn-entry-buy-index", - "description": "Buys", - "params": { - "entry": "$ctrl.entry" - }, - "acl": ["buyer", "administrative"] - }, - { - "url" : "/import", - "state": "entry.card.buy.import", - "component": "vn-entry-buy-import", - "description": "Import buys", - "params": { - "entry": "$ctrl.entry" - }, + }, + { + "url": "/basic-data", + "state": "entry.card.basicData", + "component": "vn-entry-basic-data", + "description": "Basic data", + "params": { + "entry": "$ctrl.entry" + }, + "acl": ["buyer", "administrative"] + }, + { + "url": "/observation", + "state": "entry.card.observation", + "component": "vn-entry-observation", + "description": "Notes", + "params": { + "entry": "$ctrl.entry" + }, + "acl": ["buyer", "administrative"] + }, + { + "url" : "/log", + "state": "entry.card.log", + "component": "vn-entry-log", + "description": "Log", + "acl": ["buyer", "administrative"] + }, + { + "url": "/buy", + "state": "entry.card.buy", + "abstract": true, + "component": "ui-view", + "acl": ["buyer"] + }, + { + "url" : "/index", + "state": "entry.card.buy.index", + "component": "vn-entry-buy-index", + "description": "Buys", + "params": { + "entry": "$ctrl.entry" + }, + "acl": ["buyer", "administrative"] + }, + { + "url" : "/import", + "state": "entry.card.buy.import", + "component": "vn-entry-buy-import", + "description": "Import buys", + "params": { + "entry": "$ctrl.entry" + }, "acl": ["buyer"] } ] -} \ No newline at end of file +} diff --git a/modules/entry/front/search-panel/index.html b/modules/entry/front/search-panel/index.html deleted file mode 100644 index adcb9d6d4..000000000 --- a/modules/entry/front/search-panel/index.html +++ /dev/null @@ -1,100 +0,0 @@ -
-
- - - - - - - - - - - - - - - - - - - - - - - {{name}}: {{nickname}} - - - - - - - - - - - - - - - - - - - - - -
-
\ No newline at end of file diff --git a/modules/entry/front/search-panel/index.js b/modules/entry/front/search-panel/index.js deleted file mode 100644 index e87f31056..000000000 --- a/modules/entry/front/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.vnComponent('vnEntrySearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/entry/front/search-panel/locale/es.yml b/modules/entry/front/search-panel/locale/es.yml deleted file mode 100644 index 05b71da99..000000000 --- a/modules/entry/front/search-panel/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Ticket id: Id ticket -Client id: Id cliente -Nickname: Alias -From: Desde -To: Hasta -Agency: Agencia -Warehouse: Almacén -Search entry by id or a suppliers by name or alias: Buscar entrada por id o proveedores por nombre y alias -Invoice number: Núm. factura \ No newline at end of file diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html index baa310bb6..22ea87bdf 100644 --- a/modules/entry/front/summary/index.html +++ b/modules/entry/front/summary/index.html @@ -1,196 +1,195 @@ +vn-id="buysModel" +url="Entries/{{$ctrl.entry.id}}/getBuys" +limit="5" +data="buys" +auto-load="true"> -
- - - - #{{$ctrl.entryData.id}} - {{$ctrl.entryData.supplier.nickname}} -
- - - - - - - - - - - - - - - - - {{$ctrl.entryData.travel.ref}} - - - - - - - - +
+ + + + #{{$ctrl.entryData.id}} - {{$ctrl.entryData.supplier.nickname}} +
+ + + + + + + + + + + + + + + + + {{$ctrl.entryData.travel.ref}} + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - -

Buys

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
QuantityStickersPackageWeightPackingGroupingBuying valueImportPVP
{{::line.quantity}}{{::line.stickers | dashIfEmpty}}{{::line.packagingFk | dashIfEmpty}}{{::line.weight}} - - {{::line.packing | dashIfEmpty}} - - - - {{::line.grouping | dashIfEmpty}} - - - {{::line.buyingValue | currency: 'EUR':2}}{{::line.quantity * line.buyingValue | currency: 'EUR':2}}{{::line.price2 | currency: 'EUR':2 | dashIfEmpty}} / {{::line.price3 | currency: 'EUR':2 | dashIfEmpty}}
- - {{::line.item.itemType.code}} - - - - {{::line.item.id}} - - - - {{::line.item.size}} - - - - {{::line.item.minPrice | currency: 'EUR':2}} - - -
- {{::line.item.name}} - -

{{::line.item.subName}}

-
-
- - -
- - -
-
+ + + + + + + +
+
+ + +

Buys

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
QuantityStickersPackageWeightPackingGroupingBuying valueImportPVP
{{::line.quantity}}{{::line.stickers | dashIfEmpty}}{{::line.packagingFk | dashIfEmpty}}{{::line.weight}} + + {{::line.packing | dashIfEmpty}} + + + + {{::line.grouping | dashIfEmpty}} + + + {{::line.buyingValue | currency: 'EUR':2}}{{::line.quantity * line.buyingValue | currency: 'EUR':2}}{{::line.price2 | currency: 'EUR':2 | dashIfEmpty}} / {{::line.price3 | currency: 'EUR':2 | dashIfEmpty}}
+ + {{::line.item.itemType.code}} + + + + {{::line.item.id}} + + + + {{::line.item.size}} + + + + {{::line.item.minPrice | currency: 'EUR':2}} + + +
+ {{::line.item.name}} + +

{{::line.item.subName}}

+
+
+ + +
+ + +
+
+vn-id="item-descriptor" +warehouse-fk="$ctrl.vnConfig.warehouseFk"> +vn-id="travelDescriptor"> - diff --git a/modules/entry/front/summary/index.spec.js b/modules/entry/front/summary/index.spec.js deleted file mode 100644 index baeb43ac8..000000000 --- a/modules/entry/front/summary/index.spec.js +++ /dev/null @@ -1,49 +0,0 @@ -import './index'; - -describe('component vnEntrySummary', () => { - let controller; - let $httpBackend; - let $scope; - - beforeEach(angular.mock.module('entry', $translateProvider => { - $translateProvider.translations('en', {}); - })); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - const $element = angular.element(``); - controller = $componentController('vnEntrySummary', {$element, $scope}); - })); - - describe('entry setter/getter', () => { - it('should check if value.id is defined', () => { - jest.spyOn(controller, 'getEntryData'); - - controller.entry = {id: 1}; - - expect(controller.getEntryData).toHaveBeenCalledWith(); - }); - - it('should return the entry and then call getEntryData()', () => { - jest.spyOn(controller, 'getEntryData'); - controller.entry = {id: 99}; - - expect(controller._entry.id).toEqual(99); - expect(controller.getEntryData).toHaveBeenCalledWith(); - }); - }); - - describe('getEntryData()', () => { - it('should perform a get and then store data on the controller', () => { - controller._entry = {id: 999}; - - const query = `Entries/${controller._entry.id}/getEntry`; - $httpBackend.expectGET(query).respond('I am the entryData'); - controller.getEntryData(); - $httpBackend.flush(); - - expect(controller.entryData).toEqual('I am the entryData'); - }); - }); -}); diff --git a/modules/entry/front/summary/locale/es.yml b/modules/entry/front/summary/locale/es.yml deleted file mode 100644 index 1761561ed..000000000 --- a/modules/entry/front/summary/locale/es.yml +++ /dev/null @@ -1,11 +0,0 @@ -Inventory: Inventario -Raid: Redada -Entry: Entrada -Stickers: Etiquetas -Item size: Tamaño -Item type: Tipo -Minimum price: Precio mínimo -Buys: Compras -Travel: Envio -Go to the entry: Ir a la entrada -Invoice number: Núm. factura 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 f21dad9f2..2105cd9c0 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 @@ -1,15 +1,7 @@ -const LoopBackContext = require('loopback-context'); const models = require('vn-loopback/server/server').models; describe('invoiceInDueDay new()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); it('should correctly create a new due day', async() => { const userId = 9; diff --git a/modules/invoiceIn/back/methods/invoice-in/exchangeRateUpdate.js b/modules/invoiceIn/back/methods/invoice-in/exchangeRateUpdate.js index 3ad06b242..989b1d4a2 100644 --- a/modules/invoiceIn/back/methods/invoice-in/exchangeRateUpdate.js +++ b/modules/invoiceIn/back/methods/invoice-in/exchangeRateUpdate.js @@ -54,6 +54,20 @@ module.exports = Self => { value: rate }); } + const monday = 1; + if (xmlDateWithoutTime.getDay() === monday) { + const saturday = new Date(xmlDateWithoutTime); + saturday.setDate(xmlDateWithoutTime.getDate() - 2); + const sunday = new Date(xmlDateWithoutTime); + sunday.setDate(xmlDateWithoutTime.getDate() - 1); + + for (const date of [saturday, sunday]) { + await models.ReferenceRate.upsertWithWhere( + {currencyFk: currency.id, dated: date}, + {currencyFk: currency.id, dated: date, value: rate} + ); + } + } } } } diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js index 0d3b5f14a..936f7bb6c 100644 --- a/modules/invoiceIn/back/methods/invoice-in/filter.js +++ b/modules/invoiceIn/back/methods/invoice-in/filter.js @@ -82,7 +82,15 @@ module.exports = Self => { { arg: 'correctedFk', type: 'number', - description: 'The corrected invoice', + description: 'The rectified invoice', + }, + { + arg: 'correctingFk', + type: 'Boolean', + }, + { + arg: 'supplierActivityFk', + type: 'string', } ], returns: { @@ -111,6 +119,8 @@ module.exports = Self => { } let correctings; + + let correcteds; if (args.correctedFk) { correctings = await models.InvoiceInCorrection.find({ fields: ['correctingFk'], @@ -118,6 +128,9 @@ module.exports = Self => { }); } + if (args.correctingFk || args.correctingFk === false) + correcteds = await models.InvoiceInCorrection.find(); + const where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': @@ -125,9 +138,9 @@ module.exports = Self => { ? {'ii.id': value} : {'s.name': {like: `%${value}%`}}; case 'from': - return {'ii.created': {gte: value}}; + return {'ii.issued': {gte: value}}; case 'to': - return {'ii.created': {lte: value}}; + return {'ii.issued': {lte: value}}; case 'fi': return {'s.nif': value}; case 'account': @@ -141,8 +154,15 @@ module.exports = Self => { return {[`ii.${param}`]: value}; case 'awbCode': return {'sub.code': value}; + case 'correctingFk': + if (!correcteds.length && !args.correctingFk) return; + return args.correctingFk + ? {'ii.id': {inq: correcteds.map(x => x.correctingFk)}} + : {'ii.id': {nin: correcteds.map(x => x.correctingFk)}}; case 'correctedFk': return {'ii.id': {inq: correctings.map(x => x.correctingFk)}}; + case 'supplierActivityFk': + return {'s.supplierActivityFk': value}; } }); @@ -153,7 +173,6 @@ module.exports = Self => { const stmt = new ParameterizedSQL( `SELECT ii.id, - ii.serialNumber, ii.serial, ii.issued, ii.isBooked, diff --git a/modules/invoiceIn/back/methods/invoice-in/getSerial.js b/modules/invoiceIn/back/methods/invoice-in/getSerial.js index dcc1fbc3c..29c7cae2f 100644 --- a/modules/invoiceIn/back/methods/invoice-in/getSerial.js +++ b/modules/invoiceIn/back/methods/invoice-in/getSerial.js @@ -46,7 +46,7 @@ module.exports = Self => { } }); - filter = mergeFilters(args.filter, {where}); + const filter = mergeFilters(args.filter, {where}); const stmt = new ParameterizedSQL( `SELECT i.serial, SUM(IF(i.isBooked, 0,1)) pending, COUNT(*) total diff --git a/modules/invoiceIn/back/methods/invoice-in/getTotals.js b/modules/invoiceIn/back/methods/invoice-in/getTotals.js index 7bef9f7e9..c4e73abc2 100644 --- a/modules/invoiceIn/back/methods/invoice-in/getTotals.js +++ b/modules/invoiceIn/back/methods/invoice-in/getTotals.js @@ -27,10 +27,12 @@ module.exports = Self => { const [result] = await Self.rawSql(` SELECT iit.*, - SUM(iidd.amount) totalDueDay + SUM(iidd.amount) totalDueDay, + SUM(iidd.foreignValue) totalDueDayForeignValue FROM vn.invoiceIn ii LEFT JOIN ( SELECT SUM(iit.taxableBase) totalTaxableBase, + SUM(iit.foreignValue) totalTaxableBaseForeignValue, CAST( SUM(IFNULL(iit.taxableBase * (1 + (ti.PorcentajeIva / 100)), iit.taxableBase)) AS DECIMAL(10, 2) diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/clone.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/clone.spec.js index 436306aab..cf1e0ac2d 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/clone.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/clone.spec.js @@ -1,24 +1,11 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('invoiceIn clone()', () => { - let ctx; + const ctx = beforeAll.getCtx(); let options; let tx; beforeEach(async() => { - ctx = { - req: { - accessToken: {userId: 1}, - headers: {origin: 'http://localhost'} - }, - args: {} - }; - - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: ctx.req - }); - options = {transaction: tx}; tx = await models.Sale.beginTransaction({}); options.transaction = tx; @@ -28,7 +15,8 @@ describe('invoiceIn clone()', () => { await tx.rollback(); }); - it('should return the cloned invoiceIn and also clone invoiceInDueDays and invoiceInTaxes if there are any referencing the invoiceIn', async() => { + it('should return the cloned invoiceIn and also clone invoiceInDueDays ' + + 'and invoiceInTaxes if there are any referencing the invoiceIn', async() => { const clone = await models.InvoiceIn.clone(ctx, 1, false, options); expect(clone.supplierRef).toEqual('1234(2)'); @@ -51,7 +39,8 @@ describe('invoiceIn clone()', () => { expect(invoiceInDueDay.length).toEqual(2); }); - it('should return the cloned invoiceIn and also clone invoiceInIntrastat and invoiceInTaxes if it is rectificative', async() => { + it('should return the cloned invoiceIn and also clone invoiceInIntrastat ' + + 'and invoiceInTaxes if it is rectificative', async() => { const clone = await models.InvoiceIn.clone(ctx, 1, true, options); expect(clone.supplierRef).toEqual('1234(2)'); diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js index 1047cd028..c63f02439 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js @@ -1,24 +1,11 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('invoiceIn corrective()', () => { - let ctx; + const ctx = beforeAll.getCtx(); let options; let tx; beforeEach(async() => { - ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'http://localhost'} - }, - args: {} - }; - - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: ctx.req - }); - options = {transaction: tx}; tx = await models.Sale.beginTransaction({}); options.transaction = tx; 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 ff2164783..48310b32a 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js @@ -47,29 +47,6 @@ describe('InvoiceIn filter()', () => { } }); - it('should return the invoice in matching the serial number', async() => { - const tx = await models.InvoiceIn.beginTransaction({}); - const options = {transaction: tx}; - - try { - const ctx = { - args: { - serialNumber: '1002', - } - }; - - const result = await models.InvoiceIn.filter(ctx, {}, options); - - expect(result.length).toEqual(1); - expect(result[0].serialNumber).toEqual(1002); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - it('should return the invoice in matching the account', async() => { const tx = await models.InvoiceIn.beginTransaction({}); const options = {transaction: tx}; @@ -158,7 +135,7 @@ describe('InvoiceIn filter()', () => { const result = await models.InvoiceIn.filter(ctx, {}, options); - expect(result.length).toEqual(5); + expect(result.length).toEqual(6); await tx.rollback(); } catch (e) { diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/toUnbook.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/toUnbook.spec.js new file mode 100644 index 000000000..b7d98e307 --- /dev/null +++ b/modules/invoiceIn/back/methods/invoice-in/specs/toUnbook.spec.js @@ -0,0 +1,32 @@ +const models = require('vn-loopback/server/server').models; + +describe('invoiceIn toUnbook()', () => { + it('should check that invoiceIn is unbooked', async() => { + const userId = 1; + const ctx = { + req: { + + accessToken: {userId: userId}, + headers: {origin: 'http://localhost:5000'}, + } + }; + const invoiceInId = 1; + const tx = await models.InvoiceIn.beginTransaction({}); + const options = {transaction: tx}; + + try { + await models.InvoiceIn.toBook(ctx, invoiceInId, options); + const bookEntry = await models.InvoiceIn.toUnbook(ctx, invoiceInId, options); + const invoiceIn = await models.InvoiceIn.findById(invoiceInId, null, options); + + expect(bookEntry.accountingEntries).toEqual(4); + expect(bookEntry.isLinked).toBeFalsy(); + expect(invoiceIn.isBooked).toEqual(false); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/invoiceIn/back/methods/invoice-in/toBook.js b/modules/invoiceIn/back/methods/invoice-in/toBook.js index 778742911..c3be5f8fc 100644 --- a/modules/invoiceIn/back/methods/invoice-in/toBook.js +++ b/modules/invoiceIn/back/methods/invoice-in/toBook.js @@ -32,7 +32,7 @@ module.exports = Self => { } try { - await Self.rawSql(`CALL vn.invoiceIn_booking(?)`, [id], myOptions); + await Self.rawSql(`CALL vn.invoiceIn_booking(?, NULL)`, [id], myOptions); if (tx) await tx.commit(); } catch (e) { if (tx) await tx.rollback(); diff --git a/modules/invoiceIn/back/methods/invoice-in/toUnbook.js b/modules/invoiceIn/back/methods/invoice-in/toUnbook.js new file mode 100644 index 000000000..a697e9ddc --- /dev/null +++ b/modules/invoiceIn/back/methods/invoice-in/toUnbook.js @@ -0,0 +1,80 @@ +module.exports = Self => { + Self.remoteMethodCtx('toUnbook', { + description: 'To unbook the invoiceIn', + accessType: 'WRITE', + accepts: { + arg: 'id', + type: 'number', + required: true, + description: 'The invoiceIn id', + http: {source: 'path'} + }, + returns: { + type: 'object', + root: true + }, + http: { + path: '/:id/toUnbook', + verb: 'POST' + } + }); + + Self.toUnbook = async(ctx, invoiceInId, options) => { + let tx; + const models = Self.app.models; + const myOptions = {userId: ctx.req.accessToken.userId}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + let isLinked; + let accountingEntries; + + let bookEntry = await models.Xdiario.findOne({ + fields: ['ASIEN'], + where: { + and: [ + {key: invoiceInId}, + {enlazado: false}, + {enlazadoSage: false} + ] + } + }, myOptions); + + let asien = bookEntry?.ASIEN; + if (asien) { + accountingEntries = await models.Xdiario.count({ASIEN: asien}, myOptions); + + await models.Xdiario.destroyAll({ASIEN: asien}, myOptions); + await Self.updateAll({id: invoiceInId}, {isBooked: false}, myOptions); + } else { + const linkedBookEntry = await models.Xdiario.findOne({ + fields: ['ASIEN'], + where: { + key: invoiceInId, + and: [{or: [{enlazado: true, enlazadoSage: true}]}] + } + }, myOptions); + + asien = linkedBookEntry?.ASIEN; + isLinked = true; + } + if (tx) await tx.commit(); + + return { + isLinked, + bookEntry: asien, + accountingEntries + }; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js new file mode 100644 index 000000000..92a1ba8ee --- /dev/null +++ b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js @@ -0,0 +1,104 @@ +module.exports = Self => { + Self.remoteMethodCtx('updateInvoiceIn', { + description: 'To update the invoiceIn attributes', + accessType: 'WRITE', + accepts: [{ + arg: 'id', + type: 'number', + required: true, + description: 'The invoiceIn id', + http: {source: 'path'} + }, { + arg: 'supplierFk', + type: 'number', + required: true + }, { + arg: 'supplierRef', + type: 'any', + }, { + arg: 'issued', + type: 'any', + }, { + arg: 'operated', + type: 'any', + }, { + arg: 'deductibleExpenseFk', + type: 'any', + }, { + arg: 'dmsFk', + type: 'any', + }, { + arg: 'bookEntried', + type: 'any', + }, { + arg: 'booked', + type: 'any', + }, { + arg: 'currencyFk', + type: 'number', + required: true + }, { + arg: 'companyFk', + type: 'any', + }, { + arg: 'withholdingSageFk', + type: 'any', + }, + ], + returns: { + type: 'object', + root: true + }, + http: { + path: '/:id/updateInvoiceIn', + verb: 'PATCH' + } + }); + + Self.updateInvoiceIn = async(ctx, + id, + supplierFk, + supplierRef, + issued, + operated, + deductibleExpenseFk, + dmsFk, + bookEntried, + booked, + currencyFk, + companyFk, + withholdingSageFk, + options + ) => { + let tx; + const myOptions = {userId: ctx.req.accessToken.userId}; + + if (typeof options == 'object') Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const invoiceIn = await Self.findById(id, null, myOptions); + invoiceIn.updateAttributes({supplierFk, + supplierRef, + issued, + operated, + deductibleExpenseFk, + dmsFk, + bookEntried, + booked, + currencyFk, + companyFk, + withholdingSageFk + }, myOptions); + if (tx) await tx.commit(); + return invoiceIn; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/invoiceIn/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoice-in.js index 31cdc1abe..1e69c0ef8 100644 --- a/modules/invoiceIn/back/models/invoice-in.js +++ b/modules/invoiceIn/back/models/invoice-in.js @@ -11,6 +11,8 @@ module.exports = Self => { require('../methods/invoice-in/getSerial')(Self); require('../methods/invoice-in/corrective')(Self); require('../methods/invoice-in/exchangeRateUpdate')(Self); + require('../methods/invoice-in/toUnbook')(Self); + require('../methods/invoice-in/updateInvoiceIn')(Self); Self.rewriteDbError(function(err) { if (err.code === 'ER_ROW_IS_REFERENCED_2' && err.sqlMessage.includes('vehicleInvoiceIn')) diff --git a/modules/invoiceIn/front/basic-data/index.html b/modules/invoiceIn/front/basic-data/index.html deleted file mode 100644 index a22abbb33..000000000 --- a/modules/invoiceIn/front/basic-data/index.html +++ /dev/null @@ -1,315 +0,0 @@ - - - - - - - - - -
- - - - - {{::id}} - {{::nickname}} - - - - - - - - - - - - - - - {{id}} - {{name}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/invoiceIn/front/basic-data/index.js b/modules/invoiceIn/front/basic-data/index.js deleted file mode 100644 index 246f1b16f..000000000 --- a/modules/invoiceIn/front/basic-data/index.js +++ /dev/null @@ -1,187 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import UserError from 'core/lib/user-error'; - -class Controller extends Section { - constructor($element, $, vnFile) { - super($element, $, vnFile); - this.dms = { - files: [], - hasFile: false, - hasFileAttached: false - }; - this.vnFile = vnFile; - this.getAllowedContentTypes(); - this._editDownloadDisabled = false; - } - - get contentTypesInfo() { - return this.$t('ContentTypesInfo', { - allowedContentTypes: this.allowedContentTypes - }); - } - - get editDownloadDisabled() { - return this._editDownloadDisabled; - } - - async checkFileExists(dmsId) { - if (!dmsId) return; - let filter = { - fields: ['id'] - }; - await this.$http.get(`Dms/${dmsId}`, {filter}) - .then(() => this._editDownloadDisabled = false) - .catch(() => this._editDownloadDisabled = true); - } - - async getFile(dmsId) { - const path = `Dms/${dmsId}`; - await this.$http.get(path).then(res => { - const dms = res.data && res.data; - this.dms = { - dmsId: dms.id, - reference: dms.reference, - warehouseId: dms.warehouseFk, - companyId: dms.companyFk, - dmsTypeId: dms.dmsTypeFk, - description: dms.description, - hasFile: dms.hasFile, - hasFileAttached: false, - files: [] - }; - }); - } - - getAllowedContentTypes() { - this.$http.get('DmsContainers/allowedContentTypes').then(res => { - if (res.data.length > 0) { - const contentTypes = res.data.join(', '); - this.allowedContentTypes = contentTypes; - } - }); - } - - openEditDialog(dmsId) { - this.getFile(dmsId).then(() => this.$.dmsEditDialog.show()); - } - - openCreateDialog() { - const params = {filter: { - where: {code: 'invoiceIn'} - }}; - this.$http.get('DmsTypes/findOne', {params}).then(res => { - this.dms = { - reference: this.invoiceIn.supplierRef, - warehouseId: this.vnConfig.warehouseFk, - companyId: this.vnConfig.companyFk, - dmsTypeId: res.data.id, - description: this.invoiceIn.supplier.name, - hasFile: true, - hasFileAttached: true, - files: null - }; - this.$.dmsCreateDialog.show(); - }); - } - - downloadFile(dmsId) { - this.vnFile.download(`api/dms/${dmsId}/downloadFile`); - } - - onFileChange(files) { - let hasFileAttached = false; - if (files.length > 0) - hasFileAttached = true; - - this.$.$applyAsync(() => { - this.dms.hasFileAttached = hasFileAttached; - }); - } - - onEdit() { - if (!this.dms.companyId) - throw new UserError(`The company can't be empty`); - if (!this.dms.warehouseId) - throw new UserError(`The warehouse can't be empty`); - if (!this.dms.dmsTypeId) - throw new UserError(`The DMS Type can't be empty`); - if (!this.dms.description) - throw new UserError(`The description can't be empty`); - - const query = `dms/${this.dms.dmsId}/updateFile`; - const options = { - method: 'POST', - url: query, - params: this.dms, - headers: { - 'Content-Type': undefined - }, - transformRequest: files => { - const formData = new FormData(); - - for (let i = 0; i < files.length; i++) - formData.append(files[i].name, files[i]); - - return formData; - }, - data: this.dms.files - }; - - this.$http(options).then(res => { - if (res) { - this.vnApp.showSuccess(this.$t('Data saved!')); - if (res.data.length > 0) this.invoiceIn.dmsFk = res.data[0].id; - } - }); - } - - onCreate() { - if (!this.dms.companyId) - throw new UserError(`The company can't be empty`); - if (!this.dms.warehouseId) - throw new UserError(`The warehouse can't be empty`); - if (!this.dms.dmsTypeId) - throw new UserError(`The DMS Type can't be empty`); - if (!this.dms.description) - throw new UserError(`The description can't be empty`); - if (!this.dms.files) - throw new UserError(`The files can't be empty`); - - const query = `Dms/uploadFile`; - const options = { - method: 'POST', - url: query, - params: this.dms, - headers: { - 'Content-Type': undefined - }, - transformRequest: files => { - const formData = new FormData(); - - for (let i = 0; i < files.length; i++) - formData.append(files[i].name, files[i]); - - return formData; - }, - data: this.dms.files - }; - - this.$http(options).then(res => { - if (res) { - this.vnApp.showSuccess(this.$t('Data saved!')); - if (res.data.length > 0) this.invoiceIn.dmsFk = res.data[0].id; - } - }); - } -} - -Controller.$inject = ['$element', '$scope', 'vnFile']; - -ngModule.vnComponent('vnInvoiceInBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - invoiceIn: '<' - } -}); diff --git a/modules/invoiceIn/front/basic-data/index.spec.js b/modules/invoiceIn/front/basic-data/index.spec.js deleted file mode 100644 index 98710ac35..000000000 --- a/modules/invoiceIn/front/basic-data/index.spec.js +++ /dev/null @@ -1,102 +0,0 @@ -import './index.js'; -import watcher from 'core/mocks/watcher'; - -describe('InvoiceIn', () => { - describe('Component vnInvoiceInBasicData', () => { - let controller; - let $scope; - let $httpBackend; - let $httpParamSerializer; - - beforeEach(ngModule('invoiceIn')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { - $scope = $rootScope.$new(); - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - const $element = angular.element(''); - controller = $componentController('vnInvoiceInBasicData', {$element, $scope}); - controller.$.watcher = watcher; - $httpBackend.expect('GET', `DmsContainers/allowedContentTypes`).respond({}); - })); - - describe('onFileChange()', () => { - it('should set dms hasFileAttached property to true if has any files', () => { - const files = [{id: 1, name: 'MyFile'}]; - controller.onFileChange(files); - - $scope.$apply(); - - expect(controller.dms.hasFileAttached).toBeTruthy(); - }); - }); - - describe('checkFileExists()', () => { - it(`should return false if a file exists`, () => { - const fileIdExists = 1; - controller.checkFileExists(fileIdExists); - - expect(controller.editDownloadDisabled).toBe(false); - }); - }); - - describe('onEdit()', () => { - it(`should perform a POST query to edit the dms properties`, () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - - const dms = { - dmsId: 1, - reference: 'Ref1', - warehouseId: 1, - companyId: 442, - dmsTypeId: 20, - description: 'This is a description', - files: [] - }; - - controller.dms = dms; - const serializedParams = $httpParamSerializer(controller.dms); - const query = `dms/${controller.dms.dmsId}/updateFile?${serializedParams}`; - - $httpBackend.expectPOST(query).respond({}); - controller.onEdit(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('onCreate()', () => { - it(`should perform a POST query to create a new dms`, () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - - const dms = { - reference: 'Ref1', - warehouseId: 1, - companyId: 442, - dmsTypeId: 20, - description: 'This is a description', - files: [{ - lastModified: 1668673957761, - lastModifiedDate: Date.vnNew(), - name: 'file-example.png', - size: 19653, - type: 'image/png', - webkitRelativePath: '' - }] - }; - - controller.dms = dms; - const serializedParams = $httpParamSerializer(controller.dms); - const query = `Dms/uploadFile?${serializedParams}`; - - $httpBackend.expectPOST(query).respond({}); - controller.onCreate(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - }); -}); - diff --git a/modules/invoiceIn/front/basic-data/locale/en.yml b/modules/invoiceIn/front/basic-data/locale/en.yml deleted file mode 100644 index 19f4dc8c2..000000000 --- a/modules/invoiceIn/front/basic-data/locale/en.yml +++ /dev/null @@ -1 +0,0 @@ -ContentTypesInfo: Allowed file types {{allowedContentTypes}} diff --git a/modules/invoiceIn/front/basic-data/locale/es.yml b/modules/invoiceIn/front/basic-data/locale/es.yml deleted file mode 100644 index e2e494fa5..000000000 --- a/modules/invoiceIn/front/basic-data/locale/es.yml +++ /dev/null @@ -1,15 +0,0 @@ -Upload file: Subir fichero -Edit file: Editar fichero -Upload: Subir -Document: Documento -ContentTypesInfo: "Tipos de archivo permitidos: {{allowedContentTypes}}" -Generate identifier for original file: Generar identificador para archivo original -File management: Gestión documental -Hard copy: Copia -This file will be deleted: Este fichero va a ser borrado -Are you sure?: Estas seguro? -File deleted: Fichero eliminado -Remove file: Eliminar fichero -Download file: Descargar fichero -Edit document: Editar documento -Create document: Crear documento diff --git a/modules/invoiceIn/front/create/index.html b/modules/invoiceIn/front/create/index.html deleted file mode 100644 index 16ecf26cf..000000000 --- a/modules/invoiceIn/front/create/index.html +++ /dev/null @@ -1,55 +0,0 @@ - - -
-
- - - {{id}}: {{nif}}: {{name}} - - - - - - - - - - - - - - -
-
\ No newline at end of file diff --git a/modules/invoiceIn/front/create/index.js b/modules/invoiceIn/front/create/index.js deleted file mode 100644 index 885d55359..000000000 --- a/modules/invoiceIn/front/create/index.js +++ /dev/null @@ -1,30 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - $onInit() { - this.invoiceIn = {}; - if (this.$params && this.$params.supplierFk) - this.invoiceIn.supplierFk = this.$params.supplierFk; - this.invoiceIn.issued = Date.vnNew(); - } - - get companyFk() { - return this.invoiceIn.companyFk || this.vnConfig.companyFk; - } - - set companyFk(value) { - this.invoiceIn.companyFk = value; - } - - onSubmit() { - this.$.watcher.submit().then( - res => this.$state.go('invoiceIn.card.basicData', {id: res.data.id}) - ); - } -} - -ngModule.vnComponent('vnInvoiceInCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/invoiceIn/front/create/locale/es.yml b/modules/invoiceIn/front/create/locale/es.yml deleted file mode 100644 index 35bfe3ca4..000000000 --- a/modules/invoiceIn/front/create/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -a:a \ No newline at end of file diff --git a/modules/invoiceIn/front/dueDay/index.html b/modules/invoiceIn/front/dueDay/index.html deleted file mode 100644 index abc91312d..000000000 --- a/modules/invoiceIn/front/dueDay/index.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - -
- - - - - - {{id}}: {{bank}} - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/modules/invoiceIn/front/dueDay/index.js b/modules/invoiceIn/front/dueDay/index.js deleted file mode 100644 index ee9b13e5c..000000000 --- a/modules/invoiceIn/front/dueDay/index.js +++ /dev/null @@ -1,37 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - add() { - this.$.model.insert({ - dueDated: Date.vnNew(), - bankFk: this.vnConfig.local.bankFk - }); - } - - onSubmit() { - this.$.watcher.check(); - this.$.model.save().then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - this.card.reload(); - }); - } - - bankSearchFunc($search) { - return /^\d+$/.test($search) - ? {id: $search} - : {bank: {like: '%' + $search + '%'}}; - } -} - -ngModule.vnComponent('vnInvoiceInDueDay', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnInvoiceInCard' - }, - bindings: { - invoiceIn: '<' - } -}); diff --git a/modules/invoiceIn/front/dueDay/index.spec.js b/modules/invoiceIn/front/dueDay/index.spec.js deleted file mode 100644 index 7dddd3bb0..000000000 --- a/modules/invoiceIn/front/dueDay/index.spec.js +++ /dev/null @@ -1,44 +0,0 @@ -import './index.js'; -import watcher from 'core/mocks/watcher'; -import crudModel from 'core/mocks/crud-model'; - -describe('InvoiceIn', () => { - describe('Component due day', () => { - let controller; - let $scope; - let vnApp; - - beforeEach(ngModule('invoiceIn')); - - beforeEach(inject(($componentController, $rootScope, _vnApp_) => { - vnApp = _vnApp_; - jest.spyOn(vnApp, 'showError'); - $scope = $rootScope.$new(); - $scope.model = crudModel; - $scope.watcher = watcher; - - const $element = angular.element(''); - controller = $componentController('vnInvoiceInDueDay', {$element, $scope}); - controller.invoiceIn = {id: 1}; - })); - - describe('onSubmit()', () => { - it('should make HTTP POST request to save due day values', () => { - controller.card = {reload: () => {}}; - jest.spyOn($scope.watcher, 'check'); - jest.spyOn($scope.watcher, 'notifySaved'); - jest.spyOn($scope.watcher, 'updateOriginalData'); - jest.spyOn(controller.card, 'reload'); - jest.spyOn($scope.model, 'save'); - - controller.onSubmit(); - - expect($scope.model.save).toHaveBeenCalledWith(); - expect($scope.watcher.updateOriginalData).toHaveBeenCalledWith(); - expect($scope.watcher.check).toHaveBeenCalledWith(); - expect($scope.watcher.notifySaved).toHaveBeenCalledWith(); - expect(controller.card.reload).toHaveBeenCalledWith(); - }); - }); - }); -}); diff --git a/modules/invoiceIn/front/index.js b/modules/invoiceIn/front/index.js index e257cfee3..8155e7089 100644 --- a/modules/invoiceIn/front/index.js +++ b/modules/invoiceIn/front/index.js @@ -1,17 +1,7 @@ export * from './module'; import './main'; -import './index/'; -import './search-panel'; import './card'; import './descriptor'; import './descriptor-popover'; import './summary'; -import './basic-data'; -import './tax'; -import './dueDay'; -import './intrastat'; -import './create'; -import './log'; -import './serial'; -import './serial-search-panel'; diff --git a/modules/invoiceIn/front/index/index.html b/modules/invoiceIn/front/index/index.html deleted file mode 100644 index 008d615b1..000000000 --- a/modules/invoiceIn/front/index/index.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - ID - Supplier - Supplier ref. - Serial number - Serial - File - Issued - Is booked - AWB - Amount - - - - - - {{::invoiceIn.id}} - - - {{::invoiceIn.supplierName}} - - - {{::invoiceIn.supplierRef | dashIfEmpty}} - {{::invoiceIn.serialNumber}} - {{::invoiceIn.serial}} - - - {{::invoiceIn.file}} - - - {{::invoiceIn.issued | date:'dd/MM/yyyy' | dashIfEmpty}} - - - - - {{::invoiceIn.awbCode}} - {{::invoiceIn.amount | currency:'EUR'}} - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/invoiceIn/front/index/index.js b/modules/invoiceIn/front/index/index.js deleted file mode 100644 index 254e6d3bf..000000000 --- a/modules/invoiceIn/front/index/index.js +++ /dev/null @@ -1,58 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $, vnFile) { - super($element, $, vnFile); - this.vnFile = vnFile; - } - - exprBuilder(param, value) { - switch (param) { - case 'issued': - return {'ii.issued': { - between: this.dateRange(value)} - }; - case 'id': - case 'supplierFk': - case 'supplierRef': - case 'serialNumber': - case 'serial': - case 'created': - case 'isBooked': - return {[`ii.${param}`]: value}; - case 'account': - case 'fi': - return {[`s.${param}`]: value}; - case 'awbCode': - return {'awb.code': value}; - default: - return {[param]: value}; - } - } - - dateRange(value) { - const minHour = new Date(value); - minHour.setHours(0, 0, 0, 0); - const maxHour = new Date(value); - maxHour.setHours(23, 59, 59, 59); - - return [minHour, maxHour]; - } - - preview(invoiceIn) { - this.selectedInvoiceIn = invoiceIn; - this.$.summary.show(); - } - - downloadFile(dmsId) { - this.vnFile.download(`api/dms/${dmsId}/downloadFile`); - } -} - -Controller.$inject = ['$element', '$scope', 'vnFile']; - -ngModule.vnComponent('vnInvoiceInIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/invoiceIn/front/index/locale/es.yml b/modules/invoiceIn/front/index/locale/es.yml deleted file mode 100644 index e1b354316..000000000 --- a/modules/invoiceIn/front/index/locale/es.yml +++ /dev/null @@ -1,6 +0,0 @@ -Created: Fecha creación -Issued: Fecha emisión -Supplier ref.: Ref. proveedor -Serial number: Num. serie -Serial: Serie -Is booked: Conciliada \ No newline at end of file diff --git a/modules/invoiceIn/front/intrastat/index.html b/modules/invoiceIn/front/intrastat/index.html deleted file mode 100644 index fc0139303..000000000 --- a/modules/invoiceIn/front/intrastat/index.html +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - - - - - - - - - -
- - - - {{id}}: {{description}} - - - - - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/modules/invoiceIn/front/intrastat/index.js b/modules/invoiceIn/front/intrastat/index.js deleted file mode 100644 index 659929513..000000000 --- a/modules/invoiceIn/front/intrastat/index.js +++ /dev/null @@ -1,60 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - set invoceInIntrastat(value) { - this._invoceInIntrastat = value; - - if (value) this.calculateTotals(); - } - - get invoceInIntrastat() { - return this._invoceInIntrastat; - } - - calculateTotals() { - this.amountTotal = 0.0; - this.netTotal = 0.0; - this.stemsTotal = 0.0; - if (!this.invoceInIntrastat) return; - - this.invoceInIntrastat.forEach(intrastat => { - this.amountTotal += intrastat.amount; - this.netTotal += intrastat.net; - this.stemsTotal += intrastat.stems; - }); - } - - add() { - this.$.model.insert({}); - } - - deleteIntrastat($index) { - this.$.model.remove($index); - this.$.model.save().then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.calculateTotals(); - }); - } - - onSubmit() { - this.$.watcher.check(); - this.$.model.save().then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - this.calculateTotals(); - this.card.reload(); - }); - } -} - -ngModule.vnComponent('vnInvoiceInIntrastat', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnInvoiceInCard' - }, - bindings: { - invoiceIn: '<' - } -}); diff --git a/modules/invoiceIn/front/intrastat/index.spec.js b/modules/invoiceIn/front/intrastat/index.spec.js deleted file mode 100644 index d7d50ac5b..000000000 --- a/modules/invoiceIn/front/intrastat/index.spec.js +++ /dev/null @@ -1,85 +0,0 @@ -import './index.js'; -import watcher from 'core/mocks/watcher'; -import crudModel from 'core/mocks/crud-model'; - -describe('InvoiceIn', () => { - describe('Component intrastat', () => { - let controller; - let $scope; - let vnApp; - - beforeEach(ngModule('invoiceIn')); - - beforeEach(inject(($componentController, $rootScope, _vnApp_) => { - vnApp = _vnApp_; - jest.spyOn(vnApp, 'showError'); - $scope = $rootScope.$new(); - $scope.model = crudModel; - $scope.watcher = watcher; - - const $element = angular.element(''); - controller = $componentController('vnInvoiceInIntrastat', {$element, $scope}); - controller.invoiceIn = {id: 1}; - })); - - describe('calculateTotals()', () => { - it('should set amountTotal, netTotal and stemsTotal to 0 if salesClaimed has no data', () => { - controller.invoceInIntrastat = []; - controller.calculateTotals(); - - expect(controller.amountTotal).toEqual(0); - expect(controller.netTotal).toEqual(0); - expect(controller.stemsTotal).toEqual(0); - }); - - it('should set amountTotal, netTotal and stemsTotal', () => { - controller.invoceInIntrastat = [ - { - id: 1, - invoiceInFk: 1, - net: 30.5, - intrastatFk: 5080000, - amount: 10, - stems: 162, - countryFk: 5, - statisticalValue: 0 - }, - { - id: 2, - invoiceInFk: 1, - net: 10, - intrastatFk: 6021010, - amount: 20, - stems: 205, - countryFk: 5, - statisticalValue: 0 - } - ]; - controller.calculateTotals(); - - expect(controller.amountTotal).toEqual(30); - expect(controller.netTotal).toEqual(40.5); - expect(controller.stemsTotal).toEqual(367); - }); - }); - - describe('onSubmit()', () => { - it('should make HTTP POST request to save intrastat values', () => { - controller.card = {reload: () => {}}; - jest.spyOn($scope.watcher, 'check'); - jest.spyOn($scope.watcher, 'notifySaved'); - jest.spyOn($scope.watcher, 'updateOriginalData'); - jest.spyOn(controller.card, 'reload'); - jest.spyOn($scope.model, 'save'); - - controller.onSubmit(); - - expect($scope.model.save).toHaveBeenCalledWith(); - expect($scope.watcher.updateOriginalData).toHaveBeenCalledWith(); - expect($scope.watcher.check).toHaveBeenCalledWith(); - expect($scope.watcher.notifySaved).toHaveBeenCalledWith(); - expect(controller.card.reload).toHaveBeenCalledWith(); - }); - }); - }); -}); diff --git a/modules/invoiceIn/front/log/index.html b/modules/invoiceIn/front/log/index.html deleted file mode 100644 index 2cfc9dfb1..000000000 --- a/modules/invoiceIn/front/log/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/modules/invoiceIn/front/log/index.js b/modules/invoiceIn/front/log/index.js deleted file mode 100644 index 7a018de0f..000000000 --- a/modules/invoiceIn/front/log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnInvoiceInLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/invoiceIn/front/main/index.html b/modules/invoiceIn/front/main/index.html index 2dc87b2ee..e69de29bb 100644 --- a/modules/invoiceIn/front/main/index.html +++ b/modules/invoiceIn/front/main/index.html @@ -1,18 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/modules/invoiceIn/front/main/index.js b/modules/invoiceIn/front/main/index.js index f7b767458..c22b37924 100644 --- a/modules/invoiceIn/front/main/index.js +++ b/modules/invoiceIn/front/main/index.js @@ -1,7 +1,16 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; -export default class InvoiceIn extends ModuleMain {} +export default class InvoiceIn extends ModuleMain { + constructor($element, $) { + super($element, $); + } + + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`invoice-in/`); + } +} ngModule.vnComponent('vnInvoiceIn', { controller: InvoiceIn, diff --git a/modules/invoiceIn/front/search-panel/index.html b/modules/invoiceIn/front/search-panel/index.html deleted file mode 100644 index 609fa56d8..000000000 --- a/modules/invoiceIn/front/search-panel/index.html +++ /dev/null @@ -1,97 +0,0 @@ -
-
- - - - - - - - - - - - - - {{::id}} - {{::nickname}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/modules/invoiceIn/front/search-panel/index.js b/modules/invoiceIn/front/search-panel/index.js deleted file mode 100644 index a8e41b7ef..000000000 --- a/modules/invoiceIn/front/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.vnComponent('vnInvoiceInSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/invoiceIn/front/search-panel/locale/es.yml b/modules/invoiceIn/front/search-panel/locale/es.yml deleted file mode 100644 index 57e2944ea..000000000 --- a/modules/invoiceIn/front/search-panel/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Supplier fiscal id: CIF proveedor -Search invoices in by id or supplier fiscal name: Buscar facturas recibidas por id o por nombre fiscal del proveedor \ No newline at end of file diff --git a/modules/invoiceIn/front/serial-search-panel/index.html b/modules/invoiceIn/front/serial-search-panel/index.html deleted file mode 100644 index 0dda54852..000000000 --- a/modules/invoiceIn/front/serial-search-panel/index.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - -
- - {{$ctrl.$t('Serial')}}: {{$ctrl.filter.serial}} - -
-
diff --git a/modules/invoiceIn/front/serial-search-panel/index.js b/modules/invoiceIn/front/serial-search-panel/index.js deleted file mode 100644 index b11911ee3..000000000 --- a/modules/invoiceIn/front/serial-search-panel/index.js +++ /dev/null @@ -1,44 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; -import './style.scss'; - -class Controller extends SearchPanel { - constructor($element, $) { - super($element, $); - this.filter = {}; - const filter = { - fields: ['daysAgo'] - }; - this.$http.get('InvoiceInConfigs', {filter}).then(res => { - if (res.data) { - this.invoiceInConfig = res.data[0]; - this.addFilters(); - } - }); - } - - removeItemFilter(param) { - this.filter[param] = null; - this.addFilters(); - } - - onKeyPress($event) { - if ($event.key === 'Enter') - this.addFilters(); - } - - addFilters() { - if (!this.filter.daysAgo) - this.filter.daysAgo = this.invoiceInConfig.daysAgo; - - return this.model.addFilter({}, this.filter); - } -} - -ngModule.component('vnInvoiceInSerialSearchPanel', { - template: require('./index.html'), - controller: Controller, - bindings: { - model: '<' - } -}); diff --git a/modules/invoiceIn/front/serial-search-panel/index.spec.js b/modules/invoiceIn/front/serial-search-panel/index.spec.js deleted file mode 100644 index b5228e126..000000000 --- a/modules/invoiceIn/front/serial-search-panel/index.spec.js +++ /dev/null @@ -1,43 +0,0 @@ -import './index.js'; - -describe('InvoiceIn', () => { - describe('Component serial-search-panel', () => { - let controller; - let $scope; - - beforeEach(ngModule('invoiceIn')); - - beforeEach(inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnInvoiceInSerialSearchPanel', {$element, $scope}); - controller.model = { - addFilter: jest.fn(), - }; - controller.invoiceInConfig = { - daysAgo: 45, - }; - })); - - describe('addFilters()', () => { - it('should add default daysAgo if it is not already set', () => { - controller.filter = { - serial: 'R', - }; - controller.addFilters(); - - expect(controller.filter.daysAgo).toEqual(controller.invoiceInConfig.daysAgo); - }); - - it('should not add default daysAgo if it is already set', () => { - controller.filter = { - daysAgo: 1, - serial: 'R', - }; - controller.addFilters(); - - expect(controller.filter.daysAgo).toEqual(1); - }); - }); - }); -}); diff --git a/modules/invoiceIn/front/serial-search-panel/style.scss b/modules/invoiceIn/front/serial-search-panel/style.scss deleted file mode 100644 index 4abfcbfa2..000000000 --- a/modules/invoiceIn/front/serial-search-panel/style.scss +++ /dev/null @@ -1,24 +0,0 @@ -@import "variables"; - -vn-invoice-in-serial-search-panel vn-side-menu div { - & > .input { - padding-left: $spacing-md; - padding-right: $spacing-md; - border-color: $color-spacer; - border-bottom: $border-thin; - } - & > .horizontal { - grid-auto-flow: column; - grid-column-gap: $spacing-sm; - align-items: center; - } - & > .chips { - display: flex; - flex-wrap: wrap; - padding: $spacing-md; - overflow: hidden; - max-width: 100%; - border-color: $color-spacer; - border-top: $border-thin; - } -} diff --git a/modules/invoiceIn/front/serial/index.html b/modules/invoiceIn/front/serial/index.html deleted file mode 100644 index 1649ec7d7..000000000 --- a/modules/invoiceIn/front/serial/index.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - Serial - Pending - Total - - - - - - {{::invoiceIn.serial}} - {{::invoiceIn.pending}} - {{::invoiceIn.total}} - - - - - - - - - diff --git a/modules/invoiceIn/front/serial/index.js b/modules/invoiceIn/front/serial/index.js deleted file mode 100644 index 193a57492..000000000 --- a/modules/invoiceIn/front/serial/index.js +++ /dev/null @@ -1,22 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - } - - goToIndex(daysAgo, serial) { - const issued = Date.vnNew(); - issued.setDate(issued.getDate() - daysAgo); - this.$state.go('invoiceIn.index', - {q: `{"serial": "${serial}", "isBooked": false, "from": ${issued.getTime()}}`}); - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnInvoiceInSerial', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/invoiceIn/front/serial/locale/es.yml b/modules/invoiceIn/front/serial/locale/es.yml deleted file mode 100644 index 92a49cc82..000000000 --- a/modules/invoiceIn/front/serial/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Serial: Serie -Pending: Pendientes -Go to InvoiceIn: Ir al listado de facturas recibidas diff --git a/modules/invoiceIn/front/tax/index.html b/modules/invoiceIn/front/tax/index.html deleted file mode 100644 index e13f769ce..000000000 --- a/modules/invoiceIn/front/tax/index.html +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - -
- - - - {{id}}: {{name}} - - - - - - - - - -
{{::vat}}
-
#{{::id}}
-
-
- - -
{{::transaction}}
-
#{{::id}}
-
-
- - - - - - - - -
- - - - -
- - - - -
- - - - -
-
{{$ctrl.$t('New expense')}}
- - - - - - - - - - -
-
- - - - -
diff --git a/modules/invoiceIn/front/tax/index.js b/modules/invoiceIn/front/tax/index.js deleted file mode 100644 index d05a77f29..000000000 --- a/modules/invoiceIn/front/tax/index.js +++ /dev/null @@ -1,66 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import UserError from 'core/lib/user-error'; - -class Controller extends Section { - constructor($element, $, vnWeekDays) { - super($element, $); - this.expense = {}; - } - taxRate(invoiceInTax, taxRateSelection) { - const taxTypeSage = taxRateSelection && taxRateSelection.rate; - const taxableBase = invoiceInTax && invoiceInTax.taxableBase; - - if (taxTypeSage && taxableBase) - return (taxTypeSage / 100) * taxableBase; - - return 0; - } - - add() { - this.$.model.insert({ - invoiceIn: this.$params.id - }); - } - - onSubmit() { - this.$.watcher.check(); - this.$.model.save().then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - this.card.reload(); - }); - } - - onResponse() { - try { - if (!this.expense.code) - throw new Error(`The code can't be empty`); - if (!this.expense.description) - throw new UserError(`The description can't be empty`); - - const data = [{ - id: this.expense.code, - isWithheld: this.expense.isWithheld, - name: this.expense.description - }]; - - this.$http.post(`Expenses`, data) .then(() => { - this.vnApp.showSuccess(this.$t('Expense saved!')); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - } - } -} - -ngModule.vnComponent('vnInvoiceInTax', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnInvoiceInCard' - }, - bindings: { - invoiceIn: '<' - } -}); diff --git a/modules/invoiceIn/front/tax/index.spec.js b/modules/invoiceIn/front/tax/index.spec.js deleted file mode 100644 index 52114afe5..000000000 --- a/modules/invoiceIn/front/tax/index.spec.js +++ /dev/null @@ -1,113 +0,0 @@ -import './index.js'; -import watcher from 'core/mocks/watcher'; -import crudModel from 'core/mocks/crud-model'; - -describe('InvoiceIn', () => { - describe('Component tax', () => { - let controller; - let $scope; - let vnApp; - let $httpBackend; - - beforeEach(ngModule('invoiceIn')); - - beforeEach(inject(($componentController, $rootScope, _vnApp_, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - vnApp = _vnApp_; - jest.spyOn(vnApp, 'showError'); - $scope = $rootScope.$new(); - $scope.model = crudModel; - $scope.watcher = watcher; - - const $element = angular.element(''); - controller = $componentController('vnInvoiceInTax', {$element, $scope}); - controller.$.model = crudModel; - controller.invoiceIn = {id: 1}; - })); - - describe('taxRate()', () => { - it('should set tax rate with the Sage tax type value', () => { - const taxRateSelection = { - rate: 21 - }; - const invoiceInTax = { - taxableBase: 200 - }; - - const taxRate = controller.taxRate(invoiceInTax, taxRateSelection); - - expect(taxRate).toEqual(42); - }); - }); - - describe('onSubmit()', () => { - it('should make HTTP POST request to save tax values', () => { - controller.card = {reload: () => {}}; - jest.spyOn($scope.watcher, 'check'); - jest.spyOn($scope.watcher, 'notifySaved'); - jest.spyOn($scope.watcher, 'updateOriginalData'); - jest.spyOn(controller.card, 'reload'); - jest.spyOn($scope.model, 'save'); - - controller.onSubmit(); - - expect($scope.model.save).toHaveBeenCalledWith(); - expect($scope.watcher.updateOriginalData).toHaveBeenCalledWith(); - expect($scope.watcher.check).toHaveBeenCalledWith(); - expect($scope.watcher.notifySaved).toHaveBeenCalledWith(); - expect(controller.card.reload).toHaveBeenCalledWith(); - }); - }); - - describe('onResponse()', () => { - it('should return success message', () => { - controller.expense = { - code: 7050000005, - isWithheld: 0, - description: 'Test' - }; - - const data = [{ - id: controller.expense.code, - isWithheld: controller.expense.isWithheld, - name: controller.expense.description - }]; - - jest.spyOn(controller.vnApp, 'showSuccess'); - $httpBackend.expect('POST', `Expenses`, data).respond(); - - controller.onResponse(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Expense saved!'); - }); - - it('should return an error if code is empty', () => { - controller.expense = { - code: null, - isWithheld: 0, - description: 'Test' - }; - - jest.spyOn(controller.vnApp, 'showError'); - controller.onResponse(); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`The code can't be empty`); - }); - - it('should return an error if description is empty', () => { - controller.expense = { - code: 7050000005, - isWithheld: 0, - description: null - }; - - jest.spyOn(controller.vnApp, 'showError'); - controller.onResponse(); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`The description can't be empty`); - }); - }); - }); -}); - diff --git a/modules/invoiceIn/front/tax/locale/es.yml b/modules/invoiceIn/front/tax/locale/es.yml deleted file mode 100644 index 3ff68ea40..000000000 --- a/modules/invoiceIn/front/tax/locale/es.yml +++ /dev/null @@ -1,7 +0,0 @@ -Create expense: Crear gasto -New expense: Nuevo gasto -It's a withholding: Es una retención -The fields can't be empty: Los campos no pueden estar vacíos -The code can't be empty: El código no puede estar vacío -The description can't be empty: La descripción no puede estar vacía -Expense saved!: Gasto guardado! \ No newline at end of file diff --git a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js index 63b00fe38..5526d214a 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js @@ -75,7 +75,7 @@ module.exports = Self => { AND c.isTaxDataChecked AND c.isActive AND NOT t.isDeleted - GROUP BY c.id, IF(c.hasToInvoiceByAddress, a.id, TRUE) + GROUP BY IF(c.hasToInvoiceByAddress, a.id, c.id) HAVING SUM(t.totalWithVat) > 0;`; const addresses = await Self.rawSql(query, [ diff --git a/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js index c46da0ba5..a06128848 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js @@ -10,6 +10,11 @@ module.exports = Self => { type: 'any', description: 'The invoiceable client id' }, + { + arg: 'addressFk', + type: 'any', + description: 'The address id' + }, { arg: 'ticketFk', type: 'any', @@ -23,7 +28,8 @@ module.exports = Self => { { arg: 'serial', type: 'string', - description: 'The invoice serial' + description: 'The invoice serial', + required: true }, { arg: 'taxArea', @@ -46,108 +52,126 @@ module.exports = Self => { } }); - Self.createManualInvoice = async(ctx, clientFk, ticketFk, maxShipped, serial, taxArea, reference, options) => { - if (!clientFk && !ticketFk) throw new UserError(`Select ticket or client`); - const models = Self.app.models; - const myOptions = {userId: ctx.req.accessToken.userId}; - let tx; + Self.createManualInvoice = + async(ctx, clientFk, addressFk, ticketFk, maxShipped, serial, taxArea, reference, options) => { + if (!clientFk && !ticketFk) throw new UserError(`Select ticket or client`); + const models = Self.app.models; + const myOptions = {userId: ctx.req.accessToken.userId}; + let tx; - if (typeof options == 'object') - Object.assign(myOptions, options); + if (typeof options == 'object') + Object.assign(myOptions, options); - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } - let companyId; - let newInvoice; - let query; - try { - if (ticketFk) { - const ticket = await models.Ticket.findById(ticketFk, null, myOptions); - const company = await models.Company.findById(ticket.companyFk, null, myOptions); + let companyFk; + let newInvoice; + let query; + try { + if (ticketFk) { + const ticket = await models.Ticket.findById(ticketFk, { + fields: ['clientFk', 'companyFk', 'shipped', 'refFk', 'totalWithVat'] + }, myOptions); + const company = await models.Company.findById(ticket.companyFk, { + fields: ['code'] + }, myOptions); - clientFk = ticket.clientFk; - maxShipped = ticket.shipped; - companyId = ticket.companyFk; + clientFk = ticket.clientFk; + maxShipped = ticket.shipped; + companyFk = ticket.companyFk; - // Validates invoiced ticket - if (ticket.refFk) - throw new UserError('This ticket is already invoiced'); + if (ticket.refFk) + throw new UserError('This ticket is already invoiced'); - // Validates ticket amount - if (ticket.totalWithVat == 0) - throw new UserError(`A ticket with an amount of zero can't be invoiced`); + if (ticket.totalWithVat == 0) + throw new UserError(`A ticket with an amount of zero can't be invoiced`); - // Validates ticket nagative base - const hasNegativeBase = await getNegativeBase(maxShipped, clientFk, companyId, myOptions); - if (hasNegativeBase && company.code == 'VNL') - throw new UserError(`A ticket with a negative base can't be invoiced`); - } else { - if (!maxShipped) - throw new UserError(`Max shipped required`); + const hasNegativeBase = await getNegativeBase(maxShipped, clientFk, companyFk, myOptions); + if (hasNegativeBase && company.code == 'VNL') + throw new UserError(`A ticket with a negative base can't be invoiced`); + } else { + if (!maxShipped) + throw new UserError(`Max shipped required`); - const company = await models.Ticket.findOne({ - fields: ['companyFk'], - where: { - clientFk: clientFk, - shipped: {lte: maxShipped} + if (addressFk) { + const address = await models.Address.findById(addressFk, { + fields: ['clientFk'] + }, myOptions); + + if (clientFk && clientFk !== address.clientFk) + throw new UserError('The provided clientFk does not match'); } - }, myOptions); - companyId = company.companyFk; + const company = await models.Ticket.findOne({ + fields: ['companyFk'], + where: { + clientFk: clientFk, + shipped: {lte: maxShipped} + } + }, myOptions); + companyFk = company.companyFk; + } + + const isClientInvoiceable = await isInvoiceable(clientFk, myOptions); + if (!isClientInvoiceable) + throw new UserError(`This client is not invoiceable`); + + const tomorrow = Date.vnNew(); + tomorrow.setDate(tomorrow.getDate() + 1); + + if (maxShipped >= tomorrow) + throw new UserError(`Can't invoice to future`); + + const maxInvoiceDate = await getMaxIssued(serial, companyFk, myOptions); + if (Date.vnNew() < maxInvoiceDate) + throw new UserError(`Can't invoice to past`); + + if (ticketFk) { + query = `CALL invoiceOut_newFromTicket(?, ?, ?, ?, @newInvoiceId)`; + await Self.rawSql(query, [ + ticketFk, + serial, + taxArea, + reference + ], myOptions); + } else if (addressFk) { + query = `CALL invoiceOut_newFromAddress(?, ?, ?, ?, ?, ?, @newInvoiceId)`; + await Self.rawSql(query, [ + addressFk, + serial, + maxShipped, + companyFk, + taxArea, + reference + ], myOptions); + } else { + query = `CALL invoiceOut_newFromClient(?, ?, ?, ?, ?, ?, @newInvoiceId)`; + await Self.rawSql(query, [ + clientFk, + serial, + maxShipped, + companyFk, + taxArea, + reference + ], myOptions); + } + + [newInvoice] = await Self.rawSql(`SELECT @newInvoiceId id`, null, myOptions); + + if (tx) await tx.commit(); + } catch (e) { + if (tx) await tx.rollback(); + throw e; } - // Validate invoiceable client - const isClientInvoiceable = await isInvoiceable(clientFk, myOptions); - if (!isClientInvoiceable) - throw new UserError(`This client is not invoiceable`); + if (!newInvoice.id) throw new UserError('It was not able to create the invoice'); - // Can't invoice tickets into future - const tomorrow = Date.vnNew(); - tomorrow.setDate(tomorrow.getDate() + 1); + await Self.createPdf(ctx, newInvoice.id); - if (maxShipped >= tomorrow) - throw new UserError(`Can't invoice to future`); - - const maxInvoiceDate = await getMaxIssued(serial, companyId, myOptions); - if (Date.vnNew() < maxInvoiceDate) - throw new UserError(`Can't invoice to past`); - - if (ticketFk) { - query = `CALL invoiceOut_newFromTicket(?, ?, ?, ?, @newInvoiceId)`; - await Self.rawSql(query, [ - ticketFk, - serial, - taxArea, - reference - ], myOptions); - } else { - query = `CALL invoiceOut_newFromClient(?, ?, ?, ?, ?, ?, @newInvoiceId)`; - await Self.rawSql(query, [ - clientFk, - serial, - maxShipped, - companyId, - taxArea, - reference - ], myOptions); - } - - [newInvoice] = await Self.rawSql(`SELECT @newInvoiceId id`, null, myOptions); - - if (tx) await tx.commit(); - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - - if (!newInvoice.id) throw new UserError('It was not able to create the invoice'); - - await Self.createPdf(ctx, newInvoice.id); - - return newInvoice; - }; + return newInvoice; + }; async function isInvoiceable(clientFk, options) { const models = Self.app.models; @@ -159,10 +183,10 @@ module.exports = Self => { return result.invoiceable; } - async function getNegativeBase(maxShipped, clientFk, companyId, options) { + async function getNegativeBase(maxShipped, clientFk, companyFk, options) { const models = Self.app.models; await models.InvoiceOut.rawSql('CALL invoiceOut_exportationFromClient(?,?,?)', - [maxShipped, clientFk, companyId], options + [maxShipped, clientFk, companyFk], options ); const query = 'SELECT vn.hasAnyNegativeBase() AS base'; const [result] = await models.InvoiceOut.rawSql(query, [], options); @@ -170,14 +194,14 @@ module.exports = Self => { return result.base; } - async function getMaxIssued(serial, companyId, options) { + async function getMaxIssued(serial, companyFk, options) { const models = Self.app.models; const query = `SELECT MAX(issued) AS issued FROM invoiceOut WHERE serial = ? AND companyFk = ?`; const [maxIssued] = await models.InvoiceOut.rawSql(query, - [serial, companyId], options); - const maxInvoiceDate = maxIssued && maxIssued.issued || Date.vnNew(); + [serial, companyFk], options); + const maxInvoiceDate = maxIssued?.issued || Date.vnNew(); return maxInvoiceDate; } diff --git a/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js b/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js index 530b02353..2fad1afd8 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js +++ b/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js @@ -28,6 +28,11 @@ module.exports = Self => { type: 'number', description: 'The company id to invoice', required: true + }, { + arg: 'serialType', + type: 'string', + description: 'Invoice serial number type (see vn.invoiceOutSerial.type enum)', + required: true } ], returns: { @@ -39,17 +44,19 @@ module.exports = Self => { verb: 'POST' } }); - Self.invoiceClient = async(ctx, options) => { const args = ctx.args; const models = Self.app.models; - options = typeof options == 'object' - ? Object.assign({}, options) : {}; - options.userId = ctx.req.accessToken.userId; - let tx; - if (!options.transaction) - tx = options.transaction = await Self.beginTransaction({}); + const myOptions = {userId: ctx.req.accessToken.userId}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } const minShipped = Date.vnNew(); minShipped.setFullYear(args.maxShipped.getFullYear() - 1); @@ -57,7 +64,7 @@ module.exports = Self => { try { const client = await models.Client.findById(args.clientId, { fields: ['id', 'hasToInvoiceByAddress'] - }, options); + }, myOptions); if (client.hasToInvoiceByAddress) { await Self.rawSql('CALL ticketToInvoiceByAddress(?, ?, ?, ?)', [ @@ -65,23 +72,22 @@ module.exports = Self => { args.maxShipped, args.addressId, args.companyFk - ], options); + ], myOptions); } else { await Self.rawSql('CALL invoiceFromClient(?, ?, ?)', [ args.maxShipped, client.id, args.companyFk - ], options); + ], myOptions); } - const invoiceType = 'G'; const invoiceId = await models.Ticket.makeInvoice( ctx, - invoiceType, + args.serialType, args.companyFk, args.invoiceDate, null, - options + myOptions ); if (tx) await tx.commit(); diff --git a/modules/invoiceOut/back/methods/invoiceOut/refund.js b/modules/invoiceOut/back/methods/invoiceOut/refund.js index 1b7ccc1e4..4f43a7a84 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/refund.js +++ b/modules/invoiceOut/back/methods/invoiceOut/refund.js @@ -43,7 +43,7 @@ module.exports = Self => { const tickets = await models.Ticket.find(filter, myOptions); const ticketsIds = tickets.map(ticket => ticket.id); - const refundedTickets = await models.Ticket.refund(ctx, ticketsIds, withWarehouse, myOptions); + const refundedTickets = await models.Ticket.cloneAll(ctx, ticketsIds, withWarehouse, true, myOptions); if (tx) await tx.commit(); diff --git a/modules/invoiceOut/back/methods/invoiceOut/refundAndInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/refundAndInvoice.js new file mode 100644 index 000000000..41a645ff3 --- /dev/null +++ b/modules/invoiceOut/back/methods/invoiceOut/refundAndInvoice.js @@ -0,0 +1,95 @@ +module.exports = Self => { + Self.remoteMethodCtx('refundAndInvoice', { + description: 'Refund an invoice and create a new one', + accessType: 'WRITE', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'Issued invoice id' + }, + { + arg: 'withWarehouse', + type: 'boolean', + required: true + }, + { + arg: 'cplusRectificationTypeFk', + type: 'number', + required: true + }, + { + arg: 'siiTypeInvoiceOutFk', + type: 'number', + required: true + }, + { + arg: 'invoiceCorrectionTypeFk', + type: 'number', + required: true + }, + ], + returns: { + type: 'object', + root: true + }, + http: { + path: '/refundAndInvoice', + verb: 'post' + } + }); + + Self.refundAndInvoice = async( + ctx, + id, + withWarehouse, + cplusRectificationTypeFk, + siiTypeInvoiceOutFk, + invoiceCorrectionTypeFk, + options + ) => { + const models = Self.app.models; + const myOptions = {userId: ctx.req.accessToken.userId}; + let refundId; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + let tx; + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const originalInvoice = await models.InvoiceOut.findById(id, myOptions); + + const refundedTickets = await Self.refund(ctx, originalInvoice.ref, withWarehouse, myOptions); + + const invoiceCorrection = { + correctedFk: id, + cplusRectificationTypeFk, + siiTypeInvoiceOutFk, + invoiceCorrectionTypeFk + }; + const ticketIds = refundedTickets.map(ticket => ticket.id); + refundId = await models.Ticket.invoiceTickets(ctx, ticketIds, invoiceCorrection, myOptions); + + tx && await tx.commit(); + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + + if (tx) { + try { + await models.InvoiceOut.makePdfList(ctx, refundId); + } catch (e) { + throw new UserError('The invoices have been created but the PDFs could not be generated'); + } + } + + return {refundId}; + }; +}; diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js index 3af7542ca..bebc9a8e4 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('invoiceOut book()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; + const ctx = beforeAll.getCtx(); const invoiceOutId = 5; it('should update the booked property', async() => { diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js new file mode 100644 index 000000000..470690c5a --- /dev/null +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js @@ -0,0 +1,75 @@ +const models = require('vn-loopback/server/server').models; + +describe('InvoiceOut clientsToInvoice()', () => { + const userId = 1; + const clientId = 1101; + const companyFk = 442; + const maxShipped = new Date(); + maxShipped.setMonth(11); + maxShipped.setDate(31); + maxShipped.setHours(23, 59, 59, 999); + const invoiceDate = new Date(); + const activeCtx = { + getLocale: () => { + return 'en'; + }, + accessToken: {userId: userId}, + __: value => { + return value; + }, + headers: {origin: 'http://localhost'} + }; + const ctx = {req: activeCtx}; + + it('should return a list of clients to invoice', async() => { + spyOn(models.InvoiceOut, 'rawSql').and.callFake(query => { + if (query.includes('ticketPackaging_add')) + return Promise.resolve(true); + else if (query.includes('SELECT c.id clientId')) { + return Promise.resolve([ + { + clientId: clientId, + clientName: 'Test Client', + id: 1, + nickname: 'Address 1' + } + ]); + } + }); + + const tx = await models.InvoiceOut.beginTransaction({}); + const options = {transaction: tx}; + + try { + const addresses = await models.InvoiceOut.clientsToInvoice( + ctx, clientId, invoiceDate, maxShipped, companyFk, options); + + expect(addresses.length).toBeGreaterThan(0); + expect(addresses[0].clientId).toBe(clientId); + expect(addresses[0].clientName).toBe('Test Client'); + expect(addresses[0].id).toBe(1); + expect(addresses[0].nickname).toBe('Address 1'); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should handle errors and rollback transaction', async() => { + spyOn(models.InvoiceOut, 'rawSql').and.callFake(() => { + return Promise.reject(new Error('Test Error')); + }); + + const tx = await models.InvoiceOut.beginTransaction({}); + const options = {transaction: tx}; + + try { + await models.InvoiceOut.clientsToInvoice(ctx, clientId, invoiceDate, maxShipped, companyFk, options); + } catch (e) { + expect(e.message).toBe('Test Error'); + await tx.rollback(); + } + }); +}); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/createManualInvoice.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/createManualInvoice.spec.js index 55739e570..58c18b730 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/createManualInvoice.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/createManualInvoice.spec.js @@ -6,110 +6,90 @@ describe('InvoiceOut createManualInvoice()', () => { const clientId = 1106; const activeCtx = {accessToken: {userId: 1}}; const ctx = {req: activeCtx}; + let tx; let options; + + beforeEach(async() => { + spyOn(models.InvoiceOut, 'createPdf').and.returnValue(Promise.resolve(true)); + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + + tx = await models.InvoiceOut.beginTransaction({}); + options = {transaction: tx}; + }); + + afterEach(async() => { + await tx.rollback(); + }); it('should throw an error trying to invoice again', async() => { - spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true))); - - const tx = await models.InvoiceOut.beginTransaction({}); - const options = {transaction: tx}; - let error; try { - await createInvoice(ctx, options, undefined, ticketId); - await createInvoice(ctx, options, undefined, ticketId); - - await tx.rollback(); + await createInvoice(ctx, options, undefined, undefined, ticketId); + await createInvoice(ctx, options, undefined, undefined, ticketId); } catch (e) { error = e; - await tx.rollback(); } expect(error.message).toContain('This ticket is already invoiced'); }); it('should throw an error for a ticket with an amount of zero', async() => { - spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true))); - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - - const tx = await models.InvoiceOut.beginTransaction({}); - const options = {transaction: tx}; - let error; try { const ticket = await models.Ticket.findById(ticketId, null, options); await ticket.updateAttributes({totalWithVat: 0}, options); - await createInvoice(ctx, options, undefined, ticketId); - await tx.rollback(); + await createInvoice(ctx, options, undefined, undefined, ticketId); } catch (e) { error = e; - await tx.rollback(); } expect(error.message).toContain(`A ticket with an amount of zero can't be invoiced`); }); it('should throw an error when the clientFk property is set without the max shipped date', async() => { - spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true))); - - const tx = await models.InvoiceOut.beginTransaction({}); - const options = {transaction: tx}; - let error; try { await createInvoice(ctx, options, clientId); - await tx.rollback(); } catch (e) { error = e; - await tx.rollback(); } expect(error.message).toContain(`Max shipped required`); }); it('should throw an error for a non-invoiceable client', async() => { - spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true))); - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - - const tx = await models.InvoiceOut.beginTransaction({}); - const options = {transaction: tx}; - let error; try { const client = await models.Client.findById(clientId, null, options); await client.updateAttributes({isTaxDataChecked: false}, options); - await createInvoice(ctx, options, undefined, ticketId); - - await tx.rollback(); + await createInvoice(ctx, options, undefined, undefined, ticketId); } catch (e) { error = e; - await tx.rollback(); } expect(error.message).toContain(`This client is not invoiceable`); }); - it('should create a manual invoice', async() => { - spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true))); + it('should create a manual invoice with ticket', async() => { + const result = await createInvoice(ctx, options, undefined, undefined, ticketId); - const tx = await models.InvoiceOut.beginTransaction({}); - const options = {transaction: tx}; + expect(result.id).toEqual(jasmine.any(Number)); + }); - try { - const result = await createInvoice(ctx, options, undefined, ticketId); + it('should create a manual invoice with client', async() => { + const result = await createInvoice(ctx, options, clientId, undefined, undefined, Date.vnNew()); - expect(result.id).toEqual(jasmine.any(Number)); + expect(result.id).toEqual(jasmine.any(Number)); + }); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + it('should create a manual invoice with address', async() => { + const addressFk = 126; + const result = await createInvoice(ctx, options, clientId, addressFk, undefined, Date.vnNew()); + + expect(result.id).toEqual(jasmine.any(Number)); }); }); @@ -117,6 +97,7 @@ function createInvoice( ctx, options, clientFk = undefined, + addressFk = undefined, ticketFk = undefined, maxShipped = undefined, serial = 'T', @@ -124,6 +105,6 @@ function createInvoice( reference = undefined ) { return models.InvoiceOut.createManualInvoice( - ctx, clientFk, ticketFk, maxShipped, serial, taxArea, reference, options + ctx, clientFk, addressFk, ticketFk, maxShipped, serial, taxArea, reference, options ); } diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js index 0faa8fe1a..c731912ec 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js @@ -1,16 +1,16 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('InvoiceOut invoiceClient()', () => { const userId = 1; const clientId = 1101; - const addressId = 121; + const addressFk = 121; const companyFk = 442; const minShipped = Date.vnNew(); minShipped.setFullYear(minShipped.getFullYear() - 1); minShipped.setMonth(1); minShipped.setDate(1); minShipped.setHours(0, 0, 0, 0); - const invoiceSerial = 'A'; const activeCtx = { getLocale: () => { return 'en'; @@ -23,9 +23,14 @@ describe('InvoiceOut invoiceClient()', () => { }; const ctx = {req: activeCtx}; + beforeAll(() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); - it('should make a global invoicing', async() => { - spyOn(models.InvoiceOut, 'makePdf').and.returnValue(new Promise(resolve => resolve(true))); + it('should make a global invoicing by address and verify billing status', async() => { + spyOn(models.InvoiceOut, 'makePdf').and.returnValue(Promise.resolve(true)); spyOn(models.InvoiceOut, 'invoiceEmail'); const tx = await models.InvoiceOut.beginTransaction({}); @@ -34,20 +39,96 @@ describe('InvoiceOut invoiceClient()', () => { try { ctx.args = { clientId: clientId, - addressId: addressId, + addressId: addressFk, invoiceDate: Date.vnNew(), maxShipped: Date.vnNew(), companyFk: companyFk, - minShipped: minShipped + serialType: 'global' }; + const invoiceOutId = await models.InvoiceOut.invoiceClient(ctx, options); + const invoiceOut = await models.InvoiceOut.findById(invoiceOutId, null, options); - const [firstTicket] = await models.Ticket.find({ + + expect(invoiceOutId).toBeGreaterThan(0); + + const allClientTickets = await models.Ticket.find({ + where: { + clientFk: clientId, + or: [ + {refFk: null}, + {refFk: invoiceOut.ref} + ] + } + }, options); + + const billedTickets = await models.Ticket.find({ where: {refFk: invoiceOut.ref} }, options); + const allBilledTicketsHaveCorrectAddress = billedTickets.every(ticket => ticket.addressFk === addressFk); + + expect(allBilledTicketsHaveCorrectAddress).toBe(true); + + const addressTickets = allClientTickets.filter(ticket => ticket.addressFk === addressFk); + + const allAddressTicketsBilled = addressTickets.every(ticket => ticket.refFk === invoiceOut.ref); + + expect(allAddressTicketsBilled).toBe(true); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should invoice all tickets regardless of address when hasToInvoiceByAddress is false', async() => { + spyOn(models.InvoiceOut, 'makePdf').and.returnValue(Promise.resolve(true)); + spyOn(models.InvoiceOut, 'invoiceEmail'); + + const tx = await models.InvoiceOut.beginTransaction({}); + const options = {transaction: tx}; + + try { + const client = await models.Client.findById(clientId, null, options); + await client.updateAttribute('hasToInvoiceByAddress', false, options); + + ctx.args = { + clientId: clientId, + invoiceDate: Date.vnNew(), + maxShipped: Date.vnNew(), + companyFk: companyFk, + serialType: 'global' + }; + + const invoiceOutId = await models.InvoiceOut.invoiceClient(ctx, options); + + const invoiceOut = await models.InvoiceOut.findById(invoiceOutId, null, options); + expect(invoiceOutId).toBeGreaterThan(0); - expect(firstTicket.refFk).toContain(invoiceSerial); + + const allClientTickets = await models.Ticket.find({ + where: { + clientFk: clientId, + or: [ + {refFk: null}, + {refFk: invoiceOut.ref} + ] + } + }, options); + + const billedTickets = await models.Ticket.find({ + where: {refFk: invoiceOut.ref} + }, options); + + const allTicketsBilled = allClientTickets.every(ticket => ticket.refFk === invoiceOut.ref); + + expect(allTicketsBilled).toBe(true); + + const billedAddresses = new Set(billedTickets.map(ticket => ticket.addressFk)); + + expect(billedAddresses.size).toBeGreaterThan(1); await tx.rollback(); } catch (e) { diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/makePdfAndNotify.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/makePdfAndNotify.spec.js new file mode 100644 index 000000000..002face07 --- /dev/null +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/makePdfAndNotify.spec.js @@ -0,0 +1,105 @@ +const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); +const UserError = require('vn-loopback/util/user-error'); + +describe('InvoiceOut makePdfAndNotify()', () => { + const userId = 5; + const ctx = { + req: { + accessToken: {userId}, + __: (key, obj) => `Translated: ${key}, ${JSON.stringify(obj)}`, + getLocale: () => 'es' + }, + args: {} + }; + const activeCtx = {accessToken: {userId}}; + const id = 4; + const printerFk = 1; + + beforeEach(() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: activeCtx}); + }); + + it('should generate PDF and send email when client is to be mailed', async() => { + const tx = await models.InvoiceOut.beginTransaction({}); + const options = {transaction: tx}; + + try { + await models.InvoiceOut.makePdfAndNotify(ctx, id, printerFk, options); + + const invoice = await models.InvoiceOut.findById(id, { + fields: ['ref', 'clientFk'], + include: { + relation: 'client', + scope: { + fields: ['id', 'email', 'isToBeMailed', 'salesPersonFk'] + } + } + }, options); + + expect(invoice).toBeDefined(); + expect(invoice.client().isToBeMailed).toBe(true); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should generate PDF and print when client is not to be mailed', async() => { + const tx = await models.InvoiceOut.beginTransaction({}); + const options = {transaction: tx}; + + try { + await models.InvoiceOut.makePdfAndNotify(ctx, id, null, options); + + const invoice = await models.InvoiceOut.findById(id, { + fields: ['ref', 'clientFk'], + include: { + relation: 'client', + scope: { + fields: ['id', 'email', 'isToBeMailed', 'salesPersonFk'] + } + } + }, options); + + expect(invoice).toBeDefined(); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should throw UserError when PDF generation fails', async() => { + const tx = await models.InvoiceOut.beginTransaction({}); + const options = {transaction: tx}; + + try { + await models.InvoiceOut.makePdfAndNotify(ctx, null, null, options); + await tx.rollback(); + } catch (e) { + expect(e instanceof UserError).toBe(true); + expect(e.message).toContain('Error while generating PDF'); + await tx.rollback(); + } + }); + + it('should send message to salesperson when email fails', async() => { + const tx = await models.InvoiceOut.beginTransaction({}); + const options = {transaction: tx}; + + try { + spyOn(models.InvoiceOut, 'invoiceEmail').and.rejectWith(new Error('Test Error')); + await models.InvoiceOut.makePdfAndNotify(ctx, id, null, options); + await tx.rollback(); + } catch (e) { + expect(e instanceof UserError).toBe(true); + expect(e.message).toContain('Error when sending mail to client'); + + await tx.rollback(); + } + }); +}); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/refundAndInvoice.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/refundAndInvoice.spec.js new file mode 100644 index 000000000..ed15fb404 --- /dev/null +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/refundAndInvoice.spec.js @@ -0,0 +1,81 @@ +const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); + +describe('InvoiceOut refundAndInvoice()', () => { + const userId = 5; + const ctx = {req: {accessToken: {userId}}}; + const activeCtx = {accessToken: {userId}}; + const id = 4; + const cplusRectificationTypeFk = 1; + const siiTypeInvoiceOutFk = 1; + const invoiceCorrectionTypeFk = 1; + + beforeEach(() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: activeCtx}); + }); + + it('should refund an invoice and create a new invoice with warehouse', async() => { + const tx = await models.InvoiceOut.beginTransaction({}); + const options = {transaction: tx}; + const withWarehouse = true; + + try { + const result = await models.InvoiceOut.refundAndInvoice( + ctx, + id, + withWarehouse, + cplusRectificationTypeFk, + siiTypeInvoiceOutFk, + invoiceCorrectionTypeFk, + options + ); + + expect(result).toBeDefined(); + expect(result.refundId).toBeDefined(); + + const invoicesAfter = await models.InvoiceOut.find({where: {id: result.refundId}}, options); + const ticketsAfter = await models.Ticket.find( + {where: {refFk: 'R10100001', warehouse: {neq: null}}}, options); + + expect(invoicesAfter.length).toBeGreaterThan(0); + expect(ticketsAfter.length).toBeGreaterThan(0); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should refund an invoice and create a new invoice with warehouse null', async() => { + const tx = await models.InvoiceOut.beginTransaction({}); + const options = {transaction: tx}; + const withWarehouse = false; + + try { + const result = await models.InvoiceOut.refundAndInvoice( + ctx, + id, + withWarehouse, + cplusRectificationTypeFk, + siiTypeInvoiceOutFk, + invoiceCorrectionTypeFk, + options + ); + + expect(result).toBeDefined(); + expect(result.refundId).toBeDefined(); + + const invoicesAfter = await models.InvoiceOut.find({where: {id: result.refundId}}, options); + const ticketsAfter = await models.Ticket.find({where: {refFk: 'R10100001', warehouse: null}}, options); + + expect(invoicesAfter.length).toBeGreaterThan(0); + expect(ticketsAfter.length).toBeGreaterThan(0); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/transfer.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/transfer.spec.js new file mode 100644 index 000000000..8ec91743e --- /dev/null +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/transfer.spec.js @@ -0,0 +1,135 @@ +const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); +const UserError = require('vn-loopback/util/user-error'); + +describe('InvoiceOut transfer()', () => { + const userId = 5; + let options; + let tx; + let ctx; + const activeCtx = {accessToken: {userId}}; + const id = 4; + const newClientFk = 1101; + const cplusRectificationTypeFk = 1; + const siiTypeInvoiceOutFk = 1; + const invoiceCorrectionTypeFk = 1; + + beforeEach(async() => { + ctx = { + req: { + accessToken: {userId: 1106}, + headers: {origin: 'http://localhost'}, + __: value => value, + getLocale: () => 'es' + }, + args: {} + }; + + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: activeCtx}); + options = {transaction: tx}; + tx = await models.Sale.beginTransaction({}); + options.transaction = tx; + }); + + afterEach(async() => { + await tx.rollback(); + }); + + it('should transfer an invoice to a new client and return the new invoice ID', async() => { + const makeInvoice = true; + const makePdfListMock = spyOn(models.InvoiceOut, 'makePdfList').and.returnValue(); + + const [result] = await models.InvoiceOut.transfer( + ctx, + id, + newClientFk, + cplusRectificationTypeFk, + siiTypeInvoiceOutFk, + invoiceCorrectionTypeFk, + makeInvoice, + options + ); + + const newInvoice = await models.InvoiceOut.findById(result, null, options); + + expect(newInvoice.clientFk).toBe(newClientFk); + + const transferredTickets = await models.Ticket.find({ + where: { + refFk: newInvoice.ref, + clientFk: newClientFk + } + }, options); + + expect(transferredTickets.length).toBeGreaterThan(0); + expect(makePdfListMock).toHaveBeenCalledWith(ctx, [result]); + }); + + it('should throw an error if original invoice is not found', async() => { + const makeInvoice = true; + try { + await models.InvoiceOut.transfer( + ctx, + 'idNotExists', + newClientFk, + cplusRectificationTypeFk, + siiTypeInvoiceOutFk, + invoiceCorrectionTypeFk, + makeInvoice, + options + ); + fail('Expected an error to be thrown'); + } catch (e) { + expect(e).toBeInstanceOf(UserError); + expect(e.message).toBe('Original invoice not found'); + } + }); + + it('should throw an error if the new client is the same as the original client', async() => { + const makeInvoice = true; + const originalInvoice = await models.InvoiceOut.findById(id, options); + + try { + await models.InvoiceOut.transfer( + ctx, + id, + originalInvoice.clientFk, + cplusRectificationTypeFk, + siiTypeInvoiceOutFk, + invoiceCorrectionTypeFk, + makeInvoice, + options + ); + fail('Expected an error to be thrown'); + } catch (e) { + expect(e).toBeInstanceOf(UserError); + expect(e.message).toBe('Select a different client'); + } + }); + + it('should not create a new invoice if makeInvoice is false', async() => { + const originalTickets = await models.Ticket.find({ + where: {clientFk: newClientFk, refFk: null}, + options + }); + + const result = await models.InvoiceOut.transfer( + ctx, + id, + newClientFk, + cplusRectificationTypeFk, + siiTypeInvoiceOutFk, + invoiceCorrectionTypeFk, + false, + options + ); + + expect(result).toBeUndefined(); + + const transferredTickets = await models.Ticket.find({ + where: {clientFk: newClientFk, refFk: null} + }, options); + + expect(transferredTickets.length).toBeGreaterThan(originalTickets.length); + }); +}); diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/transferinvoice.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/transferinvoice.spec.js deleted file mode 100644 index eaaef3e26..000000000 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/transferinvoice.spec.js +++ /dev/null @@ -1,102 +0,0 @@ - -const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); - -describe('InvoiceOut transferInvoice()', () => { - const activeCtx = { - accessToken: {userId: 5}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - const ctx = {req: activeCtx}; - - beforeEach(() => { - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - spyOn(models.InvoiceOut, 'makePdfAndNotify'); - }); - - it('should return the id of the created issued invoice', async() => { - const tx = await models.InvoiceOut.beginTransaction({}); - const options = {transaction: tx}; - const args = { - id: '4', - refFk: 'T4444444', - newClientFk: 1, - cplusRectificationTypeFk: 1, - siiTypeInvoiceOutFk: 1, - invoiceCorrectionTypeFk: 1 - }; - ctx.args = args; - try { - const {clientFk: oldClient} = await models.InvoiceOut.findById(args.id, {fields: ['clientFk']}); - const invoicesBefore = await models.InvoiceOut.find({}, options); - const result = await models.InvoiceOut.transferInvoice( - ctx, - options); - const invoicesAfter = await models.InvoiceOut.find({}, options); - const rectificativeInvoice = invoicesAfter[invoicesAfter.length - 2]; - const newInvoice = invoicesAfter[invoicesAfter.length - 1]; - - expect(result).toBeDefined(); - expect(invoicesAfter.length - invoicesBefore.length).toEqual(2); - expect(rectificativeInvoice.clientFk).toEqual(oldClient); - expect(newInvoice.clientFk).toEqual(args.newClientFk); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - - it('should throw an UserError when it is the same client', async() => { - const tx = await models.InvoiceOut.beginTransaction({}); - const options = {transaction: tx}; - const args = { - id: '1', - refFk: 'T1111111', - newClientFk: 1101, - cplusRectificationTypeFk: 1, - siiTypeInvoiceOutFk: 1, - invoiceCorrectionTypeFk: 1 - }; - ctx.args = args; - try { - await models.InvoiceOut.transferInvoice( - ctx, - options); - await tx.rollback(); - } catch (e) { - expect(e.message).toBe(`Select a different client`); - await tx.rollback(); - } - }); - - it('should throw an UserError when it is refund', async() => { - const tx = await models.InvoiceOut.beginTransaction({}); - const options = {transaction: tx}; - const args = { - id: '1', - refFk: 'T1111111', - newClientFk: 1102, - cplusRectificationTypeFk: 1, - siiTypeInvoiceOutFk: 1, - invoiceCorrectionTypeFk: 1 - }; - ctx.args = args; - try { - await models.InvoiceOut.transferInvoice( - ctx, - options); - await tx.rollback(); - } catch (e) { - expect(e.message).toContain(`This ticket is already a refund`); - await tx.rollback(); - } - }); -}); diff --git a/modules/invoiceOut/back/methods/invoiceOut/transfer.js b/modules/invoiceOut/back/methods/invoiceOut/transfer.js new file mode 100644 index 000000000..aa5c0d9d2 --- /dev/null +++ b/modules/invoiceOut/back/methods/invoiceOut/transfer.js @@ -0,0 +1,123 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('transfer', { + description: 'Transfer an issued invoice to another client', + accessType: 'WRITE', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'Issued invoice id' + }, + { + arg: 'newClientFk', + type: 'number', + required: true + }, + { + arg: 'cplusRectificationTypeFk', + type: 'number', + required: true + }, + { + arg: 'siiTypeInvoiceOutFk', + type: 'number', + required: true + }, + { + arg: 'invoiceCorrectionTypeFk', + type: 'number', + required: true + }, + { + arg: 'makeInvoice', + type: 'boolean', + required: true + }, + ], + returns: {type: 'object', root: true}, + http: {path: '/transfer', verb: 'post'} + }); + + Self.transfer = async( + ctx, + id, + newClientFk, + cplusRectificationTypeFk, + siiTypeInvoiceOutFk, + invoiceCorrectionTypeFk, + makeInvoice, + options + ) => { + const models = Self.app.models; + let tx; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + const originalInvoice = await models.InvoiceOut.findById(id); + if (!originalInvoice) + throw new UserError('Original invoice not found'); + + if (originalInvoice.clientFk === newClientFk) + throw new UserError('Select a different client'); + + let transferredInvoiceId; + try { + await Self.refundAndInvoice( + ctx, + id, + false, + cplusRectificationTypeFk, + siiTypeInvoiceOutFk, + invoiceCorrectionTypeFk, + myOptions + ); + + const tickets = await models.Ticket.find({where: {refFk: originalInvoice.ref}}, myOptions); + const ticketIds = tickets.map(ticket => ticket.id); + const transferredTickets = await models.Ticket.cloneAll(ctx, ticketIds, false, false, myOptions); + const client = await models.Client.findById(newClientFk, + {fields: ['id', 'defaultAddressFk']}, myOptions); + const address = await models.Address.findById(client.defaultAddressFk, + {fields: ['id', 'nickname']}, myOptions); + + const transferredTicketIds = transferredTickets.map(ticket => ticket.id); + await models.Ticket.updateAll( + {id: {inq: transferredTicketIds}}, + { + clientFk: newClientFk, + addressFk: client.defaultAddressFk, + nickname: address.nickname + }, + myOptions + ); + + if (makeInvoice) + transferredInvoiceId = await models.Ticket.invoiceTickets(ctx, transferredTicketIds, null, myOptions); + + if (tx) await tx.commit(); + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + + if (transferredInvoiceId) { + try { + await models.InvoiceOut.makePdfList(ctx, transferredInvoiceId); + } catch (e) { + throw new UserError('The invoices have been created but the PDFs could not be generatedd'); + } + } + + return transferredInvoiceId; + }; +}; diff --git a/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js deleted file mode 100644 index b5eb9bed5..000000000 --- a/modules/invoiceOut/back/methods/invoiceOut/transferInvoice.js +++ /dev/null @@ -1,114 +0,0 @@ -const UserError = require('vn-loopback/util/user-error'); - -module.exports = Self => { - Self.remoteMethodCtx('transferInvoice', { - description: 'Transfer an issued invoice to another client', - accessType: 'WRITE', - accepts: [ - { - arg: 'id', - type: 'number', - required: true, - description: 'Issued invoice id' - }, - { - arg: 'refFk', - type: 'string', - required: true - }, - { - arg: 'newClientFk', - type: 'number', - required: true - }, - { - arg: 'cplusRectificationTypeFk', - type: 'number', - required: true - }, - { - arg: 'siiTypeInvoiceOutFk', - type: 'number', - required: true - }, - { - arg: 'invoiceCorrectionTypeFk', - type: 'number', - required: true - }, - { - arg: 'checked', - type: 'boolean', - required: true - }, - ], - returns: { - type: 'boolean', - root: true - }, - http: { - path: '/transferInvoice', - verb: 'post' - } - }); - - Self.transferInvoice = async(ctx, options) => { - const models = Self.app.models; - const myOptions = {userId: ctx.req.accessToken.userId}; - const {id, refFk, newClientFk, cplusRectificationTypeFk, siiTypeInvoiceOutFk, invoiceCorrectionTypeFk} = ctx.args; - const checked = ctx.args.checked; - let tx; - if (typeof options == 'object') - Object.assign(myOptions, options); - - const {clientFk} = await models.InvoiceOut.findById(id); - - if (clientFk == newClientFk) - throw new UserError(`Select a different client`); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - try { - const filterRef = {where: {refFk: refFk}}; - const tickets = await models.Ticket.find(filterRef, myOptions); - const ticketsIds = tickets.map(ticket => ticket.id); - const refundTickets = await models.Ticket.refund(ctx, ticketsIds, null, myOptions); - - const filterTicket = {where: {ticketFk: {inq: ticketsIds}}}; - - const services = await models.TicketService.find(filterTicket, myOptions); - const servicesIds = services.map(service => service.id); - - const sales = await models.Sale.find(filterTicket, myOptions); - const salesIds = sales.map(sale => sale.id); - - const clonedTickets = await models.Sale.clone(ctx, salesIds, servicesIds, null, false, myOptions); - const clonedTicketIds = []; - - for (const clonedTicket of clonedTickets) { - await clonedTicket.updateAttribute('clientFk', newClientFk, myOptions); - clonedTicketIds.push(clonedTicket.id); - } - - const invoiceCorrection = { - correctedFk: id, - cplusRectificationTypeFk, - siiTypeInvoiceOutFk, - invoiceCorrectionTypeFk - }; - const refundTicketIds = refundTickets.map(ticket => ticket.id); - - await models.Ticket.invoiceTickets(ctx, refundTicketIds, invoiceCorrection, myOptions); - - if (!checked) { - const [invoiceId] = await models.Ticket.invoiceTicketsAndPdf(ctx, clonedTicketIds, null, myOptions); - return invoiceId; - } - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - }; -}; diff --git a/modules/invoiceOut/back/models/invoice-out-serial.json b/modules/invoiceOut/back/models/invoice-out-serial.json index 912269fd7..30e1f1b39 100644 --- a/modules/invoiceOut/back/models/invoice-out-serial.json +++ b/modules/invoiceOut/back/models/invoice-out-serial.json @@ -20,6 +20,9 @@ }, "isCEE": { "type": "boolean" + }, + "type": { + "type": "string" } }, "relations": { @@ -35,4 +38,4 @@ "principalId": "$everyone", "permission": "ALLOW" }] -} \ No newline at end of file +} diff --git a/modules/invoiceOut/back/models/invoice-out.js b/modules/invoiceOut/back/models/invoice-out.js index b0e05b626..bab1fa375 100644 --- a/modules/invoiceOut/back/models/invoice-out.js +++ b/modules/invoiceOut/back/models/invoice-out.js @@ -26,7 +26,8 @@ module.exports = Self => { require('../methods/invoiceOut/getInvoiceDate')(Self); require('../methods/invoiceOut/negativeBases')(Self); require('../methods/invoiceOut/negativeBasesCsv')(Self); - require('../methods/invoiceOut/transferInvoice')(Self); + require('../methods/invoiceOut/transfer')(Self); + require('../methods/invoiceOut/refundAndInvoice')(Self); Self.filePath = async function(id, options) { const fields = ['ref', 'issued']; @@ -82,8 +83,10 @@ module.exports = Self => { const invoiceOutSerial = await Self.app.models.InvoiceOutSerial.findById(serial); if (invoiceOutSerial?.taxAreaFk == 'WORLD') { const address = await Self.app.models.Address.findById(addressId); - if (!address || !address.customsAgentFk || !address.incotermsFk) - throw new UserError('The address of the customer must have information about Incoterms and Customs Agent'); + if (!address?.customsAgentFk || !address.incotermsFk) { + throw new UserError( + 'The address of the customer must have information about Incoterms and Customs Agent'); + } } return serial; diff --git a/modules/invoiceOut/back/models/invoice-out.json b/modules/invoiceOut/back/models/invoice-out.json index 2bf5182e8..1ee36accb 100644 --- a/modules/invoiceOut/back/models/invoice-out.json +++ b/modules/invoiceOut/back/models/invoice-out.json @@ -44,6 +44,11 @@ "model": "Client", "foreignKey": "clientFk" }, + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "clientFk" + }, "company": { "type": "belongsTo", "model": "Company", diff --git a/modules/invoiceOut/front/card/index.html b/modules/invoiceOut/front/card/index.html deleted file mode 100644 index a6f56f775..000000000 --- a/modules/invoiceOut/front/card/index.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - diff --git a/modules/invoiceOut/front/card/index.js b/modules/invoiceOut/front/card/index.js deleted file mode 100644 index c443912d9..000000000 --- a/modules/invoiceOut/front/card/index.js +++ /dev/null @@ -1,41 +0,0 @@ -import ngModule from '../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - const filter = { - fields: [ - 'id', - 'ref', - 'issued', - 'serial', - 'amount', - 'clientFk', - 'companyFk', - 'hasPdf' - ], - include: [ - { - relation: 'company', - scope: { - fields: ['id', 'code'] - } - }, { - relation: 'client', - scope: { - fields: ['id', 'socialName', 'name', 'email'] - } - } - ] - }; - - this.$http.get(`InvoiceOuts/${this.$params.id}`, {filter}) - .then(res => this.invoiceOut = res.data); - } -} - -ngModule.vnComponent('vnInvoiceOutCard', { - template: require('./index.html'), - controller: Controller -}); - diff --git a/modules/invoiceOut/front/card/index.spec.js b/modules/invoiceOut/front/card/index.spec.js deleted file mode 100644 index 2a8d576dc..000000000 --- a/modules/invoiceOut/front/card/index.spec.js +++ /dev/null @@ -1,27 +0,0 @@ -import './index.js'; - -describe('vnInvoiceOut', () => { - let controller; - let $httpBackend; - let data = {id: 1, name: 'fooName'}; - - beforeEach(ngModule('invoiceOut')); - - beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => { - $httpBackend = _$httpBackend_; - - let $element = angular.element('
'); - controller = $componentController('vnInvoiceOutCard', {$element}); - - $stateParams.id = data.id; - $httpBackend.whenRoute('GET', 'InvoiceOuts/:id').respond(data); - })); - - it('should request data and set it on the controller', () => { - controller.reload(); - $httpBackend.flush(); - - expect(controller.invoiceOut).toEqual(data); - }); -}); - diff --git a/modules/invoiceOut/front/descriptor-menu/index.html b/modules/invoiceOut/front/descriptor-menu/index.html index da04c8e72..335ab87cc 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.html +++ b/modules/invoiceOut/front/descriptor-menu/index.html @@ -88,28 +88,7 @@ translate> Show CITES letter - - Refund... - - - - with warehouse - - - without warehouse - - - - + { - const tickets = res.data; - const refundTickets = tickets.map(ticket => ticket.id); - - this.vnApp.showSuccess(this.$t('The following refund tickets have been created', { - ticketId: refundTickets.join(',') - })); - if (refundTickets.length == 1) - this.$state.go('ticket.card.sale', {id: refundTickets[0]}); - }); - } - transferInvoice() { const params = { id: this.invoiceOut.id, - refFk: this.invoiceOut.ref, newClientFk: this.clientId, cplusRectificationTypeFk: this.cplusRectificationType, siiTypeInvoiceOutFk: this.siiTypeInvoiceOut, invoiceCorrectionTypeFk: this.invoiceCorrectionType, - checked: this.checked + makeInvoice: this.checked }; this.$http.get(`Clients/${this.clientId}`).then(response => { @@ -170,7 +154,7 @@ class Controller extends Section { return; } - this.$http.post(`InvoiceOuts/transferInvoice`, params).then(res => { + this.$http.post(`InvoiceOuts/transfer`, params).then(res => { const invoiceId = res.data; this.vnApp.showSuccess(this.$t('Transferred invoice')); this.$state.go('invoiceOut.card.summary', {id: invoiceId}); diff --git a/modules/invoiceOut/front/descriptor-menu/index.spec.js b/modules/invoiceOut/front/descriptor-menu/index.spec.js index d2ccfa117..a22ca7c2a 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.spec.js +++ b/modules/invoiceOut/front/descriptor-menu/index.spec.js @@ -105,17 +105,4 @@ describe('vnInvoiceOutDescriptorMenu', () => { expect(controller.vnApp.showMessage).toHaveBeenCalled(); }); }); - - describe('refundInvoiceOut()', () => { - it('should make a query and show a success message', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - const params = {ref: controller.invoiceOut.ref}; - - $httpBackend.expectPOST(`InvoiceOuts/refund`, params).respond([{id: 1}, {id: 2}]); - controller.refundInvoiceOut(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); }); diff --git a/modules/invoiceOut/front/descriptor/locale/es.yml b/modules/invoiceOut/front/descriptor/es.yml similarity index 100% rename from modules/invoiceOut/front/descriptor/locale/es.yml rename to modules/invoiceOut/front/descriptor/es.yml diff --git a/modules/invoiceOut/front/global-invoicing/index.html b/modules/invoiceOut/front/global-invoicing/index.html deleted file mode 100644 index 3ece30862..000000000 --- a/modules/invoiceOut/front/global-invoicing/index.html +++ /dev/null @@ -1,158 +0,0 @@ - - - -
-
- - Build packaging tickets - - - {{'Invoicing client' | translate}} {{$ctrl.currentAddress.clientId}} - - - Stopping process - - - Ended process - -
-
-
- {{$ctrl.percentage | percentage: 0}} - ({{$ctrl.addressNumber}} of {{$ctrl.nAddresses}}) -
-
- {{$ctrl.nPdfs}} of {{$ctrl.totalPdfs}} - PDFs -
-
-
-
- - - - - Id - Client - Address id - Street - Error - - - - - - - {{::error.address.clientId}} - - - - {{::error.address.clientName}} - - - {{::error.address.id}} - - - {{::error.address.nickname}} - - - - {{::error.message}} - - - - - - - - - - - -
- - - - - - - - - -
{{::name}}
-
#{{::id}}
-
-
- - - - - - - - - - - - -
-
-
- - - diff --git a/modules/invoiceOut/front/global-invoicing/index.js b/modules/invoiceOut/front/global-invoicing/index.js deleted file mode 100644 index 9a936611a..000000000 --- a/modules/invoiceOut/front/global-invoicing/index.js +++ /dev/null @@ -1,174 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import UserError from 'core/lib/user-error'; -import './style.scss'; - -class Controller extends Section { - $onInit() { - const date = Date.vnNew(); - Object.assign(this, { - maxShipped: new Date(date.getFullYear(), date.getMonth(), 0), - clientsToInvoice: 'all', - companyFk: this.vnConfig.companyFk, - parallelism: 1 - }); - - const params = {companyFk: this.companyFk}; - this.$http.get('InvoiceOuts/getInvoiceDate', {params}) - .then(res => { - this.minInvoicingDate = res.data.issued ? new Date(res.data.issued) : null; - this.invoiceDate = this.minInvoicingDate; - }); - - const filter = {fields: ['parallelism']}; - this.$http.get('InvoiceOutConfigs/findOne', {filter}) - .then(res => { - if (res.data.parallelism) - this.parallelism = res.data.parallelism; - }) - .catch(res => { - if (res.status == 404) return; - throw res; - }); - } - - makeInvoice() { - this.invoicing = true; - this.status = 'packageInvoicing'; - this.errors = []; - this.addresses = null; - - try { - if (this.clientsToInvoice == 'one' && !this.clientId) - throw new UserError('Choose a valid client'); - if (!this.invoiceDate || !this.maxShipped) - throw new UserError('Invoice date and the max date should be filled'); - if (this.invoiceDate < this.maxShipped) - throw new UserError('Invoice date can\'t be less than max date'); - if (this.minInvoicingDate && this.invoiceDate.getTime() < this.minInvoicingDate.getTime()) - throw new UserError('Exists an invoice with a future date'); - if (!this.companyFk) - throw new UserError('Choose a valid company'); - if (!this.printerFk) - throw new UserError('Choose a valid printer'); - - if (this.clientsToInvoice == 'all') - this.clientId = undefined; - - const params = { - invoiceDate: this.invoiceDate, - maxShipped: this.maxShipped, - clientId: this.clientId, - companyFk: this.companyFk - }; - this.$http.post(`InvoiceOuts/clientsToInvoice`, params) - .then(res => { - this.addresses = res.data; - if (!this.addresses.length) - throw new UserError(`There aren't tickets to invoice`); - - this.nRequests = 0; - this.nPdfs = 0; - this.totalPdfs = 0; - this.addressIndex = 0; - this.invoiceClient(); - }) - .catch(err => this.handleError(err)); - } catch (err) { - this.handleError(err); - } - } - - handleError(err) { - this.invoicing = false; - this.status = null; - throw err; - } - - invoiceClient() { - if (this.nRequests == this.parallelism || this.isInvoicing) return; - - if (this.addressIndex >= this.addresses.length || this.status == 'stopping') { - if (this.nRequests) return; - this.invoicing = false; - this.status = 'done'; - return; - } - - this.status = 'invoicing'; - const address = this.addresses[this.addressIndex]; - this.currentAddress = address; - this.isInvoicing = true; - - const params = { - clientId: address.clientId, - addressId: address.id, - invoiceDate: this.invoiceDate, - maxShipped: this.maxShipped, - companyFk: this.companyFk - }; - - this.$http.post(`InvoiceOuts/invoiceClient`, params) - .then(res => { - this.isInvoicing = false; - if (res.data) - this.makePdfAndNotify(res.data, address); - this.invoiceNext(); - }) - .catch(res => { - this.isInvoicing = false; - if (res.status >= 400 && res.status < 500) { - this.invoiceError(address, res); - this.invoiceNext(); - } else { - this.invoicing = false; - this.status = 'done'; - throw new UserError(`Critical invoicing error, proccess stopped`); - } - }); - } - - invoiceNext() { - this.addressIndex++; - this.invoiceClient(); - } - - makePdfAndNotify(invoiceId, address) { - this.nRequests++; - this.totalPdfs++; - const params = {printerFk: this.printerFk}; - this.$http.post(`InvoiceOuts/${invoiceId}/makePdfAndNotify`, params) - .catch(res => { - this.invoiceError(address, res, true); - }) - .finally(() => { - this.nPdfs++; - this.nRequests--; - this.invoiceClient(); - }); - } - - invoiceError(address, res, isWarning) { - const message = res.data?.error?.message || res.message; - this.errors.unshift({address, message, isWarning}); - } - - get nAddresses() { - if (!this.addresses) return 0; - return this.addresses.length; - } - - get addressNumber() { - return Math.min(this.addressIndex + 1, this.nAddresses); - } - - get percentage() { - const len = this.nAddresses; - return Math.min(this.addressIndex, len) / len; - } -} - -ngModule.vnComponent('vnInvoiceOutGlobalInvoicing', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/invoiceOut/front/global-invoicing/index.spec.js b/modules/invoiceOut/front/global-invoicing/index.spec.js deleted file mode 100644 index 056839b20..000000000 --- a/modules/invoiceOut/front/global-invoicing/index.spec.js +++ /dev/null @@ -1,74 +0,0 @@ -import './index'; - -describe('InvoiceOut', () => { - describe('Component vnInvoiceOutGlobalInvoicing', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('invoiceOut')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - const $scope = $rootScope.$new(); - const $element = angular.element(''); - - controller = $componentController('vnInvoiceOutGlobalInvoicing', {$element, $scope}); - })); - - describe('makeInvoice()', () => { - it('should throw an error when invoiceDate or maxShipped properties are not filled in', () => { - jest.spyOn(controller.vnApp, 'showError'); - controller.clientsToInvoice = 'all'; - - let error; - try { - controller.makeInvoice(); - } catch (e) { - error = e.message; - } - - const expectedError = 'Invoice date and the max date should be filled'; - - expect(error).toBe(expectedError); - }); - - it('should throw an error when select one client and clientId is not filled in', () => { - jest.spyOn(controller.vnApp, 'showError'); - controller.clientsToInvoice = 'one'; - - let error; - try { - controller.makeInvoice(); - } catch (e) { - error = e.message; - } - - const expectedError = 'Choose a valid client'; - - expect(error).toBe(expectedError); - }); - - it('should make an http POST query and then call to the showSuccess() method', () => { - const date = Date.vnNew(); - Object.assign(controller, { - invoiceDate: date, - maxShipped: date, - minInvoicingDate: date, - clientsToInvoice: 'one', - clientId: 1101, - companyFk: 442, - printerFk: 1 - }); - $httpBackend.expectPOST(`InvoiceOuts/clientsToInvoice`).respond([{ - clientId: 1101, - id: 121 - }]); - $httpBackend.expectPOST(`InvoiceOuts/invoiceClient`).respond(); - controller.makeInvoice(); - $httpBackend.flush(); - - expect(controller.status).toEqual('done'); - }); - }); - }); -}); diff --git a/modules/invoiceOut/front/global-invoicing/locale/es.yml b/modules/invoiceOut/front/global-invoicing/locale/es.yml deleted file mode 100644 index f1a411ba1..000000000 --- a/modules/invoiceOut/front/global-invoicing/locale/es.yml +++ /dev/null @@ -1,22 +0,0 @@ -There aren't tickets to invoice: No existen tickets para facturar -Max date: Fecha límite -Invoice date: Fecha de factura -Invoice date can't be less than max date: La fecha de factura no puede ser inferior a la fecha límite -Invoice date and the max date should be filled: La fecha de factura y la fecha límite deben rellenarse -Choose a valid company: Selecciona un empresa válida -Choose a valid printer: Selecciona una impresora válida -All clients: Todos los clientes -Build packaging tickets: Generando tickets de embalajes -Address id: Id dirección -Printer: Impresora -of: de -PDFs: PDFs -Client: Cliente -Current client id: Id cliente actual -Invoicing client: Facturando cliente -Ended process: Proceso finalizado -Invoice out: Facturar -One client: Un solo cliente -Choose a valid client: Selecciona un cliente válido -Stop: Parar -Critical invoicing error, proccess stopped: Error crítico al facturar, proceso detenido diff --git a/modules/invoiceOut/front/global-invoicing/style.scss b/modules/invoiceOut/front/global-invoicing/style.scss deleted file mode 100644 index 3ad767aba..000000000 --- a/modules/invoiceOut/front/global-invoicing/style.scss +++ /dev/null @@ -1,21 +0,0 @@ -@import "variables"; - -vn-invoice-out-global-invoicing { - h5 { - color: $color-primary; - } - .status { - height: 80px; - display: flex; - align-items: center; - justify-content: center; - gap: 20px; - } - #error { - line-break: normal; - overflow-wrap: break-word; - white-space: normal; - } -} - - diff --git a/modules/invoiceOut/front/index.js b/modules/invoiceOut/front/index.js index 723e3be5a..a5e51d439 100644 --- a/modules/invoiceOut/front/index.js +++ b/modules/invoiceOut/front/index.js @@ -1,13 +1,7 @@ export * from './module'; import './main'; -import './index/'; -import './search-panel'; import './summary'; -import './card'; import './descriptor'; import './descriptor-popover'; import './descriptor-menu'; -import './index/manual'; -import './global-invoicing'; -import './negative-bases'; diff --git a/modules/invoiceOut/front/index/index.html b/modules/invoiceOut/front/index/index.html deleted file mode 100644 index dc4d5d8a9..000000000 --- a/modules/invoiceOut/front/index/index.html +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - Reference - Issued - Amount - Client - Created - Company - Due date - - - - - - - - - - {{::invoiceOut.ref | dashIfEmpty}} - {{::invoiceOut.issued | date:'dd/MM/yyyy' | dashIfEmpty}} - {{::invoiceOut.amount | currency: 'EUR': 2 | dashIfEmpty}} - - - {{::invoiceOut.clientSocialName | dashIfEmpty}} - - - {{::invoiceOut.created | date:'dd/MM/yyyy' | dashIfEmpty}} - {{::invoiceOut.companyCode | dashIfEmpty}} - {{::invoiceOut.dued | date:'dd/MM/yyyy' | dashIfEmpty}} - - - - - - - - - -
- - -
- - - - - - - - diff --git a/modules/invoiceOut/front/index/index.js b/modules/invoiceOut/front/index/index.js deleted file mode 100644 index f109cd5b0..000000000 --- a/modules/invoiceOut/front/index/index.js +++ /dev/null @@ -1,47 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - get checked() { - const rows = this.$.model.data || []; - const checkedRows = []; - for (let row of rows) { - if (row.checked) - checkedRows.push(row.id); - } - - return checkedRows; - } - - get totalChecked() { - return this.checked.length; - } - - preview(invoiceOut) { - this.selectedInvoiceOut = invoiceOut; - this.$.summary.show(); - } - - openPdf() { - const access_token = this.vnToken.tokenMultimedia; - if (this.checked.length <= 1) { - const [invoiceOutId] = this.checked; - const url = `api/InvoiceOuts/${invoiceOutId}/download?access_token=${access_token}`; - window.open(url, '_blank'); - } else { - const invoiceOutIds = this.checked; - const invoicesIds = invoiceOutIds.join(','); - const serializedParams = this.$httpParamSerializer({ - access_token, - ids: invoicesIds - }); - const url = `api/InvoiceOuts/downloadZip?${serializedParams}`; - window.open(url, '_blank'); - } - } -} - -ngModule.vnComponent('vnInvoiceOutIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/invoiceOut/front/index/locale/es.yml b/modules/invoiceOut/front/index/locale/es.yml deleted file mode 100644 index 74572da49..000000000 --- a/modules/invoiceOut/front/index/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Created: Fecha creacion -Issued: Fecha factura -Due date: Fecha vencimiento -Has PDF: PDF disponible -Minimum: Minimo -Maximum: Máximo -Global invoicing: Facturación global -Manual invoicing: Facturación manual -Files are too large: Los archivos son demasiado grandes \ No newline at end of file diff --git a/modules/invoiceOut/front/index/manual/index.html b/modules/invoiceOut/front/index/manual/index.html deleted file mode 100644 index 5872911e4..000000000 --- a/modules/invoiceOut/front/index/manual/index.html +++ /dev/null @@ -1,86 +0,0 @@ - - Create manual invoice - - - - - - -
- - - Invoicing in progress... - -
- - - -
#{{::id}}
-
{{::nickname}}
-
-
- Or - - - - -
- - - - - - - - - - -
- - - - diff --git a/modules/invoiceOut/front/index/manual/index.js b/modules/invoiceOut/front/index/manual/index.js deleted file mode 100644 index 3abe4b825..000000000 --- a/modules/invoiceOut/front/index/manual/index.js +++ /dev/null @@ -1,51 +0,0 @@ -import ngModule from '../../module'; -import Dialog from 'core/components/dialog'; -import './style.scss'; - -class Controller extends Dialog { - constructor($element, $, $transclude) { - super($element, $, $transclude); - - this.isInvoicing = false; - this.invoice = { - maxShipped: Date.vnNew() - }; - } - - responseHandler(response) { - try { - if (response !== 'accept') - return super.responseHandler(response); - - if (this.invoice.clientFk && !this.invoice.maxShipped) - throw new Error('Client and the max shipped should be filled'); - - if (!this.invoice.serial || !this.invoice.taxArea) - throw new Error('Some fields are required'); - - this.isInvoicing = true; - return this.$http.post(`InvoiceOuts/createManualInvoice`, this.invoice) - .then(res => { - this.$state.go('invoiceOut.card.summary', {id: res.data.id}); - super.responseHandler(response); - }) - .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))) - .finally(() => this.isInvoicing = false); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - this.isInvoicing = false; - return false; - } - } -} - -Controller.$inject = ['$element', '$scope', '$transclude']; - -ngModule.vnComponent('vnInvoiceOutManual', { - slotTemplate: require('./index.html'), - controller: Controller, - bindings: { - ticketFk: ' { - describe('Component vnInvoiceOutManual', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('invoiceOut')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - let $scope = $rootScope.$new(); - const $element = angular.element(''); - const $transclude = { - $$boundTransclude: { - $$slots: [] - } - }; - controller = $componentController('vnInvoiceOutManual', {$element, $scope, $transclude}); - })); - - describe('responseHandler()', () => { - it('should throw an error when clientFk property is set and the maxShipped is not filled', () => { - jest.spyOn(controller.vnApp, 'showError'); - - controller.invoice = { - clientFk: 1101, - serial: 'T', - taxArea: 'B' - }; - - controller.responseHandler('accept'); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`Client and the max shipped should be filled`); - }); - - it('should throw an error when some required fields are not filled in', () => { - jest.spyOn(controller.vnApp, 'showError'); - - controller.invoice = { - ticketFk: 1101 - }; - - controller.responseHandler('accept'); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`Some fields are required`); - }); - - it('should make an http POST query and then call to the parent showSuccess() method', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - - controller.invoice = { - ticketFk: 1101, - serial: 'T', - taxArea: 'B' - }; - - $httpBackend.expect('POST', `InvoiceOuts/createManualInvoice`).respond({id: 1}); - controller.responseHandler('accept'); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - }); -}); diff --git a/modules/invoiceOut/front/index/manual/locale/es.yml b/modules/invoiceOut/front/index/manual/locale/es.yml deleted file mode 100644 index 370e823d0..000000000 --- a/modules/invoiceOut/front/index/manual/locale/es.yml +++ /dev/null @@ -1,6 +0,0 @@ -Create manual invoice: Crear factura manual -Some fields are required: Algunos campos son obligatorios -Client and max shipped fields should be filled: Los campos de cliente y fecha límite deben rellenarse -Max date: Fecha límite -Serial: Serie -Invoicing in progress...: Facturación en progreso... \ No newline at end of file diff --git a/modules/invoiceOut/front/index/manual/style.scss b/modules/invoiceOut/front/index/manual/style.scss deleted file mode 100644 index 820c07756..000000000 --- a/modules/invoiceOut/front/index/manual/style.scss +++ /dev/null @@ -1,17 +0,0 @@ -@import "variables"; - -.vn-invoice-out-manual { - tpl-body { - width: 500px; - - .progress { - font-weight: bold; - text-align: center; - font-size: 1.5rem; - color: $color-primary; - vn-horizontal { - justify-content: center - } - } - } -} diff --git a/modules/invoiceOut/front/main/index.html b/modules/invoiceOut/front/main/index.html index ab3fce9ea..e69de29bb 100644 --- a/modules/invoiceOut/front/main/index.html +++ b/modules/invoiceOut/front/main/index.html @@ -1,18 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/modules/invoiceOut/front/main/index.js b/modules/invoiceOut/front/main/index.js index ad37e9c4b..f7e21a126 100644 --- a/modules/invoiceOut/front/main/index.js +++ b/modules/invoiceOut/front/main/index.js @@ -1,7 +1,15 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; -export default class InvoiceOut extends ModuleMain {} +export default class InvoiceOut extends ModuleMain { + constructor($element, $) { + super($element, $); + } + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`invoice-out/`); + } +} ngModule.vnComponent('vnInvoiceOut', { controller: InvoiceOut, diff --git a/modules/invoiceOut/front/locale/es.yml b/modules/invoiceOut/front/main/locale/es.yml similarity index 100% rename from modules/invoiceOut/front/locale/es.yml rename to modules/invoiceOut/front/main/locale/es.yml diff --git a/modules/invoiceOut/front/negative-bases/index.html b/modules/invoiceOut/front/negative-bases/index.html deleted file mode 100644 index 499b6bfe0..000000000 --- a/modules/invoiceOut/front/negative-bases/index.html +++ /dev/null @@ -1,134 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Company - - Country - - Client id - - Client - - Amount - - Base - - Ticket id - - Active - - Has To Invoice - - Verified data - - Comercial -
{{client.company | dashIfEmpty}}{{client.country | dashIfEmpty}} - - {{::client.clientId | dashIfEmpty}} - - {{client.clientSocialName | dashIfEmpty}}{{client.amount | currency: 'EUR':2 | dashIfEmpty}}{{client.taxableBase | dashIfEmpty}} - - {{::client.ticketFk | dashIfEmpty}} - - - - - - - - - - - - - {{::client.workerName | dashIfEmpty}} - -
-
-
-
- - - - - - diff --git a/modules/invoiceOut/front/negative-bases/index.js b/modules/invoiceOut/front/negative-bases/index.js deleted file mode 100644 index 7ce610513..000000000 --- a/modules/invoiceOut/front/negative-bases/index.js +++ /dev/null @@ -1,74 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -export default class Controller extends Section { - constructor($element, $, vnReport) { - super($element, $); - - this.vnReport = vnReport; - const now = Date.vnNew(); - const firstDayOfMonth = new Date(now.getFullYear(), now.getMonth(), 1); - const lastDayOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0); - this.params = { - from: firstDayOfMonth, - to: lastDayOfMonth - }; - this.$checkAll = false; - - this.smartTableOptions = { - activeButtons: { - search: true, - }, - columns: [ - { - field: 'isActive', - searchable: false - }, - { - field: 'hasToInvoice', - searchable: false - }, - { - field: 'isTaxDataChecked', - searchable: false - }, - ] - }; - } - - exprBuilder(param, value) { - switch (param) { - case 'company': - return {'company': value}; - case 'country': - return {'country': value}; - case 'clientId': - return {'clientId': value}; - case 'clientSocialName': - return {'clientSocialName': value}; - case 'amount': - return {'amount': value}; - case 'taxableBase': - return {'taxableBase': value}; - case 'ticketFk': - return {'ticketFk': value}; - case 'comercialName': - return {'comercialName': value}; - } - } - - downloadCSV() { - this.vnReport.show('InvoiceOuts/negativeBasesCsv', { - from: this.params.from, - to: this.params.to - }); - } -} - -Controller.$inject = ['$element', '$scope', 'vnReport']; - -ngModule.vnComponent('vnNegativeBases', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/invoiceOut/front/negative-bases/locale/es.yml b/modules/invoiceOut/front/negative-bases/locale/es.yml deleted file mode 100644 index dd3432592..000000000 --- a/modules/invoiceOut/front/negative-bases/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Has To Invoice: Facturar -Download as CSV: Descargar como CSV diff --git a/modules/invoiceOut/front/negative-bases/style.scss b/modules/invoiceOut/front/negative-bases/style.scss deleted file mode 100644 index 2d628cb94..000000000 --- a/modules/invoiceOut/front/negative-bases/style.scss +++ /dev/null @@ -1,10 +0,0 @@ -@import "./variables"; - -vn-negative-bases { - vn-date-picker{ - padding-right: 5%; - } - slot-actions{ - align-items: center; - } -} diff --git a/modules/invoiceOut/front/routes.json b/modules/invoiceOut/front/routes.json index f7f589b01..7c7495cb9 100644 --- a/modules/invoiceOut/front/routes.json +++ b/modules/invoiceOut/front/routes.json @@ -26,12 +26,6 @@ "component": "vn-invoice-out-index", "description": "InvoiceOut" }, - { - "url": "/global-invoicing?q", - "state": "invoiceOut.global-invoicing", - "component": "vn-invoice-out-global-invoicing", - "description": "Global invoicing" - }, { "url": "/summary", "state": "invoiceOut.card.summary", @@ -40,21 +34,6 @@ "params": { "invoice-out": "$ctrl.invoiceOut" } - }, - { - "url": "/:id", - "state": "invoiceOut.card", - "abstract": true, - "component": "vn-invoice-out-card" - }, - { - "url": "/negative-bases", - "state": "invoiceOut.negative-bases", - "component": "vn-negative-bases", - "description": "Negative bases", - "acl": [ - "administrative" - ] } ] } diff --git a/modules/invoiceOut/front/search-panel/index.html b/modules/invoiceOut/front/search-panel/index.html deleted file mode 100644 index f49002cca..000000000 --- a/modules/invoiceOut/front/search-panel/index.html +++ /dev/null @@ -1,68 +0,0 @@ -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/modules/invoiceOut/front/search-panel/index.js b/modules/invoiceOut/front/search-panel/index.js deleted file mode 100644 index a77d479ca..000000000 --- a/modules/invoiceOut/front/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.vnComponent('vnInvoiceSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/invoiceOut/front/summary/locale/es.yml b/modules/invoiceOut/front/summary/es.yml similarity index 100% rename from modules/invoiceOut/front/summary/locale/es.yml rename to modules/invoiceOut/front/summary/es.yml diff --git a/modules/item/back/methods/fixed-price/filter.js b/modules/item/back/methods/fixed-price/filter.js index 9c91886c1..488c2441d 100644 --- a/modules/item/back/methods/fixed-price/filter.js +++ b/modules/item/back/methods/fixed-price/filter.js @@ -1,4 +1,3 @@ - const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; @@ -129,14 +128,18 @@ module.exports = Self => { return {[param]: value}; } }); + if (ctx.req.query?.showBadDates === 'true') + where['fp.started'] = {gte: Date.vnNew()}; + filter = mergeFilters(filter, {where}); const stmts = []; const stmt = new ParameterizedSQL(` - SELECT fp.id, + SELECT DISTINCT fp.id, fp.itemFk, fp.warehouseFk, + w.name warehouseName, fp.rate2, fp.rate3, fp.started, @@ -160,6 +163,7 @@ module.exports = Self => { FROM priceFixed fp JOIN item i ON i.id = fp.itemFk JOIN itemType it ON it.id = i.typeFk + JOIN warehouse w ON fp.warehouseFk = w.id `); if (ctx.args.tags) { @@ -185,7 +189,6 @@ module.exports = Self => { } stmt.merge(conn.makeSuffix(filter)); - const fixedPriceIndex = stmts.push(stmt) - 1; const sql = ParameterizedSQL.join(stmts, ';'); const result = await conn.executeStmt(sql, myOptions); diff --git a/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js b/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js index 823406500..335159de5 100644 --- a/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js +++ b/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js @@ -1,24 +1,13 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('upsertFixedPrice()', () => { const now = Date.vnNew(); const fixedPriceId = 1; let originalFixedPrice; + beforeAll.mockLoopBackContext(); beforeAll(async() => { originalFixedPrice = await models.FixedPrice.findById(fixedPriceId); - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); }); it(`should toggle the hasMinPrice boolean if there's a minPrice and update the rest of the data`, async() => { diff --git a/modules/item/back/methods/item-barcode/toItem.js b/modules/item/back/methods/item-barcode/toItem.js index 96e9d5981..d189b77c3 100644 --- a/modules/item/back/methods/item-barcode/toItem.js +++ b/modules/item/back/methods/item-barcode/toItem.js @@ -4,7 +4,7 @@ module.exports = Self => { accessType: 'READ', accepts: [{ arg: 'barcode', - type: 'number', + type: 'string', required: true, description: 'barcode' }], @@ -18,7 +18,7 @@ module.exports = Self => { } }); - Self.toItem = async(barcode, options) => { + Self.toItem = async (barcode, options) => { const myOptions = {}; if (typeof options == 'object') diff --git a/modules/item/back/methods/item-shelving-sale/itemShelvingSaleSetQuantity.js b/modules/item/back/methods/item-shelving-sale/itemShelvingSaleSetQuantity.js index 90e66c066..add2aa404 100644 --- a/modules/item/back/methods/item-shelving-sale/itemShelvingSaleSetQuantity.js +++ b/modules/item/back/methods/item-shelving-sale/itemShelvingSaleSetQuantity.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethodCtx('itemShelvingSaleSetQuantity', { - description: 'Set quanitity of a sale in itemShelvingSale', + description: 'Set quantity of a sale in itemShelvingSale', accessType: 'WRITE', accepts: [ { @@ -20,6 +20,12 @@ module.exports = Self => { type: 'boolean', required: true, description: 'True if the shelvingFk is empty ', + }, + { + arg: 'sectorFk', + type: 'number', + required: true, + description: 'Sector Id', } ], http: { @@ -28,14 +34,14 @@ module.exports = Self => { } }); - Self.itemShelvingSaleSetQuantity = async(ctx, id, quantity, isItemShelvingSaleEmpty, options) => { + Self.itemShelvingSaleSetQuantity = async(ctx, id, quantity, isItemShelvingSaleEmpty, sectorFk, options) => { const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); - await Self.rawSql(`CALL vn.itemShelvingSale_setQuantity(?, ?, ? )`, - [id, quantity, isItemShelvingSaleEmpty], + await Self.rawSql(`CALL vn.itemShelvingSale_setQuantity(?, ?, ?, ?)`, + [id, quantity, isItemShelvingSaleEmpty, sectorFk], myOptions); }; }; diff --git a/modules/item/back/methods/item-shelving/deleteItemShelvings.js b/modules/item/back/methods/item-shelving/deleteItemShelvings.js index f534b4e9a..fbc354cce 100644 --- a/modules/item/back/methods/item-shelving/deleteItemShelvings.js +++ b/modules/item/back/methods/item-shelving/deleteItemShelvings.js @@ -34,6 +34,11 @@ module.exports = Self => { try { const promises = []; for (let itemShelvingId of itemShelvingIds) { + const itemShelvingSaleToDelete = models.ItemShelvingSale.destroyAll({ + itemShelvingFk: itemShelvingId + }, myOptions); + promises.push(itemShelvingSaleToDelete); + const itemShelvingToDelete = models.ItemShelving.destroyById(itemShelvingId, myOptions); promises.push(itemShelvingToDelete); } diff --git a/modules/item/back/methods/item-shelving/getListItemNewer.js b/modules/item/back/methods/item-shelving/getListItemNewer.js new file mode 100644 index 000000000..74c73532a --- /dev/null +++ b/modules/item/back/methods/item-shelving/getListItemNewer.js @@ -0,0 +1,70 @@ +module.exports = Self => { + Self.remoteMethod('getListItemNewer', { + description: + 'Get boolean if any or specific item of the shelving has older created in another shelving or parking', + accessType: 'READ', + accepts: [{ + arg: 'shelvingFk', + type: 'string', + required: true, + description: 'Shelving code' + }, + { + arg: 'parking', + type: 'string', + required: true, + description: 'Parking code' + }, + ], + returns: { + type: 'Array', + root: true + }, + http: { + path: `/getListItemNewer`, + verb: 'GET' + } + }); + + Self.getListItemNewer = async(shelvingFk, parking, options) => { + const myOptions = {}; + if (typeof options == 'object') + Object.assign(myOptions, options); + + const [isParkingToReview] = await Self.rawSql(` + SELECT COUNT(p.id) parkingToReview + FROM vn.parking p + JOIN vn.sector s ON s.id = p.sectorFk + JOIN vn.productionConfig pc + WHERE p.code = ? AND s.code = pc.sectorToCode;`, + [parking], myOptions); + + if (isParkingToReview['parkingToReview'] < 1) return []; + + const result = await Self.rawSql(` + WITH tItemShelving AS( + SELECT is2.itemFk, is2.created, p.sectorFK, is2.id + FROM vn.itemShelving is2 + JOIN vn.shelving sh ON sh.code = is2.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + JOIN vn.sector s ON s.id = p.sectorFk + JOIN vn.productionConfig pc + WHERE is2.shelvingFk = ? AND s.code = pc.sectorFromCode + ), tItemInSector AS ( + SELECT is2.itemFk, is2.created, is2.shelvingFk + FROM vn.itemShelving is2 + JOIN vn.shelving sh ON sh.code = is2.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + JOIN vn.sector s ON s.id = p.sectorFk + JOIN vn.productionConfig pc + WHERE is2.shelvingFk <> ? + AND s.code = pc.sectorFromCode) + SELECT ti.itemFK, tis.shelvingFk + FROM tItemShelving ti + JOIN tItemInSector tis ON tis.itemFk = ti.itemFk + JOIN vn.productionConfig pc + WHERE ti.created + INTERVAL pc.itemOlderReviewHours HOUR < tis.created;`, + [shelvingFk, shelvingFk], myOptions); + return result; + }; +}; diff --git a/modules/item/back/methods/item-shelving/hasItemOlder.js b/modules/item/back/methods/item-shelving/hasItemOlder.js deleted file mode 100644 index ee4cdc829..000000000 --- a/modules/item/back/methods/item-shelving/hasItemOlder.js +++ /dev/null @@ -1,63 +0,0 @@ -const UserError = require('vn-loopback/util/user-error'); -module.exports = Self => { - Self.remoteMethod('hasItemOlder', { - description: - 'Get boolean if any or specific item of the shelving has older created in another shelving or parking', - accessType: 'READ', - accepts: [{ - arg: 'shelvingFkIn', - type: 'string', - required: true, - description: 'Shelving code' - }, - { - arg: 'parking', - type: 'string', - description: 'Parking code' - }, - { - arg: 'shelvingFkOut', - type: 'string', - description: 'Shelving code' - }, - { - arg: 'itemFk', - type: 'integer', - description: 'Item id' - }], - returns: { - type: 'boolean', - root: true - }, - http: { - path: `/hasItemOlder`, - verb: 'GET' - } - }); - - Self.hasItemOlder = async(shelvingFkIn, parking, shelvingFkOut, itemFk, options) => { - if (!parking && !shelvingFkOut) throw new UserError('Missing data: parking or shelving'); - - const myOptions = {}; - if (typeof options == 'object') - Object.assign(myOptions, options); - - const result = await Self.rawSql(` - SELECT COUNT(ish.id) countItemOlder - FROM vn.itemShelving ish - JOIN ( - SELECT ish.itemFk, created,shelvingFk - FROM vn.itemShelving ish - JOIN vn.shelving s ON ish.shelvingFk = s.code - WHERE ish.shelvingFk = ? - )sub ON sub.itemFK = ish.itemFk - JOIN vn.shelving s ON s.code = ish.shelvingFk - JOIN vn.parking p ON p.id = s.parkingFk - WHERE sub.created > ish.created - AND (p.code <> ? OR ? IS NULL) - AND (ish.shelvingFk <> ? OR ? IS NULL) - AND (ish.itemFk <> ? OR ? IS NULL)`, - [shelvingFkIn, parking, parking, shelvingFkOut, shelvingFkOut, itemFk, itemFk], myOptions); - return result[0]['countItemOlder'] > 0; - }; -}; diff --git a/modules/item/back/methods/item-shelving/specs/deleteItemShelvings.spec.js b/modules/item/back/methods/item-shelving/specs/deleteItemShelvings.spec.js index b4113d7cf..541a529cb 100644 --- a/modules/item/back/methods/item-shelving/specs/deleteItemShelvings.spec.js +++ b/modules/item/back/methods/item-shelving/specs/deleteItemShelvings.spec.js @@ -10,7 +10,7 @@ describe('ItemShelving deleteItemShelvings()', () => { const itemShelvingIds = [1, 2]; const result = await models.ItemShelving.deleteItemShelvings(itemShelvingIds, options); - expect(result.length).toEqual(2); + expect(result.length).toEqual(4); await tx.rollback(); } catch (e) { diff --git a/modules/item/back/methods/item-shelving/specs/getAlternative.spec.js b/modules/item/back/methods/item-shelving/specs/getAlternative.spec.js index 3f4917477..3b0a65e61 100644 --- a/modules/item/back/methods/item-shelving/specs/getAlternative.spec.js +++ b/modules/item/back/methods/item-shelving/specs/getAlternative.spec.js @@ -1,13 +1,7 @@ const {models} = require('vn-loopback/server/server'); describe('itemShelving getAlternative()', () => { - beforeAll(async() => { - ctx = { - req: { - headers: {origin: 'http://localhost'}, - } - }; - }); + beforeAll.mockLoopBackContext(); it('should return a list of items without alternatives', async() => { const shelvingFk = 'HEJ'; diff --git a/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js b/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js new file mode 100644 index 000000000..962863095 --- /dev/null +++ b/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js @@ -0,0 +1,32 @@ + +const {models} = require('vn-loopback/server/server'); + +describe('itemShelving getListItemNewer()', () => { + it('should return true because there is an older item', async() => { + const shelving = 'NBB'; + const parking = '700-01'; + + const sectorCamHighCode = 'FIRST'; + const sectorCamCode = 'NS'; + + const tx = await models.Sector.beginTransaction({}); + const myOptions = {transaction: tx}; + + try { + const config = await models.ProductionConfig.findOne(); + + await config.updateAttributes({ + sectorToCode: sectorCamHighCode, + sectorFromCode: sectorCamCode + }); + + const result = await models.ItemShelving.getListItemNewer(shelving, parking, myOptions); + + expect(result.length).toEqual(3); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/item/back/methods/item-shelving/specs/hasItemOlder.spec.js b/modules/item/back/methods/item-shelving/specs/hasItemOlder.spec.js deleted file mode 100644 index abffead53..000000000 --- a/modules/item/back/methods/item-shelving/specs/hasItemOlder.spec.js +++ /dev/null @@ -1,45 +0,0 @@ - -const {models} = require('vn-loopback/server/server'); - -describe('itemShelving hasOlder()', () => { - it('should return false because there are not older items', async() => { - const shelvingFkIn = 'GVC'; - const shelvingFkOut = 'HEJ'; - const result = await models.ItemShelving.hasItemOlder(shelvingFkIn, null, shelvingFkOut); - - expect(result).toBe(false); - }); - - it('should return false because there are not older items in parking', async() => { - const shelvingFkIn = 'HEJ'; - const parking = '700-01'; - const result = await models.ItemShelving.hasItemOlder(shelvingFkIn, parking); - - expect(result).toBe(false); - }); - - it('should return true because there is an older item', async() => { - const shelvingFkIn = 'UXN'; - const shelvingFkOut = 'PCC'; - const parking = 'A-01-1'; - const itemFk = 1; - - const tx = await models.ItemShelving.beginTransaction({}); - const myOptions = {transaction: tx}; - const filter = {where: {shelvingFk: shelvingFkOut} - }; - try { - const itemShelvingBefore = await models.ItemShelving.findOne(filter, myOptions); - await itemShelvingBefore.updateAttributes({ - itemFk: itemFk - }, myOptions); - const result = await models.ItemShelving.hasItemOlder(shelvingFkIn, parking, null, null, myOptions); - - expect(result).toBe(true); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); -}); diff --git a/modules/item/back/methods/item-shelving/specs/upsertItem.spec.js b/modules/item/back/methods/item-shelving/specs/upsertItem.spec.js index 2dd43224c..f01cb985d 100644 --- a/modules/item/back/methods/item-shelving/specs/upsertItem.spec.js +++ b/modules/item/back/methods/item-shelving/specs/upsertItem.spec.js @@ -1,25 +1,13 @@ const {models} = require('vn-loopback/server/server'); -const LoopBackContext = require('loopback-context'); describe('ItemShelving upsertItem()', () => { const warehouseFk = 1; - let ctx; + + const ctx = beforeAll.getCtx(); let options; let tx; beforeEach(async() => { - ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'http://localhost'} - }, - args: {} - }; - - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: ctx.req - }); - options = {transaction: tx}; tx = await models.ItemShelving.beginTransaction({}); options.transaction = tx; diff --git a/modules/item/back/methods/item-shelving/updateFromSale.js b/modules/item/back/methods/item-shelving/updateFromSale.js index 2b9f49cae..47ca2a010 100644 --- a/modules/item/back/methods/item-shelving/updateFromSale.js +++ b/modules/item/back/methods/item-shelving/updateFromSale.js @@ -1,3 +1,4 @@ +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethod('updateFromSale', { description: 'Update the visible items', @@ -32,11 +33,18 @@ module.exports = Self => { include: {relation: 'itemShelving'} }, myOptions); + if (!itemShelvingSale?.itemShelving()) + throw new UserError('The sale not exists in the item shelving'); + const itemShelving = itemShelvingSale.itemShelving(); const quantity = itemShelving.visible + itemShelvingSale.quantity; + const available = itemShelving.available + itemShelvingSale.quantity; await itemShelving.updateAttributes( - {visible: quantity}, + { + visible: quantity, + available: available + }, myOptions ); if (tx) await tx.commit(); diff --git a/modules/item/back/methods/item/getBalance.js b/modules/item/back/methods/item/getBalance.js index 207f8020f..c835cd56f 100644 --- a/modules/item/back/methods/item/getBalance.js +++ b/modules/item/back/methods/item/getBalance.js @@ -16,7 +16,8 @@ module.exports = Self => { http: { path: `/getBalance`, verb: 'GET' - } + }, + noLimit: true }); Self.getBalance = async(ctx, filter, options) => { diff --git a/modules/item/back/methods/item/getSummary.js b/modules/item/back/methods/item/getSummary.js index 17a38cf07..55222f133 100644 --- a/modules/item/back/methods/item/getSummary.js +++ b/modules/item/back/methods/item/getSummary.js @@ -59,7 +59,7 @@ module.exports = Self => { include: [{ relation: 'country', scope: { - fields: ['id', 'country'] + fields: ['id', 'name'] } }, { relation: 'taxClass', diff --git a/modules/item/back/methods/item/getWasteByItem.js b/modules/item/back/methods/item/getWasteByItem.js index 56b90b04a..b4cc566ae 100644 --- a/modules/item/back/methods/item/getWasteByItem.js +++ b/modules/item/back/methods/item/getWasteByItem.js @@ -27,28 +27,48 @@ module.exports = Self => { }); Self.getWasteByItem = async(buyer, family, options) => { + const models = Self.app.models; const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); + const user = await models.VnUser.findOne({ + fields: ['id'], + where: {name: buyer} + }); + + const itemType = await models.ItemType.findOne({ + fields: ['id'], + where: {name: family} + }, options); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const wastes = await Self.rawSql(` - SELECT *, 100 * dwindle / total AS percentage - FROM ( - SELECT buyer, - ws.family, - ws.itemFk, - sum(ws.saleTotal) AS total, - sum(ws.saleWaste) AS dwindle - FROM bs.waste ws - WHERE buyer = ? AND family = ? - AND year = YEAR(TIMESTAMPADD(WEEK,-1, ?)) - AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1) - GROUP BY buyer, itemFk - ) sub - ORDER BY family, percentage DESC`, [buyer, family, date, date], myOptions); + SELECT *, 100 * dwindle / total percentage + FROM ( + SELECT u.name buyer, + it.name family, + w.itemFk, + SUM(w.saleTotal) total, + SUM( + w.saleExternalWaste + + w.saleFaultWaste + + w.saleContainerWaste + + w.saleBreakWaste + + w.saleOtherWaste + ) dwindle + FROM bs.waste w + JOIN account.user u ON u.id = w.buyerFk + JOIN vn.itemType it ON it.id = w.itemTypeFk + WHERE w.buyerFk = ? AND w.itemTypeFk = ? + AND w.year = YEAR(TIMESTAMPADD(WEEK, -1, ?)) + AND w.week = WEEK(TIMESTAMPADD(WEEK, -1, ?), 1) + GROUP BY w.buyerFk, w.itemFk + ) sub + ORDER BY family, percentage DESC + `, [user.id, itemType.id, date, date], myOptions); const details = []; diff --git a/modules/item/back/methods/item/getWasteByWorker.js b/modules/item/back/methods/item/getWasteByWorker.js index 8fa351eed..d2c2f7f59 100644 --- a/modules/item/back/methods/item/getWasteByWorker.js +++ b/modules/item/back/methods/item/getWasteByWorker.js @@ -22,31 +22,49 @@ module.exports = Self => { const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const wastes = await Self.rawSql(` - SELECT *, 100 * dwindle / total AS percentage - FROM ( - SELECT buyer, - ws.family, - sum(ws.saleTotal) AS total, - sum(ws.saleWaste) AS dwindle - FROM bs.waste ws - WHERE year = YEAR(TIMESTAMPADD(WEEK,-1, ?)) - AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1) - GROUP BY buyer, family - ) sub - ORDER BY percentage DESC`, [date, date], myOptions); + SELECT *, 100 * dwindle / total percentage + FROM ( + SELECT u.name buyer, + it.name family, + w.itemFk, + SUM(w.saleTotal) total, + SUM( + w.saleExternalWaste + + w.saleFaultWaste + + w.saleContainerWaste + + w.saleBreakWaste + + w.saleOtherWaste + ) dwindle + FROM bs.waste w + JOIN account.user u ON u.id = w.buyerFk + JOIN vn.itemType it ON it.id = w.itemTypeFk + WHERE year = YEAR(TIMESTAMPADD(WEEK, -1, ?)) + AND week = WEEK(TIMESTAMPADD(WEEK, -1, ?), 1) + GROUP BY buyerFk, itemTypeFk + ) sub + ORDER BY percentage DESC + `, [date, date], myOptions); const wastesTotal = await Self.rawSql(` - SELECT *, 100 * dwindle / total AS percentage + SELECT *, 100 * dwindle / total percentage FROM ( - SELECT buyer, - sum(ws.saleTotal) AS total, - sum(ws.saleWaste) AS dwindle - FROM bs.waste ws - WHERE year = YEAR(TIMESTAMPADD(WEEK,-1, ?)) - AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1) - GROUP BY buyer + SELECT u.name buyer, + SUM(w.saleTotal) total, + SUM( + w.saleExternalWaste + + w.saleFaultWaste + + w.saleContainerWaste + + w.saleBreakWaste + + w.saleOtherWaste + ) dwindle + FROM bs.waste w + JOIN account.user u ON u.id = w.buyerFk + WHERE w.year = YEAR(TIMESTAMPADD(WEEK, -1, ?)) + AND w.week = WEEK(TIMESTAMPADD(WEEK, -1, ?), 1) + GROUP BY w.buyerFk ) sub - ORDER BY percentage DESC`, [date, date], myOptions); + ORDER BY percentage DESC + `, [date, date], myOptions); const details = []; diff --git a/modules/item/back/methods/item/specs/clone.spec.js b/modules/item/back/methods/item/specs/clone.spec.js index 01210677e..5bb5fe560 100644 --- a/modules/item/back/methods/item/specs/clone.spec.js +++ b/modules/item/back/methods/item/specs/clone.spec.js @@ -1,21 +1,8 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('item clone()', () => { let nextItemId; - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); beforeEach(async() => { let query = `SELECT i1.id + 1 as id FROM vn.item i1 diff --git a/modules/item/back/methods/item/specs/getBalance.spec.js b/modules/item/back/methods/item/specs/getBalance.spec.js index 5e5148595..95de3cc50 100644 --- a/modules/item/back/methods/item/specs/getBalance.spec.js +++ b/modules/item/back/methods/item/specs/getBalance.spec.js @@ -2,17 +2,14 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('item getBalance()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; + const ctx = beforeAll.getCtx(); it('should return the balance lines of a client type loses in which one has highlighted true', async() => { const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; try { - const activeCtx = { - accessToken: {userId: 9}, - }; spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx + active: ctx }); const losesClientId = 1111; const ticket = await models.Ticket.findById(7, null, options); @@ -64,7 +61,7 @@ describe('item getBalance()', () => { const secondItemBalance = await models.Item.getBalance(ctx, secondFilter, options); expect(firstItemBalance[9].claimFk).toEqual(null); - expect(secondItemBalance[4].claimFk).toEqual(2); + expect(secondItemBalance[7].claimFk).toEqual(1); await tx.rollback(); } catch (e) { diff --git a/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js b/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js index 61bf6b3e7..adf9b7f76 100644 --- a/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js +++ b/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('item getVisibleAvailable()', () => { - it('should check available visible for today', async() => { + it('should check available visible for tomorrow', async() => { const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; @@ -9,6 +9,7 @@ describe('item getVisibleAvailable()', () => { const itemFk = 1; const warehouseFk = 1; const dated = Date.vnNew(); + dated.setDate(dated.getDate() + 1); const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options); diff --git a/modules/item/back/methods/item/specs/getWasteByItem.spec.js b/modules/item/back/methods/item/specs/getWasteByItem.spec.js index 68ba02887..51ee28a33 100644 --- a/modules/item/back/methods/item/specs/getWasteByItem.spec.js +++ b/modules/item/back/methods/item/specs/getWasteByItem.spec.js @@ -6,13 +6,13 @@ describe('Item getWasteByItem()', () => { const options = {transaction: tx}; try { - const result = await models.Item.getWasteByItem('CharlesXavier', 'Cymbidium', options); + const result = await models.Item.getWasteByItem('buyer', 'Crisantemo', options); const length = result.length; const anyResult = result[Math.floor(Math.random() * Math.floor(length))]; - expect(anyResult.buyer).toEqual('CharlesXavier'); - expect(anyResult.family).toEqual('Cymbidium'); + expect(anyResult.buyer).toEqual('buyer'); + expect(anyResult.family).toEqual('Crisantemo'); expect(anyResult.lines.length).toBeGreaterThanOrEqual(2); await tx.rollback(); diff --git a/modules/item/back/methods/item/specs/getWasteByWorker.spec.js b/modules/item/back/methods/item/specs/getWasteByWorker.spec.js index 52f806bd3..fba35d716 100644 --- a/modules/item/back/methods/item/specs/getWasteByWorker.spec.js +++ b/modules/item/back/methods/item/specs/getWasteByWorker.spec.js @@ -11,9 +11,9 @@ describe('Item getWasteByWorker()', () => { const length = result.length; const anyResult = result[Math.floor(Math.random() * Math.floor(length))]; - expect(anyResult.buyer).toMatch(/(CharlesXavier|HankPym|DavidCharlesHaller)/); + expect(anyResult.buyer).toMatch(/(buyer|it)/); expect(anyResult.total).toBeGreaterThanOrEqual(1000); - expect(anyResult.lines.length).toBeGreaterThanOrEqual(3); + expect(anyResult.lines.length).toBeGreaterThanOrEqual(1); await tx.rollback(); } catch (e) { diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js index 00488e534..2fd30c2ca 100644 --- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js +++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js @@ -1,6 +1,6 @@ const {models} = require('vn-loopback/server/server'); describe('item lastEntriesFilter()', () => { - it('should return one entry for the given item', async() => { + it('should return two entry for the given item', async() => { const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); const maxDate = Date.vnNew(); @@ -13,7 +13,7 @@ describe('item lastEntriesFilter()', () => { const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}}; const result = await models.Item.lastEntriesFilter(filter, options); - expect(result.length).toEqual(1); + expect(result.length).toEqual(2); await tx.rollback(); } catch (e) { @@ -22,7 +22,7 @@ describe('item lastEntriesFilter()', () => { } }); - it('should return five entries for the given item', async() => { + it('should return six entries for the given item', async() => { const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); minDate.setMonth(minDate.getMonth() - 2, 1); @@ -37,7 +37,7 @@ describe('item lastEntriesFilter()', () => { const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}}; const result = await models.Item.lastEntriesFilter(filter, options); - expect(result.length).toEqual(5); + expect(result.length).toEqual(6); await tx.rollback(); } catch (e) { diff --git a/modules/item/back/methods/item/specs/new.spec.js b/modules/item/back/methods/item/specs/new.spec.js index 2ffaf87a5..11570ffb9 100644 --- a/modules/item/back/methods/item/specs/new.spec.js +++ b/modules/item/back/methods/item/specs/new.spec.js @@ -1,21 +1,7 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('item new()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + const ctx = beforeAll.getCtx(); it('should create a new item, adding the name as a tag', async() => { const tx = await models.Item.beginTransaction({}); diff --git a/modules/item/back/methods/item/specs/regularize.spec.js b/modules/item/back/methods/item/specs/regularize.spec.js index e7df9a003..4e94d5d6d 100644 --- a/modules/item/back/methods/item/specs/regularize.spec.js +++ b/modules/item/back/methods/item/specs/regularize.spec.js @@ -1,27 +1,13 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('regularize()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 18}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + const ctx = beforeAll.mockLoopBackContext(18); it('should create a new ticket and add a line', async() => { const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; try { - const ctx = {req: {accessToken: {userId: 18}}}; const itemId = 1; const warehouseId = 1; const quantity = 11; diff --git a/modules/item/back/methods/item/specs/updateTaxes.spec.js b/modules/item/back/methods/item/specs/updateTaxes.spec.js index 793e43de8..828a5fec9 100644 --- a/modules/item/back/methods/item/specs/updateTaxes.spec.js +++ b/modules/item/back/methods/item/specs/updateTaxes.spec.js @@ -1,20 +1,7 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('item updateTaxes()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); it('should throw an error if the taxClassFk is blank', async() => { const tx = await models.Item.beginTransaction({}); diff --git a/modules/item/back/methods/tag/specs/onSubmit.spec.js b/modules/item/back/methods/tag/specs/onSubmit.spec.js index 1e96d9e81..e92a5fcdf 100644 --- a/modules/item/back/methods/tag/specs/onSubmit.spec.js +++ b/modules/item/back/methods/tag/specs/onSubmit.spec.js @@ -1,20 +1,7 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('tag onSubmit()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); it('should delete a tag', async() => { const tx = await models.Item.beginTransaction({}); diff --git a/modules/item/back/model-config.json b/modules/item/back/model-config.json index 40d73f1a6..5dbe4d62a 100644 --- a/modules/item/back/model-config.json +++ b/modules/item/back/model-config.json @@ -32,6 +32,9 @@ "ItemLog": { "dataSource": "vn" }, + "ItemMinimumQuantity": { + "dataSource": "vn" + }, "ItemPackingType": { "dataSource": "vn" }, @@ -50,6 +53,9 @@ "ItemShelving": { "dataSource": "vn" }, + "ItemShelvingLog": { + "dataSource": "vn" + }, "ItemShelvingSale": { "dataSource": "vn" }, @@ -74,4 +80,4 @@ "FixedPrice": { "dataSource": "vn" } -} +} \ No newline at end of file diff --git a/modules/item/back/models/expense.json b/modules/item/back/models/expense.json index 468063602..e661cbc66 100644 --- a/modules/item/back/models/expense.json +++ b/modules/item/back/models/expense.json @@ -9,7 +9,7 @@ "properties": { "id": { "id": true, - "type": "number", + "type": "string", "description": "Identifier" }, "name": { diff --git a/modules/item/back/models/item-minimum-quantity.json b/modules/item/back/models/item-minimum-quantity.json new file mode 100644 index 000000000..74eac39fc --- /dev/null +++ b/modules/item/back/models/item-minimum-quantity.json @@ -0,0 +1,63 @@ +{ + "name": "ItemMinimumQuantity", + "base": "VnModel", + "options": { + "mysql": { + "table": "itemMinimumQuantity" + } + }, + "mixins": { + "Loggable": true + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Id" + }, + "itemFk": { + "type": "number", + "required": true + }, + "quantity": { + "type": "number", + "required": true + }, + "started": { + "type": "date", + "required": true + }, + "ended": { + "type": "date" + }, + "warehouseFk": { + "type": "number" + }, + "created": { + "type": "date" + }, + "editorFk": { + "type": "number" + } + }, + "relations": { + "item": { + "type": "belongsTo", + "model": "Item", + "foreignKey": "itemFk" + }, + "warehouse": { + "type": "belongsTo", + "model": "Warehouse", + "foreignKey": "warehouseFk" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "buyer", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/modules/item/back/models/item-shelving-log.json b/modules/item/back/models/item-shelving-log.json new file mode 100644 index 000000000..f976008f1 --- /dev/null +++ b/modules/item/back/models/item-shelving-log.json @@ -0,0 +1,52 @@ +{ + "name": "ItemShelvingLog", + "base": "VnModel", + "mixins": { + "Loggable": true + }, + "options": { + "mysql": { + "table": "itemShelvingLog" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "created": { + "type": "date" + }, + "shelvingFk": { + "type": "string" + }, + "itemFk": { + "type": "number" + }, + "visible": { + "type": "number" + }, + "accion": { + "type": "string" + } + }, + "relations": { + "item": { + "type": "belongsTo", + "model": "Item", + "foreignKey": "itemFk" + }, + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "shelving": { + "type": "belongsTo", + "model": "Shelving", + "foreignKey": "shelvingFk", + "primaryKey": "code" + } + } +} \ No newline at end of file diff --git a/modules/item/back/models/item-shelving.js b/modules/item/back/models/item-shelving.js index d48ee10d5..be72dac37 100644 --- a/modules/item/back/models/item-shelving.js +++ b/modules/item/back/models/item-shelving.js @@ -4,5 +4,5 @@ module.exports = Self => { require('../methods/item-shelving/getInventory')(Self); require('../methods/item-shelving/getAlternative')(Self); require('../methods/item-shelving/updateFromSale')(Self); - require('../methods/item-shelving/hasItemOlder')(Self); + require('../methods/item-shelving/getListItemNewer')(Self); }; diff --git a/modules/item/back/models/item-shelving.json b/modules/item/back/models/item-shelving.json index 893a1f81d..5df3b0703 100644 --- a/modules/item/back/models/item-shelving.json +++ b/modules/item/back/models/item-shelving.json @@ -1,9 +1,9 @@ { "name": "ItemShelving", "base": "VnModel", - "mixins": { - "Loggable": true - }, + "mixins": { + "Loggable": true + }, "options": { "mysql": { "table": "itemShelving" @@ -17,27 +17,30 @@ }, "shelvingFk": { "type": "string" - }, + }, "itemFk": { "type": "number" - }, + }, "created": { "type": "date" - }, + }, "grouping": { "type": "number" - }, - "isChecked": { - "type": "boolean" + }, + "isChecked": { + "type": "number" }, "packing": { "type": "number" - }, - "visible": { - "type": "number" }, - "userFk": { - "type": "number" + "visible": { + "type": "number" + }, + "userFk": { + "type": "number" + }, + "available": { + "type": "number" } }, "relations": { @@ -56,6 +59,6 @@ "model": "Shelving", "foreignKey": "shelvingFk", "primaryKey": "code" - } + } } -} +} \ No newline at end of file diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json index 9d48dcbfb..eda56e938 100644 --- a/modules/item/back/models/item.json +++ b/modules/item/back/models/item.json @@ -152,9 +152,8 @@ "columnName": "doPhoto" } }, - "minQuantity": { - "type": "number", - "description": "Min quantity" + "photoMotivation": { + "type": "string" } }, "relations": { diff --git a/modules/item/back/models/specs/itemMinimumQuantity.spec.js b/modules/item/back/models/specs/itemMinimumQuantity.spec.js new file mode 100644 index 000000000..7d1e19def --- /dev/null +++ b/modules/item/back/models/specs/itemMinimumQuantity.spec.js @@ -0,0 +1,102 @@ +const {models} = require('vn-loopback/server/server'); + +describe('itemMinimumQuantity model', () => { + const itemFk = 5; + const quantity = 100; + const warehouseFk = 60; + + beforeEach(async() => { + await models.ItemMinimumQuantity.destroyAll({where: {itemFk: itemFk}}); + }); + + describe('CRUD operations', () => { + it('should create a new itemMinimumQuantity record', async() => { + const newRecord = { + itemFk: itemFk, + quantity: quantity, + started: Date.vnNew(), + ended: new Date(Date.vnNew().setFullYear(Date.vnNew().getFullYear() + 1)), + warehouseFk: warehouseFk + }; + + const createdRecord = await models.ItemMinimumQuantity.create(newRecord); + + expect(createdRecord).toBeDefined(); + expect(createdRecord.quantity).toEqual(newRecord.quantity); + }); + + it('should read an existing itemMinimumQuantity record', async() => { + const newRecord = { + itemFk: itemFk, + quantity: quantity, + started: Date.vnNew(), + ended: new Date(Date.vnNew().setFullYear(Date.vnNew().getFullYear() + 2)), + warehouseFk: warehouseFk + }; + + await models.ItemMinimumQuantity.create(newRecord); + + const existingRecord = await models.ItemMinimumQuantity.findOne({where: {itemFk: itemFk}}); + + expect(existingRecord).toBeDefined(); + expect(existingRecord.itemFk).toEqual(itemFk); + }); + + it('should update an existing itemMinimumQuantity record', async() => { + const newRecord = { + itemFk: itemFk, + quantity: quantity, + started: Date.vnNew(), + ended: new Date(Date.vnNew().setFullYear(Date.vnNew().getFullYear() + 3)), + warehouseFk: warehouseFk + }; + + await models.ItemMinimumQuantity.create(newRecord); + + const newQuantity = 150; + const existingRecord = await models.ItemMinimumQuantity.findOne({where: {itemFk: itemFk}}); + existingRecord.quantity = newQuantity; + + await existingRecord.save(); + const updatedRecord = await models.ItemMinimumQuantity.findOne({where: {itemFk: itemFk}}); + + expect(updatedRecord.quantity).toEqual(newQuantity); + }); + }); + + describe('validation and constraints', () => { + it('should enforce unique constraint on itemFk, started, ended, and warehouseFk', async() => { + const newRecord = { + itemFk: itemFk, + quantity: quantity, + started: Date.vnNew(), + ended: Date.vnNew().setFullYear(Date.vnNew().getFullYear() + 5), + warehouseFk: warehouseFk + }; + + try { + await models.ItemMinimumQuantity.create(newRecord); + await models.ItemMinimumQuantity.create(newRecord); + } catch (e) { + expect(e).toBeDefined(); + expect(e.code).toContain('ER_SIGNAL_EXCEPTION'); + } + }); + + it('should allow null values for ended and warehouseFk', async() => { + const newRecord = { + itemFk: itemFk, + quantity: quantity, + started: Date.vnNew(), + ended: null, + warehouseFk: null + }; + + const createdRecord = await models.ItemMinimumQuantity.create(newRecord); + + expect(createdRecord).toBeDefined(); + expect(createdRecord.ended).toBeNull(); + expect(createdRecord.warehouseFk).toBeNull(); + }); + }); +}); diff --git a/modules/item/front/diary/index.html b/modules/item/front/diary/index.html index 481cec51a..7fb3b870e 100644 --- a/modules/item/front/diary/index.html +++ b/modules/item/front/diary/index.html @@ -1,121 +1,2 @@ - - - - - - - - - - - - - - - - - - - - Date - Id - State - Reference - Client - In - Out - Balance - - - - - - - - - - - - - {{::sale.shipped | date:'dd/MM/yyyy' }} - - - - - {{::sale.origin | dashIfEmpty}} - - - {{::sale.stateName | dashIfEmpty}} - {{::sale.reference | dashIfEmpty}} - - - - {{::sale.name | dashIfEmpty}} - - - {{::sale.name | dashIfEmpty}} - - - - {{::sale.invalue | dashIfEmpty}} - {{::sale.out | dashIfEmpty}} - - - {{::sale.balance | dashIfEmpty}} - - - - - - - - - - - - - - - + + diff --git a/modules/item/front/diary/index.js b/modules/item/front/diary/index.js index 1d2e34a66..3d86b0b60 100644 --- a/modules/item/front/diary/index.js +++ b/modules/item/front/diary/index.js @@ -1,107 +1,21 @@ import ngModule from '../module'; import Section from 'salix/components/section'; -import './style.scss'; class Controller extends Section { - constructor($element, $scope, $anchorScroll, $location) { - super($element, $scope); - this.$anchorScroll = $anchorScroll; - this.$location = $location; - let today = Date.vnNew(); - today.setHours(0, 0, 0, 0); - this.today = today.toJSON(); + constructor($element, $) { + super($element, $); } - get item() { - return this._item; - } - - set item(value) { - this._item = value; - - this.filter = { - where: {itemFk: this.$params.id} - }; - - this.$.$applyAsync(() => { - if (this.$params.warehouseFk) - this.warehouseFk = this.$params.warehouseFk; - else if (value) - this.warehouseFk = this.vnConfig.warehouseFk; - - if (this.$params.lineFk) - this.lineFk = this.$params.lineFk; - }); - } - - set warehouseFk(value) { - if (value && value != this._warehouseFk) { - this._warehouseFk = value; - this.card.warehouseFk = value; - this.filter.where.warehouseFk = this.warehouseFk; - - this.$.model.refresh(); - } - } - - get warehouseFk() { - return this._warehouseFk; - } - - set date(value) { - this._date = value; - this.filter.where.date = value; - this.filter.where.warehouseFk = this.warehouseFk; - - this.$.model.refresh(); - } - - get date() { - return this._date; - } - - set showOld(value) { - this._showOld = value; - if (!this._showOld) this.date = null; - else this.date = new Date(); - } - - get showOld() { - return this._showOld; - } - - scrollToLine(lineFk) { - this.$.$applyAsync(() => { - const hashFk = this.lineFk || lineFk; - const hash = `vnItemDiary-${hashFk}`; - this.$location.hash(hash); - this.$anchorScroll(); - }); - } - - showDescriptor(event, sale) { - let descriptor = 'entryDescriptor'; - if (sale.isTicket) - descriptor = 'ticketDescriptor'; - - this.$[descriptor].show(event.target, sale.origin); - } - - $onDestroy() { - if (this.$state.getCurrentPath()[2].state.name === 'item') - this.card.reload(); + async $onInit() { + this.$state.go('item.card.summary', {id: this.$params.id}); + window.location.href = await this.vnApp.getUrl(`item/${this.$params.id}/diary`); } } -Controller.$inject = ['$element', '$scope', '$anchorScroll', '$location']; - ngModule.vnComponent('vnItemDiary', { template: require('./index.html'), controller: Controller, bindings: { item: '<' - }, - require: { - card: '?^vnItemCard' } }); diff --git a/modules/item/front/diary/index.spec.js b/modules/item/front/diary/index.spec.js deleted file mode 100644 index a6302346d..000000000 --- a/modules/item/front/diary/index.spec.js +++ /dev/null @@ -1,99 +0,0 @@ -import './index.js'; -import crudModel from 'core/mocks/crud-model'; - -describe('Item', () => { - describe('Component vnItemDiary', () => { - let $scope; - let controller; - - beforeEach(ngModule('item')); - - beforeEach(inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnItemDiary', {$element, $scope}); - controller.$.model = crudModel; - controller.$params = {id: 1}; - controller.card = {}; - })); - - describe('set item()', () => { - it('should set warehouseFk property based on itemType warehouseFk', () => { - jest.spyOn(controller.$, '$applyAsync'); - controller.vnConfig = {warehouseFk: 1}; - controller.item = {id: 1}; - - expect(controller.$.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function)); - $scope.$apply(); - - expect(controller.warehouseFk).toEqual(1); - expect(controller.item.id).toEqual(1); - }); - - it(`should set warehouseFk property based on url query warehouseFk`, () => { - jest.spyOn(controller.$, '$applyAsync'); - controller.$params.warehouseFk = 4; - controller.item = {id: 1, itemType: {warehouseFk: 1}}; - - expect(controller.$.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function)); - $scope.$apply(); - - expect(controller.warehouseFk).toEqual(4); - expect(controller.item.id).toEqual(1); - }); - }); - - describe('scrollToLine ()', () => { - it('should assign $location then call anchorScroll using controller value', () => { - jest.spyOn(controller, '$anchorScroll'); - controller.lineFk = 1; - controller.scrollToLine('invalidValue'); - - $scope.$apply(); - - expect(controller.$location.hash()).toEqual(`vnItemDiary-${1}`); - expect(controller.$anchorScroll).toHaveBeenCalledWith(); - }); - - it('should assign $location then call anchorScroll using received value', () => { - jest.spyOn(controller, '$anchorScroll'); - controller.lineFk = undefined; - controller.scrollToLine(1); - - $scope.$apply(); - - expect(controller.$location.hash()).toEqual(`vnItemDiary-${1}`); - expect(controller.$anchorScroll).toHaveBeenCalledWith(); - }); - }); - - describe('showDescriptor ()', () => { - it('should call to the entryDescriptor show() method', () => { - controller.$.entryDescriptor = {}; - controller.$.entryDescriptor.show = jest.fn(); - - const $event = new Event('click'); - const target = document.createElement('div'); - target.dispatchEvent($event); - const data = {id: 1, origin: 1}; - controller.showDescriptor($event, data); - - expect(controller.$.entryDescriptor.show).toHaveBeenCalledWith($event.target, data.origin); - }); - - it('should call to the ticketDescriptor show() method', () => { - controller.$.ticketDescriptor = {}; - controller.$.ticketDescriptor.show = jest.fn(); - - const $event = new Event('click'); - const target = document.createElement('div'); - target.dispatchEvent($event); - const data = {id: 1, origin: 1, isTicket: true}; - controller.showDescriptor($event, data); - - expect(controller.$.ticketDescriptor.show).toHaveBeenCalledWith($event.target, data.origin); - }); - }); - }); -}); - diff --git a/modules/item/front/diary/locale/es.yml b/modules/item/front/diary/locale/es.yml deleted file mode 100644 index a312da774..000000000 --- a/modules/item/front/diary/locale/es.yml +++ /dev/null @@ -1,5 +0,0 @@ -In: Entrada -Out: Salida -Visible quantity: Cantidad visible -Ticket/Entry: Ticket/Entrada -Show what's before the inventory: Mostrar lo anterior al inventario diff --git a/modules/item/front/diary/style.scss b/modules/item/front/diary/style.scss deleted file mode 100644 index 0a6cafcb9..000000000 --- a/modules/item/front/diary/style.scss +++ /dev/null @@ -1,33 +0,0 @@ -@import "variables"; - -vn-item-diary { - & > vn-vertical { - display: block; - } - vn-horizontal { - justify-content: center; - } - vn-autocomplete > div { - width: 400px; - } - .balanceNegative .balance { - color: $color-alert; - } - .isIn .in { - color: $color-success; - font-weight: bold; - } - .isToday .date { - color: white; - background-color: $color-main; - } - .truncate { - max-width: 250px; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - } - .table-check{ - justify-content: center; - } -} diff --git a/modules/item/front/routes.json b/modules/item/front/routes.json index 3dea69ba1..05b887a96 100644 --- a/modules/item/front/routes.json +++ b/modules/item/front/routes.json @@ -19,8 +19,8 @@ {"state": "item.card.tax", "icon": "icon-tax"}, {"state": "item.card.botanical", "icon": "local_florist"}, {"state": "item.card.shelving", "icon": "icon-inventory"}, - {"state": "item.card.itemBarcode", "icon": "icon-barcode"}, - {"state": "item.card.diary", "icon": "icon-transaction"}, + {"state": "item.card.itemBarcode", "icon": "icon-barcode"}, + {"state": "item.card.diary", "icon": "icon-transaction"}, {"state": "item.card.log", "icon": "history"} ], "itemType": [ @@ -227,4 +227,4 @@ "acl": ["buyer"] } ] -} \ No newline at end of file +} diff --git a/modules/item/front/summary/index.html b/modules/item/front/summary/index.html index 13c671d29..0e4cfc955 100644 --- a/modules/item/front/summary/index.html +++ b/modules/item/front/summary/index.html @@ -128,9 +128,6 @@ - -

diff --git a/modules/item/front/tax/index.js b/modules/item/front/tax/index.js index b72fbefa3..2d70414ab 100644 --- a/modules/item/front/tax/index.js +++ b/modules/item/front/tax/index.js @@ -11,7 +11,7 @@ export default class Controller extends Section { fields: ['id', 'countryFk', 'taxClassFk'], include: [{ relation: 'country', - scope: {fields: ['country']} + scope: {fields: ['name']} }] }; diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 301e4ac35..927f49999 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -162,7 +162,7 @@ module.exports = Self => { const stmts = []; let stmt; - + stmts.push(`SET @_optimizer_search_depth = @@optimizer_search_depth`); stmts.push(`SET SESSION optimizer_search_depth = 0`); @@ -238,51 +238,8 @@ module.exports = Self => { stmts.push(`SET SESSION optimizer_search_depth = @_optimizer_search_depth`); - // Get client debt balance - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt'); - stmts.push(` - CREATE TEMPORARY TABLE tmp.clientGetDebt - (PRIMARY KEY (clientFk)) - ENGINE = MEMORY - SELECT DISTINCT clientFk FROM tmp.filter`); - - stmt = new ParameterizedSQL('CALL client_getDebt(?)', [args.to]); - stmts.push(stmt); - stmts.push('DROP TEMPORARY TABLE tmp.clientGetDebt'); - - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.tickets'); stmt = new ParameterizedSQL(` - CREATE TEMPORARY TABLE tmp.tickets - (PRIMARY KEY (id)) - ENGINE = MEMORY - SELECT f.*, r.risk AS debt - FROM tmp.filter f - LEFT JOIN tmp.risk r ON f.clientFk = r.clientFk`); - stmts.push(stmt); - - // Sum risk to future - stmts.push(`SET @client:= 0`); - stmts.push('SET @risk := 0'); - stmts.push(` - UPDATE tmp.tickets - SET debt = IF(@client <> @client:= clientFk, - -totalWithVat + @risk:= - debt + totalWithVat, - -totalWithVat + @risk:= @risk + totalWithVat - ) - ORDER BY clientFk, shipped DESC - `); - - // Remove positive risks - stmts.push(` - UPDATE tmp.tickets t - SET debt = 0 - WHERE t.debt + t.credit >= 0 - `); - - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems'); - - stmt = new ParameterizedSQL(` - CREATE TEMPORARY TABLE tmp.sale_getProblems + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems (INDEX (ticketFk)) ENGINE = MEMORY SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped @@ -294,36 +251,30 @@ module.exports = Self => { stmts.push('CALL ticket_getProblems(FALSE)'); - stmts.push(` - INSERT INTO tmp.ticket_problems (ticketFk, risk, totalProblems) - SELECT t.id, t.debt + t.credit AS risk, 1 - FROM tmp.tickets t - WHERE (t.debt + t.credit) < 0 - ON DUPLICATE KEY UPDATE - risk = t.debt + t.credit, totalProblems = totalProblems + 1 - `); - - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getWarnings'); - stmt = new ParameterizedSQL(` - CREATE TEMPORARY TABLE tmp.sale_getWarnings - (INDEX (ticketFk, agencyModeFk)) - ENGINE = MEMORY - SELECT f.id ticketFk, f.agencyModeFk - FROM tmp.filter f`); + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getWarnings + (INDEX (ticketFk, agencyModeFk)) + ENGINE = MEMORY + SELECT f.id ticketFk, f.agencyModeFk + FROM tmp.filter f + `); stmts.push(stmt); stmts.push('CALL ticket_getWarnings()'); stmt = new ParameterizedSQL(` - SELECT t.*, - tp.*, - ((tp.risk) + cc.riskTolerance < 0) AS hasHighRisk, - tw.* - FROM tmp.tickets t - LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = t.id - LEFT JOIN tmp.ticket_warnings tw ON tw.ticketFk = t.id - JOIN clientConfig cc`); + UPDATE tmp.ticket_problems + SET risk = IF(hasRisk, risk, 0) + `); + stmts.push(stmt); + + stmt = new ParameterizedSQL(` + SELECT * + FROM tmp.filter f + LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = f.id + LEFT JOIN tmp.ticket_warnings tw ON tw.ticketFk = f.id + `); + stmts.push(stmt); const hasProblems = args.problems; if (hasProblems != undefined && (!args.from && !args.to)) @@ -334,7 +285,7 @@ module.exports = Self => { if (hasProblems === true) { whereProblems = {or: [ {'tp.isFreezed': true}, - {'tp.risk': {lt: 0}}, + {'tp.hasRisk': true}, {'tp.hasTicketRequest': true}, {'tp.hasComponentLack': true}, {'tp.isTaxDataChecked': false}, @@ -344,7 +295,7 @@ module.exports = Self => { } else if (hasProblems === false) { whereProblems = {and: [ {'tp.isFreezed': false}, - {'tp.risk': 0}, + {'tp.hasRisk': false}, {'tp.hasTicketRequest': false}, {'tp.hasComponentLack': false}, {'tp.isTaxDataChecked': true}, @@ -359,23 +310,23 @@ module.exports = Self => { switch (param) { case 'search': return /^\d+$/.test(value) - ? {'t.id': {inq: value}} - : {'t.nickname': {like: `%${value}%`}}; + ? {'f.id': {inq: value}} + : {'f.nickname': {like: `%${value}%`}}; case 'nickname': - return {'t.nickname': {like: `%${value}%`}}; + return {'f.nickname': {like: `%${value}%`}}; case 'refFk': - return {'t.refFk': value}; + return {'f.refFk': value}; case 'provinceFk': - return {'t.provinceFk': value}; + return {'f.provinceFk': value}; case 'stateFk': - return {'t.stateFk': value}; + return {'f.stateFk': value}; case 'alertLevel': - return {'t.alertLevel': value}; + return {'f.alertLevel': value}; case 'pending': if (value) { - return {'t.alertLevelCode': {inq: [ + return {'f.alertLevelCode': {inq: [ 'FIXING', 'FREE', 'NOT_READY', @@ -385,7 +336,7 @@ module.exports = Self => { 'WAITING_FOR_PAYMENT' ]}}; } else { - return {'t.alertLevelCode': {inq: [ + return {'f.alertLevelCode': {inq: [ 'ON_PREPARATION', 'ON_CHECKING', 'CHECKED', @@ -409,7 +360,7 @@ module.exports = Self => { } case 'agencyModeFk': case 'warehouseFk': - param = `t.${param}`; + param = `f.${param}`; return {[param]: value}; } }); @@ -422,14 +373,14 @@ module.exports = Self => { stmt.merge(conn.makeLimit(filter)); const ticketsIndex = stmts.push(stmt) - 1; - stmts.push( - `DROP TEMPORARY TABLE + stmts.push(` + DROP TEMPORARY TABLE tmp.filter, tmp.ticket_problems, tmp.sale_getProblems, tmp.sale_getWarnings, - tmp.ticket_warnings, - tmp.risk`); + tmp.ticket_warnings + `); const sql = ParameterizedSQL.join(stmts, ';'); const result = await conn.executeStmt(sql, myOptions); diff --git a/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js b/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js index bdafd14e2..738af5219 100644 --- a/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js +++ b/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js @@ -39,7 +39,7 @@ describe('SalesMonitor salesFilter()', () => { const filter = {}; const result = await models.SalesMonitor.salesFilter(ctx, filter, options); - expect(result.length).toBeGreaterThan(11); + expect(result.length).toBeGreaterThan(9); await tx.rollback(); } catch (e) { @@ -68,7 +68,7 @@ describe('SalesMonitor salesFilter()', () => { const filter = {}; const result = await models.SalesMonitor.salesFilter(ctx, filter, options); - expect(result.length).toEqual(0); + expect(result.length).toEqual(4); await tx.rollback(); } catch (e) { @@ -146,13 +146,20 @@ describe('SalesMonitor salesFilter()', () => { try { const options = {transaction: tx}; + const alertLevel = await models.AlertLevel.findOne({ + where: {code: 'FREE'}, + options + }); + + const alertLevelFree = alertLevel.id; + const ctx = {req: {accessToken: {userId: 9}}, args: {pending: false}}; const filter = {order: 'alertLevel ASC'}; const result = await models.SalesMonitor.salesFilter(ctx, filter, options); - const firstRow = result[0]; - expect(result.length).toEqual(12); - expect(firstRow.alertLevel).not.toEqual(0); + result.forEach(row => { + expect(row.alertLevel).toBeGreaterThan(alertLevelFree); + }); await tx.rollback(); } catch (e) { @@ -218,8 +225,8 @@ describe('SalesMonitor salesFilter()', () => { const firstTicket = result.shift(); const secondTicket = result.shift(); - expect(firstTicket.totalProblems).toEqual(1); - expect(secondTicket.totalProblems).toEqual(1); + expect(firstTicket.totalProblems).toEqual(3); + expect(secondTicket.totalProblems).toEqual(3); await tx.rollback(); } catch (e) { diff --git a/modules/monitor/front/index.js b/modules/monitor/front/index.js index 19ea06b5a..a7209a0bd 100644 --- a/modules/monitor/front/index.js +++ b/modules/monitor/front/index.js @@ -1,8 +1,3 @@ export * from './module'; import './main'; -import './index/'; -import './index/tickets'; -import './index/clients'; -import './index/orders'; -import './index/search-panel'; diff --git a/modules/monitor/front/index/clients/index.html b/modules/monitor/front/index/clients/index.html deleted file mode 100644 index c0e3d1b14..000000000 --- a/modules/monitor/front/index/clients/index.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - - Clients on website - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Date - - Hour - - Salesperson - - Client -
- - {{::visit.dated | date:'dd/MM/yy'}} - - - - {{::visit.hour | date: 'HH:mm'}} - - - - {{::visit.salesPerson | dashIfEmpty}} - - - - {{::visit.clientName}} - -
-
- - - - -
-
- - - - diff --git a/modules/monitor/front/index/clients/index.js b/modules/monitor/front/index/clients/index.js deleted file mode 100644 index ac3ce9140..000000000 --- a/modules/monitor/front/index/clients/index.js +++ /dev/null @@ -1,96 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - - const date = Date.vnNew(); - this.dateFrom = date; - this.dateTo = date; - this.filter = { - where: { - 'v.stamp': { - between: this.dateRange() - } - } - }; - - this.smartTableOptions = { - activeButtons: { - search: true - }, - columns: [ - { - field: 'clientFk', - autocomplete: { - url: 'Clients', - showField: 'name', - valueField: 'id' - } - }, - { - field: 'salesPersonFk', - autocomplete: { - url: 'Workers/activeWithInheritedRole', - where: `{role: 'salesPerson'}`, - searchFunction: '{firstName: $search}', - showField: 'nickname', - valueField: 'id', - } - }, - { - field: 'dated', - searchable: false - }, - { - field: 'hour', - searchable: false - } - ] - }; - } - - exprBuilder(param, value) { - switch (param) { - case 'clientFk': - return {[`c.id`]: value}; - case 'salesPersonFk': - return {[`c.${param}`]: value}; - } - } - - dateRange() { - let from = this.dateFrom; - let to = this.dateTo; - if (!from) - from = Date.vnNew(); - if (!to) - to = Date.vnNew(); - const minHour = new Date(from); - minHour.setHours(0, 0, 0, 0); - const maxHour = new Date(to); - maxHour.setHours(23, 59, 59, 59); - - return [minHour, maxHour]; - } - - addFilterDate() { - this.$.model.filter = { - where: { - 'v.stamp': { - between: this.dateRange() - } - } - }; - this.$.model.refresh(); - } -} - -ngModule.vnComponent('vnMonitorSalesClients', { - template: require('./index.html'), - controller: Controller, - require: { - main: '^vnMonitorIndex' - } -}); diff --git a/modules/monitor/front/index/index.html b/modules/monitor/front/index/index.html deleted file mode 100644 index 85987ac20..000000000 --- a/modules/monitor/front/index/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/modules/monitor/front/index/index.js b/modules/monitor/front/index/index.js deleted file mode 100644 index 72ca9dae9..000000000 --- a/modules/monitor/front/index/index.js +++ /dev/null @@ -1,34 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - - const isTopPanelHidden = localStorage.getItem('ticketTopPanelHidden'); - if (isTopPanelHidden === 'true') - this.isTopPanelHidden = true; - } - - toggle() { - const monitor = this.element.querySelector('vn-horizontal'); - const isHidden = monitor.classList.contains('hidden'); - - if (!isHidden) { - monitor.classList.add('hidden'); - localStorage.setItem('ticketTopPanelHidden', true); - } else { - monitor.classList.remove('hidden'); - localStorage.setItem('ticketTopPanelHidden', false); - } - } -} - -ngModule.vnComponent('vnMonitorIndex', { - template: require('./index.html'), - controller: Controller, - require: { - main: '^vnMonitorIndex' - } -}); diff --git a/modules/monitor/front/index/index.spec.js b/modules/monitor/front/index/index.spec.js deleted file mode 100644 index 506e75720..000000000 --- a/modules/monitor/front/index/index.spec.js +++ /dev/null @@ -1,38 +0,0 @@ -import './index.js'; -describe('Component vnMonitorIndex', () => { - let controller; - let $element; - - beforeEach(ngModule('monitor')); - - beforeEach(inject(($compile, $rootScope) => { - $element = $compile('')($rootScope); - controller = $element.controller('vnMonitorIndex'); - })); - - describe('toggle()', () => { - it('should add the hidden class to the horizontal contaning the panel to hide', () => { - controller.toggle(); - - const targetElement = $element[0].querySelector('vn-horizontal'); - const firstClass = targetElement.classList[0]; - - const isTopPanelHidden = localStorage.getItem('ticketTopPanelHidden'); - - expect(firstClass).toEqual('hidden'); - expect(isTopPanelHidden).toEqual('true'); - }); - - it('should remove the hidden class to the horizontal contaning the panel to hide', () => { - const targetElement = $element[0].querySelector('vn-horizontal'); - targetElement.classList.add('hidden'); - controller.toggle(); - const firstClass = targetElement.classList[0]; - - const isTopPanelHidden = localStorage.getItem('ticketTopPanelHidden'); - - expect(firstClass).toBeUndefined(); - expect(isTopPanelHidden).toEqual('false'); - }); - }); -}); diff --git a/modules/monitor/front/index/locale/es.yml b/modules/monitor/front/index/locale/es.yml deleted file mode 100644 index f114a2259..000000000 --- a/modules/monitor/front/index/locale/es.yml +++ /dev/null @@ -1,16 +0,0 @@ -Tickets monitor: Monitor de tickets -Clients on website: Clientes activos en la web -Recent order actions: Acciones recientes en pedidos -Search tickets: Buscar tickets -Delete selected elements: Eliminar los elementos seleccionados -All the selected elements will be deleted. Are you sure you want to continue?: Todos los elementos seleccionados serán eliminados. ¿Seguro que quieres continuar? -Component lack: Faltan componentes -Ticket too little: Ticket demasiado pequeño -Minimize/Maximize: Minimizar/Maximizar -Problems: Problemas -Theoretical: Teórica -Practical: Práctica -Preparation: Preparación -Auto-refresh: Auto-refresco -Toggle auto-refresh every 2 minutes: Conmuta el refresco automático cada 2 minutos -Is fragile: Es frágil diff --git a/modules/monitor/front/index/orders/index.html b/modules/monitor/front/index/orders/index.html deleted file mode 100644 index 4d1171185..000000000 --- a/modules/monitor/front/index/orders/index.html +++ /dev/null @@ -1,141 +0,0 @@ - - - - - Recent order actions - - - - - - - - - - - - - - - - - - - Date - Client - SalesPerson - - - - - - - - - - - {{::order.date_send | date: 'dd/MM/yyyy'}} - - - - - {{::order.clientName}} - - - - - {{::order.salesPerson | dashIfEmpty}} - - - - - - - - {{::order.date_make | date: 'dd/MM/yyyy HH:mm'}} - - - - - {{::order.agencyName | dashIfEmpty}} - - - - {{::order.import | currency: 'EUR':2}} - - - - - - - - - - - - - - - Filter by selection - - - Exclude selection - - - Remove filter - - - Remove all filters - - - Copy value - - - - - diff --git a/modules/monitor/front/index/orders/index.js b/modules/monitor/front/index/orders/index.js deleted file mode 100644 index 40100b79f..000000000 --- a/modules/monitor/front/index/orders/index.js +++ /dev/null @@ -1,74 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -export default class Controller extends Section { - get checked() { - const rows = this.$.model.data || []; - const checkedRows = []; - for (let row of rows) { - if (row.checked) - checkedRows.push(row.id); - } - - return checkedRows; - } - - get totalChecked() { - return this.checked.length; - } - - onDelete() { - const params = {deletes: this.checked}; - const query = `SalesMonitors/deleteOrders`; - this.$http.post(query, params).then( - () => this.$.model.refresh()); - } - - chipColor(date) { - const today = Date.vnNew(); - today.setHours(0, 0, 0, 0); - - const orderLanded = new Date(date); - orderLanded.setHours(0, 0, 0, 0); - - const difference = today - orderLanded; - - if (difference == 0) - return 'warning'; - if (difference < 0) - return 'success'; - if (difference > 0) - return 'alert'; - } - - exprBuilder(param, value) { - switch (param) { - case 'date_send': - return {[`o.date_send`]: { - between: this.dateRange(value)} - }; - case 'clientFk': - return {[`c.id`]: value}; - case 'salesPersonFk': - return {[`c.${param}`]: value}; - } - } - - dateRange(value) { - const minHour = new Date(value); - minHour.setHours(0, 0, 0, 0); - const maxHour = new Date(value); - maxHour.setHours(23, 59, 59, 59); - - return [minHour, maxHour]; - } -} - -ngModule.vnComponent('vnMonitorSalesOrders', { - template: require('./index.html'), - controller: Controller, - require: { - main: '^vnMonitorIndex' - } -}); diff --git a/modules/monitor/front/index/orders/index.spec.js b/modules/monitor/front/index/orders/index.spec.js deleted file mode 100644 index 109925358..000000000 --- a/modules/monitor/front/index/orders/index.spec.js +++ /dev/null @@ -1,50 +0,0 @@ -import './index.js'; -import crudModel from 'core/mocks/crud-model'; - -describe('Component vnMonitorSalesOrders', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('monitor')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - const $element = angular.element(''); - controller = $componentController('vnMonitorSalesOrders', {$element}); - controller.$.model = crudModel; - controller.$.model.data = [ - {id: 1, name: 'My item 1'}, - {id: 2, name: 'My item 2'}, - {id: 3, name: 'My item 3'} - ]; - })); - - describe('checked() getter', () => { - it('should return a the selected rows', () => { - const modelData = controller.$.model.data; - modelData[0].checked = true; - modelData[1].checked = true; - - const result = controller.checked; - - expect(result).toEqual(expect.arrayContaining([1, 2])); - }); - }); - - describe('onDelete()', () => { - it('should make a query and then call to the model refresh() method', () => { - jest.spyOn(controller.$.model, 'refresh'); - - const modelData = controller.$.model.data; - modelData[0].checked = true; - modelData[1].checked = true; - - const expectedParams = {deletes: [1, 2]}; - $httpBackend.expect('POST', 'SalesMonitors/deleteOrders', expectedParams).respond(200); - controller.onDelete(); - $httpBackend.flush(); - - expect(controller.$.model.refresh).toHaveBeenCalledWith(); - }); - }); -}); diff --git a/modules/monitor/front/index/orders/style.scss b/modules/monitor/front/index/orders/style.scss deleted file mode 100644 index 64d6497c9..000000000 --- a/modules/monitor/front/index/orders/style.scss +++ /dev/null @@ -1,19 +0,0 @@ -@import "variables"; - -vn-monitor-sales-orders { - vn-table.scrollable { - max-height: 350px; - overflow-x: hidden - } - - vn-table a.vn-tbody { - & > vn-tr:nth-child(2) { - color: gray; - - & > vn-td { - border-bottom: $border; - font-size: 13px; - } - } - } -} \ No newline at end of file diff --git a/modules/monitor/front/index/search-panel/index.html b/modules/monitor/front/index/search-panel/index.html deleted file mode 100644 index 25a3510ab..000000000 --- a/modules/monitor/front/index/search-panel/index.html +++ /dev/null @@ -1,120 +0,0 @@ -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{name}} - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/modules/monitor/front/index/search-panel/index.js b/modules/monitor/front/index/search-panel/index.js deleted file mode 100644 index ef6625e8a..000000000 --- a/modules/monitor/front/index/search-panel/index.js +++ /dev/null @@ -1,59 +0,0 @@ -import ngModule from '../../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -class Controller extends SearchPanel { - constructor($, $element) { - super($, $element); - this.filter = this.$.filter; - - this.getGroupedStates(); - } - - getGroupedStates() { - let groupedStates = []; - this.$http.get('AlertLevels').then(res => { - for (let state of res.data) { - groupedStates.push({ - id: state.id, - code: state.code, - name: this.$t(state.code) - }); - } - this.groupedStates = groupedStates; - }); - } - - get from() { - return this._from; - } - - set from(value) { - this._from = value; - this.filter.scopeDays = null; - } - - get to() { - return this._to; - } - - set to(value) { - this._to = value; - this.filter.scopeDays = null; - } - - get scopeDays() { - return this._scopeDays; - } - - set scopeDays(value) { - this._scopeDays = value; - - this.filter.from = null; - this.filter.to = null; - } -} - -ngModule.vnComponent('vnMonitorSalesSearchPanel', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/monitor/front/index/search-panel/index.spec.js b/modules/monitor/front/index/search-panel/index.spec.js deleted file mode 100644 index 18cf1abfc..000000000 --- a/modules/monitor/front/index/search-panel/index.spec.js +++ /dev/null @@ -1,71 +0,0 @@ -import './index'; - -describe('Monitor Component vnMonitorSalesSearchPanel', () => { - let $httpBackend; - let controller; - - beforeEach(ngModule('monitor')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnMonitorSalesSearchPanel', {$element: null}); - controller.$t = () => {}; - controller.filter = {}; - })); - - describe('getGroupedStates()', () => { - it('should set an array of groupedStates with the adition of a name translation', () => { - jest.spyOn(controller, '$t').mockReturnValue('miCodigo'); - const data = [ - { - id: 9999, - code: 'myCode' - } - ]; - $httpBackend.whenGET('AlertLevels').respond(data); - controller.getGroupedStates(); - $httpBackend.flush(); - - expect(controller.groupedStates).toEqual([{ - id: 9999, - code: 'myCode', - name: 'miCodigo' - }]); - }); - }); - - describe('from() setter', () => { - it('should clear the scope days when setting the from property', () => { - controller.filter.scopeDays = 1; - - controller.from = Date.vnNew(); - - expect(controller.filter.scopeDays).toBeNull(); - expect(controller.from).toBeDefined(); - }); - }); - - describe('to() setter', () => { - it('should clear the scope days when setting the to property', () => { - controller.filter.scopeDays = 1; - - controller.to = Date.vnNew(); - - expect(controller.filter.scopeDays).toBeNull(); - expect(controller.to).toBeDefined(); - }); - }); - - describe('scopeDays() setter', () => { - it('should clear the date range when setting the scopeDays property', () => { - controller.filter.from = Date.vnNew(); - controller.filter.to = Date.vnNew(); - - controller.scopeDays = 1; - - expect(controller.filter.from).toBeNull(); - expect(controller.filter.to).toBeNull(); - expect(controller.scopeDays).toBeDefined(); - }); - }); -}); diff --git a/modules/monitor/front/index/style.scss b/modules/monitor/front/index/style.scss deleted file mode 100644 index 2b193ac88..000000000 --- a/modules/monitor/front/index/style.scss +++ /dev/null @@ -1,85 +0,0 @@ -@import "variables"; -@import "effects"; - -vn-monitor-index { - .header { - padding: 12px 0 5px 0; - color: gray; - font-size: 1.2rem; - border-bottom: $border; - margin-bottom: 10px; - - & > vn-none > vn-icon { - @extend %clickable-light; - color: $color-button; - font-size: 1.4rem; - } - - vn-none > .arrow { - transition: transform 200ms; - } - } - - vn-monitor-sales-clients { - vn-card { - margin-right: 15px; - } - - .header { - padding-right: 15px; - - & > vn-none > .arrow { - display: none - } - } - } - - vn-table.scrollable { - height: 300px - } - - vn-horizontal { - flex-wrap: wrap - } - - .hidden { - vn-card { - display: none - } - - .header > vn-none > .arrow { - transform: rotate(180deg); - } - } -} - -@media (max-width:1150px) { - vn-monitor-index { - & > vn-horizontal { - flex-direction: column; - - vn-monitor-sales-clients, - vn-monitor-sales-orders { - width: 100% - } - - vn-monitor-sales-clients { - margin-bottom: 15px - } - } - - vn-monitor-sales-clients { - vn-card { - margin-right: 0 - } - - .header { - padding-right: 0; - - & > vn-none > .arrow { - display: inline-block - } - } - } - } -} \ No newline at end of file diff --git a/modules/monitor/front/index/tickets/index.html b/modules/monitor/front/index/tickets/index.html deleted file mode 100644 index 94a950baf..000000000 --- a/modules/monitor/front/index/tickets/index.html +++ /dev/null @@ -1,270 +0,0 @@ - - - - - - - - - Tickets monitor - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Problems - - Identifier - - Client - - Salesperson - - Date - - Theoretical - - Practical - - Preparation - - Province - - State - - Fragile - - Zone - - Total -
- - - - - - - - - - - - - - - - - {{ticket.id}} - - - - {{ticket.nickname}} - - - - {{ticket.userName | dashIfEmpty}} - - - - {{ticket.shippedDate | date: 'dd/MM/yyyy'}} - - {{ticket.zoneLanding | date: 'HH:mm'}}{{ticket.practicalHour | date: 'HH:mm'}}{{ticket.shipped | date: 'HH:mm'}}{{ticket.province}} - - {{ticket.refFk}} - - - {{ticket.state}} - - - - - - - {{ticket.zoneName | dashIfEmpty}} - - - - {{(ticket.totalWithVat ? ticket.totalWithVat : 0) | currency: 'EUR': 2}} - - - - - - -
-
-
-
- - - - - - - - - - - - - - - - Filter by selection - - - Exclude selection - - - Remove filter - - - Remove all filters - - - Copy value - - - diff --git a/modules/monitor/front/index/tickets/index.js b/modules/monitor/front/index/tickets/index.js deleted file mode 100644 index 2f2dead05..000000000 --- a/modules/monitor/front/index/tickets/index.js +++ /dev/null @@ -1,178 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - - this.filterParams = this.fetchParams(); - this.smartTableOptions = { - activeButtons: { - search: true, - shownColumns: true, - }, - columns: [ - { - field: 'totalProblems', - searchable: false - }, - { - field: 'salesPersonFk', - autocomplete: { - url: 'Workers/activeWithInheritedRole', - where: `{role: 'salesPerson'}`, - searchFunction: '{firstName: $search}', - showField: 'nickname', - valueField: 'id', - } - }, - { - field: 'provinceFk', - autocomplete: { - url: 'Provinces', - } - }, - { - field: 'stateFk', - autocomplete: { - url: 'States', - } - }, - { - field: 'zoneFk', - autocomplete: { - url: 'Zones', - } - }, - { - field: 'warehouseFk', - autocomplete: { - url: 'Warehouses', - } - }, - { - field: 'shippedDate', - datepicker: true - }, - { - field: 'theoreticalHour', - searchable: false - }, - { - field: 'preparationHour', - searchable: false - } - ] - }; - } - - $onInit() { - if (!this.$params.q) { - this.$.$applyAsync( - () => this.$.model.applyFilter(null, this.filterParams)); - } - } - - fetchParams($params = {}) { - const excludedParams = [ - 'search', - 'clientFk', - 'orderFk', - 'refFk', - 'scopeDays' - ]; - - const hasExcludedParams = excludedParams.some(param => { - return $params && $params[param] != undefined; - }); - const hasParams = Object.entries($params).length; - if (!hasParams || !hasExcludedParams) - $params.scopeDays = 1; - - if (typeof $params.scopeDays === 'number') { - const from = Date.vnNew(); - from.setHours(0, 0, 0, 0); - - const to = new Date(from.getTime()); - to.setDate(to.getDate() + $params.scopeDays); - to.setHours(23, 59, 59, 999); - - Object.assign($params, {from, to}); - } - - return $params; - } - - compareDate(date) { - let today = Date.vnNew(); - today.setHours(0, 0, 0, 0); - let timeTicket = new Date(date); - timeTicket.setHours(0, 0, 0, 0); - - let comparation = today - timeTicket; - - if (comparation == 0) - return 'warning'; - if (comparation < 0) - return 'success'; - } - - totalPriceColor(ticket) { - const total = parseInt(ticket.totalWithVat); - if (total > 0 && total < 50) - return 'warning'; - } - - exprBuilder(param, value) { - switch (param) { - case 'stateFk': - return {'ts.stateFk': value}; - case 'salesPersonFk': - return {'c.salesPersonFk': value}; - case 'provinceFk': - return {'a.provinceFk': value}; - case 'theoreticalHour': - return {'z.hour': value}; - case 'practicalHour': - return {'zed.etc': value}; - case 'shippedDate': - return {'t.shipped': { - between: this.dateRange(value)} - }; - case 'nickname': - return {[`t.nickname`]: {like: `%${value}%`}}; - case 'zoneFk': - case 'totalWithVat': - return {[`t.${param}`]: value}; - } - } - - dateRange(value) { - const minHour = new Date(value); - minHour.setHours(0, 0, 0, 0); - const maxHour = new Date(value); - maxHour.setHours(23, 59, 59, 59); - - return [minHour, maxHour]; - } - - preview(ticket) { - this.selectedTicket = ticket; - this.$.summary.show(); - } - - autoRefresh(value) { - if (value) - this.refreshTimer = setInterval(() => this.$.model.refresh(), 120000); - else { - clearInterval(this.refreshTimer); - this.refreshTimer = null; - } - } -} - -ngModule.vnComponent('vnMonitorSalesTickets', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/monitor/front/index/tickets/index.spec.js b/modules/monitor/front/index/tickets/index.spec.js deleted file mode 100644 index c12ea6844..000000000 --- a/modules/monitor/front/index/tickets/index.spec.js +++ /dev/null @@ -1,133 +0,0 @@ -import './index.js'; -describe('Component vnMonitorSalesTickets', () => { - let controller; - let $window; - let tickets = [{ - id: 1, - clientFk: 1, - checked: false, - totalWithVat: 10.5 - }, { - id: 2, - clientFk: 1, - checked: true, - totalWithVat: 20.5 - }, { - id: 3, - clientFk: 1, - checked: true, - totalWithVat: 30 - }]; - - beforeEach(ngModule('monitor')); - - beforeEach(inject(($componentController, _$window_) => { - $window = _$window_; - const $element = angular.element(''); - controller = $componentController('vnMonitorSalesTickets', {$element}); - })); - - describe('fetchParams()', () => { - it('should return a range of dates with passed scope days', () => { - let params = controller.fetchParams({ - scopeDays: 2 - }); - const from = Date.vnNew(); - from.setHours(0, 0, 0, 0); - const to = new Date(from.getTime()); - to.setDate(to.getDate() + params.scopeDays); - to.setHours(23, 59, 59, 999); - - const expectedParams = { - from, - scopeDays: params.scopeDays, - to - }; - - expect(params).toEqual(expectedParams); - }); - - it('should return default value for scope days', () => { - let params = controller.fetchParams({ - scopeDays: 1 - }); - - expect(params.scopeDays).toEqual(1); - }); - - it('should return the given scope days', () => { - let params = controller.fetchParams({ - scopeDays: 2 - }); - - expect(params.scopeDays).toEqual(2); - }); - }); - - describe('compareDate()', () => { - it('should return warning when the date is the present', () => { - let today = Date.vnNew(); - let result = controller.compareDate(today); - - expect(result).toEqual('warning'); - }); - - it('should return sucess when the date is in the future', () => { - let futureDate = Date.vnNew(); - futureDate = futureDate.setDate(futureDate.getDate() + 10); - let result = controller.compareDate(futureDate); - - expect(result).toEqual('success'); - }); - - it('should return undefined when the date is in the past', () => { - let pastDate = Date.vnNew(); - pastDate = pastDate.setDate(pastDate.getDate() - 10); - let result = controller.compareDate(pastDate); - - expect(result).toEqual(undefined); - }); - }); - - describe('totalPriceColor()', () => { - it('should return "warning" when the ticket amount is less than 50€', () => { - const result = controller.totalPriceColor({totalWithVat: '8.50'}); - - expect(result).toEqual('warning'); - }); - }); - - describe('dateRange()', () => { - it('should return two dates with the hours at the start and end of the given date', () => { - const now = Date.vnNew(); - - const today = now.getDate(); - - const dateRange = controller.dateRange(now); - const start = dateRange[0].toString(); - const end = dateRange[1].toString(); - - expect(start).toContain(today); - expect(start).toContain('00:00:00'); - - expect(end).toContain(today); - expect(end).toContain('23:59:59'); - }); - }); - - describe('preview()', () => { - it('should show the dialog summary', () => { - controller.$.summary = {show: () => {}}; - jest.spyOn(controller.$.summary, 'show'); - - let event = new MouseEvent('click', { - view: $window, - bubbles: true, - cancelable: true - }); - controller.preview(event, tickets[0]); - - expect(controller.$.summary.show).toHaveBeenCalledWith(); - }); - }); -}); diff --git a/modules/monitor/front/index/tickets/style.scss b/modules/monitor/front/index/tickets/style.scss deleted file mode 100644 index 102c92a8a..000000000 --- a/modules/monitor/front/index/tickets/style.scss +++ /dev/null @@ -1,47 +0,0 @@ -@import "variables"; - -vn-monitor-sales-tickets { - @media screen and (max-width: 1440px) { - .expendable { - display: none; - } - } - - vn-th.icon-field, - vn-th.icon-field *, - vn-td.icon-field, - vn-td.icon-field * { - padding: 0; - max-width: 50px - } - - vn-th[field="nickname"], - vn-td[name="nickname"] { - min-width: 250px - } - - vn-td.icon-field > vn-icon { - margin-left: 3px; - margin-right: 3px; - } - - vn-table.scrollable.lg { - height: 736px - } - - tbody tr[ng-repeat]:focus { - background-color: $color-primary-light - } - - .highRisk i { - color: $color-alert - } - - td[name="nickname"] { - max-width: 200px - } - - td[name="zone"] { - max-width: 150px - } -} \ No newline at end of file diff --git a/modules/monitor/front/locale/es.yml b/modules/monitor/front/locale/es.yml index 7d7e72f6b..01b26b70c 100644 --- a/modules/monitor/front/locale/es.yml +++ b/modules/monitor/front/locale/es.yml @@ -1 +1,16 @@ -Sales monitor: Monitor de ventas \ No newline at end of file +Tickets monitor: Monitor de tickets +Clients on website: Clientes activos en la web +Recent order actions: Acciones recientes en pedidos +Search tickets: Buscar tickets +Delete selected elements: Eliminar los elementos seleccionados +All the selected elements will be deleted. Are you sure you want to continue?: Todos los elementos seleccionados serán eliminados. ¿Seguro que quieres continuar? +Component lack: Faltan componentes +Ticket too little: Ticket demasiado pequeño +Minimize/Maximize: Minimizar/Maximizar +Problems: Problemas +Theoretical: Teórica +Practical: Práctica +Preparation: Preparación +Auto-refresh: Auto-refresco +Toggle auto-refresh every 2 minutes: Conmuta el refresco automático cada 2 minutos +Is fragile: Es frágil \ No newline at end of file diff --git a/modules/monitor/front/main/index.html b/modules/monitor/front/main/index.html index 6e04f06d0..e69de29bb 100644 --- a/modules/monitor/front/main/index.html +++ b/modules/monitor/front/main/index.html @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/modules/monitor/front/main/index.js b/modules/monitor/front/main/index.js index 42fc159d5..3af5292cb 100644 --- a/modules/monitor/front/main/index.js +++ b/modules/monitor/front/main/index.js @@ -1,7 +1,16 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; -export default class Monitor extends ModuleMain {} +export default class Monitor extends ModuleMain { + constructor($element, $) { + super($element, $); + } + + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`monitor/`); + } +} ngModule.vnComponent('vnMonitor', { controller: Monitor, diff --git a/modules/monitor/front/routes.json b/modules/monitor/front/routes.json index acad3ecbc..30da8bcac 100644 --- a/modules/monitor/front/routes.json +++ b/modules/monitor/front/routes.json @@ -1,13 +1,9 @@ { "module": "monitor", "name": "Monitors", - "icon" : "grid_view", - "dependencies": ["ticket", "worker", "client"], - "validations" : true, + "icon": "grid_view", "menus": { - "main": [ - {"state": "monitor.index", "icon": "grid_view"} - ], + "main": [], "card": [] }, "keybindings": [ @@ -23,7 +19,7 @@ "abstract": true, "component": "vn-monitor", "description": "Monitors" - }, + }, { "url": "/index?q", "state": "monitor.index", diff --git a/modules/order/back/methods/order-row/specs/addToOrder.spec.js b/modules/order/back/methods/order-row/specs/addToOrder.spec.js index 96544a1a9..2bc78ffef 100644 --- a/modules/order/back/methods/order-row/specs/addToOrder.spec.js +++ b/modules/order/back/methods/order-row/specs/addToOrder.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('order addToOrder()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; + const ctx = beforeAll.getCtx(); const orderId = 8; it('should add a row to a given order', async() => { const tx = await models.Order.beginTransaction({}); diff --git a/modules/order/back/methods/order/catalogFilter.js b/modules/order/back/methods/order/catalogFilter.js index ab1d7784e..27048457c 100644 --- a/modules/order/back/methods/order/catalogFilter.js +++ b/modules/order/back/methods/order/catalogFilter.js @@ -119,7 +119,7 @@ module.exports = Self => { w.firstName, tci.priceKg, ink.hex, - i.minQuantity + tci.minQuantity FROM tmp.ticketCalculateItem tci JOIN vn.item i ON i.id = tci.itemFk JOIN vn.itemType it ON it.id = i.typeFk @@ -158,21 +158,19 @@ module.exports = Self => { // Apply item prices const pricesIndex = stmts.push( - `SELECT - tcp.itemFk, + `SELECT tcp.itemFk, tcp.grouping, tcp.price, tcp.rate, tcp.warehouseFk, tcp.priceKg, - w.name AS warehouse + w.name warehouse FROM tmp.ticketComponentPrice tcp JOIN vn.warehouse w ON w.id = tcp.warehouseFk`) - 1; // Get tags from all items const itemTagsIndex = stmts.push( - `SELECT - t.id, + `SELECT t.id, t.name, t.isFree, t.sourceTable, diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index d22fa0804..affa53a55 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -59,6 +59,10 @@ module.exports = Self => { arg: 'showEmpty', type: 'boolean', description: 'Show empty orders' + }, { + arg: 'sourceApp', + type: 'string', + description: 'Application' } ], returns: { diff --git a/modules/order/back/methods/order/getItemTypeAvailable.js b/modules/order/back/methods/order/getItemTypeAvailable.js index b84863953..fd7be5d57 100644 --- a/modules/order/back/methods/order/getItemTypeAvailable.js +++ b/modules/order/back/methods/order/getItemTypeAvailable.js @@ -44,16 +44,14 @@ module.exports = Self => { ]); stmts.push(stmt); - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.item'); - stmt = new ParameterizedSQL( - `CREATE TEMPORARY TABLE tmp.item + `CREATE OR REPLACE TEMPORARY TABLE tmp.item (PRIMARY KEY (itemFk)) ENGINE = MEMORY SELECT DISTINCT - i.id AS itemFk, - it.id AS typeFk, + i.id itemFk, + it.id typeFk, it.name, - ic.name AS categoryName + ic.name categoryName FROM tmp.availableCalc ac JOIN cache.available a ON a.calc_id = ac.calcFk JOIN vn.item i ON i.id = a.item_id @@ -64,7 +62,7 @@ module.exports = Self => { stmts.push(stmt); stmt = new ParameterizedSQL( - 'CALL vn.catalog_calculate(?, ?, ?,?)', [ + 'CALL vn.catalog_calculate(?, ?, ?, ?)', [ order.landed, order.addressFk, order.agencyModeFk, @@ -74,7 +72,7 @@ module.exports = Self => { stmts.push(stmt); stmt = new ParameterizedSQL(` - SELECT i.typeFk AS id, i.name, i.categoryName + SELECT i.typeFk id, i.name, i.categoryName FROM tmp.item i JOIN tmp.ticketCalculateItem tci ON tci.itemFk = i.itemFk GROUP BY i.typeFk` @@ -85,7 +83,6 @@ module.exports = Self => { const sql = ParameterizedSQL.join(stmts, ';'); const result = await Self.rawStmt(sql, myOptions); - return result[categoriesIndex]; }; }; diff --git a/modules/order/back/methods/order/specs/filter.spec.js b/modules/order/back/methods/order/specs/filter.spec.js index 68de7fe04..9e644bb2d 100644 --- a/modules/order/back/methods/order/specs/filter.spec.js +++ b/modules/order/back/methods/order/specs/filter.spec.js @@ -1,11 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('order filter()', () => { - const ctx = { - req: {accessToken: {userId: 9}}, - args: {}, - params: {} - }; + const ctx = beforeAll.getCtx(); it('should call the filter method with a basic search', async() => { const myCtx = Object.assign({}, ctx); diff --git a/modules/order/back/methods/order/specs/new.spec.js b/modules/order/back/methods/order/specs/new.spec.js index c43527f66..779de6ada 100644 --- a/modules/order/back/methods/order/specs/new.spec.js +++ b/modules/order/back/methods/order/specs/new.spec.js @@ -2,7 +2,7 @@ const models = require('vn-loopback/server/server').models; const UserError = require('vn-loopback/util/user-error'); describe('order new()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; + const ctx = beforeAll.getCtx(); it('should throw an error if the client isnt active', async() => { const tx = await models.Order.beginTransaction({}); diff --git a/modules/order/back/methods/order/specs/newFromTicket.spec.js b/modules/order/back/methods/order/specs/newFromTicket.spec.js index c509552fe..d927a0338 100644 --- a/modules/order/back/methods/order/specs/newFromTicket.spec.js +++ b/modules/order/back/methods/order/specs/newFromTicket.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('order newFromTicket()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; + const ctx = beforeAll.getCtx(); it('should create a new order from an existing ticket', async() => { const tx = await models.Order.beginTransaction({}); diff --git a/modules/order/front/basic-data/index.html b/modules/order/front/basic-data/index.html deleted file mode 100644 index 019153b0d..000000000 --- a/modules/order/front/basic-data/index.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - - -
- - - - -
{{::name}}
-
#{{::id}}
-
-
- - {{::nickname}} - -
- - - - - - - - - - -
- - - - - - -
diff --git a/modules/order/front/basic-data/index.js b/modules/order/front/basic-data/index.js deleted file mode 100644 index 16a3cea5e..000000000 --- a/modules/order/front/basic-data/index.js +++ /dev/null @@ -1,57 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - let isDirty = false; - this.$.$watch('$ctrl.selection', newValue => { - if (newValue) { - this.$.addressModel.where = {clientFk: newValue.id}; - this.$.addressModel.refresh(); - if (isDirty) - this.order.addressFk = newValue.defaultAddressFk; - isDirty = true; - } else { - this.$.addressModel.clear(); - if (isDirty) - this.order.addressFk = null; - } - }); - } - - set order(value = {}) { - this._order = value; - - const agencyModeFk = value.agencyModeFk; - this.getAvailableAgencies(); - this._order.agencyModeFk = agencyModeFk; - } - - get order() { - return this._order; - } - - getAvailableAgencies() { - const order = this.order; - order.agencyModeFk = null; - - const params = { - addressFk: order.addressFk, - landed: order.landed - }; - if (params.landed && params.addressFk) { - this.$http.get(`Agencies/landsThatDay`, {params}) - .then(res => this._availableAgencies = res.data); - } - } -} - -ngModule.vnComponent('vnOrderBasicData', { - controller: Controller, - template: require('./index.html'), - bindings: { - order: '<' - } -}); diff --git a/modules/order/front/basic-data/index.spec.js b/modules/order/front/basic-data/index.spec.js deleted file mode 100644 index 21dee0765..000000000 --- a/modules/order/front/basic-data/index.spec.js +++ /dev/null @@ -1,67 +0,0 @@ -import './index.js'; - -describe('Order', () => { - describe('Component vnOrderBasicData', () => { - let $httpBackend; - let $httpParamSerializer; - let controller; - let $scope; - - beforeEach(ngModule('order')); - - beforeEach(inject(($compile, _$httpBackend_, $rootScope, _$httpParamSerializer_) => { - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - $scope = $rootScope.$new(); - - $httpBackend.whenRoute('GET', 'Addresses') - .respond([{id: 2, nickname: 'address 2'}]); - $httpBackend.whenRoute('GET', 'Clients') - .respond([{id: 1, defaultAddressFk: 1}]); - $scope.order = {clientFk: 1, addressFk: 1}; - - let $element = $compile('')($scope); - $httpBackend.flush(); - controller = $element.controller('vnOrderBasicData'); - })); - - afterAll(() => { - $scope.$destroy(); - $element.remove(); - }); - - describe('constructor()', () => { - it('should update the address after the client changes', async() => { - const addressId = 999; - const id = 444; - - controller.selection = {id: id, defaultAddressFk: addressId}; - $scope.$digest(); - - expect(controller.order.addressFk).toEqual(addressId); - }); - }); - - describe('getAvailableAgencies()', () => { - it('should set agencyModeFk to null and get the available agencies if the order has landed and client', async() => { - controller.order.agencyModeFk = 999; - controller.order.addressFk = 999; - controller.order.landed = Date.vnNew(); - - const expectedAgencies = [{id: 1}, {id: 2}]; - - const paramsObj = { - addressFk: controller.order.addressFk, - landed: controller.order.landed - }; - const serializedParams = $httpParamSerializer(paramsObj); - $httpBackend.expect('GET', `Agencies/landsThatDay?${serializedParams}`).respond(expectedAgencies); - controller.getAvailableAgencies(); - $httpBackend.flush(); - - expect(controller.order.agencyModeFk).toBeDefined(); - expect(controller._availableAgencies).toEqual(expectedAgencies); - }); - }); - }); -}); diff --git a/modules/order/front/basic-data/locale/es.yml b/modules/order/front/basic-data/locale/es.yml deleted file mode 100644 index 5c6014c9c..000000000 --- a/modules/order/front/basic-data/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -This form has been disabled because there are lines in this order or it's confirmed: Este formulario ha sido deshabilitado por que esta orden contiene líneas o está confirmada \ No newline at end of file diff --git a/modules/order/front/basic-data/style.scss b/modules/order/front/basic-data/style.scss deleted file mode 100644 index 34d6c2931..000000000 --- a/modules/order/front/basic-data/style.scss +++ /dev/null @@ -1,9 +0,0 @@ -vn-order-basic-data { - .disabledForm { - text-align: center; - color: red; - span { - margin: 0 auto; - } - } -} \ No newline at end of file diff --git a/modules/order/front/card/index.html b/modules/order/front/card/index.html deleted file mode 100644 index 4f10c1728..000000000 --- a/modules/order/front/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/order/front/card/index.js b/modules/order/front/card/index.js deleted file mode 100644 index a7e5eeb5d..000000000 --- a/modules/order/front/card/index.js +++ /dev/null @@ -1,58 +0,0 @@ -import ngModule from '../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - let filter = { - include: [ - { - relation: 'agencyMode', - scope: { - fields: ['name'] - } - }, { - relation: 'address', - scope: { - fields: ['nickname'] - } - }, { - relation: 'rows', - scope: { - fields: ['id'] - } - }, { - relation: 'client', - scope: { - fields: [ - 'salesPersonFk', - 'name', - 'isActive', - 'isFreezed', - 'isTaxDataChecked' - ], - include: { - relation: 'salesPersonUser', - scope: { - fields: ['id', 'name'] - } - } - } - } - ] - }; - - return this.$q.all([ - this.$http.get(`Orders/${this.$params.id}`, {filter}) - .then(res => this.order = res.data), - this.$http.get(`Orders/${this.$params.id}/getTotal`) - .then(res => ({total: res.data})) - ]).then(res => { - this.order = Object.assign.apply(null, res); - }); - } -} - -ngModule.vnComponent('vnOrderCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/order/front/card/index.spec.js b/modules/order/front/card/index.spec.js deleted file mode 100644 index f0de26b72..000000000 --- a/modules/order/front/card/index.spec.js +++ /dev/null @@ -1,31 +0,0 @@ -import './index.js'; - -describe('Order', () => { - describe('Component vnOrderCard', () => { - let controller; - let $httpBackend; - let data = {id: 1, name: 'fooName'}; - let total = 10.5; - - beforeEach(ngModule('order')); - - beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => { - $httpBackend = _$httpBackend_; - - let $element = angular.element('
'); - controller = $componentController('vnOrderCard', {$element}); - - $stateParams.id = data.id; - $httpBackend.whenRoute('GET', 'Orders/:id').respond(data); - $httpBackend.whenRoute('GET', 'Orders/:id/getTotal').respond(200, total); - })); - - it('should request data and total, merge them, and set it on the controller', () => { - controller.reload(); - $httpBackend.flush(); - - expect(controller.order).toEqual(Object.assign({}, data, {total})); - }); - }); -}); - diff --git a/modules/order/front/catalog-search-panel/index.html b/modules/order/front/catalog-search-panel/index.html deleted file mode 100644 index 42f2e0f50..000000000 --- a/modules/order/front/catalog-search-panel/index.html +++ /dev/null @@ -1,54 +0,0 @@ -
-
- - - - - - - - - - - - - - - - - - - -
-
diff --git a/modules/order/front/catalog-search-panel/index.js b/modules/order/front/catalog-search-panel/index.js deleted file mode 100644 index b84243ca7..000000000 --- a/modules/order/front/catalog-search-panel/index.js +++ /dev/null @@ -1,38 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -class Controller extends SearchPanel { - constructor($element, $) { - super($element, $); - - this.filter = {}; - } - - get filter() { - return this.$.filter; - } - - set filter(value) { - if (!value) - value = {}; - if (!value.values) - value.values = [{}]; - - this.$.filter = value; - } - - addValue() { - this.filter.values.push({}); - setTimeout(() => this.parentPopover.relocate()); - } -} - -ngModule.vnComponent('vnOrderCatalogSearchPanel', { - template: require('./index.html'), - controller: Controller, - bindings: { - onSubmit: '&?', - parentPopover: ' - -
- -
-
-
-
- -
-
- -

- {{::item.subName}} -

-
- - - - - - -
- - - - - - {{::item.minQuantity}} - - -
-
-
-
- - - - - diff --git a/modules/order/front/catalog-view/index.js b/modules/order/front/catalog-view/index.js deleted file mode 100644 index 6f2cead8f..000000000 --- a/modules/order/front/catalog-view/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import ngModule from '../module'; -import Component from 'core/lib/component'; -import './style.scss'; - -ngModule.vnComponent('vnOrderCatalogView', { - template: require('./index.html'), - controller: Component, - bindings: { - order: '<', - model: '<' - } -}); diff --git a/modules/order/front/catalog-view/locale/es.yml b/modules/order/front/catalog-view/locale/es.yml deleted file mode 100644 index 8fb3c7896..000000000 --- a/modules/order/front/catalog-view/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Order created: Orden creada -Minimal quantity: Cantidad mínima \ No newline at end of file diff --git a/modules/order/front/catalog-view/style.scss b/modules/order/front/catalog-view/style.scss deleted file mode 100644 index 1e48745ca..000000000 --- a/modules/order/front/catalog-view/style.scss +++ /dev/null @@ -1,50 +0,0 @@ -@import "variables"; - -vn-order-catalog { - .catalog-header { - border-bottom: $border-thin; - padding: $spacing-md; - align-items: center; - - & > vn-one { - display: flex; - flex: 1; - - span { - color: $color-font-secondary - } - } - & > vn-auto { - width: 448px; - display: flex; - overflow: hidden; - - & > * { - padding-left: $spacing-md; - } - } - } - .catalog-list { - padding-top: $spacing-sm; - } - .item-color-background { - background: linear-gradient($color-bg-panel, $color-main); - border-radius: 50%; - margin-left: 140px; - margin-top: 140px; - width: 40px; - height: 40px; - position: absolute; - } - .item-color { - margin: auto; - margin-top: 5px; - border-radius: 50%; - width: 30px; - height: 30px; - position: relative; - } - .alert { - color: $color-alert; - } -} diff --git a/modules/order/front/catalog/index.html b/modules/order/front/catalog/index.html deleted file mode 100644 index 0f7928c8b..000000000 --- a/modules/order/front/catalog/index.html +++ /dev/null @@ -1,166 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -
{{name}}
-
- {{categoryName}} -
-
-
-
- - - - - -
- More than {{model.limit}} results -
-
- - - - - - - - - - - - - - - -
- - Id: {{$ctrl.itemId}} - - -
- - Name: - - {{$ctrl.itemName}} -
-
- - {{category.selection.name}} - - - {{type.selection.name}} - - -
- - {{::tagGroup.tagSelection.name}}: - - - , - "{{::tagValue.value}}" - -
-
-
-
diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js deleted file mode 100644 index c0777ebc9..000000000 --- a/modules/order/front/catalog/index.js +++ /dev/null @@ -1,377 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.itemTypes = []; - this._tagGroups = []; - - // Static autocomplete data - this.orderWays = [ - {way: 'ASC', name: 'Ascendant'}, - {way: 'DESC', name: 'Descendant'}, - ]; - this.defaultOrderFields = [ - {field: 'relevancy DESC, name', name: 'Relevancy', priority: 999}, - {field: 'showOrder, price', name: 'Color and price', priority: 999}, - {field: 'name', name: 'Name', priority: 999}, - {field: 'price', name: 'Price', priority: 999} - ]; - this.orderFields = [].concat(this.defaultOrderFields); - this._orderWay = this.orderWays[0].way; - this.orderField = this.orderFields[0].field; - } - - $onChanges() { - this.getData().then(() => { - if (this.order && this.order.isConfirmed) - this.$state.go('order.card.line'); - }); - } - - getData() { - return this.$http.get(`Orders/${this.$params.id}`) - .then(res => this.order = res.data); - } - - /** - * Fills order autocomplete with tags - * obtained from last filtered - */ - get order() { - return this._order; - } - - /** - * Sets filter values from state params - * - * @param {Object} value - Order data - */ - set order(value) { - this._order = value; - - if (!value) return; - - this.$.$applyAsync(() => { - if (this.$params.categoryId) - this.categoryId = parseInt(this.$params.categoryId); - - if (this.$params.typeId) - this.typeId = parseInt(this.$params.typeId); - - if (this.$params.tagGroups) - this.tagGroups = JSON.parse(this.$params.tagGroups); - }); - } - - get items() { - return this._items; - } - - set items(value) { - this._items = value; - - if (!value) return; - - this.fetchResultTags(value); - this.buildOrderFilter(); - } - - get categoryId() { - return this._categoryId; - } - - set categoryId(value = null) { - this._categoryId = value; - this.itemTypes = []; - this.typeId = null; - - this.updateStateParams(); - - if (this.tagGroups.length > 0) - this.applyFilters(); - - if (value) - this.updateItemTypes(); - } - - changeCategory(id) { - if (this._categoryId == id) id = null; - this.categoryId = id; - } - - get typeId() { - return this._typeId; - } - - set typeId(value) { - this._typeId = value; - - this.updateStateParams(); - - if (value || this.tagGroups.length > 0) - this.applyFilters(); - } - - get tagGroups() { - return this._tagGroups; - } - - set tagGroups(value) { - this._tagGroups = value; - - this.updateStateParams(); - - if (value.length) - this.applyFilters(); - } - - /** - * Get order way ASC/DESC - */ - get orderWay() { - return this._orderWay; - } - - set orderWay(value) { - this._orderWay = value; - if (value) this.applyOrder(); - } - - /** - * Returns the order way selection - */ - get orderSelection() { - return this._orderSelection; - } - - set orderSelection(value) { - this._orderSelection = value; - - if (value) this.applyOrder(); - } - - /** - * Apply order to model - */ - applyOrder() { - if (this.typeId || this.tagGroups.length > 0 || this.itemName) - this.$.model.addFilter(null, {orderBy: this.getOrderBy()}); - } - - /** - * Returns order param - * - * @return {Object} - Order param - */ - getOrderBy() { - const isTag = !!(this.orderSelection && this.orderSelection.isTag); - return { - field: this.orderField, - way: this.orderWay, - isTag: isTag - }; - } - - /** - * Refreshes item type dropdown data - */ - updateItemTypes() { - let params = { - itemCategoryId: this.categoryId - }; - - const query = `Orders/${this.order.id}/getItemTypeAvailable`; - this.$http.get(query, {params}).then(res => - this.itemTypes = res.data); - } - - /** - * Search by tag value - * @param {object} event - */ - onSearchByTag(event) { - const value = this.$.search.value; - if (event.key !== 'Enter' || !value) return; - this.tagGroups.push({values: [{value: value}]}); - this.$.search.value = null; - this.updateStateParams(); - this.applyFilters(); - } - - remove(index) { - this.tagGroups.splice(index, 1); - this.updateStateParams(); - - if (this.tagGroups.length >= 0 || this.itemId || this.typeId) - this.applyFilters(); - } - - removeItemId() { - this.itemId = null; - this.$.searchbar.doSearch({}, 'bar'); - } - - removeItemName() { - this.itemName = null; - this.$.searchbar.doSearch({}, 'bar'); - } - - applyFilters(filter = {}) { - let newParams = {}; - let newFilter = Object.assign({}, filter); - const model = this.$.model; - - if (this.categoryId) - newFilter.categoryFk = this.categoryId; - - if (this.typeId) - newFilter.typeFk = this.typeId; - - newParams = { - orderFk: this.$params.id, - orderBy: this.getOrderBy(), - tagGroups: this.tagGroups, - }; - - return model.applyFilter({where: newFilter}, newParams); - } - - openPanel(event) { - if (event.defaultPrevented) return; - event.preventDefault(); - - this.panelFilter = {}; - this.$.popover.show(this.$.search.element); - } - - onPanelSubmit(filter) { - this.$.popover.hide(); - const values = filter.values; - const nonEmptyValues = values.filter(tagValue => { - return tagValue.value; - }); - - filter.values = nonEmptyValues; - - if (filter.tagFk && nonEmptyValues.length) { - this.tagGroups.push(filter); - this.updateStateParams(); - this.applyFilters(); - } - } - - /** - * Updates url state params from filter values - */ - updateStateParams() { - const params = {}; - - params.categoryId = undefined; - if (this.categoryId) - params.categoryId = this.categoryId; - - params.typeId = undefined; - if (this.typeId) - params.typeId = this.typeId; - - params.tagGroups = undefined; - if (this.tagGroups && this.tagGroups.length) - params.tagGroups = JSON.stringify(this.sanitizedTagGroupParam()); - - this.$state.go(this.$state.current.name, params); - } - - sanitizedTagGroupParam() { - const tagGroups = []; - for (let tagGroup of this.tagGroups) { - const tagParam = {values: []}; - - for (let tagValue of tagGroup.values) - tagParam.values.push({value: tagValue.value}); - - if (tagGroup.tagFk) - tagParam.tagFk = tagGroup.tagFk; - - if (tagGroup.tagSelection) { - tagParam.tagSelection = { - name: tagGroup.tagSelection.name - }; - } - - tagGroups.push(tagParam); - } - - return tagGroups; - } - - fetchResultTags(items) { - const resultTags = []; - for (let item of items) { - for (let itemTag of item.tags) { - const alreadyAdded = resultTags.findIndex(tag => { - return tag.tagFk == itemTag.tagFk; - }); - - if (alreadyAdded == -1) - resultTags.push({...itemTag, priority: 1}); - else - resultTags[alreadyAdded].priority += 1; - } - } - this.resultTags = resultTags; - } - - buildOrderFilter() { - const filter = [].concat(this.defaultOrderFields); - for (let tag of this.resultTags) - filter.push({...tag, field: tag.id, isTag: true}); - - this.orderFields = filter; - } - - onSearch(params) { - if (!params) return; - - this.itemId = null; - this.itemName = null; - - if (params.search) { - if (/^\d+$/.test(params.search)) { - this.itemId = params.search; - return this.applyFilters({ - 'i.id': params.search - }); - } else { - this.itemName = params.search; - return this.applyFilters({ - 'i.name': {like: `%${params.search}%`} - }); - } - } else return this.applyFilters(); - } - - formatTooltip(tagGroup) { - const tagValues = tagGroup.values; - - let title = ''; - if (tagGroup.tagFk) { - const tagName = tagGroup.tagSelection.name; - title += `${tagName}: `; - } - - for (let [i, tagValue] of tagValues.entries()) { - if (i > 0) title += ', '; - title += `"${tagValue.value}"`; - } - - return `${title}`; - } -} - -ngModule.vnComponent('vnOrderCatalog', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/order/front/catalog/index.spec.js b/modules/order/front/catalog/index.spec.js deleted file mode 100644 index 03d7c41ba..000000000 --- a/modules/order/front/catalog/index.spec.js +++ /dev/null @@ -1,386 +0,0 @@ -import './index.js'; -import crudModel from 'core/mocks/crud-model'; - -describe('Order', () => { - describe('Component vnOrderCatalog', () => { - let $scope; - let $state; - let controller; - let $httpBackend; - - beforeEach(ngModule('order')); - - beforeEach(inject(($componentController, _$state_, _$httpBackend_, $rootScope) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - $scope.model = crudModel; - $scope.search = {}; - $scope.itemId = {}; - $state = _$state_; - $state.current.name = 'my.current.state'; - const $element = angular.element(''); - controller = $componentController('vnOrderCatalog', {$element, $scope}); - controller._order = {id: 4}; - controller.$params = { - categoryId: 1, - typeId: 2, - id: 4 - }; - })); - - describe('getData()', () => { - it(`should make a query an fetch the order data`, () => { - controller._order = null; - - $httpBackend.expect('GET', `Orders/4`).respond(200, {id: 4, isConfirmed: true}); - $httpBackend.expect('GET', `Orders/4/getItemTypeAvailable?itemCategoryId=1`).respond(); - controller.getData(); - $httpBackend.flush(); - - const order = controller.order; - - expect(order.id).toEqual(4); - expect(order.isConfirmed).toBeTruthy(); - }); - }); - - describe('order() setter', () => { - it(`should call scope $applyAsync() method and apply filters from state params`, () => { - $httpBackend.expect('GET', `Orders/4/getItemTypeAvailable?itemCategoryId=1`).respond(); - controller.order = {id: 4}; - - $scope.$apply(); - - expect(controller.categoryId).toEqual(1); - expect(controller.typeId).toEqual(2); - }); - }); - - describe('items() setter', () => { - it(`should return an object with order params`, () => { - jest.spyOn(controller, 'fetchResultTags'); - jest.spyOn(controller, 'buildOrderFilter'); - - const expectedResult = [{field: 'showOrder, price', name: 'Color and price', priority: 999}]; - const items = [{id: 1, name: 'My Item', tags: [ - {tagFk: 4, name: 'Length'}, - {tagFk: 5, name: 'Color'} - ]}]; - controller.items = items; - - expect(controller.orderFields.length).toEqual(6); - expect(controller.orderFields).toEqual(jasmine.arrayContaining(expectedResult)); - expect(controller.fetchResultTags).toHaveBeenCalledWith(items); - expect(controller.buildOrderFilter).toHaveBeenCalledWith(); - }); - }); - - describe('categoryId() setter', () => { - it(`should set category property to null, call updateStateParams() method and not call applyFilters()`, () => { - jest.spyOn(controller, 'updateStateParams'); - - controller.categoryId = null; - - expect(controller.updateStateParams).toHaveBeenCalledWith(); - }); - - it(`should set category property and then call updateStateParams() and applyFilters() methods`, () => { - jest.spyOn(controller, 'updateStateParams'); - - controller.categoryId = 2; - - expect(controller.updateStateParams).toHaveBeenCalledWith(); - }); - }); - - describe('changeCategory()', () => { - it(`should set categoryId property to null if the new value equals to the old one`, () => { - controller.categoryId = 2; - controller.changeCategory(2); - - expect(controller.categoryId).toBeNull(); - }); - - it(`should set categoryId property`, () => { - controller.categoryId = 2; - controller.changeCategory(1); - - expect(controller.categoryId).toEqual(1); - }); - }); - - describe('typeId() setter', () => { - it(`should set type property to null, call updateStateParams() method and not call applyFilters()`, () => { - jest.spyOn(controller, 'updateStateParams'); - jest.spyOn(controller, 'applyFilters'); - - controller.typeId = null; - - expect(controller.updateStateParams).toHaveBeenCalledWith(); - expect(controller.applyFilters).not.toHaveBeenCalledWith(); - }); - - it(`should set category property and then call updateStateParams() and applyFilters() methods`, () => { - jest.spyOn(controller, 'updateStateParams'); - jest.spyOn(controller, 'applyFilters'); - - controller.typeId = 2; - - expect(controller.updateStateParams).toHaveBeenCalledWith(); - expect(controller.applyFilters).toHaveBeenCalledWith(); - }); - }); - - describe('tagGroups() setter', () => { - it(`should set tagGroups property and then call updateStateParams() and applyFilters() methods`, () => { - jest.spyOn(controller, 'updateStateParams'); - jest.spyOn(controller, 'applyFilters'); - - controller.tagGroups = [{tagFk: 11, values: [{value: 'Brown'}]}]; - - expect(controller.updateStateParams).toHaveBeenCalledWith(); - expect(controller.applyFilters).toHaveBeenCalledWith(); - }); - }); - - describe('onSearchByTag()', () => { - it(`should not add a new tag if the event key code doesn't equals to 'Enter'`, () => { - jest.spyOn(controller, 'applyFilters'); - - controller.order = {id: 4}; - controller.$.search.value = 'Brown'; - controller.onSearchByTag({key: 'Tab'}); - - expect(controller.applyFilters).not.toHaveBeenCalledWith(); - }); - - it(`should add a new tag if the event key code equals to 'Enter' an then call applyFilters()`, () => { - jest.spyOn(controller, 'applyFilters'); - - controller.order = {id: 4}; - controller.$.search.value = 'Brown'; - controller.onSearchByTag({key: 'Enter'}); - - expect(controller.applyFilters).toHaveBeenCalledWith(); - }); - }); - - describe('onSearch()', () => { - it(`should apply a filter by item id an then call the applyFilters method`, () => { - jest.spyOn(controller, 'applyFilters'); - - const itemId = 1; - controller.onSearch({search: itemId}); - - expect(controller.applyFilters).toHaveBeenCalledWith({ - 'i.id': itemId - }); - }); - - it(`should apply a filter by item name an then call the applyFilters method`, () => { - jest.spyOn(controller, 'applyFilters'); - - const itemName = 'Bow'; - controller.onSearch({search: itemName}); - - expect(controller.applyFilters).toHaveBeenCalledWith({ - 'i.name': {like: `%${itemName}%`} - }); - }); - }); - - describe('applyFilters()', () => { - it(`should call model applyFilter() method with a new filter`, () => { - jest.spyOn(controller.$.model, 'applyFilter'); - - controller._categoryId = 2; - controller._typeId = 4; - - controller.applyFilters(); - - expect(controller.$.model.applyFilter).toHaveBeenCalledWith( - {where: {categoryFk: 2, typeFk: 4}}, - {orderFk: 4, orderBy: controller.getOrderBy(), tagGroups: []}); - }); - }); - - describe('remove()', () => { - it(`should remove a tag from tags property`, () => { - jest.spyOn(controller, 'applyFilters'); - - controller.tagGroups = [ - {tagFk: 1, values: [{value: 'Brown'}]}, - {tagFk: 67, values: [{value: 'Concussion'}]} - ]; - controller.remove(0); - - const firstTag = controller.tagGroups[0]; - - expect(controller.tagGroups.length).toEqual(1); - expect(firstTag.tagFk).toEqual(67); - expect(controller.applyFilters).toHaveBeenCalledWith(); - }); - - it(`should remove a tag from tags property and call applyFilters() if there's no more tags`, () => { - jest.spyOn(controller, 'applyFilters'); - - controller._categoryId = 1; - controller._typeId = 1; - controller.tagGroups = [{tagFk: 1, values: [{value: 'Blue'}]}]; - controller.remove(0); - - expect(controller.tagGroups.length).toEqual(0); - expect(controller.applyFilters).toHaveBeenCalledWith(); - }); - }); - - describe('updateStateParams()', () => { - it(`should call state go() method passing category and type state params`, () => { - jest.spyOn(controller.$state, 'go'); - - controller._categoryId = 2; - controller._typeId = 4; - controller._tagGroups = [ - {tagFk: 67, values: [{value: 'Concussion'}], tagSelection: {name: 'Category'}} - ]; - const tagGroups = JSON.stringify([ - {values: [{value: 'Concussion'}], tagFk: 67, tagSelection: {name: 'Category'}} - ]); - const expectedResult = {categoryId: 2, typeId: 4, tagGroups: tagGroups}; - controller.updateStateParams(); - - expect(controller.$state.go).toHaveBeenCalledWith('my.current.state', expectedResult); - }); - }); - - describe('getOrderBy()', () => { - it(`should return an object with order params`, () => { - controller.orderField = 'relevancy DESC, name'; - controller.orderWay = 'DESC'; - let expectedResult = { - field: 'relevancy DESC, name', - way: 'DESC', - isTag: false - }; - let result = controller.getOrderBy(); - - expect(result).toEqual(expectedResult); - }); - }); - - describe('applyOrder()', () => { - it(`should apply order param to model calling getOrderBy()`, () => { - jest.spyOn(controller, 'getOrderBy'); - jest.spyOn(controller.$.model, 'addFilter'); - - controller.field = 'relevancy DESC, name'; - controller.way = 'ASC'; - controller._categoryId = 1; - controller._typeId = 1; - let expectedOrder = {orderBy: controller.getOrderBy()}; - - controller.applyOrder(); - - expect(controller.getOrderBy).toHaveBeenCalledWith(); - expect(controller.$.model.addFilter).toHaveBeenCalledWith(null, expectedOrder); - }); - }); - - describe('fetchResultTags()', () => { - it(`should create an array of non repeated tags then set the resultTags property`, () => { - const items = [ - { - id: 1, name: 'My Item 1', tags: [ - {tagFk: 4, name: 'Length', value: 1}, - {tagFk: 5, name: 'Color', value: 'red'} - ] - }, - { - id: 2, name: 'My Item 2', tags: [ - {tagFk: 4, name: 'Length', value: 1}, - {tagFk: 5, name: 'Color', value: 'blue'} - ] - }]; - controller.fetchResultTags(items); - - expect(controller.resultTags.length).toEqual(2); - }); - }); - - describe('buildOrderFilter()', () => { - it(`should create an array of non repeated tags plus default filters and then set the orderFields property`, () => { - const items = [ - { - id: 1, name: 'My Item 1', tags: [ - {tagFk: 4, name: 'Length'}, - {tagFk: 5, name: 'Color'} - ] - }, - { - id: 2, name: 'My Item 2', tags: [ - {tagFk: 5, name: 'Color'}, - {tagFk: 6, name: 'Relevancy'} - ] - }]; - - controller.fetchResultTags(items); - controller.buildOrderFilter(); - - expect(controller.orderFields.length).toEqual(7); - }); - }); - - describe('formatTooltip()', () => { - it(`should return a formatted text with the tag name and values`, () => { - const tagGroup = { - values: [{value: 'Silver'}, {value: 'Brown'}], - tagFk: 1, - tagSelection: { - name: 'Color' - } - }; - - const result = controller.formatTooltip(tagGroup); - - expect(result).toEqual(`Color: "Silver", "Brown"`); - }); - - it(`should return a formatted text with the tag value`, () => { - const tagGroup = { - values: [{value: 'Silver'}] - }; - - const result = controller.formatTooltip(tagGroup); - - expect(result).toEqual(`"Silver"`); - }); - }); - - describe('sanitizedTagGroupParam()', () => { - it(`should return an array of tags`, () => { - const dirtyTagGroups = [{ - values: [{value: 'Silver'}, {value: 'Brown'}], - tagFk: 1, - tagSelection: { - name: 'Color', - $orgRow: {name: 'Color'} - }, - $orgIndex: 1 - }]; - controller.tagGroups = dirtyTagGroups; - - const expectedResult = [{ - values: [{value: 'Silver'}, {value: 'Brown'}], - tagFk: 1, - tagSelection: { - name: 'Color' - } - }]; - const result = controller.sanitizedTagGroupParam(); - - expect(result).toEqual(expect.objectContaining(expectedResult)); - }); - }); - }); -}); - diff --git a/modules/order/front/catalog/locale/es.yml b/modules/order/front/catalog/locale/es.yml deleted file mode 100644 index fc78755ae..000000000 --- a/modules/order/front/catalog/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Name: Nombre -Search by item id or name: Buscar por id de artículo o nombre -OR: O \ No newline at end of file diff --git a/modules/order/front/catalog/style.scss b/modules/order/front/catalog/style.scss deleted file mode 100644 index 9ffe81dfb..000000000 --- a/modules/order/front/catalog/style.scss +++ /dev/null @@ -1,54 +0,0 @@ -@import "variables"; - -vn-order-catalog vn-side-menu div { - & > .input { - padding-left: $spacing-md; - padding-right: $spacing-md; - border-color: $color-spacer; - border-bottom: $border-thin; - } - .item-category { - padding: $spacing-sm; - justify-content: flex-start; - align-items: flex-start; - flex-wrap: wrap; - - vn-autocomplete[vn-id="category"] { - display: none - } - - & > vn-one { - padding: $spacing-sm; - min-width: 33.33%; - text-align: center; - box-sizing: border-box; - - & > vn-icon { - padding: $spacing-sm; - background-color: $color-font-secondary; - border-radius: 50%; - cursor: pointer; - - &.active { - background-color: $color-main; - color: #FFF - } - & > i:before { - font-size: 2.6rem; - width: 16px; - height: 16px; - } - } - } - } - .chips { - display: flex; - flex-wrap: wrap; - padding: $spacing-md; - overflow: hidden; - max-width: 100%; - } - vn-autocomplete[vn-id="type"] .list { - max-height: 320px - } -} \ No newline at end of file diff --git a/modules/order/front/create/card.html b/modules/order/front/create/card.html deleted file mode 100644 index ed6f752d3..000000000 --- a/modules/order/front/create/card.html +++ /dev/null @@ -1,38 +0,0 @@ - - {{id}}: {{name}} - - - {{nickname}}: {{street}}, {{city}} - - - - - diff --git a/modules/order/front/create/card.js b/modules/order/front/create/card.js deleted file mode 100644 index 315cc8255..000000000 --- a/modules/order/front/create/card.js +++ /dev/null @@ -1,114 +0,0 @@ -import ngModule from '../module'; -import Component from 'core/lib/component'; - -class Controller extends Component { - constructor($element, $) { - super($element, $); - this.order = {}; - this.clientFk = this.$params.clientFk; - } - - $onInit() { - if (this.$params && this.$params.clientFk) - this.clientFk = this.$params.clientFk; - } - - set order(value) { - if (value) - this._order = value; - } - - get order() { - return this._order; - } - - set clientFk(value) { - this.order.clientFk = value; - - if (value) { - let filter = { - include: { - relation: 'defaultAddress', - scope: { - fields: 'id' - } - }, - where: {id: value} - }; - filter = encodeURIComponent(JSON.stringify(filter)); - let query = `Clients?filter=${filter}`; - this.$http.get(query).then(res => { - if (res.data) { - let client = res.data[0]; - let defaultAddress = client.defaultAddress; - this.addressFk = defaultAddress.id; - } - }); - } else - this.addressFk = null; - } - - get clientFk() { - return this.order.clientFk; - } - - set addressFk(value) { - this.order.addressFk = value; - this.getAvailableAgencies(); - } - - get addressFk() { - return this.order.addressFk; - } - - set landed(value) { - this.order.landed = value; - this.getAvailableAgencies(); - } - - get landed() { - return this.order.landed; - } - - get warehouseFk() { - return this.order.warehouseFk; - } - - getAvailableAgencies() { - let order = this.order; - order.agencyModeFk = null; - - let params = { - addressFk: order.addressFk, - landed: order.landed - }; - if (params.landed && params.addressFk) { - this.$http.get(`Agencies/landsThatDay`, {params}) - .then(res => this._availableAgencies = res.data); - } - } - - onSubmit() { - this.createOrder(); - } - - createOrder() { - let params = { - landed: this.order.landed, - addressId: this.order.addressFk, - agencyModeId: this.order.agencyModeFk - }; - this.$http.post(`Orders/new`, params).then(res => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.$state.go('order.card.catalog', {id: res.data}); - }); - } -} - -ngModule.vnComponent('vnOrderCreateCard', { - template: require('./card.html'), - controller: Controller, - bindings: { - order: ' { - describe('Component vnOrderCreateCard', () => { - let controller; - let $httpBackend; - let $scope; - - beforeEach(ngModule('order')); - - beforeEach(inject(($componentController, _$httpBackend_, _vnApp_, $rootScope) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnOrderCreateCard', {$element, $scope}); - controller.item = {id: 3}; - })); - - describe('set order', () => { - it(`should set order if the value given is not null`, () => { - controller.order = 1; - - expect(controller.order).toEqual(1); - }); - }); - - describe('set clientFk', () => { - it(`should set addressFk to null and clientFk to a value and set addressFk to a value given`, () => { - let filter = { - include: { - relation: 'defaultAddress', - scope: { - fields: 'id' - } - }, - where: {id: 2} - }; - filter = encodeURIComponent(JSON.stringify(filter)); - let response = [ - { - defaultAddress: {id: 1} - } - ]; - $httpBackend.whenGET(`Clients?filter=${filter}`).respond(response); - $httpBackend.expectGET(`Clients?filter=${filter}`); - - controller.clientFk = 2; - $httpBackend.flush(); - - expect(controller.clientFk).toEqual(2); - expect(controller.order.addressFk).toBe(1); - }); - }); - - describe('set addressFk', () => { - it(`should set agencyModeFk property to null and addressFk to a value`, () => { - controller.addressFk = 1101; - - expect(controller.addressFk).toEqual(1101); - expect(controller.order.agencyModeFk).toBe(null); - }); - }); - - describe('getAvailableAgencies()', () => { - it(`should make a query if landed and addressFk exists`, () => { - controller.order.addressFk = 1101; - controller.order.landed = 1101; - - $httpBackend.whenRoute('GET', 'Agencies/landsThatDay') - .respond({data: 1}); - - controller.getAvailableAgencies(); - $httpBackend.flush(); - }); - }); - - describe('onSubmit()', () => { - it(`should call createOrder()`, () => { - jest.spyOn(controller, 'createOrder'); - controller.onSubmit(); - - expect(controller.createOrder).toHaveBeenCalledWith(); - }); - }); - - describe('createOrder()', () => { - it(`should make a query, call vnApp.showSuccess and $state.go if the response is defined`, () => { - controller.order.landed = 1101; - controller.order.addressFk = 1101; - controller.order.agencyModeFk = 1101; - - jest.spyOn(controller.vnApp, 'showSuccess'); - jest.spyOn(controller.$state, 'go'); - $httpBackend.expect('POST', 'Orders/new', {landed: 1101, addressId: 1101, agencyModeId: 1101}).respond(200, 1); - controller.createOrder(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.$state.go).toHaveBeenCalledWith('order.card.catalog', {id: 1}); - }); - }); - }); -}); - diff --git a/modules/order/front/create/index.html b/modules/order/front/create/index.html deleted file mode 100644 index 86df579a6..000000000 --- a/modules/order/front/create/index.html +++ /dev/null @@ -1,16 +0,0 @@ -
- - - - - - - - - -
\ No newline at end of file diff --git a/modules/order/front/create/index.js b/modules/order/front/create/index.js deleted file mode 100644 index 317c4e27e..000000000 --- a/modules/order/front/create/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - async onSubmit() { - let newOrderID = await this.$.card.createOrder(); - this.$state.go('order.card.summary', {id: newOrderID}); - } -} - -ngModule.vnComponent('vnOrderCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/order/front/create/index.spec.js b/modules/order/front/create/index.spec.js deleted file mode 100644 index af8c8f974..000000000 --- a/modules/order/front/create/index.spec.js +++ /dev/null @@ -1,34 +0,0 @@ -import './index.js'; - -describe('Order', () => { - describe('Component vnOrderCreate', () => { - let $scope; - let controller; - - beforeEach(ngModule('order')); - - beforeEach(inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - $scope.card = {createOrder: () => {}}; - const $element = angular.element(''); - controller = $componentController('vnOrderCreate', {$element, $scope}); - })); - - describe('onSubmit()', () => { - it(`should call createOrder()`, () => { - jest.spyOn(controller.$.card, 'createOrder'); - controller.onSubmit(); - - expect(controller.$.card.createOrder).toHaveBeenCalledWith(); - }); - - it(`should call go()`, async() => { - jest.spyOn(controller.$state, 'go'); - await controller.onSubmit(); - - expect(controller.$state.go).toHaveBeenCalledWith('order.card.summary', {id: undefined}); - }); - }); - }); -}); - diff --git a/modules/order/front/create/locale/es.yml b/modules/order/front/create/locale/es.yml deleted file mode 100644 index 49cd64c4a..000000000 --- a/modules/order/front/create/locale/es.yml +++ /dev/null @@ -1,6 +0,0 @@ -You can't create an order for a frozen client: No puedes crear una orden a un cliente congelado -You can't create an order for an inactive client: No puedes crear una orden a un cliente inactivo -You can't create an order for a client that doesn't has tax data verified: - No puedes crear una orden a un cliente cuyos datos fiscales no han sido verificados -You can't create an order for a client that has a debt: No puedes crear una orden a un cliente que tiene deuda -New order: Nueva orden \ No newline at end of file diff --git a/modules/order/front/descriptor/index.html b/modules/order/front/descriptor/index.html deleted file mode 100644 index 538789027..000000000 --- a/modules/order/front/descriptor/index.html +++ /dev/null @@ -1,78 +0,0 @@ - - - - Delete order - - - -
- - - - - {{$ctrl.order.client.salesPersonUser.name}} - - - - - - - - - - - - -
- -
-
- - - - - - - \ No newline at end of file diff --git a/modules/order/front/descriptor/index.js b/modules/order/front/descriptor/index.js deleted file mode 100644 index 5d22dd721..000000000 --- a/modules/order/front/descriptor/index.js +++ /dev/null @@ -1,32 +0,0 @@ -import ngModule from '../module'; -import Descriptor from 'salix/components/descriptor'; - -class Controller extends Descriptor { - get order() { - return this.entity; - } - - set order(value) { - this.entity = value; - } - - get ticketFilter() { - return JSON.stringify({orderFk: this.id}); - } - - deleteOrder() { - return this.$http.delete(`Orders/${this.id}`) - .then(() => { - this.$state.go('order.index'); - this.vnApp.showSuccess(this.$t('Order deleted')); - }); - } -} - -ngModule.vnComponent('vnOrderDescriptor', { - template: require('./index.html'), - controller: Controller, - bindings: { - order: '<' - } -}); diff --git a/modules/order/front/descriptor/index.spec.js b/modules/order/front/descriptor/index.spec.js deleted file mode 100644 index e6147faee..000000000 --- a/modules/order/front/descriptor/index.spec.js +++ /dev/null @@ -1,29 +0,0 @@ -import './index.js'; - -describe('Order Component vnOrderDescriptor', () => { - let $httpBackend; - let controller; - const order = {id: 1}; - - beforeEach(ngModule('order')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnOrderDescriptor', {$element: null}, {order}); - })); - - describe('deleteOrder()', () => { - it(`should perform a DELETE query`, () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - jest.spyOn(controller.$state, 'go'); - - $httpBackend.expectDELETE(`Orders/${order.id}`).respond(); - controller.deleteOrder(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.$state.go).toHaveBeenCalledWith('order.index'); - }); - }); -}); - diff --git a/modules/order/front/descriptor/locale/es.yml b/modules/order/front/descriptor/locale/es.yml deleted file mode 100644 index 0734d7638..000000000 --- a/modules/order/front/descriptor/locale/es.yml +++ /dev/null @@ -1,12 +0,0 @@ -Client: Cliente -Confirmed: Confirmado -Not confirmed: Sin confirmar -State: Estado -Landed: F. entrega -Items: Articulos -Agency: Agencia -Sales person: Comercial -Order ticket list: Ticket del pedido -Delete order: Eliminar pedido -You are going to delete this order: El pedido se eliminará -continue anyway?: ¿Continuar de todos modos? \ No newline at end of file diff --git a/modules/order/front/index.js b/modules/order/front/index.js index 4d5b5615e..a7209a0bd 100644 --- a/modules/order/front/index.js +++ b/modules/order/front/index.js @@ -1,17 +1,3 @@ export * from './module'; import './main'; -import './index/'; -import './card'; -import './descriptor'; -import './search-panel'; -import './catalog-search-panel'; -import './catalog-view'; -import './catalog'; -import './summary'; -import './line'; -import './prices-popover'; -import './volume'; -import './create'; -import './create/card'; -import './basic-data'; diff --git a/modules/order/front/index/index.html b/modules/order/front/index/index.html deleted file mode 100644 index c4bed7307..000000000 --- a/modules/order/front/index/index.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - Id - Sales person - Client - Confirmed - Created - Landed - Hour - Agency - Total - - - - - {{::order.id}} - - - {{::order.name | dashIfEmpty}} - - - - - {{::order.clientName}} - - - - - - - {{::order.created | date: 'dd/MM/yyyy HH:mm'}} - - - {{::order.landed | date:'dd/MM/yyyy'}} - - - {{::(order.hourTheoretical - ? order.hourTheoretical - : order.hourEffective) | dashIfEmpty - }} - {{::order.agencyName}} - {{::order.total | currency: 'EUR': 2 | dashIfEmpty}} - - - - - - - - - - - - - - - - - - - - diff --git a/modules/order/front/index/index.js b/modules/order/front/index/index.js deleted file mode 100644 index 750f2e226..000000000 --- a/modules/order/front/index/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - preview(order) { - this.selectedOrder = order; - this.$.summary.show(); - } - - compareDate(date) { - let today = Date.vnNew(); - today.setHours(0, 0, 0, 0); - - date = new Date(date); - date.setHours(0, 0, 0, 0); - - const timeDifference = today - date; - if (timeDifference == 0) return 'warning'; - if (timeDifference < 0) return 'success'; - } -} - -ngModule.vnComponent('vnOrderIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/order/front/index/index.spec.js b/modules/order/front/index/index.spec.js deleted file mode 100644 index abe336478..000000000 --- a/modules/order/front/index/index.spec.js +++ /dev/null @@ -1,67 +0,0 @@ -import './index.js'; -describe('Component vnOrderIndex', () => { - let controller; - let $window; - let orders = [{ - id: 1, - clientFk: 1, - isConfirmed: false - }, { - id: 2, - clientFk: 1, - isConfirmed: false - }, { - id: 3, - clientFk: 1, - isConfirmed: true - }]; - - beforeEach(ngModule('order')); - - beforeEach(inject(($componentController, _$window_) => { - $window = _$window_; - const $element = angular.element(''); - controller = $componentController('vnOrderIndex', {$element}); - })); - - describe('compareDate()', () => { - it('should return warning when the date is the present', () => { - let curDate = Date.vnNew(); - let result = controller.compareDate(curDate); - - expect(result).toEqual('warning'); - }); - - it('should return sucess when the date is in the future', () => { - let futureDate = Date.vnNew(); - futureDate = futureDate.setDate(futureDate.getDate() + 10); - let result = controller.compareDate(futureDate); - - expect(result).toEqual('success'); - }); - - it('should return undefined when the date is in the past', () => { - let pastDate = Date.vnNew(); - pastDate = pastDate.setDate(pastDate.getDate() - 10); - let result = controller.compareDate(pastDate); - - expect(result).toEqual(undefined); - }); - }); - - describe('preview()', () => { - it('should show the dialog summary', () => { - controller.$.summary = {show: () => {}}; - jest.spyOn(controller.$.summary, 'show'); - - let event = new MouseEvent('click', { - view: $window, - bubbles: true, - cancelable: true - }); - controller.preview(event, orders[0]); - - expect(controller.$.summary.show).toHaveBeenCalledWith(); - }); - }); -}); diff --git a/modules/order/front/line/index.html b/modules/order/front/line/index.html deleted file mode 100644 index 7be5a00af..000000000 --- a/modules/order/front/line/index.html +++ /dev/null @@ -1,96 +0,0 @@ - - -
- Subtotal - {{$ctrl.subtotal | currency: 'EUR':2}} -
-
- VAT - {{$ctrl.VAT | currency: 'EUR':2}} -
-
- Total - {{$ctrl.order.total | currency: 'EUR':2}} -
-
- - - - - - Id - Description - Warehouse - Shipped - Quantity - Price - Amount - - - - - - - - - - - {{::row.itemFk}} - - - -
- {{::row.item.name}} - -

{{::row.item.subName}}

-
-
- - -
- {{::row.warehouse.name}} - {{::row.shipped | date: 'dd/MM/yyyy'}} - {{::row.quantity}} - - {{::row.price | currency: 'EUR':2}} - - - {{::row.price * row.quantity | currency: 'EUR':2}} - - - - - -
-
-
-
-
- - - - - - \ No newline at end of file diff --git a/modules/order/front/line/index.js b/modules/order/front/line/index.js deleted file mode 100644 index 94d1fbfbf..000000000 --- a/modules/order/front/line/index.js +++ /dev/null @@ -1,70 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - $onInit() { - this.getRows(); - } - - set order(value) { - this._order = value; - this.getVAT(); - } - - get order() { - return this._order; - } - - get subtotal() { - return this.order ? this.order.total - this.VAT : 0; - } - - getRows() { - let filter = { - where: {orderFk: this.$params.id}, - include: [ - {relation: 'item'}, - {relation: 'warehouse'} - ] - }; - this.$http.get(`OrderRows`, {filter}) - .then(res => this.rows = res.data); - } - - getVAT() { - this.$http.get(`Orders/${this.$params.id}/getVAT`) - .then(res => this.VAT = res.data); - } - - deleteRow(index) { - let [row] = this.rows.splice(index, 1); - let params = { - rows: [row.id], - actualOrderId: this.$params.id - }; - return this.$http.post(`OrderRows/removes`, params) - .then(() => this.card.reload()) - .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); - } - - save() { - this.$http.post(`Orders/${this.$params.id}/confirm`).then(() => { - this.vnApp.showSuccess(this.$t('Order confirmed')); - this.$state.go(`ticket.index`, { - q: JSON.stringify({clientFk: this.order.clientFk}) - }); - }); - } -} - -ngModule.vnComponent('vnOrderLine', { - template: require('./index.html'), - controller: Controller, - bindings: { - order: '<' - }, - require: { - card: '^vnOrderCard' - } -}); diff --git a/modules/order/front/line/index.spec.js b/modules/order/front/line/index.spec.js deleted file mode 100644 index ad0e1edbc..000000000 --- a/modules/order/front/line/index.spec.js +++ /dev/null @@ -1,66 +0,0 @@ -import './index.js'; - -describe('Order', () => { - describe('Component vnOrderLine', () => { - let $state; - let controller; - let $httpBackend; - - const vat = 10.5; - const rows = [ - { - quantity: 4, - price: 10.5 - }, { - quantity: 3, - price: 2.4 - } - ]; - - beforeEach(ngModule('order')); - - beforeEach(inject(($componentController, _$state_, _$httpBackend_) => { - $state = _$state_; - $httpBackend = _$httpBackend_; - - $state.params.id = 1; - $httpBackend.whenGET(`OrderRows`).respond(rows); - $httpBackend.whenRoute('GET', `Orders/:id/getVAT`).respond(200, vat); - - controller = $componentController('vnOrderLine', {$element: null}); - })); - - describe('getRows()', () => { - it('should make a query to get the rows of a given order', () => { - controller.getRows(); - $httpBackend.flush(); - - expect(controller.rows).toEqual(rows); - }); - }); - - describe('getVAT()', () => { - it('should make a query to get the VAT of a given order', () => { - controller.getVAT(); - $httpBackend.flush(); - - expect(controller.VAT).toBe(vat); - }); - }); - - describe('deleteRow()', () => { - it('should remove a row from rows and add save the data if the response is accept', () => { - controller.getRows(); - $httpBackend.flush(); - - controller.card = {reload: jasmine.createSpy('reload')}; - $httpBackend.expectPOST(`OrderRows/removes`).respond(); - controller.deleteRow(0); - $httpBackend.flush(); - - expect(controller.rows.length).toBe(1); - expect(controller.card.reload).toHaveBeenCalled(); - }); - }); - }); -}); diff --git a/modules/order/front/line/locale/es.yml b/modules/order/front/line/locale/es.yml deleted file mode 100644 index d1368d369..000000000 --- a/modules/order/front/line/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Delete row: Eliminar linea -Order confirmed: Pedido confirmado -Are you sure you want to delete this row?: ¿Estas seguro de que quieres eliminar esta línea? \ No newline at end of file diff --git a/modules/order/front/line/style.scss b/modules/order/front/line/style.scss deleted file mode 100644 index 4da941a2c..000000000 --- a/modules/order/front/line/style.scss +++ /dev/null @@ -1,18 +0,0 @@ -@import "./variables"; - -vn-order-line { - vn-table { - img { - border-radius: 50%; - width: 50px; - height: 50px; - } - } - .header { - text-align: right; - - & > div { - margin-bottom: $spacing-xs; - } - } -} \ No newline at end of file diff --git a/modules/order/front/main/index.js b/modules/order/front/main/index.js index caf819c9d..61b0201fd 100644 --- a/modules/order/front/main/index.js +++ b/modules/order/front/main/index.js @@ -2,8 +2,12 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; export default class Order extends ModuleMain { - $postLink() { - this.filter = {showEmpty: false}; + constructor($element, $) { + super($element, $); + } + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`order/`); } } diff --git a/modules/order/front/prices-popover/index.html b/modules/order/front/prices-popover/index.html deleted file mode 100644 index 2551853e6..000000000 --- a/modules/order/front/prices-popover/index.html +++ /dev/null @@ -1,52 +0,0 @@ - -
- - - - - - {{::price.warehouse}} - - - -
- {{::price.grouping}} - x {{::price.price | currency: 'EUR': 2}} -
-
- {{::price.priceKg | currency: 'EUR'}}/Kg -
-
- - - - - - - -
-
-
- -
-
diff --git a/modules/order/front/prices-popover/index.js b/modules/order/front/prices-popover/index.js deleted file mode 100644 index aa5570f59..000000000 --- a/modules/order/front/prices-popover/index.js +++ /dev/null @@ -1,115 +0,0 @@ -import ngModule from '../module'; -import Popover from 'core/components/popover'; -import './style.scss'; - -class Controller extends Popover { - constructor(...args) { - super(...args); - this.totalBasquet = 0; - } - - set prices(value) { - this._prices = value; - if (value && value[0].grouping) - this.getTotalQuantity(); - } - - get prices() { - return this._prices; - } - - show(parent, item) { - this.id = item.id; - this.item = JSON.parse(JSON.stringify(item)); - this.maxQuantity = this.item.available; - this.prices = this.item.prices; - - super.show(parent); - } - - onClose() { - this.id = null; - this.item = {}; - this.tags = {}; - this._prices = {}; - this.totalQuantity = 0; - super.onClose(); - } - - getTotalQuantity() { - let total = 0; - for (let price of this.prices) { - if (!price.quantity) price.quantity = 0; - total += price.quantity; - } - - this.totalQuantity = total; - } - - addQuantity(price) { - this.getTotalQuantity(); - const quantity = this.totalQuantity + price.grouping; - if (quantity <= this.maxQuantity) - price.quantity += price.grouping; - } - - getGroupings() { - const filledRows = []; - for (let priceOption of this.prices) { - if (priceOption.quantity && priceOption.quantity > 0) { - const priceMatch = filledRows.find(row => { - return row.warehouseFk == priceOption.warehouseFk - && row.price == priceOption.price; - }); - - if (!priceMatch) - filledRows.push(Object.assign({}, priceOption)); - else priceMatch.quantity += priceOption.quantity; - } - } - - return filledRows; - } - - submit() { - const filledRows = this.getGroupings(); - - try { - const hasInvalidGropings = filledRows.some(row => - row.quantity % row.grouping != 0 - ); - - if (filledRows.length <= 0) - throw new Error('First you must add some quantity'); - - if (hasInvalidGropings) - throw new Error(`The amounts doesn't match with the grouping`); - - const params = { - orderFk: this.order.id, - items: filledRows - }; - this.$http.post(`OrderRows/addToOrder`, params) - .then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.hide(); - if (this.card) this.card.reload(); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } - return true; - } -} - -ngModule.vnComponent('vnOrderPricesPopover', { - slotTemplate: require('./index.html'), - controller: Controller, - bindings: { - order: '<' - }, - require: { - card: '?^vnOrderCard' - } -}); diff --git a/modules/order/front/prices-popover/index.spec.js b/modules/order/front/prices-popover/index.spec.js deleted file mode 100644 index 734a9e254..000000000 --- a/modules/order/front/prices-popover/index.spec.js +++ /dev/null @@ -1,171 +0,0 @@ -import './index.js'; - -describe('Order', () => { - describe('Component vnOrderPricesPopover', () => { - let controller; - let $httpBackend; - let orderId = 16; - - beforeEach(ngModule('order')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - const $scope = $rootScope.$new(); - const $element = angular.element(''); - const $transclude = { - $$boundTransclude: { - $$slots: [] - } - }; - controller = $componentController('vnOrderPricesPopover', {$element, $scope, $transclude}); - controller._prices = [ - {warehouseFk: 1, grouping: 10, quantity: 0}, - {warehouseFk: 1, grouping: 100, quantity: 100} - ]; - controller.item = {available: 1000}; - controller.maxQuantity = 1000; - controller.order = {id: orderId}; - })); - - describe('prices() setter', () => { - it('should call to the getTotalQuantity() method', () => { - controller.getTotalQuantity = jest.fn(); - - controller.prices = [ - {grouping: 10, quantity: 0}, - {grouping: 100, quantity: 0}, - {grouping: 1000, quantity: 0}, - ]; - - expect(controller.getTotalQuantity).toHaveBeenCalledWith(); - }); - }); - - describe('getTotalQuantity()', () => { - it('should set the totalQuantity property', () => { - controller.getTotalQuantity(); - - expect(controller.totalQuantity).toEqual(100); - }); - }); - - describe('addQuantity()', () => { - it('should call to the getTotalQuantity() method and NOT set the quantity property', () => { - jest.spyOn(controller, 'getTotalQuantity'); - - controller.prices = [ - {grouping: 10, quantity: 0}, - {grouping: 100, quantity: 0}, - {grouping: 1000, quantity: 1000}, - ]; - - const oneThousandGrouping = controller.prices[2]; - - expect(oneThousandGrouping.quantity).toEqual(1000); - - controller.addQuantity(oneThousandGrouping); - - expect(controller.getTotalQuantity).toHaveBeenCalledWith(); - expect(oneThousandGrouping.quantity).toEqual(1000); - }); - - it('should call to the getTotalQuantity() method and then set the quantity property', () => { - jest.spyOn(controller, 'getTotalQuantity'); - - const oneHandredGrouping = controller.prices[1]; - controller.addQuantity(oneHandredGrouping); - - expect(controller.getTotalQuantity).toHaveBeenCalledWith(); - expect(oneHandredGrouping.quantity).toEqual(200); - }); - }); - - describe('getGroupings()', () => { - it('should return a row with the total filled quantity', () => { - jest.spyOn(controller, 'getTotalQuantity'); - - controller.prices = [ - {warehouseFk: 1, grouping: 10, quantity: 10}, - {warehouseFk: 1, grouping: 100, quantity: 100}, - {warehouseFk: 1, grouping: 1000, quantity: 1000}, - ]; - - const rows = controller.getGroupings(); - const firstRow = rows[0]; - - expect(rows.length).toEqual(1); - expect(firstRow.quantity).toEqual(1110); - }); - - it('should return two filled rows with a quantity', () => { - jest.spyOn(controller, 'getTotalQuantity'); - - controller.prices = [ - {warehouseFk: 1, grouping: 10, quantity: 10}, - {warehouseFk: 2, grouping: 10, quantity: 10}, - {warehouseFk: 1, grouping: 100, quantity: 0}, - {warehouseFk: 1, grouping: 1000, quantity: 1000}, - ]; - - const rows = controller.getGroupings(); - const firstRow = rows[0]; - const secondRow = rows[1]; - - expect(rows.length).toEqual(2); - expect(firstRow.quantity).toEqual(1010); - expect(secondRow.quantity).toEqual(10); - }); - }); - - describe('submit()', () => { - it('should throw an error if none of the rows contains a quantity', () => { - jest.spyOn(controller, 'getTotalQuantity'); - jest.spyOn(controller.vnApp, 'showError'); - - controller.prices = [ - {warehouseFk: 1, grouping: 10, quantity: 0}, - {warehouseFk: 1, grouping: 100, quantity: 0} - ]; - - controller.submit(); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`First you must add some quantity`); - }); - - it(`should throw an error if the quantity doesn't match the grouping value`, () => { - jest.spyOn(controller, 'getTotalQuantity'); - jest.spyOn(controller.vnApp, 'showError'); - - controller.prices = [ - {warehouseFk: 1, grouping: 10, quantity: 0}, - {warehouseFk: 1, grouping: 100, quantity: 1101} - ]; - - controller.submit(); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`The amounts doesn't match with the grouping`); - }); - - it('should should make an http query and then show a success message', () => { - jest.spyOn(controller, 'getTotalQuantity'); - jest.spyOn(controller.vnApp, 'showSuccess'); - - controller.prices = [ - {warehouseFk: 1, grouping: 10, quantity: 0}, - {warehouseFk: 1, grouping: 100, quantity: 100} - ]; - - const params = { - orderFk: orderId, - items: [{warehouseFk: 1, grouping: 100, quantity: 100}] - }; - - $httpBackend.expectPOST('OrderRows/addToOrder', params).respond(200); - controller.submit(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith(`Data saved!`); - }); - }); - }); -}); diff --git a/modules/order/front/prices-popover/locale/es.yml b/modules/order/front/prices-popover/locale/es.yml deleted file mode 100644 index 27eac802d..000000000 --- a/modules/order/front/prices-popover/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Qty.: Cant. -First you must add some quantity: Primero debes agregar alguna cantidad -The amounts doesn't match with the grouping: Las cantidades no coinciden con el grouping \ No newline at end of file diff --git a/modules/order/front/prices-popover/style.scss b/modules/order/front/prices-popover/style.scss deleted file mode 100644 index deaeab044..000000000 --- a/modules/order/front/prices-popover/style.scss +++ /dev/null @@ -1,18 +0,0 @@ -@import "variables"; - -.vn-order-prices-popover .content { - .prices { - vn-table { - .price-kg { - color: $color-font-secondary; - font-size: .75rem - } - .vn-input-number { - width: 80px; - } - } - .footer { - text-align: center; - } - } -} \ No newline at end of file diff --git a/modules/order/front/routes.json b/modules/order/front/routes.json index 2eeb60553..25c68300f 100644 --- a/modules/order/front/routes.json +++ b/modules/order/front/routes.json @@ -28,19 +28,19 @@ "abstract": true, "component": "vn-order", "description": "Orders" - }, + }, { "url": "/index?q", "state": "order.index", "component": "vn-order-index", "description": "Orders" - }, + }, { "url": "/:id", "state": "order.card", "abstract": true, "component": "vn-order-card" - }, + }, { "url": "/summary", "state": "order.card.summary", @@ -49,48 +49,6 @@ "params": { "order": "$ctrl.order" } - }, - { - "url": "/catalog?q&categoryId&typeId&tagGroups", - "state": "order.card.catalog", - "component": "vn-order-catalog", - "description": "Catalog", - "params": { - "order": "$ctrl.order" - } - }, - { - "url": "/volume", - "state": "order.card.volume", - "component": "vn-order-volume", - "description": "Volume", - "params": { - "order": "$ctrl.order" - } - }, - { - "url": "/line", - "state": "order.card.line", - "component": "vn-order-line", - "description": "Lines", - "params": { - "order": "$ctrl.order" - } - }, - { - "url": "/create?clientFk", - "state": "order.create", - "component": "vn-order-create", - "description": "New order" - }, - { - "url": "/basic-data", - "state": "order.card.basicData", - "component": "vn-order-basic-data", - "description": "Basic data", - "params": { - "order": "$ctrl.order" - } } ] -} \ No newline at end of file +} diff --git a/modules/order/front/search-panel/index.html b/modules/order/front/search-panel/index.html deleted file mode 100644 index 001fc0bcb..000000000 --- a/modules/order/front/search-panel/index.html +++ /dev/null @@ -1,86 +0,0 @@ -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/modules/order/front/search-panel/index.js b/modules/order/front/search-panel/index.js deleted file mode 100644 index 07be9ca24..000000000 --- a/modules/order/front/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.vnComponent('vnOrderSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/order/front/search-panel/locale/es.yml b/modules/order/front/search-panel/locale/es.yml deleted file mode 100644 index 9801e151f..000000000 --- a/modules/order/front/search-panel/locale/es.yml +++ /dev/null @@ -1,11 +0,0 @@ -Order id: Id cesta -Client id: Id cliente -From landed: Desde f. entrega -To landed: Hasta f. entrega -To: Hasta -Agency: Agencia -Application: Aplicación -SalesPerson: Comercial -Order confirmed: Pedido confirmado -Show empty: Mostrar vacías -Search orders by ticket id: Buscar pedido por id ticket \ No newline at end of file diff --git a/modules/order/front/summary/index.html b/modules/order/front/summary/index.html deleted file mode 100644 index 218359992..000000000 --- a/modules/order/front/summary/index.html +++ /dev/null @@ -1,131 +0,0 @@ - -
- - - - - Basket #{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}} - ({{$ctrl.summary.client.id}}) - - - -
- - - - - - - {{$ctrl.summary.address.nickname}} - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Subtotal {{$ctrl.summary.subTotal | currency: 'EUR':2}}

-

VAT {{$ctrl.summary.VAT | currency: 'EUR':2}}

-

Total {{$ctrl.summary.total | currency: 'EUR':2}}

-
- - - - - - Item - Description - Quantity - Price - Amount - - - - - - - - - - - - {{::row.itemFk}} - - - -
- {{::row.item.name}} - -

{{::row.item.subName}}

-
-
- - -
- {{::row.quantity}} - {{::row.price | currency: 'EUR':2}} - {{::row.quantity * row.price | currency: 'EUR':2}} -
-
- -
-
-
- - - - diff --git a/modules/order/front/summary/index.js b/modules/order/front/summary/index.js deleted file mode 100644 index cc1df8f5d..000000000 --- a/modules/order/front/summary/index.js +++ /dev/null @@ -1,41 +0,0 @@ -import ngModule from '../module'; -import Summary from 'salix/components/summary'; -import './style.scss'; - -class Controller extends Summary { - setSummary() { - this.$http.get(`Orders/${this.order.id}/summary`) - .then(res => this.summary = res.data); - } - - get formattedAddress() { - if (!this.summary) return null; - - let address = this.summary.address; - let province = address.province ? `(${address.province.name})` : ''; - - return `${address.street} - ${address.city} ${province}`; - } - - $onChanges() { - if (this.order && this.order.id) - this.setSummary(); - } - - save() { - this.$http.post(`Orders/${this.order.id}/confirm`).then(() => { - this.vnApp.showSuccess(this.$t('Order confirmed')); - this.$state.go(`ticket.index`, { - q: JSON.stringify({clientFk: this.order.clientFk}) - }); - }); - } -} - -ngModule.vnComponent('vnOrderSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - order: '<' - } -}); diff --git a/modules/order/front/summary/index.spec.js b/modules/order/front/summary/index.spec.js deleted file mode 100644 index 0c04593e1..000000000 --- a/modules/order/front/summary/index.spec.js +++ /dev/null @@ -1,47 +0,0 @@ -import './index'; - -describe('Order', () => { - describe('Component vnOrderSummary', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('order')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - const $element = angular.element(''); - controller = $componentController('vnOrderSummary', {$element}); - controller.order = {id: 1}; - })); - - describe('getSummary()', () => { - it('should now perform a GET query and define the summary property', () => { - let res = { - id: 1, - nickname: 'Batman' - }; - $httpBackend.expectGET(`Orders/1/summary`).respond(res); - controller.setSummary(); - $httpBackend.flush(); - - expect(controller.summary).toEqual(res); - }); - }); - - describe('formattedAddress()', () => { - it('should return a full fromatted address with city and province', () => { - controller.summary = { - address: { - province: { - name: 'Gotham' - }, - street: '1007 Mountain Drive', - city: 'Gotham' - } - }; - - expect(controller.formattedAddress).toEqual('1007 Mountain Drive - Gotham (Gotham)'); - }); - }); - }); -}); diff --git a/modules/order/front/summary/style.scss b/modules/order/front/summary/style.scss deleted file mode 100644 index a2537c58f..000000000 --- a/modules/order/front/summary/style.scss +++ /dev/null @@ -1,20 +0,0 @@ -@import "./variables"; - -vn-order-summary .summary{ - max-width: $width-lg; - - & > vn-horizontal > vn-one { - min-width: 160px; - - &.taxes { - border: $border-thin-light; - text-align: right; - padding: 8px; - - & > p { - font-size: 1.2rem; - margin: 3px; - } - } - } -} \ No newline at end of file diff --git a/modules/order/front/volume/index.html b/modules/order/front/volume/index.html deleted file mode 100644 index e0053f9ed..000000000 --- a/modules/order/front/volume/index.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - Item - Description - Quantity - m³ per quantity - - - - - - - {{::row.itemFk}} - - - -
- {{::row.item.name}} - -

{{::row.item.subName}}

-
-
- - -
- {{::row.quantity}} - {{::row.volume | number:3}} -
-
-
-
-
- - - diff --git a/modules/order/front/volume/index.js b/modules/order/front/volume/index.js deleted file mode 100644 index c1bc5ec7d..000000000 --- a/modules/order/front/volume/index.js +++ /dev/null @@ -1,37 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.filter = { - include: { - relation: 'item' - }, - order: 'itemFk' - }; - this.order = {}; - this.ticketVolumes = []; - } - - onDataChange() { - this.$http.get(`Orders/${this.$params.id}/getVolumes`) - .then(res => { - this.$.model.data.forEach(order => { - res.data.volumes.forEach(volume => { - if (order.itemFk === volume.itemFk) - order.volume = volume.volume; - }); - }); - }); - } -} - -ngModule.vnComponent('vnOrderVolume', { - template: require('./index.html'), - controller: Controller, - bindings: { - order: '<' - } -}); diff --git a/modules/order/front/volume/index.spec.js b/modules/order/front/volume/index.spec.js deleted file mode 100644 index 6d7b18865..000000000 --- a/modules/order/front/volume/index.spec.js +++ /dev/null @@ -1,42 +0,0 @@ -import './index'; - -describe('Order', () => { - describe('Component vnOrderVolume', () => { - let controller; - let $httpBackend; - let $scope; - - beforeEach(ngModule('order')); - - beforeEach(inject(($componentController, $state, _$httpBackend_, $rootScope) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - $scope.model = { - data: [ - {itemFk: 1}, - {itemFk: 2} - ] - }; - - $state.params.id = 1; - const $element = angular.element(''); - controller = $componentController('vnOrderVolume', {$element, $scope}); - })); - - it('should join the sale volumes to its respective sale', () => { - let response = { - volumes: [ - {itemFk: 1, volume: 0.008}, - {itemFk: 2, volume: 0.003} - ] - }; - - $httpBackend.expectGET(`Orders/1/getVolumes`).respond(response); - controller.onDataChange(); - $httpBackend.flush(); - - expect(controller.$.model.data[0].volume).toBe(0.008); - expect(controller.$.model.data[1].volume).toBe(0.003); - }); - }); -}); diff --git a/modules/order/front/volume/style.scss b/modules/order/front/volume/style.scss deleted file mode 100644 index da13eca0d..000000000 --- a/modules/order/front/volume/style.scss +++ /dev/null @@ -1,12 +0,0 @@ - -@import "./variables"; - -vn-order-volume { - .header { - text-align: right; - - & > div { - margin-bottom: $spacing-xs; - } - } -} diff --git a/modules/route/back/locale/routesMonitor/en.yml b/modules/route/back/locale/routesMonitor/en.yml index 8908ee636..c28c5cb4d 100644 --- a/modules/route/back/locale/routesMonitor/en.yml +++ b/modules/route/back/locale/routesMonitor/en.yml @@ -13,7 +13,6 @@ columns: m3: m3 priority: priority etd: etd - expeditionTruckFk: truck m3boxes: m3 boxes bufferFk: buffer - isPickingAllowed: is picking allowed \ No newline at end of file + isPickingAllowed: is picking allowed diff --git a/modules/route/back/locale/routesMonitor/es.yml b/modules/route/back/locale/routesMonitor/es.yml index 9ded8983d..a8e807626 100644 --- a/modules/route/back/locale/routesMonitor/es.yml +++ b/modules/route/back/locale/routesMonitor/es.yml @@ -13,7 +13,6 @@ columns: m3: m3 priority: prioridad etd: etd - expeditionTruckFk: camión m3boxes: m3 cajas bufferFk: buffer - isPickingAllowed: está permitido recoger \ No newline at end of file + isPickingAllowed: está permitido recoger diff --git a/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js b/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js index d3a0755ef..24ffa9cd7 100644 --- a/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js +++ b/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js @@ -1,21 +1,7 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('AgencyTerm createInvoiceIn()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + const ctx = beforeAll.getCtx(); const rows = [ { routeFk: 2, diff --git a/modules/route/back/methods/roadmap/clone.js b/modules/route/back/methods/roadmap/clone.js index b74cf803c..5f1ab9229 100644 --- a/modules/route/back/methods/roadmap/clone.js +++ b/modules/route/back/methods/roadmap/clone.js @@ -37,17 +37,12 @@ module.exports = Self => { fields: [ 'id', 'name', - 'tractorPlate', - 'trailerPlate', - 'phone', 'supplierFk', - 'etd', - 'observations', - 'price'], + 'etd'], include: [{ - relation: 'expeditionTruck', + relation: 'roadmapStop', scope: { - fields: ['roadmapFk', 'warehouseFk', 'eta', 'description'] + fields: ['roadmapFk', 'addressFk', 'eta', 'description'] } }] diff --git a/modules/route/back/methods/roadmapStop/getPalletMatchState.js b/modules/route/back/methods/roadmapStop/getPalletMatchState.js new file mode 100644 index 000000000..f47669993 --- /dev/null +++ b/modules/route/back/methods/roadmapStop/getPalletMatchState.js @@ -0,0 +1,62 @@ +module.exports = Self => { + Self.remoteMethod('getPalletMatchState', { + description: 'Get list of pallet from truckFk with true or false if state is matched', + accessType: 'WRITE', + accepts: [{ + arg: 'truckFk', + type: 'number', + required: true, + description: 'The truckFk id' + }, + { + arg: 'state', + type: 'string', + required: true, + description: 'State code' + }], + returns: { + type: 'object', + root: true + }, + http: { + path: `/getPalletMatchState`, + verb: 'GET' + } + }); + + Self.getPalletMatchState = async(truckFk, state, options) => { + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const result = await Self.rawSql(` + WITH tPallet AS( + SELECT ep.id pallet, e.id expedition, e.stateTypeFk + FROM vn.expeditionPallet ep + JOIN vn.expeditionScan es ON es.palletFk = ep.id + JOIN expedition e ON e.id = es.expeditionFk + WHERE ep.truckFk = ? + ),totalPalletExpedition AS( + SELECT t.*, COUNT(expedition) totalPalletExpedition + FROM tPallet t + GROUP BY expedition + ),totalPalletExpeditionCode AS( + SELECT t.*, COUNT(expedition) totalPalletExpeditionCode + FROM tPallet t + JOIN vn.expeditionStateType est ON est.id = t.stateTypeFk + WHERE code = ? + GROUP BY expedition + ) + SELECT t.pallet, + tpe.totalPalletExpedition = tpec.totalPalletExpeditionCode hasMatchStateCode + FROM tPallet t + LEFT JOIN totalPalletExpedition tpe ON tpe.expedition = t.expedition + LEFT JOIN totalPalletExpeditionCode tpec ON tpec.expedition = t.expedition + GROUP BY t.pallet;`, + [truckFk, state], + myOptions); + + return result; + }; +}; diff --git a/modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js b/modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js new file mode 100644 index 000000000..3152f666d --- /dev/null +++ b/modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js @@ -0,0 +1,11 @@ +const {models} = require('vn-loopback/server/server'); + +describe('roadMapStop getPalletMatchState()', () => { + it('should return list of pallet with true or false if state is matched', async() => { + const truckFk = 1; + const state = 'ON DELIVERY'; + const result = await models.RoadmapStop.getPalletMatchState(truckFk, state); + + expect(result[0].hasMatchStateCode).toBe(1); + }); +}); diff --git a/modules/route/back/methods/route/getExternalCmrs.js b/modules/route/back/methods/route/cmrs.js similarity index 84% rename from modules/route/back/methods/route/getExternalCmrs.js rename to modules/route/back/methods/route/cmrs.js index 89536f50a..6f271a4cf 100644 --- a/modules/route/back/methods/route/getExternalCmrs.js +++ b/modules/route/back/methods/route/cmrs.js @@ -3,8 +3,8 @@ const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; module.exports = Self => { - Self.remoteMethod('getExternalCmrs', { - description: 'Returns an array of external cmrs', + Self.remoteMethod('cmrs', { + description: 'Returns an array of cmrs', accessType: 'READ', accepts: [ { @@ -47,37 +47,25 @@ module.exports = Self => { type: 'date', description: 'The to date filter', }, + { + arg: 'warehouseFk', + type: 'integer', + } ], returns: { type: ['object'], root: true }, http: { - path: `/getExternalCmrs`, + path: `/cmrs`, verb: 'GET' } }); - Self.getExternalCmrs = async( - filter, - cmrFk, - ticketFk, - routeFk, - country, - clientFk, - hasCmrDms, - shipped, - options + Self.cmrs = async( + filter, cmrFk, ticketFk, routeFk, country, clientFk, hasCmrDms, shipped, warehouseFk, options ) => { - const params = { - cmrFk, - ticketFk, - routeFk, - country, - clientFk, - hasCmrDms, - shipped, - }; + const params = {cmrFk, ticketFk, routeFk, country, clientFk, hasCmrDms, warehouseFk, shipped}; const conn = Self.dataSource.connector; let where = buildFilter(params, (param, value) => { @@ -103,10 +91,13 @@ module.exports = Self => { SELECT t.cmrFk, t.id ticketFk, t.routeFk, - co.name country, + co.id countryFk, + co.name countryName, t.clientFk, IF(sub.id, TRUE, FALSE) hasCmrDms, - DATE(t.shipped) shipped + DATE(t.shipped) shipped, + t.warehouseFk, + w.name warehouseName FROM ticket t JOIN ticketState ts ON ts.ticketFk = t.id JOIN state s ON s.id = ts.stateFk @@ -124,8 +115,7 @@ module.exports = Self => { JOIN dmsType dt ON dt.id = d.dmsTypeFk WHERE dt.name = 'cmr' ) sub ON sub.ticketFk = t.id - WHERE co.code <> 'ES' - AND am.name <> 'ABONO' + WHERE am.name <> 'ABONO' AND w.code = 'ALG' AND t.cmrFk ) sub diff --git a/modules/route/back/methods/route/downloadCmrsZip.js b/modules/route/back/methods/route/downloadCmrsZip.js index c6934edca..895ff7a16 100644 --- a/modules/route/back/methods/route/downloadCmrsZip.js +++ b/modules/route/back/methods/route/downloadCmrsZip.js @@ -41,14 +41,16 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - ids = ids.split(','); - - for (const id of ids) { + const downloadAddZip = async id => { ctx.args = ctx.args || {}; ctx.args.id = Number(id); const [data] = await models.Route.cmr(ctx, myOptions); zip.file(`${id}.pdf`, data, {binary: true}); - } + }; + + ids = ids.split(','); + const promises = ids.map(id => downloadAddZip(id)); + await Promise.all(promises); const zipStream = zip.generateNodeStream({streamFiles: true}); return [zipStream, 'application/zip', `filename="cmrs.zip"`]; }; diff --git a/modules/route/back/methods/route/filter.js b/modules/route/back/methods/route/filter.js index 5b13a9004..925927cc8 100644 --- a/modules/route/back/methods/route/filter.js +++ b/modules/route/back/methods/route/filter.js @@ -91,25 +91,20 @@ module.exports = Self => { let where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': - return {'r.id': value}; + return {'id': value}; case 'from': - return {'r.created': {gte: value}}; + return {'created': {gte: value}}; case 'to': - return {'r.created': {lte: value}}; - case 'm3': - return {'r.m3': value}; + return {'created': {lte: value}}; case 'description': - return {'r.description': {like: `%${value}%`}}; + return {'description': {like: `%${value}%`}}; + case 'isOk': + case 'm3': case 'warehouseFk': - param = `v.${param}`; - return {[param]: value}; case 'workerFk': case 'vehicleFk': case 'agencyModeFk': - param = `r.${param}`; return {[param]: value}; - case 'isOk': - return {'r.isOk': value}; } }); @@ -119,34 +114,38 @@ module.exports = Self => { let stmt; stmt = new ParameterizedSQL( - `SELECT - r.id, - r.workerFk, - r.created, - r.vehicleFk, - r.agencyModeFk, - r.time, - r.isOk, - r.kmStart, - r.kmEnd, - r.started, - r.finished, - r.gestdocFk, - r.cost, - r.m3, - r.description, - am.name agencyName, - u.name AS workerUserName, - v.numberPlate AS vehiclePlateNumber, - Date_format(r.time, '%H:%i') hour, - eu.email - FROM route r - LEFT JOIN agencyMode am ON am.id = r.agencyModeFk - LEFT JOIN agency a ON a.id = am.agencyFk - LEFT JOIN vehicle v ON v.id = r.vehicleFk - LEFT JOIN worker w ON w.id = r.workerFk - LEFT JOIN account.user u ON u.id = w.id - LEFT JOIN account.emailUser eu ON eu.userFk = r.workerFk` + `SELECT * + FROM( + SELECT + r.id, + r.workerFk, + r.created, + r.vehicleFk, + r.agencyModeFk, + r.time, + r.isOk, + r.kmStart, + r.kmEnd, + r.started, + r.finished, + r.gestdocFk, + r.cost, + r.m3, + r.description, + am.name agencyName, + u.name workerUserName, + v.numberPlate vehiclePlateNumber, + Date_format(r.time, '%H:%i') hour, + eu.email, + v.warehouseFk + FROM route r + LEFT JOIN agencyMode am ON am.id = r.agencyModeFk + LEFT JOIN agency a ON a.id = am.agencyFk + LEFT JOIN vehicle v ON v.id = r.vehicleFk + LEFT JOIN worker w ON w.id = r.workerFk + LEFT JOIN account.user u ON u.id = w.id + LEFT JOIN account.emailUser eu ON eu.userFk = r.workerFk + ) sub` ); stmt.merge(conn.makeSuffix(filter)); diff --git a/modules/route/back/methods/route/getByWorker.js b/modules/route/back/methods/route/getByWorker.js index 9243cfbfb..5d1881c20 100644 --- a/modules/route/back/methods/route/getByWorker.js +++ b/modules/route/back/methods/route/getByWorker.js @@ -28,11 +28,11 @@ module.exports = Self => { if (canViewAll) { const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions); filterGrant = { - where: {'a.warehouseFk': userConfig.warehouseFk} + where: {'warehouseFk': userConfig.warehouseFk} }; } else { filterGrant = { - where: {'r.workerFk': userId} + where: {'workerFk': userId} }; } @@ -46,16 +46,16 @@ module.exports = Self => { and: [ { or: [ - {'r.created': currentDate}, - {'r.created': nextDay} + {'created': currentDate}, + {'created': nextDay} ] } ] }, order: [ - 'r.created ASC', - 'r.time ASC', - 'am.name ASC' + 'created ASC', + 'time ASC', + 'agencyName ASC' ] }; diff --git a/modules/route/back/methods/route/getExpeditionSummary.js b/modules/route/back/methods/route/getExpeditionSummary.js index 2bd2ca43a..afe54b030 100644 --- a/modules/route/back/methods/route/getExpeditionSummary.js +++ b/modules/route/back/methods/route/getExpeditionSummary.js @@ -48,7 +48,7 @@ module.exports = Self => { LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk JOIN vn.agencyMode am ON am.id = r.agencyModeFk JOIN vn.agency ag ON ag.id = am.agencyFk - LEFT JOIN vn.userConfig uc ON uc.userFk = account.myUser_getId() + LEFT JOIN vn.userMultiConfig uc ON uc.userFk = account.myUser_getId() WHERE t.routeFk = ? GROUP BY t.addressFk, e.itemPackingTypeFk ) sub diff --git a/modules/route/back/methods/route/specs/clone.spec.js b/modules/route/back/methods/route/specs/clone.spec.js index 496ae1c89..a064e35ba 100644 --- a/modules/route/back/methods/route/specs/clone.spec.js +++ b/modules/route/back/methods/route/specs/clone.spec.js @@ -1,21 +1,7 @@ const app = require('vn-loopback/server/server'); -const LoopBackContext = require('loopback-context'); describe('route clone()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); const createdDate = Date.vnNew(); it('should throw an error if the amount of ids pased to the clone function do no match the database', async() => { diff --git a/modules/route/back/methods/route/specs/guessPriority.spec.js b/modules/route/back/methods/route/specs/guessPriority.spec.js index 902647ba1..522801f43 100644 --- a/modules/route/back/methods/route/specs/guessPriority.spec.js +++ b/modules/route/back/methods/route/specs/guessPriority.spec.js @@ -1,20 +1,9 @@ const app = require('vn-loopback/server/server'); -const LoopBackContext = require('loopback-context'); describe('route guessPriority()', () => { const targetRouteId = 7; let routeTicketsToRestore; - - const activeCtx = { - accessToken: {userId: 9}, - __: () => {} - }; - - beforeAll(() => { - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + const ctx = beforeAll.getCtx(); afterAll(async() => { let restoreFixtures = []; @@ -25,9 +14,6 @@ describe('route guessPriority()', () => { }); it('should call guessPriority() then check all tickets in that route have their priorities defined', async() => { - const ctx = { - req: activeCtx - }; routeTicketsToRestore = await app.models.Ticket.find({where: {routeFk: targetRouteId}}); await app.models.Route.guessPriority(ctx, targetRouteId); diff --git a/modules/route/back/methods/route/specs/updateWorkCenter.spec.js b/modules/route/back/methods/route/specs/updateWorkCenter.spec.js index a1c716299..b4b9253f8 100644 --- a/modules/route/back/methods/route/specs/updateWorkCenter.spec.js +++ b/modules/route/back/methods/route/specs/updateWorkCenter.spec.js @@ -1,20 +1,7 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('route updateWorkCenter()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); const routeId = 1; it('should set the commission work center if the worker has workCenter', async() => { diff --git a/modules/route/back/model-config.json b/modules/route/back/model-config.json index 09cda6b2d..ccae87bd9 100644 --- a/modules/route/back/model-config.json +++ b/modules/route/back/model-config.json @@ -8,6 +8,9 @@ "DeliveryPoint": { "dataSource": "vn" }, + "RoadmapAddress": { + "dataSource": "vn" + }, "RoadmapStop": { "dataSource": "vn" }, diff --git a/modules/route/back/models/roadmap.json b/modules/route/back/models/roadmap.json index 01572d718..1434b1602 100644 --- a/modules/route/back/models/roadmap.json +++ b/modules/route/back/models/roadmap.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "roadmap" + "table": "roadmap" } }, "properties": { @@ -41,10 +41,22 @@ }, "driverName": { "type": "string" + }, + "kmStart": { + "type": "number" + }, + "kmEnd": { + "type": "number" + }, + "started": { + "type": "date" + }, + "finished": { + "type": "date" } }, - "relations": { - "worker": { + "relations": { + "worker": { "type": "belongsTo", "model": "Worker", "foreignKey": "id" @@ -59,5 +71,5 @@ "model": "RoadmapStop", "foreignKey": "roadmapFk" } - } + } } diff --git a/modules/route/back/models/roadmapAddress.json b/modules/route/back/models/roadmapAddress.json new file mode 100644 index 000000000..0241ce0d8 --- /dev/null +++ b/modules/route/back/models/roadmapAddress.json @@ -0,0 +1,26 @@ +{ + "name": "RoadmapAddress", + "base": "VnModel", + "options": { + "mysql": { + "table": "roadmapAddress" + } + }, + "properties": { + "addressFk": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "isActive": { + "type": "number" + } + }, + "relations": { + "address": { + "type": "belongsTo", + "model": "Address", + "foreignKey": "addressFk" + } + } +} diff --git a/modules/route/back/models/roadmapStop.js b/modules/route/back/models/roadmapStop.js new file mode 100644 index 000000000..9e286776d --- /dev/null +++ b/modules/route/back/models/roadmapStop.js @@ -0,0 +1,3 @@ +module.exports = Self => { + require('../methods/roadmapStop/getPalletMatchState')(Self); +}; diff --git a/modules/route/back/models/roadmapStop.json b/modules/route/back/models/roadmapStop.json index 51aa3a6db..d34cee6e5 100644 --- a/modules/route/back/models/roadmapStop.json +++ b/modules/route/back/models/roadmapStop.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "roadmapStop" + "table": "roadmapStop" } }, "properties": { @@ -15,7 +15,7 @@ "roadmapFk": { "type": "number" }, - "warehouseFk": { + "addressFk": { "type": "number" }, "eta": { @@ -28,16 +28,16 @@ "type": "number" } }, - "relations": { - "roadmap": { + "relations": { + "roadmap": { "type": "belongsTo", "model": "Roadmap", "foreignKey": "roadmapFk" }, - "warehouse": { + "address": { "type": "belongsTo", - "model": "Warehouse", - "foreignKey": "warehouseFk" + "model": "RoadmapAddress", + "foreignKey": "addressFk" } - } + } } diff --git a/modules/route/back/models/route.js b/modules/route/back/models/route.js index bf1f26e74..242623d6e 100644 --- a/modules/route/back/models/route.js +++ b/modules/route/back/models/route.js @@ -15,26 +15,9 @@ module.exports = Self => { require('../methods/route/sendSms')(Self); require('../methods/route/downloadZip')(Self); require('../methods/route/cmr')(Self); - require('../methods/route/getExternalCmrs')(Self); + require('../methods/route/cmrs')(Self); require('../methods/route/downloadCmrsZip')(Self); require('../methods/route/cmrEmail')(Self); require('../methods/route/getExpeditionSummary')(Self); require('../methods/route/getByWorker')(Self); - - Self.validate('kmStart', validateDistance, { - message: 'Distance must be lesser than 4000' - }); - - Self.validate('kmEnd', validateDistance, { - message: 'Distance must be lesser than 4000' - }); - - function validateDistance(err) { - if (this.kmEnd) { - const routeTotalKm = this.kmEnd - this.kmStart; - const routeMaxKm = 4000; - if (routeTotalKm > routeMaxKm || this.kmStart > this.kmEnd) - err(); - } - } }; diff --git a/modules/route/back/models/routesMonitor.json b/modules/route/back/models/routesMonitor.json index 122026336..c5fe4c1ce 100644 --- a/modules/route/back/models/routesMonitor.json +++ b/modules/route/back/models/routesMonitor.json @@ -48,7 +48,7 @@ "priority": { "type": "number" }, - "expeditionTruckFk": { + "roadmapStopFk": { "type": "number" }, "m3boxes": { diff --git a/modules/route/front/agency-term-search-panel/index.html b/modules/route/front/agency-term-search-panel/index.html deleted file mode 100644 index fdd6b649b..000000000 --- a/modules/route/front/agency-term-search-panel/index.html +++ /dev/null @@ -1,52 +0,0 @@ -
- - -
- - - - - - - - - - -
- - - - - - -
- - - -
-
diff --git a/modules/route/front/agency-term-search-panel/index.js b/modules/route/front/agency-term-search-panel/index.js deleted file mode 100644 index d5d8ea7a6..000000000 --- a/modules/route/front/agency-term-search-panel/index.js +++ /dev/null @@ -1,17 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -class Controller extends SearchPanel { - get filter() { - return this.$.filter; - } - - set filter(value = {}) { - this.$.filter = value; - } -} - -ngModule.vnComponent('vnAgencyTermSearchPanel', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/route/front/agency-term-search-panel/locale/es.yml b/modules/route/front/agency-term-search-panel/locale/es.yml deleted file mode 100644 index 74336a03b..000000000 --- a/modules/route/front/agency-term-search-panel/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Search by invoiceIn id or autonomous name: Buscar por id de recibida o por nombre de autónomo -Search autonomous: Buscar autónomos \ No newline at end of file diff --git a/modules/route/front/agency-term/createInvoiceIn/index.html b/modules/route/front/agency-term/createInvoiceIn/index.html deleted file mode 100644 index 8f270378f..000000000 --- a/modules/route/front/agency-term/createInvoiceIn/index.html +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/modules/route/front/agency-term/createInvoiceIn/index.js b/modules/route/front/agency-term/createInvoiceIn/index.js deleted file mode 100644 index 0198ab80f..000000000 --- a/modules/route/front/agency-term/createInvoiceIn/index.js +++ /dev/null @@ -1,120 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; -import UserError from 'core/lib/user-error'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.dms = { - files: [], - hasFile: false, - hasFileAttached: false - }; - } - - get route() { - return this._route; - } - - set route(value) { - this._route = value; - - this.setDefaultParams(); - this.getAllowedContentTypes(); - } - - $onChanges() { - if (this.$params && this.$params.q) - this.params = JSON.parse(this.$params.q); - } - - getAllowedContentTypes() { - this.$http.get('DmsContainers/allowedContentTypes').then(res => { - const contentTypes = res.data.join(', '); - this.allowedContentTypes = contentTypes; - }); - } - - get contentTypesInfo() { - return this.$t('ContentTypesInfo', { - allowedContentTypes: this.allowedContentTypes - }); - } - - setDefaultParams() { - const params = {filter: { - where: {code: 'invoiceIn'} - }}; - this.$http.get('DmsTypes/findOne', {params}).then(res => { - const dmsType = res.data && res.data; - const companyId = this.vnConfig.companyFk; - const warehouseId = this.vnConfig.warehouseFk; - const defaultParams = { - warehouseId: warehouseId, - companyId: companyId, - dmsTypeId: dmsType.id, - description: this.params.supplierName - }; - - this.dms = Object.assign(this.dms, defaultParams); - }); - } - - onSubmit() { - if (this.dms.files.length > 1) throw new UserError('You cannot attach more than one document'); - const query = `dms/uploadFile`; - const options = { - method: 'POST', - url: query, - params: this.dms, - headers: { - 'Content-Type': undefined - }, - transformRequest: files => { - const formData = new FormData(); - formData.append(files[0].name, files[0]); - return formData; - }, - data: this.dms.files - }; - this.$http(options).then(res => { - if (res) { - const addedDms = res.data; - this.$.watcher.updateOriginalData(); - - const params = { - rows: this.params.rows, - dms: addedDms - }; - - this.$http.post('AgencyTerms/createInvoiceIn', params) - .then(() => { - this.$state.go('route.agencyTerm.index'); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - }); - } - - onFileChange(files) { - let hasFileAttached = false; - - if (files.length > 0) - hasFileAttached = true; - - this.$.$applyAsync(() => { - this.dms.hasFileAttached = hasFileAttached; - }); - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnAgencyTermCreateInvoiceIn', { - template: require('./index.html'), - controller: Controller, - bindings: { - route: '<' - } -}); diff --git a/modules/route/front/agency-term/createInvoiceIn/index.spec.js b/modules/route/front/agency-term/createInvoiceIn/index.spec.js deleted file mode 100644 index d6d9883a7..000000000 --- a/modules/route/front/agency-term/createInvoiceIn/index.spec.js +++ /dev/null @@ -1,107 +0,0 @@ -import './index'; -import watcher from 'core/mocks/watcher.js'; - -describe('AgencyTerm', () => { - describe('Component vnAgencyTermCreateInvoiceIn', () => { - let controller; - let $scope; - let $httpBackend; - let $httpParamSerializer; - - beforeEach(ngModule('route')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { - $scope = $rootScope.$new(); - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - const $element = angular.element(''); - controller = $componentController('vnAgencyTermCreateInvoiceIn', {$element}); - controller._route = { - id: 1 - }; - })); - - describe('$onChanges()', () => { - it('should update the params data when $params.q is defined', () => { - controller.$params = {q: '{"supplierName": "Plants SL","rows": null}'}; - - const params = {q: '{"supplierName": "Plants SL", "rows": null}'}; - const json = JSON.parse(params.q); - - controller.$onChanges(); - - expect(controller.params).toEqual(json); - }); - }); - - describe('route() setter', () => { - it('should set the ticket data and then call setDefaultParams() and getAllowedContentTypes()', () => { - jest.spyOn(controller, 'setDefaultParams'); - jest.spyOn(controller, 'getAllowedContentTypes'); - controller.route = { - id: 1 - }; - - expect(controller.route).toBeDefined(); - expect(controller.setDefaultParams).toHaveBeenCalledWith(); - expect(controller.getAllowedContentTypes).toHaveBeenCalledWith(); - }); - }); - - describe('getAllowedContentTypes()', () => { - it('should make an HTTP GET request to get the allowed content types', () => { - const expectedResponse = ['image/png', 'image/jpg']; - $httpBackend.expect('GET', `DmsContainers/allowedContentTypes`).respond(expectedResponse); - controller.getAllowedContentTypes(); - $httpBackend.flush(); - - expect(controller.allowedContentTypes).toBeDefined(); - expect(controller.allowedContentTypes).toEqual('image/png, image/jpg'); - }); - }); - - describe('setDefaultParams()', () => { - it('should perform a GET query and define the dms property on controller', () => { - const params = {filter: { - where: {code: 'invoiceIn'} - }}; - const serializedParams = $httpParamSerializer(params); - $httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: 1, code: 'invoiceIn'}); - controller.params = {supplierName: 'Plants SL'}; - controller.setDefaultParams(); - $httpBackend.flush(); - - expect(controller.dms).toBeDefined(); - expect(controller.dms.dmsTypeId).toEqual(1); - }); - }); - - describe('onSubmit()', () => { - it('should make an HTTP POST request to save the form data', () => { - controller.$.watcher = watcher; - - jest.spyOn(controller.$.watcher, 'updateOriginalData'); - const files = [{id: 1, name: 'MyFile'}]; - controller.dms = {files}; - const serializedParams = $httpParamSerializer(controller.dms); - const query = `dms/uploadFile?${serializedParams}`; - controller.params = {rows: null}; - - $httpBackend.expect('POST', query).respond({}); - $httpBackend.expect('POST', 'AgencyTerms/createInvoiceIn').respond({}); - controller.onSubmit(); - $httpBackend.flush(); - }); - }); - - describe('onFileChange()', () => { - it('should set dms hasFileAttached property to true if has any files', () => { - const files = [{id: 1, name: 'MyFile'}]; - controller.onFileChange(files); - $scope.$apply(); - - expect(controller.dms.hasFileAttached).toBeTruthy(); - }); - }); - }); -}); diff --git a/modules/route/front/agency-term/createInvoiceIn/style.scss b/modules/route/front/agency-term/createInvoiceIn/style.scss deleted file mode 100644 index 73f136fc1..000000000 --- a/modules/route/front/agency-term/createInvoiceIn/style.scss +++ /dev/null @@ -1,7 +0,0 @@ -vn-ticket-request { - .vn-textfield { - margin: 0!important; - max-width: 100px; - } -} - diff --git a/modules/route/front/agency-term/index/index.html b/modules/route/front/agency-term/index/index.html deleted file mode 100644 index 0d8ea40e7..000000000 --- a/modules/route/front/agency-term/index/index.html +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - - - - -
-
-
Total
- - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - Id - - Date - - Agency route - - Agency Agreement - - Packages - - M3 - - Km - - Price - - Received - - Autonomous -
- - - - - {{::agencyTerm.routeFk}} - - {{::agencyTerm.created | date:'dd/MM/yyyy'}}{{::agencyTerm.agencyModeName | dashIfEmpty}}{{::agencyTerm.agencyAgreement | dashIfEmpty}}{{::agencyTerm.packages | dashIfEmpty}}{{::agencyTerm.m3 | dashIfEmpty}}{{::agencyTerm.kmTotal | dashIfEmpty}}{{::agencyTerm.price | dashIfEmpty}} - - {{::agencyTerm.invoiceInFk}} - - - - {{::agencyTerm.supplierName}} - - - - -
-
-
-
- - - - - - - - - - - - - -
- - - - -
diff --git a/modules/route/front/agency-term/index/index.js b/modules/route/front/agency-term/index/index.js deleted file mode 100644 index 6c3bafc9a..000000000 --- a/modules/route/front/agency-term/index/index.js +++ /dev/null @@ -1,121 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - - this.smartTableOptions = { - activeButtons: { - search: true - }, - columns: [ - { - field: 'agencyModeFk', - autocomplete: { - url: 'AgencyModes', - showField: 'name', - valueField: 'id' - } - }, - { - field: 'agencyFk', - autocomplete: { - url: 'Agencies', - showField: 'name', - valueField: 'id' - } - }, - { - field: 'supplierFk', - autocomplete: { - url: 'Suppliers', - showField: 'name', - valueField: 'name', - } - } - ] - }; - } - - exprBuilder(param, value) { - switch (param) { - case 'agencyModeFk': - return {'a.agencyModeFk': value}; - case 'supplierFk': - return {'a.supplierName': value}; - case 'routeFk': - return {'a.routeFk': value}; - case 'created': - case 'agencyFk': - case 'packages': - case 'm3': - case 'kmTotal': - case 'price': - case 'invoiceInFk': - return {[`a.${param}`]: value}; - } - } - - get checked() { - const agencyTerms = this.$.model.data || []; - const checkedAgencyTerms = []; - for (let agencyTerm of agencyTerms) { - if (agencyTerm.checked) - checkedAgencyTerms.push(agencyTerm); - } - - return checkedAgencyTerms; - } - - get totalChecked() { - return this.checked.length; - } - - get totalPrice() { - let totalPrice = 0; - - if (this.checked.length > 0) { - for (let agencyTerm of this.checked) - totalPrice += agencyTerm.price; - - return totalPrice; - } - - return totalPrice; - } - - preview(route) { - this.routeSelected = route; - this.$.summary.show(); - } - - createInvoiceIn() { - const rowsToCreateInvoiceIn = []; - const supplierFk = this.checked[0].supplierFk; - - for (let agencyTerm of this.checked) { - let hasSameSupplier = supplierFk == agencyTerm.supplierFk; - if (hasSameSupplier) { - rowsToCreateInvoiceIn.push({ - routeFk: agencyTerm.routeFk, - supplierFk: agencyTerm.supplierFk, - created: agencyTerm.created, - totalPrice: this.totalPrice}); - } else { - this.vnApp.showError(this.$t('Two autonomous cannot be counted at the same time')); - return false; - } - } - const params = JSON.stringify({ - supplierName: this.checked[0].supplierName, - rows: rowsToCreateInvoiceIn - }); - this.$state.go('route.agencyTerm.createInvoiceIn', {q: params}); - } -} - -ngModule.vnComponent('vnAgencyTermIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/route/front/agency-term/index/index.spec.js b/modules/route/front/agency-term/index/index.spec.js deleted file mode 100644 index 55c40daa5..000000000 --- a/modules/route/front/agency-term/index/index.spec.js +++ /dev/null @@ -1,94 +0,0 @@ -import './index.js'; -import crudModel from 'core/mocks/crud-model'; - -describe('AgencyTerm', () => { - describe('Component vnAgencyTermIndex', () => { - let controller; - let $window; - - beforeEach(ngModule('route')); - - beforeEach(inject(($componentController, _$window_) => { - $window = _$window_; - const $element = angular.element(''); - controller = $componentController('vnAgencyTermIndex', {$element}); - controller.$.model = crudModel; - controller.$.model.data = [ - {supplierFk: 1, totalPrice: null}, - {supplierFk: 1}, - {supplierFk: 2} - ]; - })); - - describe('checked() getter', () => { - it('should return the checked lines', () => { - const data = controller.$.model.data; - data[0].checked = true; - - const checkedRows = controller.checked; - - const firstCheckedRow = checkedRows[0]; - - expect(firstCheckedRow.supplierFk).toEqual(1); - }); - }); - - describe('totalCheked() getter', () => { - it('should return the total checked lines', () => { - const data = controller.$.model.data; - data[0].checked = true; - - const checkedRows = controller.totalChecked; - - expect(checkedRows).toEqual(1); - }); - }); - - describe('preview()', () => { - it('should show the summary dialog', () => { - controller.$.summary = {show: () => {}}; - jest.spyOn(controller.$.summary, 'show'); - - let event = new MouseEvent('click', { - view: $window, - bubbles: true, - cancelable: true - }); - const route = {id: 1}; - - controller.preview(event, route); - - expect(controller.$.summary.show).toHaveBeenCalledWith(); - }); - }); - - describe('createInvoiceIn()', () => { - it('should throw an error if more than one autonomous are checked', () => { - jest.spyOn(controller.vnApp, 'showError'); - const data = controller.$.model.data; - data[0].checked = true; - data[2].checked = true; - - controller.createInvoiceIn(); - - expect(controller.vnApp.showError).toHaveBeenCalled(); - }); - - it('should call the function go() on $state to go to the file management', () => { - jest.spyOn(controller.$state, 'go'); - const data = controller.$.model.data; - data[0].checked = true; - - controller.createInvoiceIn(); - - delete data[0].checked; - const params = JSON.stringify({ - supplierName: data[0].supplierName, - rows: [data[0]] - }); - - expect(controller.$state.go).toHaveBeenCalledWith('route.agencyTerm.createInvoiceIn', {q: params}); - }); - }); - }); -}); diff --git a/modules/route/front/agency-term/locale/es.yml b/modules/route/front/agency-term/locale/es.yml deleted file mode 100644 index 0f6797188..000000000 --- a/modules/route/front/agency-term/locale/es.yml +++ /dev/null @@ -1,5 +0,0 @@ -Agency route: Agencia ruta -Agency Agreement: Acuerdo agencia -Autonomous: Autónomos -Two autonomous cannot be counted at the same time: Dos autonónomos no pueden ser contabilizados al mismo tiempo -You cannot attach more than one document: No puedes adjuntar más de un documento \ No newline at end of file diff --git a/modules/route/front/basic-data/index.html b/modules/route/front/basic-data/index.html deleted file mode 100644 index 7f9aef0d0..000000000 --- a/modules/route/front/basic-data/index.html +++ /dev/null @@ -1,96 +0,0 @@ - - - -
- - - - - - {{::numberPlate}} - {{::name}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/route/front/basic-data/index.js b/modules/route/front/basic-data/index.js deleted file mode 100644 index f051e23c5..000000000 --- a/modules/route/front/basic-data/index.js +++ /dev/null @@ -1,28 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - $onInit() { - this.$http.post(`Vehicles/sorted`, {warehouseFk: this.vnConfig.warehouseFk}) - .then(res => { - this.vehicles = res.data; - }); - } - - onSubmit() { - this.$.watcher.submit().then(() => - this.card.reload() - ); - } -} - -ngModule.vnComponent('vnRouteBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - route: '<' - }, - require: { - card: '^vnRouteCard' - } -}); diff --git a/modules/route/front/basic-data/locale/es.yml b/modules/route/front/basic-data/locale/es.yml deleted file mode 100644 index 9dcacbe9a..000000000 --- a/modules/route/front/basic-data/locale/es.yml +++ /dev/null @@ -1,8 +0,0 @@ -Date finished: Fecha fin -Date started: Fecha inicio -Km start: Km de inicio -Km end: Km de fin -Description: Descripción -Hour started: Hora inicio -Hour finished: Hora fin -Is served: Se ha servido diff --git a/modules/route/front/card/index.html b/modules/route/front/card/index.html deleted file mode 100644 index 9e0ae4e8c..000000000 --- a/modules/route/front/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/route/front/card/index.js b/modules/route/front/card/index.js deleted file mode 100644 index 07b5a547c..000000000 --- a/modules/route/front/card/index.js +++ /dev/null @@ -1,71 +0,0 @@ -import ngModule from '../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - let filter = { - fields: [ - 'id', - 'workerFk', - 'agencyModeFk', - 'created', - 'm3', - 'warehouseFk', - 'description', - 'vehicleFk', - 'kmStart', - 'kmEnd', - 'started', - 'finished', - 'cost', - 'zoneFk', - 'isOk' - ], - include: [ - { - relation: 'agencyMode', - scope: { - fields: ['id', 'name'] - } - }, { - relation: 'vehicle', - scope: { - fields: ['id', 'm3'] - } - }, { - relation: 'zone', - scope: { - fields: ['id', 'name'] - } - }, - { - relation: 'worker', - scope: { - fields: ['id'], - include: { - relation: 'user', - scope: { - fields: ['id'], - include: { - relation: 'emailUser', - scope: { - fields: ['email'] - } - } - } - } - } - } - ] - }; - - this.$http.get(`Routes/${this.$params.id}`, {filter}) - .then(res => this.route = res.data); - } -} - -ngModule.vnComponent('vnRouteCard', { - template: require('./index.html'), - controller: Controller -}); - diff --git a/modules/route/front/create/index.html b/modules/route/front/create/index.html deleted file mode 100644 index de341220e..000000000 --- a/modules/route/front/create/index.html +++ /dev/null @@ -1,52 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/route/front/create/index.js b/modules/route/front/create/index.js deleted file mode 100644 index c81394c10..000000000 --- a/modules/route/front/create/index.js +++ /dev/null @@ -1,20 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onSubmit() { - this.$.watcher.submit().then( - res => { - this.$http.post(`Routes/${res.data.id}/updateWorkCenter`, null) - .then(() => { - this.$state.go('route.card.summary', {id: res.data.id}); - }); - } - ); - } -} - -ngModule.vnComponent('vnRouteCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/route/front/index.js b/modules/route/front/index.js index 803fc1045..0f2208862 100644 --- a/modules/route/front/index.js +++ b/modules/route/front/index.js @@ -1,19 +1,6 @@ export * from './module'; import './main'; -import './index/'; -import './search-panel'; import './descriptor'; import './descriptor-popover'; import './summary'; -import './card'; -import './create'; -import './basic-data'; -import './log'; -import './tickets'; -import './agency-term/index'; -import './agency-term/createInvoiceIn'; -import './agency-term-search-panel'; -import './ticket-popup'; -import './sms'; -import './roadmap'; diff --git a/modules/route/front/index/index.html b/modules/route/front/index/index.html deleted file mode 100644 index 9384af6be..000000000 --- a/modules/route/front/index/index.html +++ /dev/null @@ -1,228 +0,0 @@ - - - - - - - - -
- - - -
- - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - Id - - Worker - - Agency - - Vehicle - - Date - - - - Description - - Hour started - - Hour finished -
- - - {{::route.id | dashIfEmpty}} - - -
{{name}} - {{nickname}}
-
-
-
- - - - - - - - - {{::route.m3 | dashIfEmpty}} - - - - - - - - - - - - - -
-
-
-
-
- - - - - - - - - - - - - - - - -
- - - - - - -
- - - - - - - - - - - - - - diff --git a/modules/route/front/index/index.js b/modules/route/front/index/index.js deleted file mode 100644 index bb32e1f13..000000000 --- a/modules/route/front/index/index.js +++ /dev/null @@ -1,151 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $, vnReport) { - super($element, $); - this.vnReport = vnReport; - this.droppableElement = 'a.vn-tr'; - } - - preview(route) { - this.routeSelected = route; - this.$.summary.show(); - } - - showTicketPopup(route) { - this.routeSelected = route; - this.$.ticketPopup.show(); - } - - get checked() { - const rows = this.$.model.data || []; - const checkedRows = []; - for (let row of rows) { - if (row.checked) - checkedRows.push(row); - } - - return checkedRows; - } - - get totalChecked() { - return this.checked.length; - } - - showRouteReport() { - const routesIds = []; - const access_token = this.vnToken.tokenMultimedia; - - for (let route of this.checked) - routesIds.push(route.id); - const stringRoutesIds = routesIds.join(','); - - if (this.checked.length <= 1) { - const url = `api/Routes/${stringRoutesIds}/driver-route-pdf?access_token=${access_token}`; - window.open(url, '_blank'); - } else { - const serializedParams = this.$httpParamSerializer({ - access_token, - id: stringRoutesIds - }); - const url = `api/Routes/downloadZip?${serializedParams}`; - window.open(url, '_blank'); - } - } - - openClonationDialog() { - this.$.clonationDialog.show(); - this.createdDate = Date.vnNew(); - } - - cloneSelectedRoutes() { - try { - if (!this.createdDate) - throw new Error(`The date can't be empty`); - - const routesIds = []; - for (let route of this.checked) - routesIds.push(route.id); - - return this.$http.post('Routes/clone', {ids: routesIds, created: this.createdDate}).then(() => { - this.$.model.refresh(); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - } - } - - onDrop($event) { - const target = $event.target; - const droppable = target.closest(this.droppableElement); - const ticketId = $event.dataTransfer.getData('Text'); - const routeId = droppable.id; - - if (isNaN(ticketId)) { - const regexp = new RegExp(/\/ticket\/([0-9]+)\//i); - const matches = ticketId.match(regexp); - - if (matches && matches.length) - this.insert(routeId, matches[1]); - else - this.vnApp.showError(this.$t('Ticket not found')); - } - - if (!isNaN(ticketId)) - this.insert(routeId, ticketId); - } - - insert(routeId, ticketId) { - routeId = parseInt(routeId); - ticketId = parseInt(ticketId); - - const query = `Routes/${routeId}/insertTicket`; - return this.$http.patch(query, {ticketId}).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.$.model.refresh(); - }).catch(error => { - if (error.status == 404) - return this.vnApp.showError(this.$t('Ticket not found')); - throw error; - }); - } - - updateAttributes(route) { - if (route.started == null || route.finished == null) - return this.vnApp.showError(this.$t('You must select a valid time')); - if (route.created == null) - return this.vnApp.showError(this.$t('You must select a valid date')); - const params = { - workerFk: route.workerFk, - agencyModeFk: route.agencyModeFk, - vehicleFk: route.vehicleFk, - created: route.created, - description: route.description, - started: route.started, - finished: route.finished - }; - const query = `Routes/${route.id}/`; - this.$http.patch(query, params).then(res => { - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - markAsServed() { - const routes = []; - for (let route of this.checked) - routes.push(route.id); - - const params = {isOk: true}; - for (let routeId of routes) - this.$http.patch(`Routes/${routeId}`, params); - } -} - -Controller.$inject = ['$element', '$scope', 'vnReport']; - -ngModule.vnComponent('vnRouteIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/route/front/index/index.spec.js b/modules/route/front/index/index.spec.js deleted file mode 100644 index 399ece714..000000000 --- a/modules/route/front/index/index.spec.js +++ /dev/null @@ -1,156 +0,0 @@ -import './index.js'; -import crudModel from 'core/mocks/crud-model'; - -describe('Component vnRouteIndex', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('route')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - const $element = angular.element(''); - controller = $componentController('vnRouteIndex', {$element}); - controller.$.model = crudModel; - controller.$.model.data = [{id: 1, checked: true}, {id: 2}, {id: 3}]; - })); - - describe('checked() getter', () => { - it('should return the checked lines', () => { - const data = controller.$.model.data; - data[0].checked = true; - data[2].checked = true; - - const checkedRows = controller.checked; - - const firstCheckedRow = checkedRows[0]; - const secondCheckedRow = checkedRows[1]; - - expect(firstCheckedRow.id).toEqual(1); - expect(secondCheckedRow.id).toEqual(3); - }); - }); - - describe('totalCheked() getter', () => { - it('should return the total checked lines', () => { - const data = controller.$.model.data; - data[0].checked = true; - - const checkedRows = controller.totalChecked; - - expect(checkedRows).toEqual(1); - }); - }); - - describe('showRouteReport()', () => { - it('should call to the vnReport show method', () => { - jest.spyOn(window, 'open').mockReturnThis(); - - const data = controller.$.model.data; - data[0].checked = true; - data[2].checked = true; - - controller.showRouteReport(); - - expect(window.open).toHaveBeenCalled(); - }); - }); - - describe('cloneSelectedRoutes()', () => { - it('should perform an http request to Routes/clone', () => { - controller.createdDate = Date.vnNew(); - - $httpBackend.expect('POST', 'Routes/clone').respond(); - controller.cloneSelectedRoutes(); - $httpBackend.flush(); - }); - }); - - describe('onDrop()', () => { - it('should call the insert method when dragging a ticket number', () => { - jest.spyOn(controller, 'insert'); - - const routeId = '1'; - const expectedTicketId = '16'; - const draggedElement = '16'; - const droppable = document.createElement('a'); - droppable.setAttribute('id', 1); - droppable.classList.add('vn-tr'); - - const $event = { - dataTransfer: { - getData: () => draggedElement - }, - target: droppable - }; - controller.onDrop($event); - - expect(controller.insert).toHaveBeenCalledWith(routeId, expectedTicketId); - }); - - it('should call the insert method when dragging a ticket link', () => { - jest.spyOn(controller, 'insert'); - - const routeId = '1'; - const expectedTicketId = '11'; - const draggedElement = 'http://arkamcity.com/#!/ticket/11/summary'; - const droppable = document.createElement('a'); - droppable.setAttribute('id', 1); - droppable.classList.add('vn-tr'); - - const $event = { - dataTransfer: { - getData: () => draggedElement - }, - target: droppable - }; - controller.onDrop($event); - - expect(controller.insert).toHaveBeenCalledWith(routeId, expectedTicketId); - }); - - it('should throw an error when dragging an invalid ticket link', () => { - jest.spyOn(controller.vnApp, 'showError'); - - const draggedElement = 'http://arkamcity.com/#!/item/11/summary'; - const droppable = document.createElement('a'); - droppable.setAttribute('id', 1); - droppable.classList.add('vn-tr'); - const $event = { - dataTransfer: { - getData: () => draggedElement - }, - target: droppable - }; - controller.onDrop($event); - - expect(controller.vnApp.showError).toHaveBeenCalledWith('Ticket not found'); - }); - }); - - describe('insert()', () => { - it('should perform a HTTP patch query and then call both refresh and showSuccess methods', () => { - jest.spyOn(controller.$.model, 'refresh').mockReturnThis(); - jest.spyOn(controller.vnApp, 'showSuccess'); - - const routeId = 1; - const ticketId = 11; - const data = {ticketId}; - $httpBackend.expect('PATCH', `Routes/1/insertTicket`, data).respond(); - controller.insert(routeId, ticketId); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.$.model.refresh).toHaveBeenCalledWith(); - }); - }); - - describe('markAsServed()', () => { - it('should perform a HTTP patch query', () => { - const data = {isOk: true}; - $httpBackend.expect('PATCH', `Routes/1`, data).respond(); - controller.markAsServed(); - $httpBackend.flush(); - }); - }); -}); diff --git a/modules/route/front/index/locale/es.yml b/modules/route/front/index/locale/es.yml deleted file mode 100644 index 3db84d81e..000000000 --- a/modules/route/front/index/locale/es.yml +++ /dev/null @@ -1,13 +0,0 @@ -Vehicle: Vehículo -Download selected routes as PDF: Descargar rutas seleccionadas como PDF -Clone selected routes: Clonar rutas seleccionadas -The date can't be empty: La fecha no puede estar vacía -Starting date: Fecha de inicio -Hour started: Hora inicio -Hour finished: Hora fin -Go to route: Ir a la ruta -You must select a valid time: Debe seleccionar una hora válida -You must select a valid date: Debe seleccionar una fecha válida -Mark as served: Marcar como servidas -Retrieving data from the routes: Recuperando datos de las rutas -Send SMS to all clients: Mandar sms a todos los clientes de las rutas \ No newline at end of file diff --git a/modules/route/front/locale/en.yml b/modules/route/front/locale/en.yml deleted file mode 100644 index 0e5302b14..000000000 --- a/modules/route/front/locale/en.yml +++ /dev/null @@ -1 +0,0 @@ -Unlink zone: Unlink zone {{zoneName}} from agency {{agencyName}} \ No newline at end of file diff --git a/modules/route/front/locale/es.yml b/modules/route/front/locale/es.yml deleted file mode 100644 index 74ab2cd61..000000000 --- a/modules/route/front/locale/es.yml +++ /dev/null @@ -1,5 +0,0 @@ -Routes: Rutas -Search routes by id: Buscar rutas por identificador -New route: Nueva ruta -route: ruta -Unlink zone: Desvincular zona {{zoneName}} de agencia {{agencyName}} \ No newline at end of file diff --git a/modules/route/front/log/index.html b/modules/route/front/log/index.html deleted file mode 100644 index 7df2e30ae..000000000 --- a/modules/route/front/log/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/modules/route/front/log/index.js b/modules/route/front/log/index.js deleted file mode 100644 index c1a7052a9..000000000 --- a/modules/route/front/log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnRouteLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/route/front/main/index.html b/modules/route/front/main/index.html index f1bed84ff..e69de29bb 100644 --- a/modules/route/front/main/index.html +++ b/modules/route/front/main/index.html @@ -1,20 +0,0 @@ - - - - - - - - - - diff --git a/modules/route/front/main/index.js b/modules/route/front/main/index.js index 8c57bbad6..a567e3072 100644 --- a/modules/route/front/main/index.js +++ b/modules/route/front/main/index.js @@ -2,36 +2,12 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; export default class Route extends ModuleMain { - $postLink() { - const to = Date.vnNew(); - to.setDate(to.getDate() + 1); - to.setHours(0, 0, 0, 0); - - const from = Date.vnNew(); - from.setDate(from.getDate()); - from.setHours(0, 0, 0, 0); - - this.filterParams = {from, to}; - this.$.model.applyFilter(null, this.filterParams); + constructor($element, $) { + super($element, $); } - - fetchParams($params) { - const hasEntries = Object.entries($params).length; - if (!hasEntries) - $params.scopeDays = 1; - - if (typeof $params.scopeDays === 'number') { - const from = Date.vnNew(); - from.setHours(0, 0, 0, 0); - - const to = new Date(from.getTime()); - to.setDate(to.getDate() + $params.scopeDays); - to.setHours(23, 59, 59, 999); - - Object.assign($params, {from, to}); - } - - return $params; + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`route/`); } } diff --git a/modules/route/front/main/index.spec.js b/modules/route/front/main/index.spec.js deleted file mode 100644 index 0c16a7b1f..000000000 --- a/modules/route/front/main/index.spec.js +++ /dev/null @@ -1,49 +0,0 @@ -import './index.js'; - -describe('Route Component vnRoute', () => { - let controller; - - beforeEach(ngModule('route')); - - beforeEach(inject($componentController => { - let $element = angular.element(`
`); - controller = $componentController('vnRoute', {$element}); - })); - - describe('fetchParams()', () => { - it('should return a range of dates with passed scope days', () => { - let params = controller.fetchParams({ - scopeDays: 2 - }); - const from = Date.vnNew(); - from.setHours(0, 0, 0, 0); - const to = new Date(from.getTime()); - to.setDate(to.getDate() + params.scopeDays); - to.setHours(23, 59, 59, 999); - - const expectedParams = { - from, - scopeDays: params.scopeDays, - to - }; - - expect(params).toEqual(expectedParams); - }); - - it('should return default value for scope days', () => { - let params = controller.fetchParams({ - scopeDays: 1 - }); - - expect(params.scopeDays).toEqual(1); - }); - - it('should return the given scope days', () => { - let params = controller.fetchParams({ - scopeDays: 2 - }); - - expect(params.scopeDays).toEqual(2); - }); - }); -}); diff --git a/modules/route/front/roadmap/basic-data/index.html b/modules/route/front/roadmap/basic-data/index.html deleted file mode 100644 index 28c67eb47..000000000 --- a/modules/route/front/roadmap/basic-data/index.html +++ /dev/null @@ -1,98 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - {{::id}} - {{::nickname}} - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/route/front/roadmap/basic-data/index.js b/modules/route/front/roadmap/basic-data/index.js deleted file mode 100644 index d5b39b76e..000000000 --- a/modules/route/front/roadmap/basic-data/index.js +++ /dev/null @@ -1,16 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onSubmit() { - this.$.watcher.submit(); - } -} - -ngModule.component('vnRoadmapBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - roadmap: '<' - } -}); diff --git a/modules/route/front/roadmap/card/index.html b/modules/route/front/roadmap/card/index.html deleted file mode 100644 index 97ca40f95..000000000 --- a/modules/route/front/roadmap/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/route/front/roadmap/card/index.js b/modules/route/front/roadmap/card/index.js deleted file mode 100644 index ff2d13616..000000000 --- a/modules/route/front/roadmap/card/index.js +++ /dev/null @@ -1,19 +0,0 @@ -import ngModule from '../../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - const filter = { - include: [ - {relation: 'supplier'} - ] - }; - this.$http.get(`Roadmaps/${this.$params.id}`, {filter}) - .then(res => this.roadmap = res.data); - } -} - -ngModule.vnComponent('vnRoadmapCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/route/front/roadmap/create/index.html b/modules/route/front/roadmap/create/index.html deleted file mode 100644 index f5a26566e..000000000 --- a/modules/route/front/roadmap/create/index.html +++ /dev/null @@ -1,37 +0,0 @@ - - -
- - - - - - - - - - - - - - - - -
diff --git a/modules/route/front/roadmap/create/index.js b/modules/route/front/roadmap/create/index.js deleted file mode 100644 index 7e638da94..000000000 --- a/modules/route/front/roadmap/create/index.js +++ /dev/null @@ -1,23 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $, $transclude, vnReport, vnEmail) { - super($element, $, $transclude); - this.roadmap = {etd: Date.vnNew()}; - } - - onSubmit() { - this.$.watcher.submit().then( - res => this.$state.go('route.roadmap.card.summary', {id: res.data.id}) - ); - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnRoadmapCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/route/front/roadmap/create/style.scss b/modules/route/front/roadmap/create/style.scss deleted file mode 100644 index 8ee7ecb09..000000000 --- a/modules/route/front/roadmap/create/style.scss +++ /dev/null @@ -1,6 +0,0 @@ -vn-ticket-request { - .vn-textfield { - margin: 0!important; - max-width: 100px; - } -} diff --git a/modules/route/front/roadmap/descriptor/index.html b/modules/route/front/roadmap/descriptor/index.html deleted file mode 100644 index 92ae8eab1..000000000 --- a/modules/route/front/roadmap/descriptor/index.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - Delete roadmap - - - -
- - - - - - - {{$ctrl.roadmap.supplier.nickname}} - - -
-
-
- - - - diff --git a/modules/route/front/roadmap/descriptor/index.js b/modules/route/front/roadmap/descriptor/index.js deleted file mode 100644 index 2846b073a..000000000 --- a/modules/route/front/roadmap/descriptor/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import ngModule from '../../module'; -import Descriptor from 'salix/components/descriptor'; - -class Controller extends Descriptor { - get roadmap() { - return this.entity; - } - - set roadmap(value) { - this.entity = value; - } - - onDelete() { - return this.$http.delete(`Roadmaps/${this.roadmap.id}`) - .then(() => this.$state.go('route.roadmap')) - .then(() => this.vnApp.showSuccess(this.$t('Roadmap removed'))); - } -} - -ngModule.component('vnRoadmapDescriptor', { - template: require('./index.html'), - controller: Controller, - bindings: { - roadmap: '<' - } -}); diff --git a/modules/route/front/roadmap/descriptor/locale/es.yml b/modules/route/front/roadmap/descriptor/locale/es.yml deleted file mode 100644 index 376209694..000000000 --- a/modules/route/front/roadmap/descriptor/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Delete roadmap: Eliminar troncal -The roadmap will be removed: La troncal será eliminada -Roadmap removed: Troncal eliminada diff --git a/modules/route/front/roadmap/index.js b/modules/route/front/roadmap/index.js deleted file mode 100644 index 91b782a9b..000000000 --- a/modules/route/front/roadmap/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import './main'; -import './index/'; -import './summary'; -import './card'; -import './descriptor'; -import './create'; -import './basic-data'; -import './search-panel'; -import './stops'; diff --git a/modules/route/front/roadmap/index/index.html b/modules/route/front/roadmap/index/index.html deleted file mode 100644 index 6f8cbecc4..000000000 --- a/modules/route/front/roadmap/index/index.html +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - Roadmap - ETD - Carrier - Plate - Price - Observations - - - - - - - - - - {{::roadmap.name}} - {{::roadmap.etd | date:'dd/MM/yyyy HH:mm'}} - - - {{::roadmap.supplier.nickname}} - - - {{::roadmap.tractorPlate | dashIfEmpty}} - {{::roadmap.price | currency: 'EUR':2 | dashIfEmpty}} - {{::roadmap.observations | dashIfEmpty}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/route/front/roadmap/index/index.js b/modules/route/front/roadmap/index/index.js deleted file mode 100644 index c5f5ef9d1..000000000 --- a/modules/route/front/roadmap/index/index.js +++ /dev/null @@ -1,60 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - get checked() { - const roadmaps = this.$.model.data || []; - const checkedRoadmap = []; - for (let roadmap of roadmaps) { - if (roadmap.checked) - checkedRoadmap.push(roadmap); - } - - return checkedRoadmap; - } - - get totalChecked() { - return this.checked.length; - } - - preview(roadmap) { - this.roadmapSelected = roadmap; - this.$.summary.show(); - } - - openClonationDialog() { - this.$.clonationDialog.show(); - this.etd = Date.vnNew(); - } - - cloneSelectedRoadmaps() { - try { - if (!this.etd) - throw new Error(`The date can't be empty`); - - const roadmapsIds = []; - for (let roadmap of this.checked) - roadmapsIds.push(roadmap.id); - - return this.$http.post('Roadmaps/clone', {ids: roadmapsIds, etd: this.etd}).then(() => { - this.$.model.refresh(); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - } - } - - deleteRoadmaps() { - for (const roadmap of this.checked) { - this.$http.delete(`Roadmaps/${roadmap.id}`) - .then(() => this.$.model.refresh()) - .then(() => this.vnApp.showSuccess(this.$t('Roadmaps removed'))); - } - } -} - -ngModule.vnComponent('vnRoadmapIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/route/front/roadmap/index/locale/es.yml b/modules/route/front/roadmap/index/locale/es.yml deleted file mode 100644 index dd93eac6e..000000000 --- a/modules/route/front/roadmap/index/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Delete roadmap(s): Eliminar troncal(es) -Selected roadmaps will be removed: Los troncales seleccionados serán eliminados -Roadmaps removed: Troncales eliminados diff --git a/modules/route/front/roadmap/locale/es.yml b/modules/route/front/roadmap/locale/es.yml deleted file mode 100644 index e136eca31..000000000 --- a/modules/route/front/roadmap/locale/es.yml +++ /dev/null @@ -1,14 +0,0 @@ -Roadmaps: Troncales -Roadmap: Troncal -Driver name: Nombre conductor -Plate: Matrícula -Price: Precio -Observations: Observaciones -Clone selected roadmaps: Clonar troncales seleccionadas -Select the estimated time of departure (ETD): Seleccione la hora estimada de salida (ETD) -Create roadmap: Crear troncal -Tractor plate: Matrícula tractor -Trailer plate: Matrícula trailer -Carrier: Transportista -ETD date: Fecha ETD -ETD hour: Hora ETD diff --git a/modules/route/front/roadmap/main/index.html b/modules/route/front/roadmap/main/index.html deleted file mode 100644 index 3a8eb2599..000000000 --- a/modules/route/front/roadmap/main/index.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - diff --git a/modules/route/front/roadmap/main/index.js b/modules/route/front/roadmap/main/index.js deleted file mode 100644 index e7b3366f2..000000000 --- a/modules/route/front/roadmap/main/index.js +++ /dev/null @@ -1,61 +0,0 @@ -import ngModule from '../../module'; -import ModuleMain from 'salix/components/module-main'; - -export default class Roadmap extends ModuleMain { - constructor($element, $) { - super($element, $); - - this.include = { - relation: 'supplier', - scope: { - fields: ['nickname'] - } - }; - } - - $postLink() { - const from = Date.vnNew(); - from.setHours(0, 0, 0, 0); - - const to = Date.vnNew(); - to.setHours(23, 59, 59, 999); - - this.filterParams = { - from: from, - to: to - }; - - this.$.model.addFilter({where: { - and: [ - {etd: {gte: from}}, - {etd: {lte: to}} - ] - }}); - } - - exprBuilder(param, value) { - switch (param) { - case 'search': - return /^\d+$/.test(value) - ? {id: value} - : {name: {like: `%${value}%`}}; - case 'from': - return {etd: {gte: value}}; - case 'to': - return {etd: {lte: value}}; - case 'supplierFk': - case 'price': - return {[param]: value}; - case 'tractorPlate': - case 'trailerPlate': - case 'phone': - case 'driverName': - return {[param]: {like: `%${value}%`}}; - } - } -} - -ngModule.vnComponent('vnRoadmap', { - controller: Roadmap, - template: require('./index.html') -}); diff --git a/modules/route/front/roadmap/main/locale/es.yml b/modules/route/front/roadmap/main/locale/es.yml deleted file mode 100644 index 78342bce8..000000000 --- a/modules/route/front/roadmap/main/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Search roadmap by id or trunk: Buscar troncales por id o troncal diff --git a/modules/route/front/roadmap/search-panel/index.html b/modules/route/front/roadmap/search-panel/index.html deleted file mode 100644 index 53fd37344..000000000 --- a/modules/route/front/roadmap/search-panel/index.html +++ /dev/null @@ -1,74 +0,0 @@ -
-
- - - - -
- - - - - - -
- - - - - - - - - - {{::id}} - {{::nickname}} - - - - - - - - - - - - - - -
-
diff --git a/modules/route/front/roadmap/search-panel/index.js b/modules/route/front/roadmap/search-panel/index.js deleted file mode 100644 index 499027d14..000000000 --- a/modules/route/front/roadmap/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.component('vnRoadmapSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/route/front/roadmap/stops/index.html b/modules/route/front/roadmap/stops/index.html deleted file mode 100644 index 82f30c326..000000000 --- a/modules/route/front/roadmap/stops/index.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - diff --git a/modules/route/front/roadmap/stops/index.js b/modules/route/front/roadmap/stops/index.js deleted file mode 100644 index 075a1c8a4..000000000 --- a/modules/route/front/roadmap/stops/index.js +++ /dev/null @@ -1,39 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - add() { - const filter = { - fields: ['etd'] - }; - this.$http.get(`Roadmaps/${this.$params.id}`, {filter}) - .then(res => { - this.roadmap = res.data; - - const eta = new Date(this.roadmap.etd); - eta.setDate(eta.getDate() + 1); - - this.$.model.insert({ - roadmapFk: this.$params.id, - eta: eta - }); - }); - } - - onSubmit() { - this.$.watcher.check(); - this.$.model.save().then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - this.$.model.refresh(); - }); - } -} - -ngModule.component('vnRoadmapStops', { - template: require('./index.html'), - controller: Controller, - bindings: { - roadmap: '<' - } -}); diff --git a/modules/route/front/roadmap/stops/locale/es.yml b/modules/route/front/roadmap/stops/locale/es.yml deleted file mode 100644 index 1db275949..000000000 --- a/modules/route/front/roadmap/stops/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -Remove stop: Eliminar parada -Add stop: Añadir parada -ETA date: Fecha ETA -ETA hour: Hora ETA diff --git a/modules/route/front/roadmap/summary/index.html b/modules/route/front/roadmap/summary/index.html deleted file mode 100644 index abf5ff90a..000000000 --- a/modules/route/front/roadmap/summary/index.html +++ /dev/null @@ -1,116 +0,0 @@ - -
- {{summary.id}} - {{summary.name}} -
- - - - - {{summary.supplier.nickname}} - - - - - - - - - - - - - - - - - - - -

- - Stops - - - -

- - - - Wharehouse - ETA - - - - - {{roadmapStop.warehouse.name}} - {{roadmapStop.eta | date:'dd/MM/yyyy HH:mm'}} - - - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/route/front/roadmap/summary/index.js b/modules/route/front/roadmap/summary/index.js deleted file mode 100644 index 46abe5ca2..000000000 --- a/modules/route/front/roadmap/summary/index.js +++ /dev/null @@ -1,68 +0,0 @@ -import ngModule from '../../module'; -import Component from 'core/lib/component'; -import './style.scss'; - -class Controller extends Component { - set roadmap(value) { - this._roadmap = value; - this.$.summary = null; - if (!value) return; - - this.loadData(); - } - - get roadmap() { - return this._roadmap; - } - - loadData() { - const filter = { - include: [ - {relation: 'supplier'}, - {relation: 'worker'}, - {relation: 'roadmapStop', - scope: { - include: [ - {relation: 'warehouse'} - ] - }} - ] - }; - this.$http.get(`Roadmaps/${this.roadmap.id}`, {filter}) - .then(res => this.$.summary = res.data); - } - - getETD() { - const eta = new Date(this.roadmap.etd); - eta.setDate(eta.getDate() + 1); - - this.roadmapStop = {eta: eta}; - } - - onAddAccept() { - try { - const data = { - roadmapFk: this.roadmap.id, - warehouseFk: this.roadmapStop.warehouseFk, - eta: this.roadmapStop.eta, - description: this.roadmapStop.description - }; - - this.$http.post(`RoadmapStops`, data) - .then(() => { - this.loadData(); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - } - } -} - -ngModule.component('vnRoadmapSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - roadmap: '<' - } -}); diff --git a/modules/route/front/roadmap/summary/locale/es.yml b/modules/route/front/roadmap/summary/locale/es.yml deleted file mode 100644 index f2d82438a..000000000 --- a/modules/route/front/roadmap/summary/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Stops: Paradas -Wharehouse: Almacén -You must fill all the fields: Debes rellenar todos los campos diff --git a/modules/route/front/roadmap/summary/style.scss b/modules/route/front/roadmap/summary/style.scss deleted file mode 100644 index 743500cef..000000000 --- a/modules/route/front/roadmap/summary/style.scss +++ /dev/null @@ -1,9 +0,0 @@ -@import "variables"; - -vn-roadmap-summary .summary { - a:not(vn-link-phone a) { - display: flex; - align-items: center; - height: 18.328px; - } -} diff --git a/modules/route/front/routes.json b/modules/route/front/routes.json index 3b866581d..00fedc259 100644 --- a/modules/route/front/routes.json +++ b/modules/route/front/routes.json @@ -6,18 +6,7 @@ "dependencies": ["client", "worker", "ticket", "supplier", "invoiceIn"], "menus": { "main": [ - {"state": "route.index", "icon": "icon-delivery"}, - {"state": "route.agencyTerm.index", "icon": "icon-agency-term"}, - {"state": "route.roadmap", "icon": "icon-trailer"} - ], - "card": [ - {"state": "route.card.basicData", "icon": "settings"}, - {"state": "route.card.tickets", "icon": "icon-ticket"}, - {"state": "route.card.log", "icon": "history"} - ], - "roadmap": [ - {"state": "route.roadmap.card.basicData", "icon": "settings"}, - {"state": "route.roadmap.card.stops", "icon": "icon-lines"} + {"state": "route.index", "icon": "icon-delivery"} ] }, "routes": [ @@ -33,108 +22,6 @@ "state": "route.index", "component": "vn-route-index", "description": "Routes" - }, { - "url": "/create", - "state": "route.create", - "component": "vn-route-create", - "description": "New route" - }, { - "url": "/:id", - "state": "route.card", - "abstract": true, - "component": "vn-route-card" - }, { - "url": "/agency-term?q", - "abstract": true, - "state": "route.agencyTerm", - "component": "ui-view" - }, { - "url": "/index", - "state": "route.agencyTerm.index", - "component": "vn-agency-term-index", - "description": "Autonomous", - "acl": ["administrative"] - },{ - "url": "/createInvoiceIn?q", - "state": "route.agencyTerm.createInvoiceIn", - "component": "vn-agency-term-create-invoice-in", - "description": "File management", - "params": { - "route": "$ctrl.route" - }, - "acl": ["administrative"] - }, { - "url": "/summary", - "state": "route.card.summary", - "component": "vn-route-summary", - "description": "Summary", - "params": { - "route": "$ctrl.route" - } - }, { - "url": "/basic-data", - "state": "route.card.basicData", - "component": "vn-route-basic-data", - "description": "Basic data", - "params": { - "route": "$ctrl.route" - }, - "acl": ["delivery"] - }, { - "url" : "/log", - "state": "route.card.log", - "component": "vn-route-log", - "description": "Log", - "acl": ["delivery"] - }, { - "url": "/tickets", - "state": "route.card.tickets", - "component": "vn-route-tickets", - "description": "Tickets", - "params": { - "route": "$ctrl.route" - }, - "acl": ["delivery"] - }, { - "url": "/roadmap?q", - "state": "route.roadmap", - "component": "vn-roadmap", - "description": "Roadmaps" - }, { - "url": "/create", - "state": "route.roadmap.create", - "component": "vn-roadmap-create", - "description": "Create roadmap" - },{ - "url": "/:id", - "state": "route.roadmap.card", - "component": "vn-roadmap-card", - "abstract": true, - "description": "Detail" - },{ - "url": "/summary", - "state": "route.roadmap.card.summary", - "component": "vn-roadmap-summary", - "description": "Summary", - "params": { - "roadmap": "$ctrl.roadmap" - } - },{ - "url": "/basic-data", - "state": "route.roadmap.card.basicData", - "component": "vn-roadmap-basic-data", - "description": "Basic data", - "params": { - "roadmap": "$ctrl.roadmap" - } - }, { - "url": "/stops", - "state": "route.roadmap.card.stops", - "component": "vn-roadmap-stops", - "description": "Stops", - "params": { - "route": "$ctrl.roadmap" - } } ] } diff --git a/modules/route/front/search-panel/index.html b/modules/route/front/search-panel/index.html deleted file mode 100644 index f3d392580..000000000 --- a/modules/route/front/search-panel/index.html +++ /dev/null @@ -1,96 +0,0 @@ -
- - -
- - - - - - - - - - -
- - - - - - Or - - - - - -
- - - - - - - - - - - - - - - -
-
diff --git a/modules/route/front/search-panel/index.js b/modules/route/front/search-panel/index.js deleted file mode 100644 index b5abbd94a..000000000 --- a/modules/route/front/search-panel/index.js +++ /dev/null @@ -1,43 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -class Controller extends SearchPanel { - constructor($, $element) { - super($, $element); - this.filter = this.$.filter; - } - - get from() { - return this._from; - } - - set from(value) { - this._from = value; - this.filter.scopeDays = null; - } - - get to() { - return this._to; - } - - set to(value) { - this._to = value; - this.filter.scopeDays = null; - } - - get scopeDays() { - return this._scopeDays; - } - - set scopeDays(value) { - this._scopeDays = value; - - this.filter.from = null; - this.filter.to = null; - } -} - -ngModule.vnComponent('vnRouteSearchPanel', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/route/front/search-panel/index.spec.js b/modules/route/front/search-panel/index.spec.js deleted file mode 100644 index ae15e16e4..000000000 --- a/modules/route/front/search-panel/index.spec.js +++ /dev/null @@ -1,48 +0,0 @@ -import './index'; - -describe('Route Component vnRouteSearchPanel', () => { - let controller; - - beforeEach(ngModule('route')); - - beforeEach(inject($componentController => { - controller = $componentController('vnRouteSearchPanel', {$element: null}); - controller.$t = () => {}; - controller.filter = {}; - })); - - describe('from() setter', () => { - it('should clear the scope days when setting the from property', () => { - controller.filter.scopeDays = 1; - - controller.from = Date.vnNew(); - - expect(controller.filter.scopeDays).toBeNull(); - expect(controller.from).toBeDefined(); - }); - }); - - describe('to() setter', () => { - it('should clear the scope days when setting the to property', () => { - controller.filter.scopeDays = 1; - - controller.to = Date.vnNew(); - - expect(controller.filter.scopeDays).toBeNull(); - expect(controller.to).toBeDefined(); - }); - }); - - describe('scopeDays() setter', () => { - it('should clear the date range when setting the scopeDays property', () => { - controller.filter.from = Date.vnNew(); - controller.filter.to = Date.vnNew(); - - controller.scopeDays = 1; - - expect(controller.filter.from).toBeNull(); - expect(controller.filter.to).toBeNull(); - expect(controller.scopeDays).toBeDefined(); - }); - }); -}); diff --git a/modules/route/front/sms/index.html b/modules/route/front/sms/index.html deleted file mode 100644 index 0d7dd7c11..000000000 --- a/modules/route/front/sms/index.html +++ /dev/null @@ -1,36 +0,0 @@ - - -
- - - - - - - {{'Characters remaining' | translate}}: - - {{$ctrl.charactersRemaining()}} - - - -
-
- - - - -
\ No newline at end of file diff --git a/modules/route/front/sms/index.js b/modules/route/front/sms/index.js deleted file mode 100644 index f466adea7..000000000 --- a/modules/route/front/sms/index.js +++ /dev/null @@ -1,47 +0,0 @@ -import ngModule from '../module'; -import Component from 'core/lib/component'; -import './style.scss'; - -class Controller extends Component { - open() { - this.$.SMSDialog.show(); - } - - charactersRemaining() { - const element = this.$.message; - const value = element.input.value; - - const maxLength = 160; - const textAreaLength = new Blob([value]).size; - return maxLength - textAreaLength; - } - - onResponse() { - try { - if (!this.sms.destination) - throw new Error(`The destination can't be empty`); - if (!this.sms.message) - throw new Error(`The message can't be empty`); - if (this.charactersRemaining() < 0) - throw new Error(`The message it's too long`); - - this.$http.post(`Routes/sendSms`, this.sms).then(res => { - this.vnApp.showMessage(this.$t('SMS sent')); - - if (res.data) this.emit('send', {response: res.data}); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } - return true; - } -} - -ngModule.vnComponent('vnRouteSms', { - template: require('./index.html'), - controller: Controller, - bindings: { - sms: '<', - } -}); diff --git a/modules/route/front/sms/index.spec.js b/modules/route/front/sms/index.spec.js deleted file mode 100644 index 8bf35e673..000000000 --- a/modules/route/front/sms/index.spec.js +++ /dev/null @@ -1,71 +0,0 @@ -import './index'; - -describe('Route', () => { - describe('Component vnRouteSms', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('route')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - let $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnRouteSms', {$element, $scope}); - controller.$.message = { - input: { - value: 'My SMS' - } - }; - })); - - describe('onResponse()', () => { - it('should perform a POST query and show a success snackbar', () => { - let params = {destinationFk: 1101, destination: 111111111, message: 'My SMS'}; - controller.sms = {destinationFk: 1101, destination: 111111111, message: 'My SMS'}; - - jest.spyOn(controller.vnApp, 'showMessage'); - $httpBackend.expect('POST', `Routes/sendSms`, params).respond(200, params); - - controller.onResponse(); - $httpBackend.flush(); - - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent'); - }); - - it('should call onResponse without the destination and show an error snackbar', () => { - controller.sms = {destinationFk: 1101, message: 'My SMS'}; - - jest.spyOn(controller.vnApp, 'showError'); - - controller.onResponse(); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`The destination can't be empty`); - }); - - it('should call onResponse without the message and show an error snackbar', () => { - controller.sms = {destinationFk: 1101, destination: 222222222}; - - jest.spyOn(controller.vnApp, 'showError'); - - controller.onResponse(); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`The message can't be empty`); - }); - }); - - describe('charactersRemaining()', () => { - it('should return the characters remaining in a element', () => { - controller.$.message = { - input: { - value: 'My message 0€' - } - }; - - let result = controller.charactersRemaining(); - - expect(result).toEqual(145); - }); - }); - }); -}); diff --git a/modules/route/front/sms/locale/es.yml b/modules/route/front/sms/locale/es.yml deleted file mode 100644 index 0168a6eb6..000000000 --- a/modules/route/front/sms/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Send SMS to the selected tickets: Enviar SMS a los tickets seleccionados -Routes to notify: Rutas a notificar -Message: Mensaje -SMS sent!: ¡SMS enviado! -Characters remaining: Carácteres restantes -The destination can't be empty: El destinatario no puede estar vacio -The message can't be empty: El mensaje no puede estar vacio -The message it's too long: El mensaje es demasiado largo -Special characters like accents counts as a multiple: Carácteres especiales como los acentos cuentan como varios \ No newline at end of file diff --git a/modules/route/front/sms/style.scss b/modules/route/front/sms/style.scss deleted file mode 100644 index 84571a5f4..000000000 --- a/modules/route/front/sms/style.scss +++ /dev/null @@ -1,5 +0,0 @@ -@import "variables"; - -.SMSDialog { - min-width: 400px -} \ No newline at end of file diff --git a/modules/route/front/summary/index.html b/modules/route/front/summary/index.html index 8269bf118..764312d16 100644 --- a/modules/route/front/summary/index.html +++ b/modules/route/front/summary/index.html @@ -35,10 +35,10 @@ + value="{{$ctrl.summary.route.started | date: 'HH:mm'}}"> + value="{{$ctrl.summary.route.finished | date: 'HH:mm'}}"> diff --git a/modules/route/front/ticket-popup/index.html b/modules/route/front/ticket-popup/index.html deleted file mode 100644 index 5046d5e43..000000000 --- a/modules/route/front/ticket-popup/index.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - Tickets to add -
- -
-
-
- - - - - - - - - - - - Ticket - Client - Province - - - Population - - - PC - Address - Zone - - - - - - - - - - - {{::ticket.id}} - - - - - {{::ticket.nickname}} - - - {{::ticket.address.province.name}} - {{::ticket.address.city}} - {{::ticket.address.postalCode}} - {{::ticket.address.street}} - - {{::ticket.zone.name}} - - - - - - - - - - - - - - - diff --git a/modules/route/front/ticket-popup/index.js b/modules/route/front/ticket-popup/index.js deleted file mode 100644 index 8fd7b5d71..000000000 --- a/modules/route/front/ticket-popup/index.js +++ /dev/null @@ -1,80 +0,0 @@ -import ngModule from '../module'; -import Dialog from 'core/components/dialog'; -import './style.scss'; - -class Controller extends Dialog { - constructor($element, $, $transclude) { - super($element, $, $transclude); - } - - getSelectedTickets(tickets) { - const selectedTickets = []; - - if (tickets) { - for (let i = 0; i < tickets.length; i++) { - if (tickets[i].checked) - selectedTickets.push(tickets[i]); - } - } - return selectedTickets; - } - - updateVolume() { - let url = `Routes/${this.route.id}/updateVolume`; - this.$http.post(url).then(() => { - this.$.model.refresh(); - if (this.parentReload) - this.parentReload(); - }); - } - - setTicketsRoute() { - const tickets = this.getSelectedTickets(this.possibleTickets); - if (tickets.length === 0) return; - - const updates = []; - - for (let ticket of tickets) { - delete ticket.checked; - const update = { - where: {id: ticket.id}, - data: {routeFk: this.route.id} - }; - - updates.push(update); - } - - const data = {creates: [], updates: updates, deletes: []}; - return this.$http.post(`Tickets/crud`, data) - .then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.updateVolume(); - this.hide(); - }); - } - - unlinkZone(ticket) { - const params = { - agencyModeId: this.route.agencyModeFk, - zoneId: ticket.zoneFk, - }; - - const query = `Routes/unlink`; - this.$http.post(query, params).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.$.model.refresh(); - this.hide(); - }); - } -} -Controller.$inject = ['$element', '$scope', '$transclude']; - -ngModule.vnComponent('vnRouteTicketPopup', { - slotTemplate: require('./index.html'), - controller: Controller, - bindings: { - route: '<', - model: ' { - let controller; - let $httpBackend; - let $scope; - - beforeEach(ngModule('route')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - const $element = angular.element(''); - const $transclude = { - $$boundTransclude: { - $$slots: [] - } - }; - controller = $componentController('vnRouteTicketPopup', {$element, $scope, $transclude}); - controller.route = {id: 1}; - controller.$.model = { - refresh: () => {}, - remove: () => {} - }; - controller.card = {reload: () => {}}; - })); - - describe('unlink()', () => { - it('should call the route unlink endpoint with the agency and zone ids', () => { - controller.$.model = {refresh: jest.fn()}; - jest.spyOn(controller.vnApp, 'showSuccess'); - jest.spyOn(controller, 'hide'); - - controller.route = { - agencyModeFk: 1 - }; - - const ticket = { - zoneFk: 2, - }; - const params = { - agencyModeId: controller.route.agencyModeFk, - zoneId: ticket.zoneFk, - }; - - $httpBackend.expectPOST(`Routes/unlink`, params).respond('ok'); - controller.unlinkZone(ticket); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.hide).toHaveBeenCalled(); - expect(controller.$.model.refresh).toHaveBeenCalledWith(); - }); - }); - - describe('setTicketsRoute()', () => { - it('should perform a POST query to add tickets to the route', () => { - controller.$.model = {refresh: jest.fn()}; - jest.spyOn(controller.vnApp, 'showSuccess'); - jest.spyOn(controller, 'hide'); - - controller.route = {id: 111}; - - controller.possibleTickets = [ - {id: 2, checked: false}, - {id: 3, checked: true}, - {id: 4, checked: false}, - {id: 5, checked: true}, - ]; - - $httpBackend.whenPOST(`Routes/${controller.route.id}/updateVolume`).respond(200); - $httpBackend.expectPOST('Tickets/crud').respond(); - controller.setTicketsRoute(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.hide).toHaveBeenCalled(); - expect(controller.$.model.refresh).toHaveBeenCalledWith(); - }); - }); -}); diff --git a/modules/route/front/ticket-popup/style.scss b/modules/route/front/ticket-popup/style.scss deleted file mode 100644 index 77fa48f20..000000000 --- a/modules/route/front/ticket-popup/style.scss +++ /dev/null @@ -1,5 +0,0 @@ -@import "variables"; - -.dialog{ - padding: $float-spacing -} \ No newline at end of file diff --git a/modules/route/front/tickets/__snapshots__/index.spec.js.snap b/modules/route/front/tickets/__snapshots__/index.spec.js.snap deleted file mode 100644 index 9476a8e09..000000000 --- a/modules/route/front/tickets/__snapshots__/index.spec.js.snap +++ /dev/null @@ -1,18 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Route getSelectedItems() should return the selected items 1`] = ` -Array [ - Object { - "checked": true, - "id": 1, - }, - Object { - "checked": true, - "id": 3, - }, - Object { - "checked": true, - "id": 5, - }, -] -`; diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html deleted file mode 100644 index 7fafeb0ba..000000000 --- a/modules/route/front/tickets/index.html +++ /dev/null @@ -1,203 +0,0 @@ - - - -
- -
- - - - - - - - - - - - - - - - - - - - - Order - Street - City - PC - Client - Warehouse - Packages - - Packaging - Ticket - - - - - - - - - - - - - - - - - - {{ticket.priority}} - - - - - - - {{::ticket.street}} - - {{::ticket.city}} - - {{::ticket.postalCode}} - - - {{::ticket.nickname}} - - - {{ticket.warehouseName}} - {{::ticket.packages}} - {{::ticket.volume | number:2}} - {{::ticket.ipt}} - - - {{::ticket.id}} - - - - - - - - - - - - - - - - - -
-
-
-
- - - - - - - - - -
- - - - - - -
- - - - - - - diff --git a/modules/route/front/tickets/index.js b/modules/route/front/tickets/index.js deleted file mode 100644 index a1b97005e..000000000 --- a/modules/route/front/tickets/index.js +++ /dev/null @@ -1,201 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; -import UserError from 'core/lib/user-error'; - -class Controller extends Section { - get isChecked() { - if (this.tickets) { - for (let instance of this.tickets) - if (instance.checked) return true; - } - - return false; - } - - getHighestPriority() { - let highestPriority = Math.max(...this.$.model.data.map(tag => { - return tag.priority; - })); - return highestPriority + 1; - } - - setHighestPriority(ticket) { - const highestPriority = this.getHighestPriority(); - if (highestPriority - 1 != ticket.priority) { - const params = {priority: highestPriority}; - const query = `Tickets/${ticket.id}/`; - this.$http.patch(query, params).then(res => { - ticket.priority = res.data.priority; - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - } - - setPriority(id, priority) { - let params = {priority: priority}; - let query = `Tickets/${id}/`; - this.$http.patch(query, params).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - deletePriority() { - const lines = this.getSelectedItems(this.tickets); - - for (const line of lines) { - this.$http.patch(`Tickets/${line.id}/`, {priority: null}).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.$.model.refresh(); - }); - } - } - - setOrderedPriority(lines) { - let priority = 1; - for (const line of lines) { - this.$http.patch(`Tickets/${line.id}/`, {priority: priority}).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.$.model.refresh(); - }); - priority++; - } - } - - getSelectedItems(items) { - const selectedItems = []; - - if (items) { - for (let i = 0; i < items.length; i++) { - if (items[i].checked) - selectedItems.push(items[i]); - } - } - return selectedItems; - } - - goToBuscaman(ticket) { - if (!this.route.vehicleFk) - throw new UserError(`The route doesn't have a vehicle`); - - this.$http.get(`Routes/${this.route.vehicleFk}/getDeliveryPoint`).then(res => { - if (!res.data) - throw new UserError(`The route's vehicle doesn't have a delivery point`); - - let addresses = res.data; - const lines = ticket ? [ticket] : this.getSelectedItems(this.tickets); - lines.forEach((line, index) => { - const previousLine = lines[index - 1] ? lines[index - 1].street : null; - if (previousLine != line.street) - addresses = addresses + '+to:' + line.postalCode + ' ' + line.city + ' ' + line.street; - }); - - const url = 'http://gps.buscalia.com/usuario/localizar.aspx?bmi=true&addr='; - window.open(url + encodeURI(addresses), '_blank'); - }); - } - - showDeleteConfirm(id) { - this.selectedTicket = id; - this.$.confirm.show(); - } - - removeTicketFromRoute($index) { - let params = {routeFk: null}; - let query = `Tickets/${this.selectedTicket}/`; - this.$http.patch(query, params).then(() => { - this.$.model.remove($index); - this.vnApp.showSuccess(this.$t('Ticket removed from route')); - this.updateVolume(); - }); - } - - updateVolume() { - let url = `Routes/${this.$params.id}/updateVolume`; - this.$http.post(url).then(() => { - this.card.reload(); - this.$.model.refresh(); - }); - } - - guessPriority() { - let query = `Routes/${this.$params.id}/guessPriority/`; - this.$http.patch(query).then(() => { - this.vnApp.showSuccess(this.$t('Order changed')); - this.$.model.refresh(); - }); - } - - onDrop($event) { - const ticketId = $event.dataTransfer.getData('Text'); - - if (isNaN(ticketId)) { - const regexp = new RegExp(/\/ticket\/([0-9]+)\//i); - const matches = ticketId.match(regexp); - - if (matches && matches.length) - this.insert(matches[1]); - else - this.vnApp.showError(this.$t('Ticket not found')); - } - - if (!isNaN(ticketId)) - this.insert(ticketId); - } - - insert(ticketId) { - ticketId = parseInt(ticketId); - - const query = `Routes/${this.route.id}/insertTicket`; - return this.$http.patch(query, {ticketId}).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.updateVolume(); - }).catch(error => { - if (error.status == 404) - return this.vnApp.showError(this.$t('Ticket not found')); - throw error; - }); - } - - async sendSms() { - try { - const clientsFk = []; - const clientsName = []; - const clients = []; - - const selectedTickets = this.getSelectedItems(this.$.$ctrl.tickets); - - for (let ticket of selectedTickets) { - clientsFk.push(ticket.clientFk); - let userContact = await this.$http.get(`Clients/${ticket.clientFk}`); - clientsName.push(userContact.data.name); - clients.push(userContact.data.phone); - } - - const destinationFk = String(clientsFk); - const destination = String(clients); - - this.newSMS = Object.assign({ - destinationFk: destinationFk, - destination: destination - }); - - this.$.sms.open(); - return true; - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } - } -} - -ngModule.vnComponent('vnRouteTickets', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnRouteCard' - }, - bindings: { - route: '<' - } -}); diff --git a/modules/route/front/tickets/index.spec.js b/modules/route/front/tickets/index.spec.js deleted file mode 100644 index fef4b8331..000000000 --- a/modules/route/front/tickets/index.spec.js +++ /dev/null @@ -1,277 +0,0 @@ -/* eslint max-len: ["error", { "code": 150 }]*/ -import './index'; - -describe('Route', () => { - let controller; - let $httpBackend; - let $scope; - - beforeEach(ngModule('route')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnRouteTickets', {$element, $scope}); - controller.route = {id: 1}; - controller.$.model = { - refresh: () => {}, - remove: () => {} - }; - controller.card = {reload: () => {}}; - })); - - describe('route setter/getter', () => { - it('should return the route id', () => { - controller.route = 2; - - expect(controller.route).toEqual(2); - }); - }); - - describe('isChecked getter', () => { - it('should return false if none of the tickets is checked or there are no tickets', () => { - expect(controller.isChecked).toBeFalsy(); - }); - - it('should return true if any of the tickets is checked', () => { - controller.tickets = [{checked: true}]; - - expect(controller.isChecked).toBeTruthy(); - }); - }); - - describe('getHighestPriority()', () => { - it('should return the highest value found in priorities plus 1', () => { - controller.$.model = {data: [ - {priority: 99}, - {priority: 1}, - {priority: 2}, - {priority: 3}, - {priority: 4}, - {priority: 5}, - ]}; - - let result = controller.getHighestPriority(); - - expect(result).toEqual(100); - }); - }); - - describe('setHighestPriority()', () => { - it('should set a ticket highest priority', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - controller.$.model.data = [{priority: 3}]; - const ticket = {id: 1, priority: 2}; - const res = {data: {priority: 4}}; - - $httpBackend.expectPATCH(`Tickets/${ticket.id}/`).respond(res); - controller.setHighestPriority(ticket); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('setPriority()', () => { - it('should set a ticket priority', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - const ticketId = 1; - const priority = 999; - - $httpBackend.expectPATCH(`Tickets/${ticketId}/`).respond('ok'); - controller.setPriority(ticketId, priority); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('deletePriority()', () => { - it('should delete priority of all tickets', () => { - jest.spyOn(controller.$.model, 'refresh'); - jest.spyOn(controller.vnApp, 'showSuccess'); - controller.tickets = [{id: 1, checked: true}]; - - $httpBackend.expectPATCH(`Tickets/${controller.tickets[0].id}/`).respond(); - controller.deletePriority(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.$.model.refresh).toHaveBeenCalledWith(); - }); - }); - - describe('setOrderedPriority()', () => { - it('should set priority of all tickets starting by 1', () => { - jest.spyOn(controller.$.model, 'refresh'); - jest.spyOn(controller.vnApp, 'showSuccess'); - const tickets = [{id: 1, checked: true}]; - - $httpBackend.expectPATCH(`Tickets/${tickets[0].id}/`).respond(); - controller.setOrderedPriority(tickets); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.$.model.refresh).toHaveBeenCalledWith(); - }); - }); - - describe('getSelectedItems()', () => { - it('should return the selected items', () => { - let items = [ - {id: 1, checked: true}, - {id: 2, checked: false}, - {id: 3, checked: true}, - {id: 4, checked: false}, - {id: 5, checked: true}, - ]; - - let selectedItems = controller.getSelectedItems(items); - - expect(selectedItems).toMatchSnapshot(); - }); - }); - - describe('goToBuscaman()', () => { - it('should open buscaman with the given arguments', () => { - jest.spyOn(window, 'open').mockReturnThis(); - const expectedUrl = 'http://gps.buscalia.com/usuario/localizar.aspx?bmi=true&addr=46460%20Av%20Espioca%20100+to:n19%20London%20my%20street'; - controller.route = {vehicleFk: 1}; - const url = `Routes/${controller.route.vehicleFk}/getDeliveryPoint`; - $httpBackend.expectGET(url).respond('46460 Av Espioca 100'); - - controller.tickets = [ - { - id: 1, - checked: true, - street: 'my street', - postalCode: 'n19', - city: 'London' - }, - ]; - - controller.goToBuscaman(); - $httpBackend.flush(); - - expect(window.open).toHaveBeenCalledWith(expectedUrl, '_blank'); - }); - }); - - describe('showDeleteConfirm()', () => { - it('should open a confirm dialog after setting the selected ticket into the controller', () => { - controller.$.confirm = {show: () => {}}; - jest.spyOn(controller.$.confirm, 'show'); - let ticketId = 1; - - controller.showDeleteConfirm(ticketId); - - expect(controller.selectedTicket).toEqual(ticketId); - expect(controller.$.confirm.show).toHaveBeenCalledWith(); - }); - }); - - describe('removeTicketFromRoute()', () => { - it('should perform a patch query then call showSuccess and updateVolume methods', () => { - controller.$params = {id: 1101}; - - jest.spyOn(controller.vnApp, 'showSuccess'); - jest.spyOn(controller.$.model, 'remove'); - - let ticketId = 1; - controller.selectedTicket = ticketId; - - $httpBackend.whenPOST(`Routes/${controller.$params.id}/updateVolume`).respond(200); - $httpBackend.expectPATCH(`Tickets/${ticketId}/`).respond('ok'); - controller.removeTicketFromRoute(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Ticket removed from route'); - }); - }); - - describe('updateVolume()', () => { - it('should perform a POST query then call both reload and refresh methods', () => { - controller.$params = {id: 999}; - jest.spyOn(controller.$.model, 'refresh'); - jest.spyOn(controller.card, 'reload'); - - let ticketId = 1; - controller.selectedTicket = ticketId; - - const url = `Routes/${controller.$params.id}/updateVolume`; - $httpBackend.expectPOST(url).respond('ok'); - controller.updateVolume(); - $httpBackend.flush(); - - expect(controller.$.model.refresh).toHaveBeenCalledWith(); - expect(controller.card.reload).toHaveBeenCalledWith(); - }); - }); - - describe('onDrop()', () => { - it('should call the insert method when dragging a ticket number', () => { - jest.spyOn(controller, 'insert'); - - const expectedTicketId = '11'; - const draggedElement = '11'; - const $event = { - dataTransfer: { - getData: () => draggedElement - } - }; - controller.onDrop($event); - - expect(controller.insert).toHaveBeenCalledWith(expectedTicketId); - }); - - it('should call the insert method when dragging a ticket link', () => { - jest.spyOn(controller, 'insert'); - - const expectedTicketId = '11'; - const draggedElement = 'http://arkamcity.com/#!/ticket/11/summary'; - const $event = { - dataTransfer: { - getData: () => draggedElement - } - }; - controller.onDrop($event); - - expect(controller.insert).toHaveBeenCalledWith(expectedTicketId); - }); - - it('should throw an error when dragging an invalid ticket link', () => { - jest.spyOn(controller.vnApp, 'showError'); - - const draggedElement = 'http://arkamcity.com/#!/item/11/summary'; - const $event = { - dataTransfer: { - getData: () => draggedElement - } - }; - controller.onDrop($event); - - expect(controller.vnApp.showError).toHaveBeenCalledWith('Ticket not found'); - }); - }); - - describe('insert()', () => { - it('should make a HTTP patch query and then call both refresh and showSuccess methods', () => { - controller.$params = {id: 1101}; - - jest.spyOn(controller.$.model, 'refresh').mockReturnThis(); - jest.spyOn(controller.vnApp, 'showSuccess'); - - const ticketId = 11; - const data = {ticketId}; - - $httpBackend.whenPOST(`Routes/${controller.$params.id}/updateVolume`).respond(200); - $httpBackend.expect('PATCH', `Routes/1/insertTicket`, data).respond(); - controller.insert(ticketId); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.$.model.refresh).toHaveBeenCalledWith(); - }); - }); -}); diff --git a/modules/route/front/tickets/locale/es.yml b/modules/route/front/tickets/locale/es.yml deleted file mode 100644 index e7f483d2f..000000000 --- a/modules/route/front/tickets/locale/es.yml +++ /dev/null @@ -1,18 +0,0 @@ -Remove ticket: Eliminar ticket -Open buscaman: Abrir buscaman -Ticket removed from route: Ticket quitado de la ruta -Order changed: Orden cambiado -Delete ticket from route?: ¿Quitar el ticket de la ruta? -Sort routes: Ordenar rutas -Add ticket: Añadir ticket -Tickets to add: Tickets a añadir -Ticket not found: No se ha encontrado el ticket -The selected ticket is not suitable for this route: El ticket seleccionado no es apto para esta ruta -PC: CP -The route's vehicle doesn't have a delivery point: El vehículo de la ruta no tiene un punto de entrega -The route doesn't have a vehicle: La ruta no tiene un vehículo -Population: Población -Unlink selected zone?: Desvincular zona seleccionada? -Delete priority: Borrar orden -Renumber all tickets in the order you see on the screen: Renumerar todos los tickets con el orden que ves por pantalla -Assign highest priority: Asignar máxima prioridad \ No newline at end of file diff --git a/modules/route/front/tickets/style.scss b/modules/route/front/tickets/style.scss deleted file mode 100644 index 9393a7d59..000000000 --- a/modules/route/front/tickets/style.scss +++ /dev/null @@ -1,16 +0,0 @@ -@import "variables"; - -vn-route-tickets form{ - margin: 0 auto; - max-width: $width-lg; - - .order-field { - max-width: 30px; - } -} - -.button-right{ - display: block; - padding-right: 50px; - text-align: right; -} \ No newline at end of file diff --git a/modules/shelving/back/model-config.json b/modules/shelving/back/model-config.json index 89a0832b0..6f3ffb5ea 100644 --- a/modules/shelving/back/model-config.json +++ b/modules/shelving/back/model-config.json @@ -11,6 +11,12 @@ "Sector": { "dataSource": "vn" }, + "SectorCollection": { + "dataSource": "vn" + }, + "SectorCollectionSaleGroup": { + "dataSource": "vn" + }, "Train": { "dataSource": "vn" } diff --git a/modules/shelving/back/models/sector.json b/modules/shelving/back/models/sector.json index 61d8d0628..16aa0ba6a 100644 --- a/modules/shelving/back/models/sector.json +++ b/modules/shelving/back/models/sector.json @@ -59,6 +59,9 @@ "isReserve": { "type": "boolean", "required": true + }, + "isOnReservationMode": { + "type": "boolean" } } -} +} \ No newline at end of file diff --git a/modules/shelving/back/models/sectorCollection.json b/modules/shelving/back/models/sectorCollection.json new file mode 100644 index 000000000..bf2cc7985 --- /dev/null +++ b/modules/shelving/back/models/sectorCollection.json @@ -0,0 +1,24 @@ +{ + "name": "SectorCollection", + "base": "VnModel", + "options": { + "mysql": { + "table": "sectorCollection" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "created": { + "type": "date" + }, + "userFk": { + "type": "number" + }, + "sectorFk": { + "type": "number" + } + } +} diff --git a/modules/shelving/back/models/sectorCollectionSaleGroup.json b/modules/shelving/back/models/sectorCollectionSaleGroup.json new file mode 100644 index 000000000..421bdc885 --- /dev/null +++ b/modules/shelving/back/models/sectorCollectionSaleGroup.json @@ -0,0 +1,30 @@ +{ + "name": "SectorCollectionSaleGroup", + "base": "VnModel", + "options": { + "mysql": { + "table": "sectorCollectionSaleGroup" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "created": { + "type": "date" + } + }, + "relations": { + "sectorCollection": { + "type": "belongsTo", + "model": "SectorCollection", + "foreignKey": "sectorCollectionFk" + }, + "saleGroup": { + "type": "belongsTo", + "model": "SaleGroup", + "foreignKey": "saleGroupFk" + } + } +} diff --git a/modules/supplier/back/methods/supplier/filter.js b/modules/supplier/back/methods/supplier/filter.js index 0b473f7df..a52eb6444 100644 --- a/modules/supplier/back/methods/supplier/filter.js +++ b/modules/supplier/back/methods/supplier/filter.js @@ -81,7 +81,7 @@ module.exports = Self => { let stmts = []; let stmt; stmt = new ParameterizedSQL( - `SELECT + `SELECT s.id, s.name AS socialName, s.nickname AS alias, @@ -92,10 +92,13 @@ module.exports = Self => { s.payDay, s.phone, s.city, + s.countryFk, + c.name country, pm.name AS payMethod, pd.payDem AS payDem FROM vn.supplier s LEFT JOIN vn.payMethod pm ON pm.id = s.payMethodFk + LEFT JOIN vn.country c ON c.id = s.countryFk LEFT JOIN vn.payDem pd ON pd.id = s.payDemFk` ); diff --git a/modules/supplier/back/methods/supplier/getItemsPackaging.js b/modules/supplier/back/methods/supplier/getItemsPackaging.js index c06195a55..8a27c89c4 100644 --- a/modules/supplier/back/methods/supplier/getItemsPackaging.js +++ b/modules/supplier/back/methods/supplier/getItemsPackaging.js @@ -33,7 +33,7 @@ module.exports = Self => { JOIN vn.item i ON i.id = b.itemFk WHERE e.id = ? AND e.supplierFk = ? GROUP BY i.id - ) SELECT i.id, i.name, et.quantity, SUM(b.quantity) quantityTotal, et.printedStickers + ) SELECT i.id, i.name, et.quantity, SUM(b.quantity) quantityTotal, et.printedStickers, ic.url FROM vn.buy b JOIN vn.item i ON i.id = b.itemFk JOIN vn.entry e ON e.id = b.entryFk @@ -41,6 +41,7 @@ module.exports = Self => { JOIN vn.buyConfig bc ON bc.monthsAgo JOIN vn.travel t ON t.id = e.travelFk LEFT JOIN entryTmp et ON et.id = i.id + JOIN hedera.imageConfig ic WHERE e.supplierFk = ? AND i.family IN ('EMB', 'CONT') AND b.created > (util.VN_CURDATE() - INTERVAL bc.monthsAgo MONTH) diff --git a/modules/supplier/back/methods/supplier/getSummary.js b/modules/supplier/back/methods/supplier/getSummary.js index 699233386..67767e7b4 100644 --- a/modules/supplier/back/methods/supplier/getSummary.js +++ b/modules/supplier/back/methods/supplier/getSummary.js @@ -55,7 +55,7 @@ module.exports = Self => { { relation: 'country', scope: { - fields: ['id', 'country', 'code'] + fields: ['id', 'name', 'code'] } }, { diff --git a/modules/supplier/back/methods/supplier/getWithPackaging.js b/modules/supplier/back/methods/supplier/getWithPackaging.js new file mode 100644 index 000000000..07e563412 --- /dev/null +++ b/modules/supplier/back/methods/supplier/getWithPackaging.js @@ -0,0 +1,45 @@ +module.exports = Self => { + Self.remoteMethod('getWithPackaging', { + description: 'Returns the list of suppliers with an entry of type packaging', + accessType: 'READ', + returns: { + type: 'object', + root: true + }, + http: { + path: `/getWithPackaging`, + verb: 'GET' + }, + nolimit: true + }); + Self.getWithPackaging = async options => { + const models = Self.app.models; + const myOptions = {}; + const oneYearAgo = new Date(); + oneYearAgo.setFullYear(oneYearAgo.getFullYear() - 1); + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const entries = await models.Entry.find({ + where: { + typeFk: 'packaging', + created: {gte: oneYearAgo} + }, + include: { + relation: 'supplier', + scope: { + fields: ['id', 'name'] + } + }, + fields: {supplierFk: true} + }, myOptions); + + const result = entries.map(item => ({ + id: item.supplier().id, + name: item.supplier().name + })); + return Array.from(new Map(result.map(entry => [entry.id, entry])).values()); + }; +}; + diff --git a/modules/supplier/back/methods/supplier/specs/consumption.spec.js b/modules/supplier/back/methods/supplier/specs/consumption.spec.js index 0b4d6f82c..4c729f64a 100644 --- a/modules/supplier/back/methods/supplier/specs/consumption.spec.js +++ b/modules/supplier/back/methods/supplier/specs/consumption.spec.js @@ -1,8 +1,8 @@ const app = require('vn-loopback/server/server'); describe('supplier consumption() filter', () => { + const ctx = beforeAll.getCtx(); it('should return a list of entries from the supplier 2', async() => { - const ctx = {req: {accessToken: {userId: 9}}, args: {}}; const filter = { where: { supplierFk: 2 diff --git a/modules/supplier/back/methods/supplier/specs/getWithPackaging.spec.js b/modules/supplier/back/methods/supplier/specs/getWithPackaging.spec.js new file mode 100644 index 000000000..bd30d7437 --- /dev/null +++ b/modules/supplier/back/methods/supplier/specs/getWithPackaging.spec.js @@ -0,0 +1,33 @@ +const {models} = require('vn-loopback/server/server'); + +describe('Supplier getWithPackaging()', () => { + it('should return a list of suppliers with an entry of type packaging', async() => { + const typeFk = 'packaging'; + + const tx = await models.Supplier.beginTransaction({}); + const myOptions = {transaction: tx}; + + try { + const entry = await models.Entry.findOne( + { + where: { + id: 1 + }, + myOptions + }); + + await entry.updateAttributes({ + typeFk: typeFk, + created: new Date() + }); + + const result = await models.Supplier.getWithPackaging(myOptions); + + expect(result.length).toEqual(1); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js b/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js index 7cb95f840..f1efbbbba 100644 --- a/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js +++ b/modules/supplier/back/methods/supplier/specs/updateFiscalData.spec.js @@ -3,7 +3,6 @@ const LoopBackContext = require('loopback-context'); describe('Supplier updateFiscalData()', () => { const supplierId = 1; - const administrativeId = 5; const buyerId = 35; const name = 'NEW PLANTS'; diff --git a/modules/supplier/back/models/specs/supplier.spec.js b/modules/supplier/back/models/specs/supplier.spec.js index 05d78240d..4e9bd3253 100644 --- a/modules/supplier/back/models/specs/supplier.spec.js +++ b/modules/supplier/back/models/specs/supplier.spec.js @@ -1,25 +1,13 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('loopback model Supplier', () => { let supplierOne; let supplierTwo; + beforeAll.mockLoopBackContext(); beforeAll(async() => { supplierOne = await models.Supplier.findById(1); supplierTwo = await models.Supplier.findById(442); - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); }); describe('payMethodFk', () => { diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index 2d3ffef3e..7e6908d57 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -12,6 +12,7 @@ module.exports = Self => { require('../methods/supplier/campaignMetricsEmail')(Self); require('../methods/supplier/newSupplier')(Self); require('../methods/supplier/getItemsPackaging')(Self); + require('../methods/supplier/getWithPackaging')(Self); Self.validatesPresenceOf('name', { message: 'The social name cannot be empty' diff --git a/modules/supplier/front/account/index.html b/modules/supplier/front/account/index.html deleted file mode 100644 index a0b58c737..000000000 --- a/modules/supplier/front/account/index.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - -
- - - - - - {{bic}} {{name}} - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - \ No newline at end of file diff --git a/modules/supplier/front/account/index.js b/modules/supplier/front/account/index.js deleted file mode 100644 index 5629e65d3..000000000 --- a/modules/supplier/front/account/index.js +++ /dev/null @@ -1,66 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.include = { - relation: 'bankEntity', - scope: { - fields: ['countryFk', 'id', 'name', 'bic'] - } - }; - const filter = { - where: {code: 'wireTransfer'} - }; - - this.$http.get(`payMethods/findOne`, {filter}) - .then(res => { - this.wireTransferFk = res.data.id; - }); - } - - add() { - this.$.model.insert({ - supplierFk: this.$params.id - }); - } - - onAccept(data) { - const accounts = this.supplierAccounts; - const targetAccount = accounts[data.index]; - targetAccount.bankEntityFk = data.id; - } - - onSubmit() { - this.$.watcher.check(); - return this.$.model.save() - .then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - return this.card.reload(); - }) - .then(() => { - if (this.supplier.payMethodFk != this.wireTransferFk) - this.$.payMethodToTransfer.show(); - }); - } - - setWireTransfer() { - const params = { - id: this.$params.id, - payMethodFk: this.wireTransferFk - }; - const query = `Suppliers/${this.$params.id}`; - return this.$http.patch(query, params) - .then(() => this.$.watcher.notifySaved()); - } -} - -ngModule.vnComponent('vnSupplierAccount', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnSupplierCard' - } -}); diff --git a/modules/supplier/front/account/index.spec.js b/modules/supplier/front/account/index.spec.js deleted file mode 100644 index ad29d1abc..000000000 --- a/modules/supplier/front/account/index.spec.js +++ /dev/null @@ -1,98 +0,0 @@ -import './index.js'; -import watcher from 'core/mocks/watcher'; -import crudModel from 'core/mocks/crud-model'; - -describe('Supplier Component vnSupplierAccount', () => { - let $scope; - let controller; - let $httpBackend; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - $scope.model = crudModel; - $scope.watcher = watcher; - - $scope.bankEntity = { - open: () => {} - }; - - const $element = angular.element(''); - controller = $componentController('vnSupplierAccount', {$element, $scope}); - controller.supplierAccount = { - supplierFk: 442, - name: 'Verdnatura' - }; - })); - - describe('onAccept()', () => { - it('should set the created bank entity id into the target account', () => { - controller.supplierAccounts = [{}, {}, {}]; - - const data = { - id: 999, - index: 1 - }; - - controller.onAccept(data); - - const targetAccount = controller.supplierAccounts[data.index]; - - expect(targetAccount.bankEntityFk).toEqual(data.id); - }); - }); - - describe('onSubmit()', () => { - it(`should reload the card`, done => { - controller.card = {reload: () => {}}; - controller.$.payMethodToTransfer = {show: () => {}}; - jest.spyOn(controller.$.payMethodToTransfer, 'show'); - jest.spyOn(controller.$.model, 'save').mockReturnValue(new Promise(resolve => { - return resolve({ - id: 1234 - }); - })); - jest.spyOn(controller.card, 'reload').mockReturnValue(new Promise(resolve => { - return resolve({ - id: 1234 - }); - })); - - controller.wireTransferFk = 'a'; - controller.supplier = {payMethodFk: 'b'}; - controller.onSubmit().then(() => { - expect(controller.card.reload).toHaveBeenCalledWith(); - expect(controller.$.payMethodToTransfer.show).toHaveBeenCalled(); - done(); - }).catch(done.fail); - }); - }); - - describe('setWireTransfer()', () => { - it(`should make HTTP PATCH request to set wire transfer and call notifySaved`, () => { - const supplierId = 1; - const params = { - id: supplierId, - payMethodFk: 2 - }; - const response = { - data: {id: 2} - }; - const uri = 'payMethods/findOne?filter=%7B%22where%22:%7B%22code%22:%22wireTransfer%22%7D%7D'; - jest.spyOn($scope.watcher, 'notifySaved'); - - controller.$params.id = supplierId; - controller.wireTransferFk = 2; - controller.supplier = {payMethodFk: 1}; - $httpBackend.expectGET(uri).respond(response); - $httpBackend.expectPATCH(`Suppliers/${supplierId}`, params).respond(); - controller.setWireTransfer(); - $httpBackend.flush(); - - expect($scope.watcher.notifySaved).toHaveBeenCalledWith(); - }); - }); -}); - diff --git a/modules/supplier/front/account/locale/en.yml b/modules/supplier/front/account/locale/en.yml deleted file mode 100644 index f41f5756a..000000000 --- a/modules/supplier/front/account/locale/en.yml +++ /dev/null @@ -1 +0,0 @@ -Beneficiary information: Name of the bank account holder if different from the provider \ No newline at end of file diff --git a/modules/supplier/front/account/locale/es.yml b/modules/supplier/front/account/locale/es.yml deleted file mode 100644 index f445a3fb8..000000000 --- a/modules/supplier/front/account/locale/es.yml +++ /dev/null @@ -1,6 +0,0 @@ -Bank entity: Entidad bancaria -swift: Swift BIC -Add account: Añadir cuenta -Beneficiary: Beneficiario -Beneficiary information: Nombre del titular de la cuenta bancaria en caso de ser diferente del proveedor -Do you want to change the pay method to wire transfer?: ¿Quieres modificar la forma de pago a transferencia? \ No newline at end of file diff --git a/modules/supplier/front/address/create/index.html b/modules/supplier/front/address/create/index.html deleted file mode 100644 index e3f883641..000000000 --- a/modules/supplier/front/address/create/index.html +++ /dev/null @@ -1,109 +0,0 @@ - - - - -
- - - - - - - - - - - {{code}} - {{town.name}} ({{town.province.name}}, - {{town.province.country.name}}) - - - - - - - - - {{name}}, {{province.name}} - ({{province.country.name}}) - - - - {{name}} ({{country.name}}) - - - - - - - - - - - - - - -
- - - - diff --git a/modules/supplier/front/address/create/index.js b/modules/supplier/front/address/create/index.js deleted file mode 100644 index 21b845881..000000000 --- a/modules/supplier/front/address/create/index.js +++ /dev/null @@ -1,74 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - - this.address = { - supplierFk: this.$params.id - }; - } - - onSubmit() { - this.$.watcher.submit().then(res => { - this.$state.go('supplier.card.address.index'); - }); - } - - get town() { - return this._town; - } - - // Town auto complete - set town(selection) { - this._town = selection; - - if (!selection) return; - - const province = selection.province; - const postcodes = selection.postcodes; - - if (!this.address.provinceFk) - this.address.provinceFk = province.id; - - if (postcodes.length === 1) - this.address.postalCode = postcodes[0].code; - } - - get postcode() { - return this._postcode; - } - - // Postcode auto complete - set postcode(selection) { - this._postcode = selection; - - if (!selection) return; - - const town = selection.town; - const province = town.province; - - if (!this.address.city) - this.address.city = town.name; - - if (!this.address.provinceFk) - this.address.provinceFk = province.id; - } - - onResponse(response) { - this.address.postalCode = response.code; - this.address.city = response.city; - this.address.provinceFk = response.provinceFk; - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnSupplierAddressCreate', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - } -}); diff --git a/modules/supplier/front/address/create/index.spec.js b/modules/supplier/front/address/create/index.spec.js deleted file mode 100644 index 026de3769..000000000 --- a/modules/supplier/front/address/create/index.spec.js +++ /dev/null @@ -1,102 +0,0 @@ -import './index'; -import watcher from 'core/mocks/watcher'; - -describe('Supplier', () => { - describe('Component vnSupplierAddressCreate', () => { - let $scope; - let controller; - let $element; - let $state; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, $rootScope, _$state_) => { - $scope = $rootScope.$new(); - $state = _$state_; - $state.params.id = '1234'; - $element = angular.element(''); - controller = $componentController('vnSupplierAddressCreate', {$element, $scope}); - controller.$.watcher = watcher; - controller.$.watcher.submit = () => { - return { - then: callback => { - callback({data: {id: 124}}); - } - }; - }; - controller.supplier = {id: 1}; - })); - - describe('onSubmit()', () => { - it('should perform a PATCH and then redirect to the main section', () => { - jest.spyOn(controller.$state, 'go'); - controller.onSubmit(); - - expect(controller.$state.go).toHaveBeenCalledWith('supplier.card.address.index'); - }); - }); - - describe('town() setter', () => { - it(`should set provinceFk property`, () => { - controller.town = { - provinceFk: 1, - code: 46001, - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }, - postcodes: [] - }; - - expect(controller.address.provinceFk).toEqual(1); - }); - - it(`should set provinceFk property and fill the postalCode if there's just one`, () => { - controller.town = { - provinceFk: 1, - code: 46001, - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }, - postcodes: [{code: '46001'}] - }; - - expect(controller.address.provinceFk).toEqual(1); - expect(controller.address.postalCode).toEqual('46001'); - }); - }); - - describe('postcode() setter', () => { - it(`should set the town and province properties`, () => { - controller.postcode = { - townFk: 1, - code: 46001, - town: { - id: 1, - name: 'New York', - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - } - } - }; - - expect(controller.address.city).toEqual('New York'); - expect(controller.address.provinceFk).toEqual(1); - }); - }); - }); -}); diff --git a/modules/supplier/front/address/edit/index.html b/modules/supplier/front/address/edit/index.html deleted file mode 100644 index b966023da..000000000 --- a/modules/supplier/front/address/edit/index.html +++ /dev/null @@ -1,104 +0,0 @@ - - - - - -
- - - - - - - - - - - {{code}} - {{town.name}} ({{town.province.name}}, - {{town.province.country.name}}) - - - - - - - - - {{name}}, {{province.name}} - ({{province.country.name}}) - - - - {{name}} ({{country.name}}) - - - - - - - - - - - - - -
- - - - diff --git a/modules/supplier/front/address/edit/index.js b/modules/supplier/front/address/edit/index.js deleted file mode 100644 index 4c7450666..000000000 --- a/modules/supplier/front/address/edit/index.js +++ /dev/null @@ -1,62 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onSubmit() { - this.$.watcher.submit() - .then(() => this.$state.go('supplier.card.address.index')); - } - - get town() { - return this._town; - } - - // Town auto complete - set town(selection) { - const oldValue = this._town; - this._town = selection; - - if (!selection || !oldValue) return; - - const province = selection.province; - const postcodes = selection.postcodes; - - if (!this.address.provinceFk) - this.address.provinceFk = province.id; - - if (!this.address.postalCode && postcodes.length === 1) - this.address.postalCode = postcodes[0].code; - } - - get postcode() { - return this._postcode; - } - - // Postcode auto complete - set postcode(selection) { - const oldValue = this._postcode; - this._postcode = selection; - - if (!selection || !oldValue) return; - - const town = selection.town; - const province = town.province; - - if (!this.address.city) - this.address.city = town.name; - - if (!this.address.provinceFk) - this.address.provinceFk = province.id; - } - - onResponse(response) { - this.address.postalCode = response.code; - this.address.city = response.city; - this.address.provinceFk = response.provinceFk; - } -} - -ngModule.vnComponent('vnSupplierAddressEdit', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/supplier/front/address/edit/index.spec.js b/modules/supplier/front/address/edit/index.spec.js deleted file mode 100644 index 991163baa..000000000 --- a/modules/supplier/front/address/edit/index.spec.js +++ /dev/null @@ -1,39 +0,0 @@ -import './index'; -import watcher from 'core/mocks/watcher'; - -describe('Supplier', () => { - describe('Component vnSupplierAddressEdit', () => { - let $scope; - let controller; - let $element; - let $state; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, $rootScope, _$state_) => { - $scope = $rootScope.$new(); - $state = _$state_; - $state.params.addressId = '1'; - $element = angular.element(''); - controller = $componentController('vnSupplierAddressEdit', {$element, $scope}); - controller.address = {id: 1}; - controller.$.watcher = watcher; - controller.$.watcher.submit = () => { - return { - then: callback => { - callback({data: {id: 124}}); - } - }; - }; - })); - - describe('onSubmit()', () => { - it('should perform a PATCH and then redirect to the main section', () => { - jest.spyOn(controller.$state, 'go'); - controller.onSubmit(); - - expect(controller.$state.go).toHaveBeenCalledWith('supplier.card.address.index'); - }); - }); - }); -}); diff --git a/modules/supplier/front/address/index/index.html b/modules/supplier/front/address/index/index.html deleted file mode 100644 index cb7b3d56c..000000000 --- a/modules/supplier/front/address/index/index.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - diff --git a/modules/supplier/front/address/index/index.js b/modules/supplier/front/address/index/index.js deleted file mode 100644 index c3985a0c1..000000000 --- a/modules/supplier/front/address/index/index.js +++ /dev/null @@ -1,46 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.filter = { - fields: [ - 'id', - 'nickname', - 'street', - 'city', - 'provinceFk', - 'phone', - 'mobile', - 'postalCode' - ], - order: ['nickname ASC'], - include: [{ - relation: 'province', - scope: { - fields: ['id', 'name'] - } - }] - }; - } - - exprBuilder(param, value) { - switch (param) { - case 'search': - return /^\d+$/.test(value) - ? {id: value} - : {nickname: {like: `%${value}%`}}; - } - } -} -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnSupplierAddressIndex', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - } -}); diff --git a/modules/supplier/front/address/index/index.spec.js b/modules/supplier/front/address/index/index.spec.js deleted file mode 100644 index 086d3a9fa..000000000 --- a/modules/supplier/front/address/index/index.spec.js +++ /dev/null @@ -1,34 +0,0 @@ -import './index'; - -describe('Supplier', () => { - describe('Component vnSupplierAddressIndex', () => { - let controller; - let $scope; - let $stateParams; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, $rootScope, _$stateParams_) => { - $stateParams = _$stateParams_; - $stateParams.id = 1; - $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnSupplierAddressIndex', {$element, $scope}); - controller.supplier = {id: 1}; - })); - - describe('exprBuilder()', () => { - it('should return a filter based on a search by id', () => { - const filter = controller.exprBuilder('search', '123'); - - expect(filter).toEqual({id: '123'}); - }); - - it('should return a filter based on a search by name', () => { - const filter = controller.exprBuilder('search', 'Arkham Chemicals'); - - expect(filter).toEqual({nickname: {like: '%Arkham Chemicals%'}}); - }); - }); - }); -}); diff --git a/modules/supplier/front/address/index/style.scss b/modules/supplier/front/address/index/style.scss deleted file mode 100644 index 44ce07b3c..000000000 --- a/modules/supplier/front/address/index/style.scss +++ /dev/null @@ -1,21 +0,0 @@ -@import "variables"; -@import "./effects"; - -vn-supplier-address-index { - .address { - padding-bottom: $spacing-md; - - &:last-child { - padding-bottom: 0; - } - & > a { - @extend %clickable; - box-sizing: border-box; - display: flex; - align-items: center; - width: 100%; - color: inherit; - overflow: hidden; - } - } -} \ No newline at end of file diff --git a/modules/supplier/front/address/locale/es.yml b/modules/supplier/front/address/locale/es.yml deleted file mode 100644 index 30009fa87..000000000 --- a/modules/supplier/front/address/locale/es.yml +++ /dev/null @@ -1,18 +0,0 @@ -# Index -Search by address: Buscar por dirección -You can search by address id or name: Puedes buscar por el id o nombre de la dirección - -# Create -Street address: Dirección postal -Postcode: Código postal -Town/City: Ciudad -Province: Provincia -Phone: Teléfono -Mobile: Móvil - -# Common -Fiscal name: Nombre fiscal -Street: Dirección fiscal -Addresses: Direcciones -New address: Nueva dirección -Edit address: Editar dirección \ No newline at end of file diff --git a/modules/supplier/front/agency-term/create/index.html b/modules/supplier/front/agency-term/create/index.html deleted file mode 100644 index 728e98146..000000000 --- a/modules/supplier/front/agency-term/create/index.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/supplier/front/agency-term/create/index.js b/modules/supplier/front/agency-term/create/index.js deleted file mode 100644 index 3f66ac5e9..000000000 --- a/modules/supplier/front/agency-term/create/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - - this.supplierAgencyTerm = { - supplierFk: this.$params.id - }; - } - - onSubmit() { - this.$.watcher.submit().then(res => { - this.$state.go('supplier.card.agencyTerm.index'); - }); - } -} - -ngModule.vnComponent('vnSupplierAgencyTermCreate', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - } -}); diff --git a/modules/supplier/front/agency-term/create/index.spec.js b/modules/supplier/front/agency-term/create/index.spec.js deleted file mode 100644 index 682e1cc58..000000000 --- a/modules/supplier/front/agency-term/create/index.spec.js +++ /dev/null @@ -1,28 +0,0 @@ -import './index'; -import watcher from 'core/mocks/watcher'; - -describe('Supplier', () => { - describe('Component vnSupplierAddressCreate', () => { - let $scope; - let controller; - let $element; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, $rootScope, _$state_) => { - $scope = $rootScope.$new(); - $scope.watcher = watcher; - $element = angular.element(''); - controller = $componentController('vnSupplierAgencyTermCreate', {$element, $scope}); - })); - - describe('onSubmit()', () => { - it(`should redirect to 'supplier.card.agencyTerm.index' state`, () => { - jest.spyOn(controller.$state, 'go'); - controller.onSubmit(); - - expect(controller.$state.go).toHaveBeenCalledWith('supplier.card.agencyTerm.index'); - }); - }); - }); -}); diff --git a/modules/supplier/front/agency-term/index/index.html b/modules/supplier/front/agency-term/index/index.html deleted file mode 100644 index 44c6deba9..000000000 --- a/modules/supplier/front/agency-term/index/index.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - diff --git a/modules/supplier/front/agency-term/index/index.js b/modules/supplier/front/agency-term/index/index.js deleted file mode 100644 index 9f77d686a..000000000 --- a/modules/supplier/front/agency-term/index/index.js +++ /dev/null @@ -1,36 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.filter = { - include: - {relation: 'agency', - scope: { - fields: ['id', 'name'] - } - } - }; - } - - add() { - this.$.model.insert({}); - } - - onSubmit() { - this.$.watcher.check(); - this.$.model.save().then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - }); - } -} - -ngModule.vnComponent('vnSupplierAgencyTermIndex', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - } -}); diff --git a/modules/supplier/front/agency-term/index/index.spec.js b/modules/supplier/front/agency-term/index/index.spec.js deleted file mode 100644 index 3e9ea4c1e..000000000 --- a/modules/supplier/front/agency-term/index/index.spec.js +++ /dev/null @@ -1,37 +0,0 @@ -import './index'; -import watcher from 'core/mocks/watcher'; -import crudModel from 'core/mocks/crud-model'; - -describe('Supplier', () => { - describe('Component vnSupplierAddressCreate', () => { - let $scope; - let controller; - let $element; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, $rootScope, _$state_) => { - $scope = $rootScope.$new(); - $scope.model = crudModel; - $scope.watcher = watcher; - $element = angular.element(''); - controller = $componentController('vnSupplierAgencyTermIndex', {$element, $scope}); - })); - - describe('onSubmit()', () => { - it('should make HTTP POST request to save values', () => { - jest.spyOn($scope.watcher, 'check'); - jest.spyOn($scope.watcher, 'notifySaved'); - jest.spyOn($scope.watcher, 'updateOriginalData'); - jest.spyOn($scope.model, 'save'); - - controller.onSubmit(); - - expect($scope.model.save).toHaveBeenCalledWith(); - expect($scope.watcher.updateOriginalData).toHaveBeenCalledWith(); - expect($scope.watcher.check).toHaveBeenCalledWith(); - expect($scope.watcher.notifySaved).toHaveBeenCalledWith(); - }); - }); - }); -}); diff --git a/modules/supplier/front/agency-term/locale/es.yml b/modules/supplier/front/agency-term/locale/es.yml deleted file mode 100644 index cdbd7c2ca..000000000 --- a/modules/supplier/front/agency-term/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Minimum M3: M3 minimos -Package Price: Precio bulto -Km Price: Precio Km -M3 Price: Precio M3 -Route Price: Precio ruta -Minimum Km: Km minimos -Remove row: Eliminar fila -Add row: Añadir fila -New autonomous: Nuevo autónomo diff --git a/modules/supplier/front/basic-data/index.html b/modules/supplier/front/basic-data/index.html deleted file mode 100644 index fcdb2a522..000000000 --- a/modules/supplier/front/basic-data/index.html +++ /dev/null @@ -1,62 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/supplier/front/basic-data/index.js b/modules/supplier/front/basic-data/index.js deleted file mode 100644 index 447118ebb..000000000 --- a/modules/supplier/front/basic-data/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnSupplierBasicData', { - template: require('./index.html'), - controller: Section, - bindings: { - supplier: '<' - } -}); diff --git a/modules/supplier/front/basic-data/locale/es.yml b/modules/supplier/front/basic-data/locale/es.yml deleted file mode 100644 index e965ffc2e..000000000 --- a/modules/supplier/front/basic-data/locale/es.yml +++ /dev/null @@ -1,5 +0,0 @@ -Notes: Notas -Active: Activo -Verified: Verificado -PayMethodChecked: Método de pago validado -Responsible for approving invoices: Responsable de aprobar las facturas \ No newline at end of file diff --git a/modules/supplier/front/billing-data/index.html b/modules/supplier/front/billing-data/index.html deleted file mode 100644 index 238760c1a..000000000 --- a/modules/supplier/front/billing-data/index.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - -
- - - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/modules/supplier/front/billing-data/index.js b/modules/supplier/front/billing-data/index.js deleted file mode 100644 index 9d2863f64..000000000 --- a/modules/supplier/front/billing-data/index.js +++ /dev/null @@ -1,28 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - get supplier() { - return this._supplier; - } - - set supplier(value) { - this._supplier = value; - } - - onSubmit() { - this.$.watcher.submit() - .then(() => this.card.reload()); - } -} - -ngModule.vnComponent('vnSupplierBillingData', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - }, - require: { - card: '^vnSupplierCard' - } -}); diff --git a/modules/supplier/front/billing-data/locale/es.yml b/modules/supplier/front/billing-data/locale/es.yml deleted file mode 100644 index d84d37f3a..000000000 --- a/modules/supplier/front/billing-data/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Pay day: Dia de pago \ No newline at end of file diff --git a/modules/supplier/front/card/index.html b/modules/supplier/front/card/index.html deleted file mode 100644 index 2c3c9df36..000000000 --- a/modules/supplier/front/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/supplier/front/card/index.js b/modules/supplier/front/card/index.js deleted file mode 100644 index 13fc3d52d..000000000 --- a/modules/supplier/front/card/index.js +++ /dev/null @@ -1,48 +0,0 @@ -import ngModule from '../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - let filter = { - include: [ - { - relation: 'province', - scope: { - fields: ['id', 'name'] - } - }, - { - relation: 'country', - scope: { - fields: ['id', 'name', 'code'] - } - }, - { - relation: 'payMethod', - scope: { - fields: ['id', 'name'] - } - }, - { - relation: 'payDem', - scope: { - fields: ['id', 'payDem'] - } - }, - { - relation: 'client', - scope: { - fields: ['id', 'fi'] - } - } - ] - }; - return this.$http.get(`Suppliers/${this.$params.id}`, {filter}) - .then(response => this.supplier = response.data); - } -} - -ngModule.vnComponent('vnSupplierCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/supplier/front/consumption-search-panel/index.html b/modules/supplier/front/consumption-search-panel/index.html deleted file mode 100644 index 5cba11d3c..000000000 --- a/modules/supplier/front/consumption-search-panel/index.html +++ /dev/null @@ -1,67 +0,0 @@ -
-
- - - - - - - - - - - - - -
{{name}}
-
- {{category.name}} -
-
-
- - -
- - - - - - - - - -
-
diff --git a/modules/supplier/front/consumption-search-panel/index.js b/modules/supplier/front/consumption-search-panel/index.js deleted file mode 100644 index f6c63c55c..000000000 --- a/modules/supplier/front/consumption-search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.vnComponent('vnSupplierConsumptionSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/supplier/front/consumption-search-panel/locale/es.yml b/modules/supplier/front/consumption-search-panel/locale/es.yml deleted file mode 100644 index f136283f8..000000000 --- a/modules/supplier/front/consumption-search-panel/locale/es.yml +++ /dev/null @@ -1,7 +0,0 @@ -Item id: Id artículo -From: Desde -To: Hasta -Campaign: Campaña -allSaints: Día de todos los Santos -valentinesDay: Día de San Valentín -mothersDay: Día de la madre \ No newline at end of file diff --git a/modules/supplier/front/consumption/index.html b/modules/supplier/front/consumption/index.html deleted file mode 100644 index e6c86abe3..000000000 --- a/modules/supplier/front/consumption/index.html +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - -
- - - - - - -
- - - - Entry - {{::entry.id}} - Date - {{::entry.shipped | date: 'dd/MM/yyyy'}} - Reference - {{::entry.invoiceNumber}} - - - - - - - {{::buy.itemName}} - - - -
- - -

{{::buy.subName}}

-
-
- - -
- {{::buy.quantity | dashIfEmpty}} - {{::buy.price | dashIfEmpty}} - {{::buy.total | dashIfEmpty}} - -
-
- - - - - - - - -
-
-
- - - - diff --git a/modules/supplier/front/consumption/index.js b/modules/supplier/front/consumption/index.js deleted file mode 100644 index 9af0d1747..000000000 --- a/modules/supplier/front/consumption/index.js +++ /dev/null @@ -1,88 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $, vnReport, vnEmail) { - super($element, $); - this.vnReport = vnReport; - this.vnEmail = vnEmail; - - this.setDefaultFilter(); - } - - setDefaultFilter() { - const minDate = Date.vnNew(); - minDate.setHours(0, 0, 0, 0); - minDate.setMonth(minDate.getMonth() - 2); - - const maxDate = Date.vnNew(); - maxDate.setHours(23, 59, 59, 59); - - this.filterParams = { - from: minDate, - to: maxDate - }; - } - - get reportParams() { - const userParams = this.$.model.userParams; - return Object.assign({ - authorization: this.vnToken.token, - recipientId: this.supplier.id - }, userParams); - } - - showReport() { - const path = `Suppliers/${this.supplier.id}/campaign-metrics-pdf`; - this.vnReport.show(path, this.reportParams); - } - - sendEmail() { - const params = { - filter: { - where: { - supplierFk: this.$params.id, - email: {neq: null} - }, - limit: 1 - } - }; - this.$http.get('SupplierContacts', params).then(({data}) => { - if (data.length) { - const contact = data[0]; - const params = Object.assign({ - recipient: contact.email - }, this.reportParams); - - const path = `Suppliers/${this.supplier.id}/campaign-metrics-email`; - this.vnEmail.send(path, params); - } else { - const message = this.$t(`This supplier doesn't have a contact with an email address`); - this.vnApp.showError(message); - } - }); - } - - getTotal(entry) { - if (entry.buys) { - let total = 0; - for (let buy of entry.buys) - total += buy.total; - - return total; - } - } -} - -Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail']; - -ngModule.vnComponent('vnSupplierConsumption', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - }, - require: { - card: '^vnSupplierCard' - } -}); diff --git a/modules/supplier/front/consumption/index.spec.js b/modules/supplier/front/consumption/index.spec.js deleted file mode 100644 index 0ac531a68..000000000 --- a/modules/supplier/front/consumption/index.spec.js +++ /dev/null @@ -1,110 +0,0 @@ -import './index.js'; -import crudModel from 'core/mocks/crud-model'; - -describe('Supplier', () => { - describe('Component vnSupplierConsumption', () => { - let $scope; - let controller; - let $httpParamSerializer; - let $httpBackend; - const supplierId = 2; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, $rootScope, _$httpParamSerializer_, _$httpBackend_) => { - $scope = $rootScope.$new(); - $httpParamSerializer = _$httpParamSerializer_; - $httpBackend = _$httpBackend_; - const $element = angular.element(' { - it('should call the window.open function', () => { - jest.spyOn(window, 'open').mockReturnThis(); - - const now = Date.vnNew(); - controller.$.model.userParams = { - from: now, - to: now - }; - - controller.showReport(); - - const expectedParams = { - recipientId: 2, - from: now, - to: now - }; - const serializedParams = $httpParamSerializer(expectedParams); - const path = `api/Suppliers/${supplierId}/campaign-metrics-pdf?${serializedParams}`; - - expect(window.open).toHaveBeenCalledWith(path); - }); - }); - - describe('sendEmail()', () => { - it('should throw an error', () => { - jest.spyOn(controller.vnApp, 'showError'); - - const expectedParams = { - filter: { - where: { - supplierFk: supplierId, - email: {neq: null} - }, - limit: 1 - } - }; - const serializedParams = $httpParamSerializer(expectedParams); - $httpBackend.expectGET(`SupplierContacts?${serializedParams}`).respond({}); - controller.sendEmail(); - $httpBackend.flush(); - - expect(controller.vnApp.showError) - .toHaveBeenCalledWith(`This supplier doesn't have a contact with an email address`); - }); - - it('should make a GET query sending the report', () => { - let serializedParams; - const params = { - filter: { - where: { - supplierFk: supplierId, - email: {neq: null} - }, - limit: 1 - } - }; - serializedParams = $httpParamSerializer(params); - $httpBackend.whenGET(`SupplierContacts?${serializedParams}`).respond([ - {id: 1, email: 'batman@gothamcity.com'} - ]); - - const now = Date.vnNew(); - controller.$.model.userParams = { - from: now, - to: now - }; - const expectedParams = { - recipient: 'batman@gothamcity.com', - from: now, - to: now - }; - - serializedParams = $httpParamSerializer(expectedParams); - const path = `Suppliers/${supplierId}/campaign-metrics-email`; - - $httpBackend.expect('POST', path).respond({}); - controller.sendEmail(); - $httpBackend.flush(); - }); - }); - }); -}); - diff --git a/modules/supplier/front/consumption/locale/es.yml b/modules/supplier/front/consumption/locale/es.yml deleted file mode 100644 index 08c2a22e5..000000000 --- a/modules/supplier/front/consumption/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Total entry: Total entrada -This supplier doesn't have a contact with an email address: Este proveedor no tiene ningún contacto con una dirección de email diff --git a/modules/supplier/front/contact/index.html b/modules/supplier/front/contact/index.html deleted file mode 100644 index 347e4261a..000000000 --- a/modules/supplier/front/contact/index.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - -
- -
- - - - - - - - - - - - - - - - - - - - -
- - - - -
- - - - - - -
\ No newline at end of file diff --git a/modules/supplier/front/contact/index.js b/modules/supplier/front/contact/index.js deleted file mode 100644 index 48db3d526..000000000 --- a/modules/supplier/front/contact/index.js +++ /dev/null @@ -1,27 +0,0 @@ -import ngModule from '../module'; -import './style.scss'; -import Section from 'salix/components/section'; - -class Controller extends Section { - add() { - this.$.model.insert({ - supplierFk: this.supplier.id - }); - } - - onSubmit() { - this.$.watcher.check(); - this.$.model.save().then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - }); - } -} - -ngModule.vnComponent('vnSupplierContact', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - } -}); diff --git a/modules/supplier/front/contact/style.scss b/modules/supplier/front/contact/style.scss deleted file mode 100644 index becc66dcf..000000000 --- a/modules/supplier/front/contact/style.scss +++ /dev/null @@ -1,10 +0,0 @@ -@import "variables"; - - -.contact { - max-width: $width-lg; - margin-bottom: 10px; - padding-right: 10px; - padding-left: 10px; - border: 1px solid $color-spacer; -} diff --git a/modules/supplier/front/create/index.html b/modules/supplier/front/create/index.html deleted file mode 100644 index 1e051f3a8..000000000 --- a/modules/supplier/front/create/index.html +++ /dev/null @@ -1,30 +0,0 @@ - - -
- - - - - - - - - - - - -
diff --git a/modules/supplier/front/create/index.js b/modules/supplier/front/create/index.js deleted file mode 100644 index c33367dac..000000000 --- a/modules/supplier/front/create/index.js +++ /dev/null @@ -1,23 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - } - - onSubmit() { - this.$.watcher.submit().then( - json => { - this.$state.go(`supplier.card.fiscalData`, {id: json.data.id}); - } - ); - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnSupplierCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/supplier/front/descriptor-popover/index.html b/modules/supplier/front/descriptor-popover/index.html deleted file mode 100644 index 874ba6708..000000000 --- a/modules/supplier/front/descriptor-popover/index.html +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/modules/supplier/front/descriptor-popover/index.js b/modules/supplier/front/descriptor-popover/index.js deleted file mode 100644 index a30aa4829..000000000 --- a/modules/supplier/front/descriptor-popover/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import ngModule from '../module'; -import DescriptorPopover from 'salix/components/descriptor-popover'; - -class Controller extends DescriptorPopover {} - -ngModule.vnComponent('vnSupplierDescriptorPopover', { - slotTemplate: require('./index.html'), - controller: Controller -}); diff --git a/modules/supplier/front/descriptor/index.html b/modules/supplier/front/descriptor/index.html deleted file mode 100644 index af5be2537..000000000 --- a/modules/supplier/front/descriptor/index.html +++ /dev/null @@ -1,66 +0,0 @@ - - -
- - - - - - - - - - - - -
-
- - - - -
- -
-
- - - \ No newline at end of file diff --git a/modules/supplier/front/descriptor/index.js b/modules/supplier/front/descriptor/index.js deleted file mode 100644 index f84b4ef92..000000000 --- a/modules/supplier/front/descriptor/index.js +++ /dev/null @@ -1,80 +0,0 @@ -import ngModule from '../module'; -import Descriptor from 'salix/components/descriptor'; - -class Controller extends Descriptor { - get supplier() { - return this.entity; - } - - set supplier(value) { - this.entity = value; - } - - get entryFilter() { - if (!this.supplier) return null; - - const date = Date.vnNew(); - date.setHours(0, 0, 0, 0); - - const from = new Date(date.getTime()); - from.setDate(from.getDate() - 10); - - const to = new Date(date.getTime()); - to.setDate(to.getDate() + 10); - - return JSON.stringify({ - supplierFk: this.id, - from, - to - }); - } - - loadData() { - const filter = { - fields: [ - 'id', - 'name', - 'nickname', - 'nif', - 'payMethodFk', - 'payDemFk', - 'payDay', - 'isActive', - 'isReal', - 'isTrucker', - 'account' - ], - include: [ - { - relation: 'payMethod', - scope: { - fields: ['id', 'name'] - } - }, - { - relation: 'payDem', - scope: { - fields: ['id', 'payDem'] - } - }, - { - relation: 'client', - scope: { - fields: ['id', 'fi'] - } - } - ] - }; - - return this.getData(`Suppliers/${this.id}`, {filter}) - .then(res => this.supplier = res.data); - } -} - -ngModule.vnComponent('vnSupplierDescriptor', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - } -}); diff --git a/modules/supplier/front/descriptor/index.spec.js b/modules/supplier/front/descriptor/index.spec.js deleted file mode 100644 index 12c3e43bc..000000000 --- a/modules/supplier/front/descriptor/index.spec.js +++ /dev/null @@ -1,65 +0,0 @@ -import './index.js'; - -describe('Supplier Component vnSupplierDescriptor', () => { - let $httpBackend; - let controller; - let $httpParamSerializer; - const supplier = {id: 1}; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => { - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - controller = $componentController('vnSupplierDescriptor', {$element: null}, {supplier}); - })); - - describe('loadData()', () => { - it('should perform ask for the supplier', () => { - const filter = { - fields: [ - 'id', - 'name', - 'nickname', - 'nif', - 'payMethodFk', - 'payDemFk', - 'payDay', - 'isActive', - 'isReal', - 'isTrucker', - 'account' - ], - include: [ - { - relation: 'payMethod', - scope: { - fields: ['id', 'name'] - } - }, - { - relation: 'payDem', - scope: { - fields: ['id', 'payDem'] - } - }, - { - relation: 'client', - scope: { - fields: ['id', 'fi'] - } - } - ] - }; - const serializedParams = $httpParamSerializer({filter}); - let query = `Suppliers/${controller.supplier.id}?${serializedParams}`; - jest.spyOn(controller, 'getData'); - - $httpBackend.expect('GET', query).respond({id: 1}); - controller.loadData(); - $httpBackend.flush(); - - expect(controller.getData).toHaveBeenCalledTimes(1); - }); - }); -}); diff --git a/modules/supplier/front/descriptor/locale/es.yml b/modules/supplier/front/descriptor/locale/es.yml deleted file mode 100644 index cf4a52393..000000000 --- a/modules/supplier/front/descriptor/locale/es.yml +++ /dev/null @@ -1,8 +0,0 @@ -Tax number: NIF / CIF -All entries with current supplier: Todas las entradas con el proveedor actual -Go to client: Ir al cliente -Verified supplier: Proveedor verificado -Unverified supplier: Proveedor no verificado -Inactive supplier: Proveedor inactivo -Create invoiceIn: Crear factura recibida -Supplier name: Razón social diff --git a/modules/supplier/front/fiscal-data/index.html b/modules/supplier/front/fiscal-data/index.html deleted file mode 100644 index 6455bf3fd..000000000 --- a/modules/supplier/front/fiscal-data/index.html +++ /dev/null @@ -1,237 +0,0 @@ - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - {{id}}: {{transaction}} - - - - - - - - - - - - - - {{code}} - {{town.name}} ({{town.province.name}}, - {{town.province.country.name}}) - - - - - - - - - - - {{name}}, {{province.name}} - ({{province.country.name}}) - - - - {{name}} ({{country.name}}) - - - - - - - - - - - - - - - - - - - -
- - - diff --git a/modules/supplier/front/fiscal-data/index.js b/modules/supplier/front/fiscal-data/index.js deleted file mode 100644 index 8a6a51249..000000000 --- a/modules/supplier/front/fiscal-data/index.js +++ /dev/null @@ -1,86 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - get province() { - return this._province; - } - - // Province auto complete - set province(selection) { - const oldValue = this._province; - this._province = selection; - - if (!selection || !oldValue) return; - - const country = selection.country; - - if (!this.supplier.countryFk) - this.supplier.countryFk = country.id; - } - - get town() { - return this._town; - } - - // Town auto complete - set town(selection) { - const oldValue = this._town; - this._town = selection; - - if (!selection || !oldValue) return; - - const province = selection.province; - const country = province.country; - const postcodes = selection.postcodes; - - if (!this.supplier.provinceFk) - this.supplier.provinceFk = province.id; - - if (!this.supplier.countryFk) - this.supplier.countryFk = country.id; - - if (!this.supplier.postCode && postcodes.length === 1) - this.supplier.postCode = postcodes[0].code; - } - - get postcode() { - return this._postcode; - } - - // Postcode auto complete - set postcode(selection) { - const oldValue = this._postcode; - this._postcode = selection; - - if (!selection || !oldValue) return; - - const town = selection.town; - const province = town.province; - const country = province.country; - - if (!this.supplier.city) - this.supplier.city = town.name; - - if (!this.supplier.provinceFk) - this.supplier.provinceFk = province.id; - - if (!this.supplier.countryFk) - this.supplier.countryFk = country.id; - } - - onResponse(response) { - this.supplier.postCode = response.code; - this.supplier.city = response.city; - this.supplier.provinceFk = response.provinceFk; - this.supplier.countryFk = response.countryFk; - } -} - -ngModule.vnComponent('vnSupplierFiscalData', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - } -}); diff --git a/modules/supplier/front/fiscal-data/index.spec.js b/modules/supplier/front/fiscal-data/index.spec.js deleted file mode 100644 index 6fb135c08..000000000 --- a/modules/supplier/front/fiscal-data/index.spec.js +++ /dev/null @@ -1,109 +0,0 @@ -import './index'; -import watcher from 'core/mocks/watcher'; - -describe('Supplier', () => { - describe('Component vnSupplierFiscalData', () => { - let $scope; - let $element; - let controller; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - $scope.watcher = watcher; - $scope.watcher.orgData = {id: 1}; - $element = angular.element(''); - controller = $componentController('vnSupplierFiscalData', {$element, $scope}); - controller.card = {reload: () => {}}; - controller.supplier = { - id: 1, - name: 'Batman' - }; - - controller._province = {}; - controller._town = {}; - controller._postcode = {}; - })); - - describe('province() setter', () => { - it(`should set countryFk property`, () => { - controller.supplier.countryFk = null; - controller.province = { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }; - - expect(controller.supplier.countryFk).toEqual(2); - }); - }); - - describe('town() setter', () => { - it(`should set provinceFk property`, () => { - controller.town = { - provinceFk: 1, - code: 46001, - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }, - postcodes: [] - }; - - expect(controller.supplier.provinceFk).toEqual(1); - }); - - it(`should set provinceFk property and fill the postalCode if there's just one`, () => { - controller.town = { - provinceFk: 1, - code: 46001, - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }, - postcodes: [{code: '46001'}] - }; - - expect(controller.supplier.provinceFk).toEqual(1); - expect(controller.supplier.postCode).toEqual('46001'); - }); - }); - - describe('postcode() setter', () => { - it(`should set the town, provinceFk and contryFk properties`, () => { - controller.postcode = { - townFk: 1, - code: 46001, - town: { - id: 1, - name: 'New York', - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - } - } - }; - - expect(controller.supplier.city).toEqual('New York'); - expect(controller.supplier.provinceFk).toEqual(1); - expect(controller.supplier.countryFk).toEqual(2); - }); - }); - }); -}); diff --git a/modules/supplier/front/fiscal-data/locale/es.yml b/modules/supplier/front/fiscal-data/locale/es.yml deleted file mode 100644 index ee641231f..000000000 --- a/modules/supplier/front/fiscal-data/locale/es.yml +++ /dev/null @@ -1,8 +0,0 @@ -Sage tax type: Tipo de impuesto Sage -Sage transaction type: Tipo de transacción Sage -Sage withholding: Retención Sage -Supplier activity: Actividad proveedor -Healt register: Pasaporte sanitario -Trucker: Transportista -When activating it, do not enter the country code in the ID field.: Al activarlo, no informar el código del país en el campo nif -The first two values are letters.: Los dos primeros valores son letras \ No newline at end of file diff --git a/modules/supplier/front/index.js b/modules/supplier/front/index.js index 9216d0781..a7209a0bd 100644 --- a/modules/supplier/front/index.js +++ b/modules/supplier/front/index.js @@ -1,23 +1,3 @@ export * from './module'; import './main'; -import './card'; -import './descriptor'; -import './descriptor-popover'; -import './index/'; -import './search-panel'; -import './summary'; -import './basic-data'; -import './fiscal-data'; -import './account'; -import './contact'; -import './log'; -import './consumption'; -import './consumption-search-panel'; -import './billing-data'; -import './address/index'; -import './address/create'; -import './address/edit'; -import './agency-term/index'; -import './agency-term/create'; -import './create/index'; diff --git a/modules/supplier/front/index/index.html b/modules/supplier/front/index/index.html deleted file mode 100644 index 49f38cb1b..000000000 --- a/modules/supplier/front/index/index.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/supplier/front/index/index.js b/modules/supplier/front/index/index.js deleted file mode 100644 index 77b2e8347..000000000 --- a/modules/supplier/front/index/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - openSummary(supplier, event) { - if (event.defaultPrevented) return; - event.preventDefault(); - event.stopPropagation(); - - this.supplierSelected = supplier; - this.$.dialogSummarySupplier.show(); - } -} - -ngModule.vnComponent('vnSupplierIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/supplier/front/index/locale/es.yml b/modules/supplier/front/index/locale/es.yml deleted file mode 100644 index ce06f462c..000000000 --- a/modules/supplier/front/index/locale/es.yml +++ /dev/null @@ -1,6 +0,0 @@ -Payment deadline: Plazo de pago -Pay day: Dia de pago -Account: Cuenta -Pay method: Metodo de pago -Tax number: Nif -New supplier: Nuevo proveedor \ No newline at end of file diff --git a/modules/supplier/front/log/index.html b/modules/supplier/front/log/index.html deleted file mode 100644 index 7895b585e..000000000 --- a/modules/supplier/front/log/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/modules/supplier/front/log/index.js b/modules/supplier/front/log/index.js deleted file mode 100644 index 52a491c70..000000000 --- a/modules/supplier/front/log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnSupplierLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/supplier/front/main/index.html b/modules/supplier/front/main/index.html index 04d7aa0ad..e69de29bb 100644 --- a/modules/supplier/front/main/index.html +++ b/modules/supplier/front/main/index.html @@ -1,17 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/modules/supplier/front/main/index.js b/modules/supplier/front/main/index.js index 2fd870573..fd99cc0a2 100644 --- a/modules/supplier/front/main/index.js +++ b/modules/supplier/front/main/index.js @@ -1,7 +1,15 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; -export default class Supplier extends ModuleMain {} +export default class Supplier extends ModuleMain { + constructor($element, $) { + super($element, $); + } + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`supplier/`); + } +} ngModule.vnComponent('vnSupplier', { controller: Supplier, diff --git a/modules/supplier/front/routes.json b/modules/supplier/front/routes.json index 75b8213cb..ab0022ff9 100644 --- a/modules/supplier/front/routes.json +++ b/modules/supplier/front/routes.json @@ -36,146 +36,6 @@ "state": "supplier.index", "component": "vn-supplier-index", "description": "Suppliers" - }, - { - "url": "/:id", - "state": "supplier.card", - "abstract": true, - "component": "vn-supplier-card" - }, - { - "url": "/summary", - "state": "supplier.card.summary", - "component": "vn-supplier-summary", - "description": "Summary", - "params": { - "supplier": "$ctrl.supplier" - } - }, - { - "url": "/create", - "state": "supplier.create", - "component": "vn-supplier-create", - "acl": ["administrative"], - "description": "New supplier" - }, - { - "url": "/basic-data", - "state": "supplier.card.basicData", - "component": "vn-supplier-basic-data", - "description": "Basic data", - "acl": ["administrative"], - "params": { - "supplier": "$ctrl.supplier" - } - }, - { - "url": "/fiscal-data", - "state": "supplier.card.fiscalData", - "component": "vn-supplier-fiscal-data", - "description": "Fiscal data", - "params": { - "supplier": "$ctrl.supplier" - }, - "acl": ["administrative"] - }, - { - "url" : "/log", - "state": "supplier.card.log", - "component": "vn-supplier-log", - "description": "Log" - }, - { - "url": "/contact", - "state": "supplier.card.contact", - "component": "vn-supplier-contact", - "description": "Contacts", - "params": { - "supplier": "$ctrl.supplier" - } - }, - { - "url": "/agency-term", - "state": "supplier.card.agencyTerm", - "component": "ui-view", - "abstract": true - }, - { - "url": "/index", - "state": "supplier.card.agencyTerm.index", - "component": "vn-supplier-agency-term-index", - "description": "Agency Agreement", - "params": { - "supplier": "$ctrl.supplier" - } - }, - { - "url": "/create", - "state": "supplier.card.agencyTerm.create", - "component": "vn-supplier-agency-term-create", - "description": "New autonomous", - "params": { - "supplier": "$ctrl.supplier" - } - }, - { - "url": "/consumption?q", - "state": "supplier.card.consumption", - "component": "vn-supplier-consumption", - "description": "Consumption", - "params": { - "supplier": "$ctrl.supplier" - } - }, - { - "url": "/billing-data", - "state": "supplier.card.billingData", - "component": "vn-supplier-billing-data", - "description": "Billing data", - "params": { - "supplier": "$ctrl.supplier" - }, - "acl": ["administrative"] - }, - { - "url": "/account", - "state": "supplier.card.account", - "component": "vn-supplier-account", - "description": "Accounts", - "params": { - "supplier": "$ctrl.supplier" - }, - "acl": ["administrative"] - }, - { - "url": "/address", - "state": "supplier.card.address", - "component": "ui-view", - "abstract": true - }, - { - "url": "/index?q", - "state": "supplier.card.address.index", - "component": "vn-supplier-address-index", - "description": "Addresses", - "params": { - "supplier": "$ctrl.supplier" - } - }, - { - "url": "/create", - "state": "supplier.card.address.create", - "component": "vn-supplier-address-create", - "description": "New address", - "params": { - "supplier": "$ctrl.supplier" - } - }, - { - "url": "/:addressId/edit", - "state": "supplier.card.address.edit", - "component": "vn-supplier-address-edit", - "description": "Edit address" } ] -} \ No newline at end of file +} diff --git a/modules/supplier/front/search-panel/index.html b/modules/supplier/front/search-panel/index.html deleted file mode 100644 index 161c8a98c..000000000 --- a/modules/supplier/front/search-panel/index.html +++ /dev/null @@ -1,46 +0,0 @@ -
-
- - - - - - - - - - - - - - - - - - - -
-
\ No newline at end of file diff --git a/modules/supplier/front/search-panel/index.js b/modules/supplier/front/search-panel/index.js deleted file mode 100644 index 6223b5670..000000000 --- a/modules/supplier/front/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.vnComponent('vnSupplierSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/supplier/front/search-panel/locale/es.yml b/modules/supplier/front/search-panel/locale/es.yml deleted file mode 100644 index 77253a4ef..000000000 --- a/modules/supplier/front/search-panel/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -Province: Provincia -Country: País -Tax number: NIF / CIF -Search suppliers by id, name or alias: Busca proveedores por id, nombre o alias \ No newline at end of file diff --git a/modules/supplier/front/summary/index.html b/modules/supplier/front/summary/index.html deleted file mode 100644 index 5ba713fcf..000000000 --- a/modules/supplier/front/summary/index.html +++ /dev/null @@ -1,172 +0,0 @@ - -
- - - - {{::$ctrl.summary.name}} - {{::$ctrl.summary.id}} -
- - -

- - Basic data - -

-

- Basic data -

- - - - - - - - {{$ctrl.summary.worker.user.nickname}} - - - - - - - - - -
- -

- - Billing data - -

-

- Billing data -

- - - - - - - - -
-
- - -

- - Fiscal data - -

-

- Fiscal data -

- - - - - - - - - -
-
- - -

- - Fiscal address - -

-

- Fiscal address -

- - - - - - - - - - - - - - -
-
-
- - \ No newline at end of file diff --git a/modules/supplier/front/summary/index.js b/modules/supplier/front/summary/index.js deleted file mode 100644 index a828379bc..000000000 --- a/modules/supplier/front/summary/index.js +++ /dev/null @@ -1,30 +0,0 @@ -import ngModule from '../module'; -import Summary from 'salix/components/summary'; -import './style.scss'; - -class Controller extends Summary { - $onChanges() { - if (!this.supplier) - return; - - this.getSummary(); - } - - get isAdministrative() { - return this.aclService.hasAny(['administrative']); - } - - getSummary() { - return this.$http.get(`Suppliers/${this.supplier.id}/getSummary`).then(response => { - this.summary = response.data; - }); - } -} - -ngModule.vnComponent('vnSupplierSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - supplier: '<' - } -}); diff --git a/modules/supplier/front/summary/index.spec.js b/modules/supplier/front/summary/index.spec.js deleted file mode 100644 index aa44cd14f..000000000 --- a/modules/supplier/front/summary/index.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -import './index'; - -describe('Supplier', () => { - describe('Component vnSupplierSummary', () => { - let controller; - let $httpBackend; - let $scope; - - beforeEach(ngModule('supplier')); - - beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnSupplierSummary', {$element, $scope}); - })); - - describe('getSummary()', () => { - it('should perform a get asking for the supplier data', () => { - controller.supplier = {id: 1}; - - const query = `Suppliers/${controller.supplier.id}/getSummary`; - - $httpBackend.expectGET(query).respond({id: 1}); - controller.getSummary(); - $httpBackend.flush(); - - expect(controller.summary).toEqual({id: 1}); - }); - }); - }); -}); diff --git a/modules/supplier/front/summary/locale/es.yml b/modules/supplier/front/summary/locale/es.yml deleted file mode 100644 index 35291e579..000000000 --- a/modules/supplier/front/summary/locale/es.yml +++ /dev/null @@ -1,12 +0,0 @@ -Verified: Verificado -Country: País -Tax number: NIF / CIF -Search suppliers by id, name or alias: Busca proveedores por id, nombre o alias -Is Farmer: Es agrícola -Sage tax type: Tipo de impuesto Sage -Sage transaction type: Tipo de transacción Sage -Sage withholding: Retencion Sage -Go to the supplier: Ir al proveedor -Responsible: Responsable -Supplier activity: Actividad proveedor -Healt register: Pasaporte sanitario \ No newline at end of file diff --git a/modules/supplier/front/summary/style.scss b/modules/supplier/front/summary/style.scss deleted file mode 100644 index 1eb6b2323..000000000 --- a/modules/supplier/front/summary/style.scss +++ /dev/null @@ -1,7 +0,0 @@ -@import "variables"; - -vn-client-summary { - .alert span { - color: $color-alert - } -} \ No newline at end of file diff --git a/modules/ticket/back/methods/expedition-state/addExpeditionState.js b/modules/ticket/back/methods/expedition-state/addExpeditionState.js index 8eab1a838..80d74ee92 100644 --- a/modules/ticket/back/methods/expedition-state/addExpeditionState.js +++ b/modules/ticket/back/methods/expedition-state/addExpeditionState.js @@ -44,11 +44,13 @@ module.exports = Self => { const typeFk = expeditionStateType.id; expeditionId = expedition.expeditionFk; + const isScannedExpedition = expedition.isScanned ?? false; await models.ExpeditionState.create({ expeditionFk: expedition.expeditionFk, typeFk, userFk: userId, + isScanned: isScannedExpedition, }, myOptions); } diff --git a/modules/ticket/back/methods/expedition-state/specs/addExpeditionState.spec.js b/modules/ticket/back/methods/expedition-state/specs/addExpeditionState.spec.js index 6c7739006..747352286 100644 --- a/modules/ticket/back/methods/expedition-state/specs/addExpeditionState.spec.js +++ b/modules/ticket/back/methods/expedition-state/specs/addExpeditionState.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('expeditionState addExpeditionState()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; + const ctx = beforeAll.getCtx(); it('should update the expedition states', async() => { const tx = await models.ExpeditionState.beginTransaction({}); try { diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js index 55ca474d7..75993a485 100644 --- a/modules/ticket/back/methods/expedition/deleteExpeditions.js +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -27,34 +27,33 @@ module.exports = Self => { const deletedExpeditions = []; for (let expeditionId of expeditionIds) { - const filter = { - fields: [], - where: { - id: expeditionId - }, - include: [ - { - relation: 'agencyMode', - scope: { - fields: ['code'], + try { + const expedition = await models.Expedition.findById(expeditionId, { + include: [ + { + relation: 'agencyMode', + scope: { + fields: ['code'], + } } - } - ] - }; + ] + }); + const {code} = expedition.agencyMode(); - const expedition = await models.Expedition.findOne(filter); - const {code} = expedition.agencyMode(); + if (code?.toLowerCase()?.includes('mrw') && expedition.externalId) { + const result = await models.MrwConfig.cancelShipment(expeditionId); + if (!result) throw new Error('not deleted'); + } - if (code && code.toLowerCase().substring(0, 10) == 'viaexpress') { - const isDeleted = await models.ViaexpressConfig.deleteExpedition(expeditionId); + if (code?.toLowerCase()?.substring(0, 10) == 'viaexpress') { + const result = await models.ViaexpressConfig.deleteExpedition(expeditionId); + if (result !== 'true') throw new Error('not deleted'); + } - if (isDeleted === 'true') { - const deletedExpedition = await models.Expedition.destroyById(expeditionId); - deletedExpeditions.push(deletedExpedition); - } else notDeletedExpeditions.push(expeditionId); - } else { const deletedExpedition = await models.Expedition.destroyById(expeditionId); deletedExpeditions.push(deletedExpedition); + } catch (e) { + notDeletedExpeditions.push(expeditionId); } } diff --git a/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js index bf8bafe34..4b17f98b7 100644 --- a/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js +++ b/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js @@ -1,19 +1,7 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('ticket deleteExpeditions()', () => { - let ctx; - beforeAll(async() => { - ctx = { - accessToken: {userId: 9}, - req: { - headers: {origin: 'http://localhost'} - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: ctx - }); - }); + const ctx = beforeAll.getCtx(); it('should delete the selected expeditions', async() => { const tx = await models.Expedition.beginTransaction({}); diff --git a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js index 5f211543e..c1c7c2c12 100644 --- a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js +++ b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js @@ -1,29 +1,11 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('ticket moveExpeditions()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + const ctx = beforeAll.getCtx(); it('should move the selected expeditions to new ticket', async() => { const tx = await models.Expedition.beginTransaction({}); - const ctx = { - req: {accessToken: {userId: 9}}, - args: {}, - params: {} - }; - const myCtx = Object.assign({}, ctx); + const myCtx = ctx; try { const options = {transaction: tx}; @@ -38,7 +20,7 @@ describe('ticket moveExpeditions()', () => { }; - const ticket = await models.Expedition.moveExpeditions(myCtx, options); + const ticket = await models.Expedition.moveExpeditions(ctx, options); const newestTicketIdInFixtures = 27; diff --git a/modules/ticket/back/methods/sale-tracking/setPicked.js b/modules/ticket/back/methods/sale-tracking/setPicked.js index ed3656cf4..b63a0474f 100644 --- a/modules/ticket/back/methods/sale-tracking/setPicked.js +++ b/modules/ticket/back/methods/sale-tracking/setPicked.js @@ -75,7 +75,11 @@ module.exports = Self => { const itemShelving = await models.ItemShelving.findById(itemShelvingFk, null, myOptions); - await itemShelving.updateAttributes({visible: itemShelving.visible - quantity}, myOptions); + await itemShelving.updateAttributes( + { + visible: itemShelving.visible - quantity, + available: itemShelving.available - quantity + }, myOptions); await Self.updateAll( {saleFk}, diff --git a/modules/ticket/back/methods/sale/clone.js b/modules/ticket/back/methods/sale/clone.js index 77c40d8a0..0b658a69e 100644 --- a/modules/ticket/back/methods/sale/clone.js +++ b/modules/ticket/back/methods/sale/clone.js @@ -1,40 +1,25 @@ module.exports = Self => { Self.remoteMethodCtx('clone', { - description: 'Clone sales and services provided', + description: 'Clone sales, services, and ticket packaging provided', accessType: 'WRITE', accepts: [ - { - arg: 'salesIds', - type: ['number'], - }, { - arg: 'servicesIds', - type: ['number'] - }, { - arg: 'withWarehouse', - type: 'boolean', - required: true - }, { - arg: 'negative', - type: 'boolean' - } + {arg: 'salesIds', type: ['number']}, + {arg: 'servicesIds', type: ['number']}, + {arg: 'ticketPackagingIds', type: ['number']}, + {arg: 'withWarehouse', type: 'boolean', required: true}, + {arg: 'negative', type: 'boolean'} ], - returns: { - type: ['object'], - root: true - }, - http: { - path: `/clone`, - verb: 'POST' - } + returns: {type: ['object'], root: true}, + http: {path: `/clone`, verb: 'POST'} }); - Self.clone = async(ctx, salesIds, servicesIds, withWarehouse, negative, options) => { + + Self.clone = async(ctx, salesIds, servicesIds, ticketPackagingIds, withWarehouse, negative, options) => { const models = Self.app.models; const myOptions = {}; let tx; const newTickets = []; - if (typeof options == 'object') - Object.assign(myOptions, options); + if (typeof options === 'object') Object.assign(myOptions, options); if (!myOptions.transaction) { tx = await Self.beginTransaction({}); @@ -44,8 +29,9 @@ module.exports = Self => { try { let sales; let services; + let ticketPackaging; - if (salesIds && salesIds.length) { + if (salesIds?.length) { sales = await models.Sale.find({ where: {id: {inq: salesIds}}, include: { @@ -57,12 +43,18 @@ module.exports = Self => { }, myOptions); } - if (servicesIds && servicesIds.length) { + if (servicesIds?.length) { services = await models.TicketService.find({ where: {id: {inq: servicesIds}} }, myOptions); } + if (ticketPackagingIds?.length) { + ticketPackaging = await models.TicketPackaging.find({ + where: {id: {inq: ticketPackagingIds}} + }, myOptions); + } + let ticketsIds = sales ? [...new Set(sales.map(sale => sale.ticketFk))] : [...new Set(services.map(service => service.ticketFk))]; @@ -74,12 +66,12 @@ module.exports = Self => { ctx, ticketId, withWarehouse, - negative, myOptions ); newTickets.push(newTicket); mappedTickets.set(ticketId, newTicket.id); } + if (sales) { for (const sale of sales) { const newTicketId = mappedTickets.get(sale.ticketFk); @@ -107,7 +99,7 @@ module.exports = Self => { await models.TicketService.create({ description: service.description, - quantity: negative ? - service.quantity : service.quantity, + quantity: negative ? -service.quantity : service.quantity, price: service.price, taxClassFk: service.taxClassFk, ticketFk: newTicketId, @@ -116,6 +108,18 @@ module.exports = Self => { } } + if (ticketPackaging) { + for (const packaging of ticketPackaging) { + const newTicketId = mappedTickets.get(packaging.ticketFk); + + await models.TicketPackaging.create({ + ticketFk: newTicketId, + packagingFk: packaging.packagingFk, + quantity: negative ? -packaging.quantity : packaging.quantity + }, myOptions); + } + } + if (tx) await tx.commit(); return newTickets; @@ -124,17 +128,12 @@ module.exports = Self => { throw e; } - async function createTicket( - ctx, - ticketId, - withWarehouse, - negative, - myOptions - ) { + async function createTicket(ctx, ticketId, withWarehouse, myOptions) { const models = Self.app.models; const now = Date.vnNew(); const ticket = await models.Ticket.findById(ticketId, null, myOptions); + if (!ctx.args) ctx.args = {}; ctx.args.clientId = ticket.clientFk; ctx.args.shipped = now; ctx.args.landed = now; @@ -143,17 +142,19 @@ module.exports = Self => { ctx.args.addressId = ticket.addressFk; const newTicket = await models.Ticket.new(ctx, myOptions); - - const ticketRefund = await models.TicketRefund.findOne({ - where: {refundTicketFk: ticketId} - }, myOptions); - if (negative && (withWarehouse || !ticketRefund?.id)) { + const existingRefund = await models.TicketRefund.findOne({ + where: { + originalTicketFk: ticketId, + refundTicketFk: newTicket.id + }, + myOptions + }); + if (!existingRefund) { await models.TicketRefund.create({ originalTicketFk: ticketId, refundTicketFk: newTicket.id }, myOptions); } - return newTicket; } }; diff --git a/modules/ticket/back/methods/sale/deleteSales.js b/modules/ticket/back/methods/sale/deleteSales.js index 0207815a9..0290b2b9d 100644 --- a/modules/ticket/back/methods/sale/deleteSales.js +++ b/modules/ticket/back/methods/sale/deleteSales.js @@ -66,6 +66,10 @@ module.exports = Self => { promises.push(deletedSale); } + const deletedSales = await Promise.all(promises); + + if (tx) await tx.commit(); + const salesPerson = ticket.client().salesPersonUser(); if (salesPerson) { const url = await Self.app.models.Url.getUrl(); @@ -75,13 +79,9 @@ module.exports = Self => { ticketUrl: `${url}ticket/${ticketId}/sale`, deletions: deletions }); - await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions); + await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message); } - const deletedSales = await Promise.all(promises); - - if (tx) await tx.commit(); - return deletedSales; } catch (e) { if (tx) await tx.rollback(); diff --git a/modules/ticket/back/methods/sale/specs/canEdit.spec.js b/modules/ticket/back/methods/sale/specs/canEdit.spec.js index 200ea24cc..168bd28fb 100644 --- a/modules/ticket/back/methods/sale/specs/canEdit.spec.js +++ b/modules/ticket/back/methods/sale/specs/canEdit.spec.js @@ -1,21 +1,8 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('sale canEdit()', () => { const employeeId = 1; - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); describe('sale not exists', () => { it('should return error if sale not exists', async() => { diff --git a/modules/ticket/back/methods/sale/specs/clone.spec.js b/modules/ticket/back/methods/sale/specs/clone.spec.js index e2220c028..1738cc08c 100644 --- a/modules/ticket/back/methods/sale/specs/clone.spec.js +++ b/modules/ticket/back/methods/sale/specs/clone.spec.js @@ -1,24 +1,11 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); - describe('Ticket cloning - clone function', () => { - let ctx; + const ctx = beforeAll.getCtx(); + beforeAll.mockLoopBackContext(); let options; let tx; beforeEach(async() => { - ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'http://localhost'} - }, - args: {} - }; - - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: ctx.req - }); - options = {transaction: tx}; tx = await models.Sale.beginTransaction({}); options.transaction = tx; @@ -33,7 +20,7 @@ describe('Ticket cloning - clone function', () => { const servicesIds = []; const withWarehouse = true; const negative = false; - const newTickets = await models.Sale.clone(ctx, salesIds, servicesIds, withWarehouse, negative, options); + const newTickets = await models.Sale.clone(ctx, salesIds, servicesIds, null, withWarehouse, negative, options); expect(newTickets).toBeDefined(); expect(newTickets.length).toBeGreaterThan(0); @@ -43,7 +30,7 @@ describe('Ticket cloning - clone function', () => { const negative = true; const salesIds = [7, 8]; const servicesIds = []; - const newTickets = await models.Sale.clone(ctx, salesIds, servicesIds, false, negative, options); + const newTickets = await models.Sale.clone(ctx, salesIds, servicesIds, null, false, negative, options); for (const ticket of newTickets) { const sales = await models.Sale.find({where: {ticketFk: ticket.id}}, options); @@ -56,7 +43,7 @@ describe('Ticket cloning - clone function', () => { it('should create new components and services for cloned tickets', async() => { const servicesIds = [2]; const salesIds = [5]; - const newTickets = await models.Sale.clone(ctx, salesIds, servicesIds, false, false, options); + const newTickets = await models.Sale.clone(ctx, salesIds, servicesIds, null, false, false, options); for (const ticket of newTickets) { const sale = await models.Sale.findOne({where: {ticketFk: ticket.id}}, options); @@ -71,7 +58,7 @@ describe('Ticket cloning - clone function', () => { it('should create a ticket without sales', async() => { const servicesIds = [4]; - const tickets = await models.Sale.clone(ctx, null, servicesIds, false, false, options); + const tickets = await models.Sale.clone(ctx, null, servicesIds, null, false, false, options); const refundedTicket = await getTicketRefund(tickets[0].id, options); expect(refundedTicket).toBeDefined(); diff --git a/modules/ticket/back/methods/sale/specs/deleteSales.spec.js b/modules/ticket/back/methods/sale/specs/deleteSales.spec.js index 3d3e06e22..ba14310a1 100644 --- a/modules/ticket/back/methods/sale/specs/deleteSales.spec.js +++ b/modules/ticket/back/methods/sale/specs/deleteSales.spec.js @@ -1,20 +1,8 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('sale deleteSales()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + const ctx = beforeAll.getCtx(); + beforeAll.mockLoopBackContext(); it('should throw an error if the ticket of the given sales is not editable', async() => { const tx = await models.Sale.beginTransaction({}); @@ -23,14 +11,6 @@ describe('sale deleteSales()', () => { try { const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'localhost:5000'}, - __: () => {} - } - }; - const sales = [{id: 1, instance: 0}, {id: 2, instance: 1}]; const ticketId = 2; @@ -51,13 +31,6 @@ describe('sale deleteSales()', () => { try { const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'localhost:5000'}, - __: () => {} - } - }; const sale = await models.Sale.findOne({where: {id: 9}}, options); sale.id = null; const newSale = await models.Sale.create(sale, options); diff --git a/modules/ticket/back/methods/sale/specs/recalculatePrice.spec.js b/modules/ticket/back/methods/sale/specs/recalculatePrice.spec.js index 0fc68dee7..b97060a3d 100644 --- a/modules/ticket/back/methods/sale/specs/recalculatePrice.spec.js +++ b/modules/ticket/back/methods/sale/specs/recalculatePrice.spec.js @@ -1,6 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('sale recalculatePrice()', () => { + const ctx = beforeAll.getCtx(); it('should update the sale price', async() => { const tx = await models.Sale.beginTransaction({}); const sales = [ @@ -10,7 +11,6 @@ describe('sale recalculatePrice()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}}; const response = await models.Sale.recalculatePrice(ctx, sales, options); expect(response[0].affectedRows).toBeDefined(); @@ -30,7 +30,6 @@ describe('sale recalculatePrice()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}}; const immutableSale = [{id: 1, ticketFk: 1}]; await models.Sale.recalculatePrice(ctx, immutableSale, options); diff --git a/modules/ticket/back/methods/sale/specs/reserve.spec.js b/modules/ticket/back/methods/sale/specs/reserve.spec.js index 7ba5999b3..e39f636cc 100644 --- a/modules/ticket/back/methods/sale/specs/reserve.spec.js +++ b/modules/ticket/back/methods/sale/specs/reserve.spec.js @@ -1,5 +1,4 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('sale reserve()', () => { const ctx = { @@ -10,19 +9,7 @@ describe('sale reserve()', () => { } }; - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); it('should throw an error if the ticket can not be modified', async() => { const tx = await models.Sale.beginTransaction({}); diff --git a/modules/ticket/back/methods/sale/specs/updateConcept.spec.js b/modules/ticket/back/methods/sale/specs/updateConcept.spec.js index 1b42e7140..8e3538fc3 100644 --- a/modules/ticket/back/methods/sale/specs/updateConcept.spec.js +++ b/modules/ticket/back/methods/sale/specs/updateConcept.spec.js @@ -1,22 +1,7 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('sale updateConcept()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); - - const ctx = {req: {accessToken: {userId: 9}}}; + const ctx = beforeAll.getCtx(); const saleId = 25; it('should throw if ID was undefined', async() => { diff --git a/modules/ticket/back/methods/sale/updateQuantity.js b/modules/ticket/back/methods/sale/updateQuantity.js index 610826283..36d75ffed 100644 --- a/modules/ticket/back/methods/sale/updateQuantity.js +++ b/modules/ticket/back/methods/sale/updateQuantity.js @@ -72,16 +72,20 @@ module.exports = Self => { const salesPerson = sale.ticket().client().salesPersonUser(); if (salesPerson) { const url = await Self.app.models.Url.getUrl(); - const message = $t('Changed sale quantity', { - ticketId: sale.ticket().id, + const change = $t('Changes in sales', { itemId: sale.itemFk, concept: sale.concept, oldQuantity: oldQuantity, newQuantity: newQuantity, - ticketUrl: `${url}ticket/${sale.ticket().id}/sale`, itemUrl: `${url}item/${sale.itemFk}/summary` }); + const message = $t('Changed sale quantity', { + ticketId: sale.ticket().id, + changes: change, + ticketUrl: `${url}ticket/${sale.ticket().id}/sale`, + }); + await models.Chat.sendCheckingPresence(ctx, salesPerson.id, message, myOptions); } diff --git a/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js b/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js index 668a991f4..3fe174e46 100644 --- a/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js +++ b/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js @@ -1,29 +1,8 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('ticket-request confirm()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); - let ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'http://localhost'} - } - }; - ctx.req.__ = value => { - return value; - }; + const ctx = beforeAll.getCtx(); + beforeAll.mockLoopBackContext(); it(`should throw an error if the item doesn't exist`, async() => { const tx = await models.TicketRequest.beginTransaction({}); diff --git a/modules/ticket/back/methods/ticket-request/specs/deny.spec.js b/modules/ticket/back/methods/ticket-request/specs/deny.spec.js index 875a75921..9920bd4d3 100644 --- a/modules/ticket/back/methods/ticket-request/specs/deny.spec.js +++ b/modules/ticket/back/methods/ticket-request/specs/deny.spec.js @@ -1,39 +1,15 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('ticket-request deny()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + const ctx = beforeAll.getCtx(); + beforeAll.mockLoopBackContext(); it('should return the denied ticket request', async() => { const tx = await models.TicketRequest.beginTransaction({}); try { const options = {transaction: tx}; - - const ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'http://localhost'} - }, - args: {id: 4, observation: 'my observation'}, - }; - - ctx.req.__ = value => { - return value; - }; - + ctx.args = {id: 4, observation: 'my observation'}; const result = await models.TicketRequest.deny(ctx, options); expect(result.id).toEqual(4); diff --git a/modules/ticket/back/methods/ticket-tracking/specs/setDelivered.spec.js b/modules/ticket/back/methods/ticket-tracking/specs/setDelivered.spec.js index 3d37221c4..3d39ea278 100644 --- a/modules/ticket/back/methods/ticket-tracking/specs/setDelivered.spec.js +++ b/modules/ticket/back/methods/ticket-tracking/specs/setDelivered.spec.js @@ -2,10 +2,12 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('ticket setDelivered()', () => { - const userId = 50; + const userId = 49; const activeCtx = { accessToken: {userId: userId}, + __: value => value }; + const ctx = {req: activeCtx}; beforeAll(async() => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ @@ -19,8 +21,6 @@ describe('ticket setDelivered()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 49}}}; - const originalTicketOne = await models.Ticket.findById(8, null, options); const originalTicketTwo = await models.Ticket.findById(10, null, options); diff --git a/modules/ticket/back/methods/ticket-weekly/filter.js b/modules/ticket/back/methods/ticket-weekly/filter.js index 0bf92d542..512faa4cf 100644 --- a/modules/ticket/back/methods/ticket-weekly/filter.js +++ b/modules/ticket/back/methods/ticket-weekly/filter.js @@ -38,13 +38,14 @@ module.exports = Self => { Object.assign(myOptions, options); const where = buildFilter(ctx.args, (param, value) => { - switch (param) { - case 'search': - return {or: [ - {'t.id': value}, - {'c.id': value}, - {'c.name': {like: `%${value}%`}} - ]}; + if (param === 'search') { + return { + or: [ + {'t.id': value}, + {'c.id': value}, + {'c.name': {like: `%${value}%`}} + ] + }; } }); @@ -53,13 +54,22 @@ module.exports = Self => { const stmts = []; const stmt = new ParameterizedSQL( - `SELECT t.id AS ticketFk, c.id AS clientFk, c.name AS clientName, tw.weekDay, - wh.name AS warehouseName, u.id AS workerFk, u.name AS userName, u.nickName, tw.agencyModeFk + `SELECT t.id AS ticketFk, + c.id AS clientFk, + c.name AS clientName, + tw.weekDay, + wh.name AS warehouseName, + u.id AS workerFk, + u.name AS userName, + u.nickName, + tw.agencyModeFk, + am.name agencyModeName FROM ticketWeekly tw JOIN ticket t ON t.id = tw.ticketFk JOIN client c ON c.id = t.clientFk - JOIN account.user u ON u.id = c.salesPersonFk - JOIN warehouse wh ON wh.id = t.warehouseFk` + LEFT JOIN account.user u ON u.id = c.salesPersonFk + JOIN warehouse wh ON wh.id = t.warehouseFk + LEFT JOIN agencyMode am ON am.id = tw.agencyModeFk` ); stmt.merge(conn.makeSuffix(filter)); diff --git a/modules/ticket/back/methods/ticket-weekly/specs/filter.spec.js b/modules/ticket/back/methods/ticket-weekly/specs/filter.spec.js index 453b7924f..9b1ad5209 100644 --- a/modules/ticket/back/methods/ticket-weekly/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket-weekly/specs/filter.spec.js @@ -13,11 +13,11 @@ describe('ticket-weekly filter()', () => { const ctx = {req: {accessToken: {userId: authUserId}}, args: {filter: filter}}; const result = await models.TicketWeekly.filter(ctx, null, options); - + const totalRecords = await models.TicketWeekly.count(); const firstRow = result[0]; expect(firstRow.ticketFk).toEqual(2); - expect(result.length).toEqual(4); + expect(result.length).toEqual(totalRecords); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/back/methods/ticket/addSale.js b/modules/ticket/back/methods/ticket/addSale.js index 826de6e12..ad393fc65 100644 --- a/modules/ticket/back/methods/ticket/addSale.js +++ b/modules/ticket/back/methods/ticket/addSale.js @@ -10,8 +10,8 @@ module.exports = Self => { http: {source: 'path'} }, { - arg: 'itemId', - type: 'number', + arg: 'barcode', + type: 'any', required: true }, { @@ -29,7 +29,7 @@ module.exports = Self => { } }); - Self.addSale = async(ctx, id, itemId, quantity, options) => { + Self.addSale = async(ctx, id, barcode, quantity, options) => { const $t = ctx.req.__; // $translate const models = Self.app.models; const myOptions = {userId: ctx.req.accessToken.userId}; @@ -46,7 +46,9 @@ module.exports = Self => { try { await models.Ticket.isEditableOrThrow(ctx, id, myOptions); + const itemId = await models.ItemBarcode.toItem(barcode, myOptions); const item = await models.Item.findById(itemId, null, myOptions); + const ticket = await models.Ticket.findById(id, { include: { relation: 'client', @@ -68,7 +70,7 @@ module.exports = Self => { quantity: quantity }, myOptions); - await Self.rawSql('CALL vn.sale_calculateComponent(?, NULL)', [newSale.id], myOptions); + await Self.rawSql('CALL vn.sale_calculateComponent(?, ?)', [newSale.id, 'renewPrices'], myOptions); await Self.rawSql('CALL vn.ticket_recalc(?, NULL)', [id], myOptions); const sale = await models.Sale.findById(newSale.id, { diff --git a/modules/ticket/back/methods/ticket/addSaleByCode.js b/modules/ticket/back/methods/ticket/addSaleByCode.js deleted file mode 100644 index ca3d2cb07..000000000 --- a/modules/ticket/back/methods/ticket/addSaleByCode.js +++ /dev/null @@ -1,56 +0,0 @@ -const UserError = require('vn-loopback/util/user-error'); -module.exports = Self => { - Self.remoteMethodCtx('addSaleByCode', { - description: 'Add a collection', - accessType: 'WRITE', - accepts: [ - { - arg: 'barcode', - type: 'string', - required: true - }, { - arg: 'quantity', - type: 'number', - required: true - }, { - arg: 'ticketFk', - type: 'number', - required: true - }, { - arg: 'warehouseFk', - type: 'number', - required: true - }, - - ], - http: { - path: `/addSaleByCode`, - verb: 'POST' - }, - }); - - Self.addSaleByCode = async(ctx, barcode, quantity, ticketFk, warehouseFk, options) => { - const myOptions = {userId: ctx.req.accessToken.userId}; - let tx; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - - try { - const [[item]] = await Self.rawSql('CALL vn.item_getInfo(?,?)', [barcode, warehouseFk], myOptions); - if (!item?.available) throw new UserError('We do not have availability for the selected item'); - - await Self.rawSql('CALL vn.collection_addItem(?, ?, ?)', [item.id, quantity, ticketFk], myOptions); - - if (tx) await tx.commit(); - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - }; -}; diff --git a/modules/ticket/back/methods/ticket/clone.js b/modules/ticket/back/methods/ticket/clone.js deleted file mode 100644 index 93bc2a94e..000000000 --- a/modules/ticket/back/methods/ticket/clone.js +++ /dev/null @@ -1,54 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('clone', { - description: 'clone a ticket and return the new ticket id', - accessType: 'WRITE', - accepts: [{ - arg: 'id', - type: 'number', - required: true, - description: 'The ticket id', - http: {source: 'path'} - }, { - arg: 'shipped', - type: 'date', - }, { - arg: 'withWarehouse', - type: 'boolean', - } - ], - returns: { - type: 'number', - root: true - }, - http: { - path: `/:id/clone`, - verb: 'POST' - } - }); - - Self.clone = async(ctx, id, shipped, withWarehouse, options) => { - const myOptions = {userId: ctx.req.accessToken.userId}; - let tx; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - - try { - const [, [{clonedTicketId}]] = await Self.rawSql(` - CALL vn.ticket_cloneAll(?, ?, ?, @clonedTicketId); - SELECT @clonedTicketId clonedTicketId;`, - [id, shipped, withWarehouse], myOptions); - - if (tx) await tx.commit(); - return clonedTicketId; - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - }; -}; diff --git a/modules/ticket/back/methods/ticket/cloneAll.js b/modules/ticket/back/methods/ticket/cloneAll.js new file mode 100644 index 000000000..29d45615f --- /dev/null +++ b/modules/ticket/back/methods/ticket/cloneAll.js @@ -0,0 +1,80 @@ +module.exports = Self => { + Self.remoteMethodCtx('cloneAll', { + description: 'Clone tickets, sales, services and packages', + accessType: 'WRITE', + accepts: [ + { + arg: 'ticketsIds', + type: ['number'], + required: true, + description: 'IDs of the tickets to clone' + }, + { + arg: 'withWarehouse', + type: 'boolean', + required: true, + description: 'true: keep original warehouse; false: set to null' + }, + { + arg: 'negative', + type: 'boolean', + required: true, + description: 'true: invert quantities; false: keep as is.' + } + ], + returns: { + type: ['object'], + root: true, + description: 'The cloned tickets with associated data' + }, + http: { + path: `/cloneAll`, + verb: 'POST' + } + }); + + Self.cloneAll = async(ctx, ticketsIds, withWarehouse, negative, options) => { + const models = Self.app.models; + let tx; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const filter = {where: {ticketFk: {inq: ticketsIds}}}; + + const [sales, services, ticketPackaging] = await Promise.all([ + models.Sale.find(filter, myOptions), + models.TicketService.find(filter, myOptions), + models.TicketPackaging.find(filter, myOptions) + ]); + + const salesIds = sales.map(({id}) => id); + const servicesIds = services.map(({id}) => id); + const ticketPackagingIds = ticketPackaging.map(({id}) => id); + + const clonedTickets = await models.Sale.clone( + ctx, + salesIds, + servicesIds, + ticketPackagingIds, + withWarehouse, + negative, + myOptions + ); + + if (tx) await tx.commit(); + + return clonedTickets; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index 35b9b1e37..4fd72d454 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -53,8 +53,9 @@ module.exports = Self => { JOIN province p ON p.id = c.provinceFk JOIN country co ON co.id = p.countryFk LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk + JOIN ticketConfig tc ON TRUE WHERE (al.code = 'PACKED' OR (am.code = 'refund' AND al.code <> 'delivered')) - AND DATE(t.shipped) BETWEEN ? - INTERVAL 2 DAY AND util.dayEnd(?) + AND t.shipped BETWEEN ? - INTERVAL tc.closureDaysAgo DAY AND util.dayEnd(?) AND t.refFk IS NULL GROUP BY t.id `, [toDate, toDate]); @@ -71,7 +72,8 @@ module.exports = Self => { JSON_ARRAYAGG( JSON_OBJECT( 'ticketId', ticketFk, - 'reason', reason + 'reason', reason, + 'clientId', clientFk ) ) )errors @@ -83,7 +85,8 @@ module.exports = Self => { IF(hasErrorDeleted, 'Eliminado', NULL), IF(hasErrorItemTaxCountry, 'Impuesto no informado', NULL), IF(hasErrorAddress, 'Sin dirección', NULL), - IF(hasErrorInfoTaxAreaWorld, 'Datos exportaciones', NULL)) reason + IF(hasErrorInfoTaxAreaWorld, 'Datos exportaciones', NULL)) reason, + clientFk FROM ( SELECT t.id ticketFk, SUM(NOT c.hasToInvoice) hasErrorToInvoice, @@ -91,9 +94,10 @@ module.exports = Self => { SUM(t.isDeleted) hasErrorDeleted, SUM(itc.id IS NULL) hasErrorItemTaxCountry, SUM(a.id IS NULL) hasErrorAddress, - SUM(ios.code IS NOT NULL - AND(ad.customsAgentFk IS NULL - OR ad.incotermsFk IS NULL)) hasErrorInfoTaxAreaWorld + SUM(ios.code IS NOT NULL + AND(ad.customsAgentFk IS NULL + OR ad.incotermsFk IS NULL)) hasErrorInfoTaxAreaWorld, + t.clientFk clientFk FROM ticket t LEFT JOIN address ad ON ad.id = t.addressFk JOIN sale s ON s.ticketFk = t.id @@ -105,29 +109,30 @@ module.exports = Self => { JOIN alertLevel al ON al.id = ts.alertLevel JOIN client c ON c.id = t.clientFk JOIN province p ON p.id = c.provinceFk + JOIN ticketConfig tc ON TRUE LEFT JOIN autonomy a ON a.id = p.autonomyFk JOIN country co ON co.id = p.countryFk LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id AND itc.countryFk = su.countryFk - LEFT JOIN vn.invoiceOutSerial ios ON ios.taxAreaFk = 'WORLD' - AND ios.code = invoiceSerial(t.clientFk, t.companyFk, 'M') + LEFT JOIN vn.invoiceOutSerial ios ON ios.taxAreaFk = 'WORLD' + AND ios.code = invoiceSerial(t.clientFk, t.companyFk, 'multiple') WHERE (al.code = 'PACKED' OR (am.code = 'refund' AND al.code <> 'delivered')) - AND DATE(t.shipped) BETWEEN ? - INTERVAL 2 DAY AND util.dayEnd(?) + AND t.shipped BETWEEN ? - INTERVAL tc.closureDaysAgo DAY AND util.dayEnd(?) AND t.refFk IS NULL AND IFNULL(a.hasDailyInvoice, co.hasDailyInvoice) - GROUP BY ticketFk - HAVING hasErrorToInvoice - OR hasErrorTaxDataChecked - OR hasErrorDeleted - OR hasErrorItemTaxCountry - OR hasErrorAddress + GROUP BY ticketFk + HAVING hasErrorToInvoice + OR hasErrorTaxDataChecked + OR hasErrorDeleted + OR hasErrorItemTaxCountry + OR hasErrorAddress OR hasErrorInfoTaxAreaWorld )sub )sub2 ) SELECT IF(errors = '{"tickets": null}', 'No errors', - util.notification_send('invoice-ticket-closure', errors, NULL)) + util.notification_send('invoice-ticket-closure', errors, NULL)) FROM ticketNotInvoiceable`, [toDate, toDate]); await closure(ctx, Self, tickets); @@ -138,9 +143,10 @@ module.exports = Self => { JOIN alertLevel al ON al.id = ts.alertLevel JOIN agencyMode am ON am.id = t.agencyModeFk JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + JOIN ticketConfig tc ON TRUE LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id SET t.routeFk = NULL - WHERE DATE(t.shipped) BETWEEN ? - INTERVAL 2 DAY AND util.dayEnd(?) + WHERE t.shipped BETWEEN ? - INTERVAL tc.closureDaysAgo DAY AND util.dayEnd(?) AND al.code NOT IN ('DELIVERED', 'PACKED') AND NOT t.packages AND tob.id IS NULL diff --git a/modules/ticket/back/methods/ticket/closeByAgency.js b/modules/ticket/back/methods/ticket/closeByAgency.js deleted file mode 100644 index eb1aee349..000000000 --- a/modules/ticket/back/methods/ticket/closeByAgency.js +++ /dev/null @@ -1,79 +0,0 @@ -const closure = require('./closure'); - -module.exports = Self => { - Self.remoteMethodCtx('closeByAgency', { - description: 'Makes the closure process by agency mode', - accessType: 'WRITE', - accepts: [ - { - arg: 'agencyModeFk', - type: ['number'], - required: true, - description: 'The agencies mode ids', - }, - { - arg: 'warehouseFk', - type: 'number', - description: 'The ticket warehouse id', - required: true - }, - { - arg: 'to', - type: 'date', - description: 'Max closure date', - required: true - } - ], - returns: { - type: 'object', - root: true - }, - http: { - path: `/close-by-agency`, - verb: 'POST' - } - }); - - Self.closeByAgency = async ctx => { - const args = ctx.args; - - const tickets = await Self.rawSql(` - SELECT - t.id, - t.clientFk, - t.companyFk, - c.name clientName, - c.email recipient, - c.salesPersonFk, - c.isToBeMailed, - c.hasToInvoice, - co.hasDailyInvoice, - eu.email salesPersonEmail - FROM expedition e - JOIN ticket t ON t.id = e.ticketFk - JOIN ticketState ts ON ts.ticketFk = t.id - JOIN alertLevel al ON al.id = ts.alertLevel - JOIN client c ON c.id = t.clientFk - JOIN province p ON p.id = c.provinceFk - JOIN country co ON co.id = p.countryFk - LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk - WHERE al.code = 'PACKED' - AND t.agencyModeFk IN(?) - AND t.warehouseFk = ? - AND DATE(t.shipped) BETWEEN DATE_ADD(?, INTERVAL -2 DAY) - AND util.dayEnd(?) - AND t.refFk IS NULL - GROUP BY e.ticketFk`, [ - args.agencyModeFk, - args.warehouseFk, - args.to, - args.to - ]); - - await closure(Self, tickets); - - return { - message: 'Success' - }; - }; -}; diff --git a/modules/ticket/back/methods/ticket/closeByRoute.js b/modules/ticket/back/methods/ticket/closeByRoute.js deleted file mode 100644 index 58e130b8e..000000000 --- a/modules/ticket/back/methods/ticket/closeByRoute.js +++ /dev/null @@ -1,75 +0,0 @@ -const closure = require('./closure'); -const {Email} = require('vn-print'); - -module.exports = Self => { - Self.remoteMethodCtx('closeByRoute', { - description: 'Makes the closure process by route', - accessType: 'WRITE', - accepts: [ - { - arg: 'routeFk', - type: 'number', - required: true, - description: 'The routes ids', - }, - ], - returns: { - type: 'object', - root: true - }, - http: { - path: `/close-by-route`, - verb: 'POST' - } - }); - - Self.closeByRoute = async ctx => { - const args = ctx.args; - - const tickets = await Self.rawSql(` - SELECT - t.id, - t.clientFk, - t.companyFk, - c.name clientName, - c.email recipient, - c.salesPersonFk, - c.isToBeMailed, - c.hasToInvoice, - co.hasDailyInvoice, - eu.email salesPersonEmail - FROM expedition e - JOIN ticket t ON t.id = e.ticketFk - JOIN ticketState ts ON ts.ticketFk = t.id - JOIN alertLevel al ON al.id = ts.alertLevel - JOIN client c ON c.id = t.clientFk - JOIN province p ON p.id = c.provinceFk - JOIN country co ON co.id = p.countryFk - LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk - WHERE al.code = 'PACKED' - AND t.routeFk = ? - AND t.refFk IS NULL - GROUP BY e.ticketFk`, [args.routeFk]); - - await closure(Self, tickets); - - // Send route report to the agency - const [agencyMail] = await Self.rawSql(` - SELECT am.reportMail - FROM route r - JOIN agencyMode am ON am.id = r.agencyModeFk - WHERE r.id = ?`, [args.routeFk]); - - if (agencyMail) { - const email = new Email('driver-route', { - id: args.routeFk, - recipient: agencyMail - }); - await email.send(); - } - - return { - message: 'Success' - }; - }; -}; diff --git a/modules/ticket/back/methods/ticket/closeByTicket.js b/modules/ticket/back/methods/ticket/closeByTicket.js index 8884897c2..40fe048a5 100644 --- a/modules/ticket/back/methods/ticket/closeByTicket.js +++ b/modules/ticket/back/methods/ticket/closeByTicket.js @@ -23,11 +23,25 @@ module.exports = Self => { } }); - Self.closeByTicket = async ctx => { + Self.closeByTicket = async(ctx, options) => { + let tx; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + const userId = ctx.req.accessToken.userId; + myOptions.userId = userId; + const args = ctx.args; const tickets = await Self.rawSql(` - SELECT + SELECT t.id, t.clientFk, t.companyFk, @@ -37,7 +51,8 @@ module.exports = Self => { c.isToBeMailed, c.hasToInvoice, co.hasDailyInvoice, - eu.email salesPersonEmail + eu.email salesPersonEmail, + t.addressFk FROM expedition e JOIN ticket t ON t.id = e.ticketFk JOIN ticketState ts ON ts.ticketFk = t.id @@ -49,9 +64,14 @@ module.exports = Self => { WHERE al.code = 'PACKED' AND t.id = ? AND t.refFk IS NULL - GROUP BY e.ticketFk`, [args.id]); + GROUP BY e.ticketFk`, + [args.id], + myOptions); - await closure(Self, tickets); + await closure(ctx, Self, tickets, myOptions); + + if (tx) + await tx.commit(); return { message: 'Success' diff --git a/modules/ticket/back/methods/ticket/closure.js b/modules/ticket/back/methods/ticket/closure.js index 8c59dc3b0..56bd6eccd 100644 --- a/modules/ticket/back/methods/ticket/closure.js +++ b/modules/ticket/back/methods/ticket/closure.js @@ -1,13 +1,19 @@ -/* eslint max-len: ["error", { "code": 150 }]*/ - const Report = require('vn-print/core/report'); const Email = require('vn-print/core/email'); const smtp = require('vn-print/core/smtp'); const config = require('vn-print/core/config'); const storage = require('vn-print/core/storage'); -module.exports = async function(ctx, Self, tickets, reqArgs = {}) { +module.exports = async function(ctx, Self, tickets, options) { const userId = ctx.req.accessToken.userId; + const myOptions = {userId}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + let tx; + // IMPORTANT: Due to its high cost in production, wrapping this process in a transaction may cause timeouts. + if (tickets.length == 0) return; const failedtickets = []; @@ -15,23 +21,20 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) { try { await Self.rawSql(`CALL util.debugAdd('invoicingTicket', ?)`, [ticket.id], {userId}); - await Self.app.models.InvoiceOut.getSerial(ticket.clientFk, ticket.companyFk, ticket.addressFk, 'M'); + await Self.app.models.InvoiceOut.getSerial(ticket.clientFk, ticket.companyFk, ticket.addressFk, 'quick'); await Self.rawSql( `CALL vn.ticket_closeByTicket(?)`, [ticket.id], - {userId} + myOptions ); - const [invoiceOut] = await Self.rawSql( - ` + const [invoiceOut] = await Self.rawSql(` SELECT io.id, io.ref, io.serial, cny.code companyCode, io.issued FROM ticket t JOIN invoiceOut io ON io.ref = t.refFk JOIN company cny ON cny.id = io.companyFk WHERE t.id = ? - `, - [ticket.id], - ); + `, [ticket.id], myOptions); const mailOptions = { overrideAttachments: true, @@ -68,7 +71,7 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) { await Self.rawSql( 'UPDATE invoiceOut SET hasPdf = true WHERE id = ?', [invoiceOut.id], - {userId}, + myOptions ); if (isToBeMailed) { @@ -106,17 +109,16 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) { } // Incoterms authorization - const [{firstOrder}] = await Self.rawSql( - ` - SELECT COUNT(*) as firstOrder - FROM ticket t - JOIN client c ON c.id = t.clientFk - WHERE t.clientFk = ? - AND NOT t.isDeleted - AND c.isVies - `, - [ticket.clientFk], - ); + const [{firstOrder}] = await Self.rawSql(` + SELECT COUNT(*) as firstOrder + FROM ticket t + JOIN client c ON c.id = t.clientFk + WHERE t.clientFk = ? + AND NOT t.isDeleted + AND c.isVies + `, + [ticket.clientFk], + myOptions); if (firstOrder == 1) { const args = { @@ -131,33 +133,31 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) { const email = new Email('incoterms-authorization', args); await email.send(); - const [sample] = await Self.rawSql( - `SELECT id + const [sample] = await Self.rawSql(` + SELECT id FROM sample - WHERE code = 'incoterms-authorization' - `, - ); + WHERE code = 'incoterms-authorization' + `, + null, + myOptions); - await Self.rawSql( - ` + await Self.rawSql(` INSERT INTO clientSample (clientFk, typeFk, companyFk) VALUES(?, ?, ?) - `, - [ticket.clientFk, sample.id, ticket.companyFk], - {userId}, - ); + `, + [ticket.clientFk, sample.id, ticket.companyFk], + myOptions); } } catch (error) { await Self.rawSql(` INSERT INTO util.debug (variable, value) VALUES ('invoicingTicketError', ?) `, [ticket.id + ' - ' + error]); - // Domain not found + if (error.responseCode == 450) { await invalidEmail(ticket); continue; } - // Save tickets on a list of failed ids failedtickets.push({ id: ticket.id, stacktrace: error, @@ -165,7 +165,6 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) { } } - // Send email with failed tickets if (failedtickets.length > 0) { let body = 'This following tickets have failed:

'; @@ -181,21 +180,14 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) { }).catch(err => console.error(err)); } + if (tx) + await tx.commit(); + async function invalidEmail(ticket) { await Self.rawSql( `UPDATE client SET email = NULL WHERE id = ?`, [ticket.clientFk], - {userId}, - ); - - const oldInstance = `{"email": "${ticket.recipient}"}`; - const newInstance = `{"email": ""}`; - await Self.rawSql( - ` - INSERT INTO clientLog (originFk, userFk, action, changedModel, oldInstance, newInstance) - VALUES (?, NULL, 'UPDATE', 'Client', ?, ?)`, - [ticket.clientFk, oldInstance, newInstance], - {userId}, + myOptions ); const body = `No se ha podido enviar el albarán ${ticket.id} diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 899fe05cd..06781c3c8 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -76,7 +76,8 @@ module.exports = Self => { { arg: 'myTeam', type: 'boolean', - description: `Whether to show only tickets for the current logged user team (For now it shows only the current user tickets)` + description: `Whether to show only tickets for the current logged user team + (For now it shows only the current user tickets)` }, { arg: 'problems', @@ -224,16 +225,14 @@ module.exports = Self => { const stmts = []; let stmt; - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.filter'); - stmt = new ParameterizedSQL( - `CREATE TEMPORARY TABLE tmp.filter + stmt = new ParameterizedSQL(` + CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) ENGINE = MEMORY - SELECT - t.id, + SELECT t.id, t.shipped, - CAST(DATE(t.shipped) AS CHAR) AS shippedDate, - HOUR(t.shipped) AS shippedHour, + CAST(DATE(t.shipped) AS CHAR) shippedDate, + HOUR(t.shipped) shippedHour, t.nickname, t.refFk, t.routeFk, @@ -241,26 +240,27 @@ module.exports = Self => { t.clientFk, t.totalWithoutVat, t.totalWithVat, - io.id AS invoiceOutId, + io.id invoiceOutId, a.provinceFk, - p.name AS province, - w.name AS warehouse, - am.name AS agencyMode, - am.id AS agencyModeFk, - st.name AS state, + p.name province, + w.name warehouse, + am.name agencyMode, + am.id agencyModeFk, + st.name state, st.classColor, - wk.lastName AS salesPerson, - ts.stateFk AS stateFk, - ts.alertLevel AS alertLevel, - ts.code AS alertLevelCode, - u.name AS userName, + wk.lastName salesPerson, + ts.stateFk stateFk, + ts.alertLevel alertLevel, + ts.code alertLevelCode, + u.name userName, c.salesPersonFk, - z.hour AS zoneLanding, - HOUR(z.hour) AS zoneHour, - MINUTE(z.hour) AS zoneMinute, - z.name AS zoneName, - z.id AS zoneFk, - CAST(z.hour AS CHAR) AS hour + z.hour zoneLanding, + HOUR(z.hour) zoneHour, + MINUTE(z.hour) zoneMinute, + z.name zoneName, + z.id zoneFk, + CAST(z.hour AS CHAR) hour, + a.nickname addressNickname FROM ticket t LEFT JOIN invoiceOut io ON t.refFk = io.ref LEFT JOIN zone z ON z.id = t.zoneFk @@ -273,7 +273,8 @@ module.exports = Self => { LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN worker wk ON wk.id = c.salesPersonFk LEFT JOIN account.user u ON u.id = wk.id - LEFT JOIN route r ON r.id = t.routeFk`); + LEFT JOIN route r ON r.id = t.routeFk + `); if (args.orderFk) { stmt.merge({ @@ -293,25 +294,31 @@ module.exports = Self => { stmt.merge(conn.makeWhere(filter.where)); stmts.push(stmt); - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems'); - stmt = new ParameterizedSQL(` - CREATE TEMPORARY TABLE tmp.sale_getProblems + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems (INDEX (ticketFk)) ENGINE = MEMORY SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped FROM tmp.filter f LEFT JOIN alertLevel al ON al.id = f.alertLevel WHERE (al.code = 'FREE' OR f.alertLevel IS NULL) - AND f.shipped >= ?`, [date]); - stmts.push(stmt); + AND f.shipped >= ? + `, [date]); + stmts.push(stmt); stmts.push('CALL ticket_getProblems(FALSE)'); + stmt = new ParameterizedSQL(` + UPDATE tmp.ticket_problems + SET risk = IF(hasRisk, risk, 0) + `); + stmts.push(stmt); + stmt = new ParameterizedSQL(` SELECT f.*, tp.* - FROM tmp.filter f - LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = f.id`); + FROM tmp.filter f + LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = f.id + `); if (args.problems != undefined && (!args.from && !args.to)) throw new UserError('Choose a date range or days forward'); @@ -338,7 +345,7 @@ module.exports = Self => { const problems = {[condition]: [ {'tp.isFreezed': hasProblem}, - {'tp.risk': hasProblem}, + {'tp.hasRisk': hasProblem}, {'tp.hasTicketRequest': hasProblem}, {'tp.itemShortage': range}, {'tp.hasRounding': hasProblem} @@ -347,6 +354,18 @@ module.exports = Self => { if (hasWhere) stmt.merge(conn.makeWhere(problems)); + if (filter.order) { + if (typeof filter.order == 'string') filter.order = [filter.order]; + const index = filter.order.findIndex(o => o.includes('stateFk')); + if (index > -1) { + filter.order = [ + ...filter.order.slice(0, index), + 'refFk ' + filter.order[index].split(' ')[1], + ...filter.order.slice(index) + ]; + } + } + stmt.merge(conn.makeOrderBy(filter.order)); stmt.merge(conn.makeLimit(filter)); const ticketsIndex = stmts.push(stmt) - 1; diff --git a/modules/ticket/back/methods/ticket/getTicketsAdvance.js b/modules/ticket/back/methods/ticket/getTicketsAdvance.js index ab40b9559..1bd5f83de 100644 --- a/modules/ticket/back/methods/ticket/getTicketsAdvance.js +++ b/modules/ticket/back/methods/ticket/getTicketsAdvance.js @@ -105,13 +105,12 @@ module.exports = Self => { stmt = new ParameterizedSQL( `CALL vn.ticket_canAdvance(?,?,?)`, - [args.dateFuture, args.dateToAdvance, args.warehouseFk]); + [args.dateFuture, args.dateToAdvance, args.warehouseFk] + ); stmts.push(stmt); - stmt = new ParameterizedSQL(` - SELECT f.* - FROM tmp.filter f`); + stmt = new ParameterizedSQL(`SELECT f.* FROM tmp.filter f`); stmt.merge(conn.makeWhere(filter.where)); @@ -119,9 +118,7 @@ module.exports = Self => { stmt.merge(conn.makeLimit(filter)); const ticketsIndex = stmts.push(stmt) - 1; - stmts.push( - `DROP TEMPORARY TABLE - tmp.filter`); + stmts.push(`DROP TEMPORARY TABLE tmp.filter`); const sql = ParameterizedSQL.join(stmts, ';'); const result = await conn.executeStmt(sql, myOptions); diff --git a/modules/ticket/back/methods/ticket/getTicketsFuture.js b/modules/ticket/back/methods/ticket/getTicketsFuture.js index ab5071be4..247924591 100644 --- a/modules/ticket/back/methods/ticket/getTicketsFuture.js +++ b/modules/ticket/back/methods/ticket/getTicketsFuture.js @@ -9,13 +9,13 @@ module.exports = Self => { accessType: 'READ', accepts: [ { - arg: 'originDated', + arg: 'originScopeDays', type: 'date', description: 'The date in question', required: true }, { - arg: 'futureDated', + arg: 'futureScopeDays', type: 'date', description: 'The date to probe', required: true @@ -129,9 +129,9 @@ module.exports = Self => { ] }; case 'state': - return {'f.stateCode': {like: `%${value}%`}}; + return {'f.alertLevel': value}; case 'futureState': - return {'f.futureStateCode': {like: `%${value}%`}}; + return {'f.futureAlertLevel': value}; } }); @@ -141,30 +141,36 @@ module.exports = Self => { stmt = new ParameterizedSQL( `CALL vn.ticket_canbePostponed(?,?,?)`, - [args.originDated, args.futureDated, args.warehouseFk]); + [args.originScopeDays, args.futureScopeDays, args.warehouseFk]); stmts.push(stmt); - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems'); - stmt = new ParameterizedSQL(` - CREATE TEMPORARY TABLE tmp.sale_getProblems - (INDEX (ticketFk)) - ENGINE = MEMORY - SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped, f.lines, f.liters - FROM tmp.filter f - LEFT JOIN alertLevel al ON al.id = f.alertLevel - WHERE (al.code = 'FREE' OR f.alertLevel IS NULL)`); - stmts.push(stmt); + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped, f.lines, f.liters + FROM tmp.filter f + LEFT JOIN alertLevel al ON al.id = f.alertLevel + WHERE (al.code = 'FREE' OR f.alertLevel IS NULL) + `); + stmts.push(stmt); stmts.push('CALL ticket_getProblems(FALSE)'); stmt = new ParameterizedSQL(` - SELECT f.*, tp.* - FROM tmp.filter f - LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = f.id`); + UPDATE tmp.ticket_problems + SET risk = IF(hasRisk, risk, 0) + `); + stmts.push(stmt); - if (args.problems != undefined && (!args.originDated && !args.futureDated)) + stmt = new ParameterizedSQL(` + SELECT f.*, tp.* + FROM tmp.filter f + LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = f.id + `); + + if (args.problems != undefined && (!args.originScopeDays && !args.futureScopeDays)) throw new UserError('Choose a date range or days forward'); let condition; @@ -190,7 +196,7 @@ module.exports = Self => { const problems = { [condition]: [ {'tp.isFreezed': hasProblem}, - {'tp.risk': hasProblem}, + {'tp.hasRisk': hasProblem}, {'tp.hasTicketRequest': hasProblem}, {'tp.itemShortage': range}, {'tp.hasComponentLack': hasProblem}, diff --git a/modules/ticket/back/methods/ticket/invoiceTickets.js b/modules/ticket/back/methods/ticket/invoiceTickets.js index 53400e724..3c725c4a7 100644 --- a/modules/ticket/back/methods/ticket/invoiceTickets.js +++ b/modules/ticket/back/methods/ticket/invoiceTickets.js @@ -95,7 +95,7 @@ module.exports = function(Self) { FROM vn.ticket WHERE id IN (?) `, [ticketsIds], myOptions); - return models.Ticket.makeInvoice(ctx, 'R', companyId, Date.vnNew(), invoiceCorrection, myOptions); + return models.Ticket.makeInvoice(ctx, 'quick', companyId, Date.vnNew(), invoiceCorrection, myOptions); } }; diff --git a/modules/ticket/back/methods/ticket/isEditableOrThrow.js b/modules/ticket/back/methods/ticket/isEditableOrThrow.js index 16cff84f1..555063093 100644 --- a/modules/ticket/back/methods/ticket/isEditableOrThrow.js +++ b/modules/ticket/back/methods/ticket/isEditableOrThrow.js @@ -8,18 +8,13 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const state = await models.TicketState.findOne({ - where: {ticketFk: id} - }, myOptions); - + const state = await models.TicketState.findOne({where: {ticketFk: id}}, myOptions); const isRoleAdvanced = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*'); + const isProductionReviewer = await models.ACL.checkAccessAcl(ctx, 'Sale', 'isInPreparing', '*'); const canEditWeeklyTicket = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'canEditWeekly', 'WRITE'); const alertLevel = state ? state.alertLevel : null; const ticket = await models.Ticket.findById(id, { - fields: ['clientFk'], - include: { - relation: 'client' - } + fields: ['clientFk'], include: {relation: 'client'} }, myOptions); const isLocked = await models.Ticket.isLocked(id, myOptions); @@ -29,10 +24,24 @@ module.exports = Self => { const isNormalClient = ticket && ticket.client().typeFk == 'normal'; const isEditable = !(alertLevelGreaterThanZero && isNormalClient); + const ticketCollection = await models.TicketCollection.findOne({ + include: {relation: 'collection'}, where: {ticketFk: id} + }, myOptions); + let isOwner = ticketCollection?.collection()?.workerFk === ctx.req.accessToken.userId; + + if (!isOwner) { + const saleGroup = await models.SaleGroup.findOne({fields: ['id'], where: {ticketFk: id}}, myOptions); + const sectorCollectionSaleGroup = saleGroup && await models.SectorCollectionSaleGroup.findOne({ + include: {relation: 'sectorCollection'}, where: {saleGroupFk: saleGroup.id} + }, myOptions); + + isOwner = sectorCollectionSaleGroup?.sectorCollection()?.userFk === ctx.req.accessToken.userId; + } + if (!ticket) throw new ForbiddenError(`The ticket doesn't exist.`); - if (!isEditable && !isRoleAdvanced) + if (!isEditable && !isRoleAdvanced && !isProductionReviewer && !isOwner) throw new ForbiddenError(`This ticket is not editable.`); if (isLocked && !isWeekly) diff --git a/modules/ticket/back/methods/ticket/refund.js b/modules/ticket/back/methods/ticket/refund.js deleted file mode 100644 index 7365f34df..000000000 --- a/modules/ticket/back/methods/ticket/refund.js +++ /dev/null @@ -1,58 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('refund', { - description: 'Create refund tickets with all their sales and services', - accessType: 'WRITE', - accepts: [ - { - arg: 'ticketsIds', - type: ['number'], - required: true - }, - { - arg: 'withWarehouse', - type: 'boolean', - required: true - } - ], - returns: { - type: ['object'], - root: true - }, - http: { - path: `/refund`, - verb: 'POST' - } - }); - - Self.refund = async(ctx, ticketsIds, withWarehouse, options) => { - const models = Self.app.models; - const myOptions = {}; - let tx; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - - try { - const filter = {where: {ticketFk: {inq: ticketsIds}}}; - const sales = await models.Sale.find(filter, myOptions); - const salesIds = sales.map(sale => sale.id); - - const services = await models.TicketService.find(filter, myOptions); - const servicesIds = services.map(service => service.id); - - const refundedTickets = await models.Sale.clone(ctx, salesIds, servicesIds, withWarehouse, true, myOptions); - - if (tx) await tx.commit(); - - return refundedTickets; - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - }; -}; diff --git a/modules/ticket/back/methods/ticket/saveCmr.js b/modules/ticket/back/methods/ticket/saveCmr.js index f8d0af8ef..339ac1e38 100644 --- a/modules/ticket/back/methods/ticket/saveCmr.js +++ b/modules/ticket/back/methods/ticket/saveCmr.js @@ -39,7 +39,7 @@ module.exports = Self => { }, myOptions); for (const ticketId of tickets) { - const ticket = await models.Ticket.findById(ticketId, myOptions); + const ticket = await models.Ticket.findById(ticketId, null, myOptions); if (ticket.cmrFk) { const hasDmsCmr = await Self.rawSql(` diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index 490b05320..bc0da686c 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -51,23 +51,23 @@ module.exports = Self => { fields: ['id'] }); - async function setLocation(ticketId) { + async function setLocation() { await models.Delivery.create({ - ticketFk: ticketId, + ticketFk: ticket.id, longitude: location.Longitude, latitude: location.Latitude, dated: signedTime || new Date() }, myOptions); } - async function hasSignDms(ticketId) { + async function hasSignDms() { const hasTicketDms = await Self.rawSql(` SELECT d.id FROM ticketDms td JOIN dms d ON d.id = td.dmsFk WHERE td.ticketFk = ? AND d.dmsTypeFk = ? - `, [ticketId, dmsTypeTicket.id], myOptions); + `, [ticket.id, dmsTypeTicket.id], myOptions); if (hasTicketDms.length) return true; } @@ -133,21 +133,23 @@ module.exports = Self => { if (await ticket.isSigned) throw new UserError('Ticket is already signed'); - if (location) await setLocation(ticketId); - if (!await hasSignDms(ticketId) && !isSignUploaded) - await createGestDoc(ticketId); + if (location) await setLocation(); + if (!await hasSignDms() && !isSignUploaded) + await createGestDoc(); if (isSignUploaded) await models.TicketDms.create({ticketFk: ticket.id, dmsFk: dms[0].id}, myOptions); await ticket.updateAttribute('isSigned', true, myOptions); - const deliveryState = await models.State.findOne({ - where: {code: 'DELIVERED'} - }, myOptions); + const [{stateCode}] = await Self.rawSql(` + SELECT + IF((SUM(CASE WHEN est.code = 'DELIVERED' THEN 1 ELSE 0 END) = COUNT(*)), + 'DELIVERED','PARTIAL_DELIVERED') stateCode + FROM vn.expedition e + JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk + WHERE e.ticketFk = ?; + `, [ticketId], myOptions); - await models.Ticket.state(ctx, { - ticketFk: ticketId, - stateFk: deliveryState.id - }, myOptions); + await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticketId, stateCode], myOptions); if (ticket?.address()?.province()?.country()?.code != 'ES' && ticket.cmrFk) { await models.Ticket.saveCmr(ctx, [ticketId], myOptions); diff --git a/modules/ticket/back/methods/ticket/setDeleted.js b/modules/ticket/back/methods/ticket/setDeleted.js index 9a9fd9056..a684e1cbc 100644 --- a/modules/ticket/back/methods/ticket/setDeleted.js +++ b/modules/ticket/back/methods/ticket/setDeleted.js @@ -43,11 +43,22 @@ module.exports = Self => { // Check if ticket has refunds const ticketRefunds = await models.TicketRefund.find({ - where: {originalTicketFk: id}, - fields: ['id']} - , myOptions); - if (ticketRefunds.length > 0) - throw new UserError('Tickets with associated refunds', 'TICKET_REFUND', ticketRefunds[0].id); + include: [ + {relation: 'refundTicket'} + ], + where: {originalTicketFk: id} + }, myOptions); + + const allDeleted = ticketRefunds.every(refund => refund.refundTicket().isDeleted); + + if (ticketRefunds?.length && !allDeleted) { + const notDeleted = []; + for (const refund of ticketRefunds) + if (!refund.refundTicket().isDeleted) notDeleted.push(refund.refundTicket().id); + + throw new UserError('Tickets with associated refunds', 'TICKET_REFUND', + notDeleted.join(', ')); + } // Check if has sales with shelving const canDeleteTicketWithPartPrepared = @@ -71,7 +82,10 @@ module.exports = Self => { // Check for existing purchase requests const hasPurchaseRequests = await models.TicketRequest.count({ ticketFk: id, - isOk: true + or: [ + {isOk: true}, + {isOk: null} + ] }, myOptions); if (hasPurchaseRequests) @@ -124,7 +138,7 @@ module.exports = Self => { id: id, url: `${url}ticket/${id}/summary` }); - await models.Chat.send(ctx, `@${salesPersonUser.name}`, message); + await models.Chat.sendCheckingPresence(ctx, salesPersonUser.id, message); } const updatedTicket = await ticket.updateAttribute('isDeleted', true, myOptions); diff --git a/modules/ticket/back/methods/ticket/setWeight.js b/modules/ticket/back/methods/ticket/setWeight.js new file mode 100644 index 000000000..b3b505832 --- /dev/null +++ b/modules/ticket/back/methods/ticket/setWeight.js @@ -0,0 +1,86 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('setWeight', { + description: 'Sets weight of a ticket', + accessType: 'WRITE', + accepts: [{ + arg: 'id', + type: 'number', + required: true, + description: 'The ticket id', + http: {source: 'path'} + }, { + arg: 'weight', + type: 'number', + required: true, + description: 'The weight value', + }], + returns: { + type: 'Array', + root: true + }, + http: { + path: `/:id/setWeight`, + verb: 'POST' + } + }); + + Self.setWeight = async(ctx, ticketId, weight, options) => { + const models = Self.app.models; + const userId = ctx.req.accessToken.userId; + const myOptions = {userId}; + let tx; + + if (typeof options == 'object') Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const ticket = await Self.findById(ticketId, null, myOptions); + if (ticket.weight) throw new UserError('Weight already set'); + + const canEdit = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'updateAttributes'); + const client = await models.Client.findById(ticket.clientFk, { + include: {relation: 'salesPersonUser'}}, + myOptions); + + if (!canEdit) { + const salesPersonUser = client.salesPersonUser(); + const workerDepartments = await models.WorkerDepartment.find({ + include: {relation: 'department'}, + where: {workerFk: {inq: [userId, salesPersonUser.id]}} + }, myOptions); + + if ( + workerDepartments.length == 2 && + workerDepartments[0].departmentFk != workerDepartments[1].departmentFk + ) + throw new UserError('This ticket is not allocated to your department'); + } + + await ticket.updateAttribute('weight', weight, myOptions); + + const packedState = await models.State.findOne({where: {code: 'PACKED'}}, myOptions); + const ticketState = await models.TicketState.findOne({where: {ticketFk: ticketId}}, myOptions); + + const [{taxArea}] = await Self.rawSql('SELECT clientTaxArea(?,?) taxArea', + [ticket.clientFk, ticket.warehouseFk], myOptions); + + const isInvoiceable = ticketState.alertLevel >= packedState.alertLevel && + taxArea == 'WORLD' && client.hasDailyInvoice; + + if (tx) await tx.commit(); + let invoiceIds = []; + if (isInvoiceable) invoiceIds = [...await Self.invoiceTicketsAndPdf(ctx, [ticketId])]; + + return invoiceIds; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/ticket/back/methods/ticket/specs/addSaleByCode.spec.js b/modules/ticket/back/methods/ticket/specs/addSaleByCode.spec.js deleted file mode 100644 index b97139178..000000000 --- a/modules/ticket/back/methods/ticket/specs/addSaleByCode.spec.js +++ /dev/null @@ -1,39 +0,0 @@ -const {models} = require('vn-loopback/server/server'); -const LoopBackContext = require('loopback-context'); - -describe('Ticket addSaleByCode()', () => { - const quantity = 3; - const ticketFk = 13; - const warehouseFk = 1; - beforeAll(async() => { - activeCtx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'http://localhost'}, - __: value => value - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); - - it('should add a new sale', async() => { - const tx = await models.Ticket.beginTransaction({}); - - try { - const options = {transaction: tx}; - const code = '1111111111'; - - const salesBefore = await models.Sale.find(null, options); - await models.Ticket.addSaleByCode(activeCtx, code, quantity, ticketFk, warehouseFk, options); - const salesAfter = await models.Sale.find(null, options); - - expect(salesAfter.length).toEqual(salesBefore.length + 1); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); -}); diff --git a/modules/ticket/back/methods/ticket/specs/clone.spec.js b/modules/ticket/back/methods/ticket/specs/clone.spec.js deleted file mode 100644 index 26114bd58..000000000 --- a/modules/ticket/back/methods/ticket/specs/clone.spec.js +++ /dev/null @@ -1,56 +0,0 @@ -const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); - -describe('Ticket cloning - clone function', () => { - let ctx; - let options; - let tx; - const ticketId = 1; - const shipped = Date.vnNew(); - - beforeEach(async() => { - ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'http://localhost'} - }, - args: {} - }; - - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: ctx.req - }); - - options = {transaction: tx}; - tx = await models.Ticket.beginTransaction({}); - options.transaction = tx; - }); - - afterEach(async() => { - await tx.rollback(); - }); - - it('should clone a new ticket without warehouse', async() => { - const originalTicket = await models.Ticket.findById(ticketId, null, options); - - const newTicketId = await models.Ticket.clone(ctx, ticketId, shipped, false, options); - const newTicket = await models.Ticket.findById(newTicketId, null, options); - - expect(newTicket.clientFk).toEqual(originalTicket.clientFk); - expect(newTicket.companyFk).toEqual(originalTicket.companyFk); - expect(newTicket.addressFk).toEqual(originalTicket.addressFk); - expect(newTicket.warehouseFk).toBeFalsy(); - }); - - it('should clone a new ticket with warehouse', async() => { - const originalTicket = await models.Ticket.findById(ticketId, null, options); - - const newTicketId = await models.Ticket.clone(ctx, ticketId, shipped, true, options); - const newTicket = await models.Ticket.findById(newTicketId, null, options); - - expect(newTicket.clientFk).toEqual(originalTicket.clientFk); - expect(newTicket.companyFk).toEqual(originalTicket.companyFk); - expect(newTicket.addressFk).toEqual(originalTicket.addressFk); - expect(newTicket.warehouseFk).toEqual(originalTicket.warehouseFk); - }); -}); diff --git a/modules/ticket/back/methods/ticket/specs/cloneAll.spec.js b/modules/ticket/back/methods/ticket/specs/cloneAll.spec.js new file mode 100644 index 000000000..4788df2c2 --- /dev/null +++ b/modules/ticket/back/methods/ticket/specs/cloneAll.spec.js @@ -0,0 +1,53 @@ +const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); + +describe('Ticket cloning - cloneAll function', () => { + const activeCtx = { + accessToken: {userId: 1}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + const ctx = {req: activeCtx}; + let options; + let tx; + const ticketIds = [1, 2]; + const withWarehouse = true; + const negative = false; + + beforeEach(async() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: ctx.req}); + tx = await models.Ticket.beginTransaction({}); + options = {transaction: tx}; + }); + + afterEach(async() => { + if (tx) + await tx.rollback(); + }); + + it('should clone all provided tickets with their associated sales, services, and packages', async() => { + const originalTickets = await models.Ticket.find({where: {id: {inq: ticketIds}}}, options); + const originalSales = await models.Sale.find({where: {ticketFk: {inq: ticketIds}}}, options); + const originalServices = await models.TicketService.find({where: {ticketFk: {inq: ticketIds}}}, options); + const originalTicketPackaging = + await models.TicketPackaging.find({where: {ticketFk: {inq: ticketIds}}}, options); + + // Pass the ctx correctly to the cloneAll function + const clonedTickets = await models.Ticket.cloneAll(ctx, ticketIds, withWarehouse, negative, options); + + expect(clonedTickets.length).toEqual(originalTickets.length); + + const clonedSales = await models.Sale.find({where: {ticketFk: {inq: clonedTickets.map(t => t.id)}}}, options); + const clonedServices = + await models.TicketService.find({where: {ticketFk: {inq: clonedTickets.map(t => t.id)}}}, options); + const clonedTicketPackaging = + await models.TicketPackaging.find({where: {ticketFk: {inq: clonedTickets.map(t => t.id)}}}, options); + + expect(clonedSales.length).toEqual(originalSales.length); + expect(clonedServices.length).toEqual(originalServices.length); + expect(clonedTicketPackaging.length).toEqual(originalTicketPackaging.length); + }); +}); diff --git a/modules/ticket/back/methods/ticket/specs/closure.spec.js b/modules/ticket/back/methods/ticket/specs/closure.spec.js new file mode 100644 index 000000000..cafe178cb --- /dev/null +++ b/modules/ticket/back/methods/ticket/specs/closure.spec.js @@ -0,0 +1,119 @@ +const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); +const smtp = require('vn-print/core/smtp'); +const Email = require('vn-print/core/email'); +const config = require('vn-print/core/config'); +const closure = require('../closure'); + +describe('Ticket closure functionality', () => { + const userId = 19; + const companyFk = 442; + const activeCtx = { + getLocale: () => 'es', + accessToken: {userId: userId}, + headers: {origin: 'http://localhost:5000'}, + }; + let ctx = {req: activeCtx}; + let tx; + let options; + + beforeEach(async() => { + LoopBackContext.getCurrentContext = () => ({ + active: activeCtx, + }); + + tx = await models.Sale.beginTransaction({}); + options = {transaction: tx}; + }); + + afterEach(async() => { + await tx.rollback(); + }); + + it('should successfully close a ticket and not invoiced', async() => { + const ticketId = 15; + const tickets = [{ + id: ticketId, + clientFk: 1101, + companyFk, + addressFk: 1, + isToBeMailed: true, + recipient: 'some@email.com', + salesPersonFk: userId + }]; + + const ticketStateBefore = await models.TicketState.findById(ticketId, null, options); + + await closure(ctx, models.Ticket, tickets, options); + + const ticketStateAfter = await models.TicketState.findById(ticketId, null, options); + + expect(ticketStateBefore.code).not.toBe(ticketStateAfter.code); + + const ticketAfter = await models.Ticket.findById(ticketId, null, options); + + expect(ticketAfter.refFk).toBeNull(); + }); + + it('should send Incoterms authorization email on first order', async() => { + const ticketId = 37; + ctx.args = { + id: ticketId, + }; + + const ticket = await models.Ticket.findById(ticketId, null, options); + spyOn(Email.prototype, 'send').and.returnValue(Promise.resolve()); + + await models.Ticket.closeByTicket(ctx, options); + + const sample = await models.Sample.findOne({ + where: {code: 'incoterms-authorization'}, + fields: ['id'] + }, + options); + + const insertedSample = await models.ClientSample.findOne({ + where: { + clientFk: ticket.clientFk, + typeFk: sample.id, + companyFk: companyFk + } + }, options); + + expect(insertedSample.clientFk).toEqual(ticket.clientFk); + }); + + it('should report failed tickets and set client email to null', async() => { + const ticketId = 37; + const clientId = 1110; + const tickets = [{ + id: ticketId, + clientFk: clientId, + companyFk, + addressFk: 1, + isToBeMailed: true, + recipient: 'invalid@example.com', + salesPersonFk: userId + }]; + + spyOn(Email.prototype, 'send').and.callFake(() => { + const error = new Error('Invalid email'); + error.responseCode = 450; + return Promise.reject(error); + }); + + await closure(ctx, models.Ticket, tickets, options); + + const client = await models.Client.findById(clientId, null, options); + + expect(client.email).toBeNull(); + + const reportEmail = await smtp.send({ + to: config.app.reportEmail, + subject: '[API] Nightly ticket closure report', + html: `This following tickets have failed:` + }); + + expect(reportEmail).not.toBeNull(); + }); +}); diff --git a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js index 8abb1a4a1..15dd5e4ce 100644 --- a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js +++ b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js @@ -1,8 +1,7 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('ticket componentUpdate()', () => { - const userID = 1101; + const ctx = beforeAll.getCtx(1101); const ticketID = 11; const today = Date.vnNew(); const tomorrow = Date.vnNew(); @@ -16,18 +15,8 @@ describe('ticket componentUpdate()', () => { let componentOfSaleEight; let componentValue; + beforeAll.mockLoopBackContext(); beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); const deliveryComponenet = await models.Component.findOne({where: {code: 'delivery'}}); deliveryComponentId = deliveryComponenet.id; componentOfSaleSeven = `SELECT value @@ -64,16 +53,7 @@ describe('ticket componentUpdate()', () => { isWithoutNegatives: false }; - let ctx = { - args: args, - req: { - accessToken: {userId: userID}, - headers: {origin: 'http://localhost'}, - __: value => { - return value; - } - } - }; + ctx.args = args; await models.Ticket.componentUpdate(ctx, options); [componentValue] = await models.SaleComponent.rawSql(componentOfSaleSeven, null, options); @@ -113,16 +93,7 @@ describe('ticket componentUpdate()', () => { isWithoutNegatives: false }; - const ctx = { - args: args, - req: { - accessToken: {userId: userID}, - headers: {origin: 'http://localhost'}, - __: value => { - return value; - } - } - }; + ctx.args = args; const observationTypeDelivery = await models.ObservationType.findOne({ where: {code: 'delivery'} }, options); @@ -152,6 +123,7 @@ describe('ticket componentUpdate()', () => { }); it('should change warehouse and without negatives', async() => { + const ctx = beforeAll.getCtx(9); const tx = await models.SaleComponent.beginTransaction({}); try { @@ -178,17 +150,7 @@ describe('ticket componentUpdate()', () => { option: 'renewPrices', isWithoutNegatives: true }; - - const ctx = { - args: args, - req: { - accessToken: {userId: 9}, - headers: {origin: 'http://localhost'}, - __: value => { - return value; - } - } - }; + ctx.args = args; const oldTicket = await models.Ticket.findById(ticketID, null, options); @@ -210,6 +172,7 @@ describe('ticket componentUpdate()', () => { }); describe('componentUpdate() keepPrice', () => { + const ctx = beforeAll.getCtx(); it('should change shipped and keep price', async() => { const tx = await models.Ticket.beginTransaction({}); @@ -239,16 +202,7 @@ describe('ticket componentUpdate()', () => { keepPrice: true }; - const ctx = { - args: args, - req: { - accessToken: {userId: 9}, - headers: {origin: 'http://localhost'}, - __: value => { - return value; - } - } - }; + ctx.args = args; const beforeSale = await models.Sale.findById(saleId, null, options); await models.Ticket.componentUpdate(ctx, options); @@ -292,16 +246,7 @@ describe('ticket componentUpdate()', () => { keepPrice: false }; - const ctx = { - args: args, - req: { - accessToken: {userId: 9}, - headers: {origin: 'http://localhost'}, - __: value => { - return value; - } - } - }; + ctx.args = args; const beforeSale = await models.Sale.findById(saleId, null, options); await models.Ticket.componentUpdate(ctx, options); diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index e495a41f5..d0edb24e3 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -1,6 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('ticket filter()', () => { + const ctx = beforeAll.getCtx(); it('should return the tickets matching the filter', async() => { const tx = await models.Ticket.beginTransaction({}); @@ -20,7 +21,7 @@ describe('ticket filter()', () => { } }); - it('should return the tickets matching the problems on true', async() => { + it('should return at least one ticket matching the problems on true', async() => { const tx = await models.Ticket.beginTransaction({}); try { @@ -31,15 +32,24 @@ describe('ticket filter()', () => { const today = Date.vnNew(); today.setHours(23, 59, 59, 59); - const ctx = {req: {accessToken: {userId: 9}}, args: { + const args = { problems: true, from: yesterday, to: today - }}; + }; + ctx.args = args; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); - expect(result.length).toBeGreaterThan(3); + const hasProblemTicket = result.some(ticket => + ticket.isFreezed === true || + ticket.hasRisk === true || + ticket.hasTicketRequest === true || + (typeof ticket.hasRounding === 'string' && ticket.hasRounding.trim().length > 0) || + (typeof ticket.itemShortage === 'string' && ticket.itemShortage.trim().length > 0) + ); + + expect(hasProblemTicket).toBe(true); await tx.rollback(); } catch (e) { @@ -60,15 +70,22 @@ describe('ticket filter()', () => { const today = Date.vnNew(); today.setHours(23, 59, 59, 59); - const ctx = {req: {accessToken: {userId: 9}}, args: { + const args = { problems: false, from: yesterday, to: today - }}; + }; + ctx.args = args; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); - expect(result.length).toEqual(7); + result.forEach(ticket => { + expect(ticket.isFreezed).toEqual(null); + expect(ticket.hasRisk).toEqual(null); + expect(ticket.hasTicketRequest).toEqual(null); + expect(ticket.itemShortage).toEqual(null); + expect(ticket.hasRounding).toEqual(null); + }); await tx.rollback(); } catch (e) { @@ -83,7 +100,8 @@ describe('ticket filter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}, args: {problems: null}}; + const args = {problems: null}; + ctx.args = args; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); @@ -102,7 +120,8 @@ describe('ticket filter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}, args: {orderFk: 11}}; + const args = {orderFk: 11}; + ctx.args = args; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); const firstRow = result[0]; @@ -123,7 +142,8 @@ describe('ticket filter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}, args: {pending: true}}; + const args = {pending: true}; + ctx.args = args; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); @@ -146,7 +166,8 @@ describe('ticket filter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}, args: {pending: false}}; + const args = {pending: false}; + ctx.args = args; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); const firstRow = result[0]; @@ -167,11 +188,13 @@ describe('ticket filter()', () => { it('should return the tickets from the worker team', async() => { const tx = await models.Ticket.beginTransaction({}); + const ctx = beforeAll.getCtx(18); try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 18}}, args: {myTeam: true}}; + const args = {myTeam: true}; + ctx.args = args; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); @@ -185,12 +208,14 @@ describe('ticket filter()', () => { }); it('should return the tickets that are not from the worker team', async() => { + const ctx = beforeAll.getCtx(18); const tx = await models.Ticket.beginTransaction({}); try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 18}}, args: {myTeam: false}}; + const args = {myTeam: false}; + ctx.args = args; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); @@ -204,12 +229,14 @@ describe('ticket filter()', () => { }); it('should return the tickets belonging to the collection id 1', async() => { + const ctx = beforeAll.getCtx(18); const tx = await models.Ticket.beginTransaction({}); try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 18}}, args: {collectionFk: 1}}; + const args = {collectionFk: 1}; + ctx.args = args; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); @@ -228,7 +255,8 @@ describe('ticket filter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}, args: {hasRoute: true}}; + const args = {hasRoute: true}; + ctx.args = args; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); @@ -247,7 +275,8 @@ describe('ticket filter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}, args: {hasRoute: false}}; + const args = {hasRoute: false}; + ctx.args = args; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); @@ -266,7 +295,8 @@ describe('ticket filter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}, args: {hasRoute: null}}; + const args = {hasRoute: null}; + ctx.args = args; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); @@ -285,7 +315,8 @@ describe('ticket filter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}, args: {hasInvoice: true}}; + const args = {hasInvoice: true}; + ctx.args = args; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); @@ -304,7 +335,8 @@ describe('ticket filter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}, args: {hasInvoice: null}}; + const args = {hasInvoice: null}; + ctx.args = args; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js index 5a3209a6d..488cd1fc2 100644 --- a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js @@ -1,6 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('TicketFuture getTicketsAdvance()', () => { + const ctx = beforeAll.getCtx(); const today = Date.vnNew(); today.setHours(0, 0, 0, 0); let tomorrow = Date.vnNew(); @@ -18,7 +19,7 @@ describe('TicketFuture getTicketsAdvance()', () => { warehouseFk: 1, }; - const ctx = {req: {accessToken: {userId: 9}}, args}; + ctx.args = args; const result = await models.Ticket.getTicketsAdvance(ctx, options); expect(result.length).toBeGreaterThan(0); @@ -42,7 +43,7 @@ describe('TicketFuture getTicketsAdvance()', () => { isFullMovable: true }; - const ctx = {req: {accessToken: {userId: 9}}, args}; + ctx.args = args; const result = await models.Ticket.getTicketsAdvance(ctx, options); expect(result.length).toBeGreaterThan(0); @@ -67,7 +68,7 @@ describe('TicketFuture getTicketsAdvance()', () => { isFullMovable: false }; - const ctx = {req: {accessToken: {userId: 9}}, args}; + ctx.args = args; const result = await models.Ticket.getTicketsAdvance(ctx, options); expect(result.length).toEqual(0); @@ -92,7 +93,7 @@ describe('TicketFuture getTicketsAdvance()', () => { ipt: 'V' }; - const ctx = {req: {accessToken: {userId: 9}}, args}; + ctx.args = args; const result = await models.Ticket.getTicketsAdvance(ctx, options); expect(result.length).toBeGreaterThan(5); @@ -117,7 +118,7 @@ describe('TicketFuture getTicketsAdvance()', () => { tfIpt: 'V' }; - const ctx = {req: {accessToken: {userId: 9}}, args}; + ctx.args = args; const result = await models.Ticket.getTicketsAdvance(ctx, options); expect(result.length).toBeGreaterThan(5); diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js index 44896493f..e1e9a0ed2 100644 --- a/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js @@ -1,6 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('ticket getTicketsFuture()', () => { + const ctx = beforeAll.getCtx(); const today = Date.vnNew(); today.setHours(0, 0, 0, 0); @@ -11,12 +12,12 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, }; - const ctx = {req: {accessToken: {userId: 9}}, args}; + ctx.args = args; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toBeGreaterThan(0); @@ -34,13 +35,13 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, problems: true }; - const ctx = {req: {accessToken: {userId: 9}}, args}; + ctx.args = args; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toBeGreaterThan(0); @@ -59,13 +60,13 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, problems: false }; - const ctx = {req: {accessToken: {userId: 9}}, args}; + ctx.args = args; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toEqual(0); @@ -84,13 +85,13 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, problems: null }; - const ctx = {req: {accessToken: {userId: 9}}, args}; + ctx.args = args; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toBeGreaterThan(0); @@ -109,13 +110,13 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, state: 'OK' }; - const ctx = {req: {accessToken: {userId: 9}}, args}; + ctx.args = args; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toBeGreaterThan(0); @@ -134,13 +135,13 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, futureState: 'OK' }; - const ctx = {req: {accessToken: {userId: 9}}, args}; + ctx.args = args; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toBeGreaterThan(0); @@ -159,13 +160,13 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, ipt: null }; - const ctx = {req: {accessToken: {userId: 9}}, args}; + ctx.args = args; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toBeGreaterThan(0); @@ -184,13 +185,13 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, ipt: 'H' }; - const ctx = {req: {accessToken: {userId: 9}}, args}; + ctx.args = args; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toBeGreaterThan(0); @@ -209,13 +210,13 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, futureIpt: null }; - const ctx = {req: {accessToken: {userId: 9}}, args}; + ctx.args = args; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toBeGreaterThan(0); @@ -234,13 +235,13 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, futureIpt: 'H' }; - const ctx = {req: {accessToken: {userId: 9}}, args}; + ctx.args = args; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toBeGreaterThan(0); @@ -259,13 +260,13 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, id: 13 }; - const ctx = {req: {accessToken: {userId: 9}}, args}; + ctx.args = args; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toBeGreaterThan(0); @@ -284,13 +285,13 @@ describe('ticket getTicketsFuture()', () => { const options = {transaction: tx}; const args = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: 1, futureId: 12 }; - const ctx = {req: {accessToken: {userId: 9}}, args}; + ctx.args = args; const result = await models.Ticket.getTicketsFuture(ctx, options); expect(result.length).toBeGreaterThan(0); diff --git a/modules/ticket/back/methods/ticket/specs/isEditableOrThrow.spec.js b/modules/ticket/back/methods/ticket/specs/isEditableOrThrow.spec.js index bdf547325..1a8025f09 100644 --- a/modules/ticket/back/methods/ticket/specs/isEditableOrThrow.spec.js +++ b/modules/ticket/back/methods/ticket/specs/isEditableOrThrow.spec.js @@ -1,14 +1,12 @@ const models = require('vn-loopback/server/server').models; describe('ticket isEditableOrThrow()', () => { + const ctx = beforeAll.getCtx(); it('should throw an error as the ticket does not exist', async() => { const tx = await models.Ticket.beginTransaction({}); let error; try { const options = {transaction: tx}; - const ctx = { - req: {accessToken: {userId: 9}} - }; await models.Ticket.isEditableOrThrow(ctx, 9999, options); await tx.rollback(); @@ -67,7 +65,7 @@ describe('ticket isEditableOrThrow()', () => { const options = {transaction: tx}; const ctx = {req: {accessToken: {userId: 1}}}; - await models.Ticket.isEditableOrThrow(ctx, 15, options); + await models.Ticket.isEditableOrThrow(ctx, 17, options); await tx.rollback(); } catch (e) { error = e; diff --git a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js index fea8b2096..88812dc92 100644 --- a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js +++ b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js @@ -3,7 +3,7 @@ const LoopBackContext = require('loopback-context'); describe('ticket makeInvoice()', () => { const userId = 19; - const invoiceType = 'R'; + const invoiceType = 'quick'; const companyFk = 442; const invoiceDate = Date.vnNew(); const activeCtx = { diff --git a/modules/ticket/back/methods/ticket/specs/merge.spec.js b/modules/ticket/back/methods/ticket/specs/merge.spec.js index 646b9739f..68f9d3393 100644 --- a/modules/ticket/back/methods/ticket/specs/merge.spec.js +++ b/modules/ticket/back/methods/ticket/specs/merge.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('ticket merge()', () => { + const ctx = beforeAll.getCtx(); const tickets = { originId: 13, destinationId: 12, @@ -10,30 +10,6 @@ describe('ticket merge()', () => { workerFk: 1 }; - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); - - const ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'http://localhost:5000'}, - } - }; - ctx.req.__ = value => { - return value; - }; - it('should merge two tickets', async() => { const tx = await models.Ticket.beginTransaction({}); diff --git a/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js b/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js index e5c06b6dd..7dc1c8ed2 100644 --- a/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js +++ b/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js @@ -42,7 +42,7 @@ describe('sale priceDifference()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 1106}}}; + const ctx = {req: {accessToken: {userId: 1105}}}; ctx.args = { id: 1, landed: Date.vnNew(), @@ -84,7 +84,7 @@ describe('sale priceDifference()', () => { const {items} = await models.Ticket.priceDifference(ctx, options); - expect(items[0].movable).toEqual(410); + expect(items[0].movable).toEqual(386); expect(items[1].movable).toEqual(1810); await tx.rollback(); diff --git a/modules/ticket/back/methods/ticket/specs/recalculateComponents.spec.js b/modules/ticket/back/methods/ticket/specs/recalculateComponents.spec.js index d358a79f5..f9c7284f5 100644 --- a/modules/ticket/back/methods/ticket/specs/recalculateComponents.spec.js +++ b/modules/ticket/back/methods/ticket/specs/recalculateComponents.spec.js @@ -3,6 +3,7 @@ const ForbiddenError = require('vn-loopback/util/forbiddenError'); describe('ticket recalculateComponents()', () => { const ticketId = 11; + const ctx = beforeAll.getCtx(); it('should update the ticket components', async() => { const tx = await models.Ticket.beginTransaction({}); @@ -10,7 +11,6 @@ describe('ticket recalculateComponents()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}}; const response = await models.Ticket.recalculateComponents(ctx, ticketId, options); expect(response.affectedRows).toBeDefined(); @@ -29,7 +29,6 @@ describe('ticket recalculateComponents()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}}; const immutableTicketId = 1; await models.Ticket.recalculateComponents(ctx, immutableTicketId, options); diff --git a/modules/ticket/back/methods/ticket/specs/saveSign.spec.js b/modules/ticket/back/methods/ticket/specs/saveSign.spec.js index 792e9e824..e93408973 100644 --- a/modules/ticket/back/methods/ticket/specs/saveSign.spec.js +++ b/modules/ticket/back/methods/ticket/specs/saveSign.spec.js @@ -26,4 +26,29 @@ describe('Ticket saveSign()', () => { expect(error).toBeDefined(); }); + + it('should change state for ticket', async() => { + const tx = await models.Ticket.beginTransaction({}); + const ticketWithPackedState = 7; + spyOn(models.Dms, 'uploadFile').and.returnValue([{id: 1}]); + let ticketTrackingAfter; + + try { + const options = {transaction: tx}; + const tickets = [ticketWithPackedState]; + + const expedition = await models.Expedition.findById(3, null, options); + expedition.updateAttribute('ticketFk', ticketWithPackedState, options); + + await models.Ticket.saveSign(ctx, tickets, null, null, options); + ticketTrackingAfter = await models.TicketLastState.findById(ticketWithPackedState, null, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + + expect(ticketTrackingAfter.name).toBe('Entregado en parte'); + }); }); diff --git a/modules/ticket/back/methods/ticket/specs/sendSms.spec.js b/modules/ticket/back/methods/ticket/specs/sendSms.spec.js index afc1ada54..2a7b82ea0 100644 --- a/modules/ticket/back/methods/ticket/specs/sendSms.spec.js +++ b/modules/ticket/back/methods/ticket/specs/sendSms.spec.js @@ -1,13 +1,13 @@ const models = require('vn-loopback/server/server').models; describe('ticket sendSms()', () => { + const ctx = beforeAll.getCtx(); it('should send a message and log it', async() => { const tx = await models.Ticket.beginTransaction({}); try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}}; const id = 11; const destination = 222222222; const message = 'this is the message created in a test'; diff --git a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js index 520a9e403..782c31c02 100644 --- a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js +++ b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js @@ -1,17 +1,8 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('ticket setDeleted()', () => { - const userId = 1106; - const activeCtx = { - accessToken: {userId: userId}, - }; - - beforeEach(() => { - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + const ctx = beforeAll.getCtx(); + beforeAll.mockLoopBackContext(); it('should throw an error if the given ticket has a claim', async() => { const tx = await models.Ticket.beginTransaction({}); @@ -20,7 +11,6 @@ describe('ticket setDeleted()', () => { try { const options = {transaction: tx}; - const ctx = {req: activeCtx}; const ticketId = 16; await models.Ticket.setDeleted(ctx, ticketId, options); @@ -40,16 +30,7 @@ describe('ticket setDeleted()', () => { try { const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'http://localhost:5000'}, - } - }; - ctx.req.__ = value => { - return value; - }; - const ticketId = 23; + const ticketId = 24; const [sectorCollectionBefore] = await models.Ticket.rawSql( `SELECT COUNT(*) numberRows FROM vn.sectorCollection`, [], options); @@ -75,19 +56,10 @@ describe('ticket setDeleted()', () => { try { const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'http://localhost:5000'}, - } - }; - ctx.req.__ = value => { - return value; - }; const [ticketCollectionOld] = await models.Ticket.rawSql( `SELECT COUNT(*) numberRows FROM vn.ticketCollection`, [], options); - const ticketId = 23; + const ticketId = 34; await models.Ticket.setDeleted(ctx, ticketId, options); @@ -104,31 +76,42 @@ describe('ticket setDeleted()', () => { } }); - it('should show error trying to delete a ticket with a refund', async() => { - const tx = await models.Ticket.beginTransaction({}); - let error; - try { - const options = {transaction: tx}; + describe('ticket with refund setDeleted()', () => { + it('should show error trying to delete a ticket with a refund', async() => { + const tx = await models.Ticket.beginTransaction({}); + let error; + try { + const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'http://localhost:5000'}, - } - }; - ctx.req.__ = value => { - return value; - }; + const ticketId = 8; + await models.Ticket.setDeleted(ctx, ticketId, options); - const ticketId = 8; - await models.Ticket.setDeleted(ctx, ticketId, options); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } - await tx.rollback(); - } catch (e) { - await tx.rollback(); - error = e; - } + expect(error.message).toContain('Tickets with associated refunds'); + }); - expect(error.message).toContain('Tickets with associated refunds'); + it('should delete a ticket with a refund if ticket refund is deleted', async() => { + const tx = await models.Ticket.beginTransaction({}); + try { + const options = {transaction: tx}; + + const ticketId = 8; + const ticketRefundId = 24; + await models.Ticket.updateAll({id: ticketRefundId}, {isDeleted: true}, options); + await models.Ticket.setDeleted(ctx, ticketId, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).not.toContain('Tickets with associated refunds'); + }); }); }); diff --git a/modules/ticket/back/methods/ticket/specs/setWeight.spec.js b/modules/ticket/back/methods/ticket/specs/setWeight.spec.js new file mode 100644 index 000000000..f6ef1f8e7 --- /dev/null +++ b/modules/ticket/back/methods/ticket/specs/setWeight.spec.js @@ -0,0 +1,70 @@ +const {models} = require('vn-loopback/server/server'); + +describe('ticket setWeight()', () => { + const ctx = beforeAll.getCtx(); + beforeAll.mockLoopBackContext(); + let opts; + let tx; + const employeeId = 1; + const administrativeId = 5; + + beforeEach(async() => { + opts = {transaction: tx}; + tx = await models.Ticket.beginTransaction({}); + opts.transaction = tx; + ctx.req.accessToken.userId = administrativeId; + }); + + afterEach(async() => await tx.rollback()); + + it('should throw an error if the weight is already set', async() => { + try { + const ticketId = 1; + const weight = 10; + + await models.Ticket.setWeight(ctx, ticketId, weight, opts); + } catch (e) { + expect(e.message).toEqual('Weight already set'); + } + }); + + it('should set the weight of a ticket', async() => { + const ticketId = 31; + const weight = 15; + + await models.Ticket.setWeight(ctx, ticketId, weight, opts); + + const ticket = await models.Ticket.findById(ticketId, null, opts); + + expect(ticket.weight).toEqual(weight); + }); + + it('should throw an error if the user is not allocated to the same department', async() => { + ctx.req.accessToken.userId = employeeId; + try { + const ticketId = 10; + const weight = 20; + + await models.Ticket.setWeight(ctx, ticketId, weight, opts); + } catch (e) { + expect(e.message).toEqual('This ticket is not allocated to your department'); + } + }); + + it('should call invoiceTicketsAndPdf if the ticket is invoiceable', async() => { + const ticketId = 10; + const weight = 25; + + spyOn(models.Client, 'findById').and.returnValue({ + hasDailyInvoice: true, + salesPersonUser: () => ({id: 1}) + }); + spyOn(models.TicketState, 'findOne').and.returnValue({alertLevel: 3}); + spyOn(models.Ticket, 'rawSql').and.returnValue([{taxArea: 'WORLD'}]); + spyOn(models.Ticket, 'invoiceTicketsAndPdf').and.returnValue([10]); + + const invoiceIds = await models.Ticket.setWeight(ctx, ticketId, weight, opts); + + expect(invoiceIds.length).toBeGreaterThan(0); + }); +}); diff --git a/modules/ticket/back/methods/ticket/specs/state.spec.js b/modules/ticket/back/methods/ticket/specs/state.spec.js index 947e72b79..04abd4ca8 100644 --- a/modules/ticket/back/methods/ticket/specs/state.spec.js +++ b/modules/ticket/back/methods/ticket/specs/state.spec.js @@ -1,14 +1,11 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); -describe('ticket state()', () => { +xdescribe('ticket state()', () => { + const ctx = beforeAll.getCtx(); const salesPersonId = 18; const employeeId = 1; const productionId = 49; - const activeCtx = { - accessToken: {userId: 9}, - }; - const ctx = {req: activeCtx}; const now = Date.vnNew(); const sampleTicket = { shipped: now, @@ -32,7 +29,7 @@ describe('ticket state()', () => { beforeAll(async() => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx + active: ctx }); }); @@ -44,7 +41,7 @@ describe('ticket state()', () => { try { const options = {transaction: tx}; - activeCtx.accessToken.userId = salesPersonId; + ctx.req.accessToken.userId = salesPersonId; await models.Ticket.state(ctx, {ticketFk: 2, stateFk: 3}, options); @@ -65,7 +62,7 @@ describe('ticket state()', () => { try { const options = {transaction: tx}; - activeCtx.accessToken.userId = employeeId; + ctx.req.accessToken.userId = employeeId; await models.Ticket.state(ctx, {ticketFk: 11, stateFk: 13}, options); @@ -87,8 +84,9 @@ describe('ticket state()', () => { const ticket = await models.Ticket.create(sampleTicket, options); - activeCtx.accessToken.userId = productionId; - const params = {ticketFk: ticket.id, stateFk: 3}; + ctx.req.accessToken.userId = productionId; + const stateOk = await models.State.findOne({where: {code: 'OK'}}, options); + const params = {ticketFk: ticket.id, stateFk: stateOk.id}; const ticketTracking = await models.Ticket.state(ctx, params, options); @@ -111,17 +109,103 @@ describe('ticket state()', () => { try { const options = {transaction: tx}; + spyOn(models.Chat, 'sendCheckingPresence').and.callThrough(); const ticket = await models.Ticket.create(sampleTicket, options); - const ctx = {req: {accessToken: {userId: 18}}}; + ctx.req.accessToken.userId = salesPersonId; const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options); - const params = {ticketFk: ticket.id, stateFk: assignedState.id, userFk: 1}; - const res = await models.Ticket.state(ctx, params, options); + const paramsAssigned = {ticketFk: ticket.id, stateFk: assignedState.id, userFk: 1}; + const resAssigned = await models.Ticket.state(ctx, paramsAssigned, options); - expect(res.ticketFk).toBe(params.ticketFk); - expect(res.stateFk).toBe(params.stateFk); - expect(res.userFk).toBe(params.userFk); - expect(res.userFk).toBe(1); - expect(res.id).toBeDefined(); + expect(resAssigned.ticketFk).toBe(paramsAssigned.ticketFk); + expect(resAssigned.stateFk).toBe(paramsAssigned.stateFk); + expect(resAssigned.userFk).toBe(paramsAssigned.userFk); + expect(resAssigned.userFk).toBe(1); + expect(resAssigned.id).toBeDefined(); + expect(models.Chat.sendCheckingPresence).not.toHaveBeenCalled(); + + ctx.req.accessToken.userId = productionId; + const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options); + const paramsPacked = {ticketFk: ticket.id, stateFk: packedState.id, userFk: salesPersonId}; + const resPacked = await models.Ticket.state(ctx, paramsPacked, options); + + expect(resPacked.stateFk).toBe(paramsPacked.stateFk); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('Should equalize the quantities of quantity and originalQuantity' + + ' if they are different', async() => { + const tx = await models.TicketTracking.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const ticket = await models.Ticket.create(sampleTicket, options); + ctx.req.accessToken.userId = salesPersonId; + + const sampleSale = { + ticketFk: ticket.id, + itemFk: 1, + concept: 'Test', + quantity: 10, + originalQuantity: 6 + }; + await models.Sale.create(sampleSale, options); + const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options); + const paramsAssigned = {ticketFk: ticket.id, stateFk: assignedState.id, userFk: 1}; + const resAssigned = await models.Ticket.state(ctx, paramsAssigned, options); + + expect(resAssigned.ticketFk).toBe(paramsAssigned.ticketFk); + expect(resAssigned.stateFk).toBe(paramsAssigned.stateFk); + expect(resAssigned.userFk).toBe(paramsAssigned.userFk); + expect(resAssigned.userFk).toBe(1); + expect(resAssigned.id).toBeDefined(); + + ctx.req.accessToken.userId = productionId; + const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options); + const paramsPacked = {ticketFk: ticket.id, stateFk: packedState.id, userFk: salesPersonId}; + const resPacked = await models.Ticket.state(ctx, paramsPacked, options); + + const sale = await models.Sale.findOne({where: {ticketFk: ticket.id}}, options); + + expect(resPacked.stateFk).toBe(paramsPacked.stateFk); + expect(sale.quantity).toBe(sale.originalQuantity); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should not call sendCheckingPresence if sales.length is 0 because quantities are equal', async() => { + const tx = await models.TicketTracking.beginTransaction({}); + spyOn(models.Chat, 'sendCheckingPresence').and.callThrough(); + + try { + const options = {transaction: tx}; + const ticket = await models.Ticket.create(sampleTicket, options); + activeCtx.accessToken.userId = productionId; + + const sampleSale = { + ticketFk: ticket.id, + itemFk: 1, + concept: 'Test', + quantity: 10, + originalQuantity: 10 + }; + await models.Sale.create(sampleSale, options); + + const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options); + const params = {ticketFk: ticket.id, stateFk: packedState.id}; + + await models.Ticket.state(ctx, params, options); + + expect(models.Chat.sendCheckingPresence).not.toHaveBeenCalled(); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/back/methods/ticket/specs/transferClient.spec.js b/modules/ticket/back/methods/ticket/specs/transferClient.spec.js index 5f1c09776..d3ac3c6aa 100644 --- a/modules/ticket/back/methods/ticket/specs/transferClient.spec.js +++ b/modules/ticket/back/methods/ticket/specs/transferClient.spec.js @@ -4,18 +4,12 @@ describe('Ticket transferClient()', () => { const originalTicketId = 8; const refundTicketId = 24; const clientId = 1; - let ctx; + + const ctx = beforeAll.getCtx(); let options; let tx; - beforeEach(async() => { - ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'http://localhost'} - }, - args: {} - }; + beforeEach(async() => { options = {transaction: tx}; tx = await models.Ticket.beginTransaction({}); options.transaction = tx; @@ -28,21 +22,23 @@ describe('Ticket transferClient()', () => { it('should throw an error as the ticket is not editable', async() => { try { const ticketId = 4; - const clientId = 1; await models.Ticket.transferClient(ctx, ticketId, clientId, options); } catch (e) { - expect(e.message).toEqual(`This ticket is locked`); + expect(e.message).toEqual('This ticket is locked'); } }); - it('should be assigned a different clientFk in the original ticket', async() => { + it('should be assigned a different clientFk and nickname in the original ticket', async() => { await models.Ticket.transferClient(ctx, 2, clientId, options); const afterTransfer = await models.Ticket.findById(2, null, options); + const client = await models.Client.findById(clientId, {fields: ['defaultAddressFk']}, options); + const address = await models.Address.findById(client.defaultAddressFk, {fields: ['nickname']}, options); expect(afterTransfer.clientFk).toEqual(clientId); + expect(afterTransfer.nickname).toEqual(address.nickname); }); - it('should be assigned a different clientFk in the original and refund ticket and claim', async() => { + it('should be assigned a different clientFk and nickname in the original and refund ticket and claim', async() => { await models.Ticket.transferClient(ctx, originalTicketId, clientId, options); const [originalTicket, refundTicket] = await models.Ticket.find({ @@ -53,8 +49,14 @@ describe('Ticket transferClient()', () => { where: {ticketFk: originalTicketId} }, options); + const client = await models.Client.findById(clientId, {fields: ['defaultAddressFk']}, options); + const address = await models.Address.findById(client.defaultAddressFk, {fields: ['nickname']}, options); + expect(originalTicket.clientFk).toEqual(clientId); expect(refundTicket.clientFk).toEqual(clientId); expect(claim.clientFk).toEqual(clientId); + + expect(originalTicket.nickname).toEqual(address.nickname); + expect(refundTicket.nickname).toEqual(address.nickname); }); }); diff --git a/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js b/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js index 41de1fd6e..272387a30 100644 --- a/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js +++ b/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js @@ -1,20 +1,8 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('sale updateDiscount()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + const ctx = beforeAll.getCtx(); + beforeAll.mockLoopBackContext(); const originalSaleId = 8; it('should throw an error if no sales were selected', async() => { @@ -24,13 +12,6 @@ describe('sale updateDiscount()', () => { try { const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'localhost:5000'}, - __: () => {} - } - }; const ticketId = 11; const sales = []; const newDiscount = 10; @@ -53,13 +34,6 @@ describe('sale updateDiscount()', () => { try { const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'localhost:5000'}, - __: () => {} - } - }; const ticketId = 11; const sales = [1, 14]; const newDiscount = 10; @@ -82,13 +56,6 @@ describe('sale updateDiscount()', () => { try { const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'localhost:5000'}, - __: () => {} - } - }; const ticketId = 1; const sales = [1]; const newDiscount = 100; @@ -106,17 +73,11 @@ describe('sale updateDiscount()', () => { it('should update the discount if the salesPerson has mana and manaCode = "mana"', async() => { const tx = await models.Ticket.beginTransaction({}); + const ctx = beforeAll.getCtx(18); try { const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 18}, - headers: {origin: 'localhost:5000'}, - __: () => {} - } - }; const ticketId = 11; const sales = [originalSaleId]; const newDiscount = 100; @@ -151,17 +112,11 @@ describe('sale updateDiscount()', () => { it('should update the discount if the salesPerson has mana and manaCode = "manaClaim"', async() => { const tx = await models.Ticket.beginTransaction({}); + const ctx = beforeAll.getCtx(18); try { const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 18}, - headers: {origin: 'localhost:5000'}, - __: () => {} - } - }; const ticketId = 11; const sales = [originalSaleId]; const newDiscount = 100; @@ -200,13 +155,6 @@ describe('sale updateDiscount()', () => { try { const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'localhost:5000'}, - __: () => {} - } - }; const ticketId = 11; const sales = [originalSaleId]; const newDiscount = 100; diff --git a/modules/ticket/back/methods/ticket/summary.js b/modules/ticket/back/methods/ticket/summary.js index 1ce91e1b2..6bfa478ec 100644 --- a/modules/ticket/back/methods/ticket/summary.js +++ b/modules/ticket/back/methods/ticket/summary.js @@ -56,6 +56,7 @@ module.exports = Self => { const filter = { include: [ {relation: 'warehouse', scope: {fields: ['name']}}, + {relation: 'ticketCollections', scope: {fields: ['collectionFk']}}, {relation: 'agencyMode', scope: {fields: ['name']}}, {relation: 'zone', scope: {fields: ['name']}}, {relation: 'client', diff --git a/modules/ticket/back/methods/ticket/transferClient.js b/modules/ticket/back/methods/ticket/transferClient.js index d38c0e8a7..95bee008d 100644 --- a/modules/ticket/back/methods/ticket/transferClient.js +++ b/modules/ticket/back/methods/ticket/transferClient.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethodCtx('transferClient', { - description: 'Transfering ticket to another client', + description: 'Transferring ticket to another client', accessType: 'WRITE', accepts: [{ arg: 'id', @@ -40,10 +40,13 @@ module.exports = Self => { include: [{relation: 'refundTicket'}, {relation: 'originalTicket'}] }, myOptions); - const {defaultAddressFk: addressFk} = await models.Client.findById(clientFk, + const client = await models.Client.findById(clientFk, {fields: ['id', 'defaultAddressFk']}, myOptions); - const attributes = {clientFk, addressFk}; + const address = await models.Address.findById(client.defaultAddressFk, + {fields: ['id', 'nickname']}, myOptions); + + const attributes = {clientFk, addressFk: client.defaultAddressFk, nickname: address.nickname}; const tickets = []; const ticketIds = []; diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index 54306510c..5f5fdde67 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -83,12 +83,12 @@ module.exports = Self => { for (const sale of sales) { const originalSale = map.get(sale.id); - if (sale.quantity == originalSale.quantity) { + if (sale.quantity == originalSale?.quantity) { query = `UPDATE sale SET ticketFk = ? WHERE id = ?`; await Self.rawSql(query, [ticketId, sale.id], myOptions); - } else if (sale.quantity != originalSale.quantity) { + } else if (sale.quantity != originalSale?.quantity) { await transferPartialSale( ticketId, originalSale, sale, myOptions); } diff --git a/modules/ticket/back/models/component-type.json b/modules/ticket/back/models/component-type.json index 26daf5216..735227a35 100644 --- a/modules/ticket/back/models/component-type.json +++ b/modules/ticket/back/models/component-type.json @@ -12,7 +12,7 @@ "type": "number", "description": "Identifier" }, - "type": { + "name": { "type": "string" }, "isBase":{ diff --git a/modules/ticket/back/models/expedition-state.json b/modules/ticket/back/models/expedition-state.json index eda0f79fd..159a9275e 100644 --- a/modules/ticket/back/models/expedition-state.json +++ b/modules/ticket/back/models/expedition-state.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "expeditionState" + "table": "expeditionState" } }, "properties": { @@ -23,13 +23,16 @@ }, "userFk": { "type": "number" + }, + "isScanned": { + "type": "boolean" } }, "relations": { - "expeditionStateType": { - "type": "belongsTo", - "model": "ExpeditionStateType", - "foreignKey": "typeFk" - } + "expeditionStateType": { + "type": "belongsTo", + "model": "ExpeditionStateType", + "foreignKey": "typeFk" + } } -} +} \ No newline at end of file diff --git a/modules/ticket/back/models/sale.js b/modules/ticket/back/models/sale.js index 1b4d8e31c..3aa4cbf2a 100644 --- a/modules/ticket/back/models/sale.js +++ b/modules/ticket/back/models/sale.js @@ -65,7 +65,7 @@ module.exports = Self => { throw new UserError('You can only add negative amounts in refund tickets'); const item = await models.Item.findOne({ - fields: ['family', 'minQuantity'], + fields: ['family'], where: {id: itemId}, }, ctx.options); if (item.family == 'EMB') return; @@ -88,7 +88,30 @@ module.exports = Self => { if (await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*')) return; - if (newQuantity < item.minQuantity && newQuantity != available) + const itemMinimalQuantity = await models.ItemMinimumQuantity.find({ + fields: ['quantity', 'warehouseFk'], + where: { + itemFk: itemId, + started: {lte: ticket.shipped}, + or: [ + {ended: {gte: ticket.shipped}}, + {ended: null} + ], + // eslint-disable-next-line no-dupe-keys + or: [ + {warehouseFk: ticket.warehouseFk}, + {warehouseFk: null} + ] + }, + }, ctx.options); + + const minQuantity = itemMinimalQuantity.reduce((selected, item) => { + if (item.warehouseFk === ticket.warehouseFk) return item; + if (item.warehouseFk === null && !selected) return item; + return selected; + }, null); + + if (newQuantity < minQuantity?.quantity && newQuantity != available) throw new UserError('The amount cannot be less than the minimum'); if (ctx.isNewInstance || isReduction) return; @@ -114,4 +137,3 @@ module.exports = Self => { throw new UserError('The price of the item changed'); }); }; - diff --git a/modules/ticket/back/models/saleGroup.json b/modules/ticket/back/models/saleGroup.json index d5cf82cb5..aa78b4167 100644 --- a/modules/ticket/back/models/saleGroup.json +++ b/modules/ticket/back/models/saleGroup.json @@ -14,6 +14,9 @@ }, "parkingFk": { "type": "number" + }, + "ticketFk": { + "type": "number" } }, "relations": { diff --git a/modules/ticket/back/models/specs/sale.spec.js b/modules/ticket/back/models/specs/sale.spec.js index d078dc8e2..d4261443d 100644 --- a/modules/ticket/back/models/specs/sale.spec.js +++ b/modules/ticket/back/models/specs/sale.spec.js @@ -1,361 +1,339 @@ /* eslint max-len: ["error", { "code": 150 }]*/ - -const models = require('vn-loopback/server/server').models; +const {models} = require('vn-loopback/server/server'); const LoopBackContext = require('loopback-context'); describe('sale model ', () => { - const ctx = { - req: { - accessToken: {userId: 9}, - headers: {origin: 'localhost:5000'}, - __: () => {} - } - }; - function getActiveCtx(userId) { - return { - active: { - accessToken: {userId}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - } - }; + const developerId = 9; + const buyerId = 35; + const employeeId = 1; + const productionId = 49; + const salesPersonId = 18; + const reviewerId = 130; + + const barcode = '4444444444'; + const ticketCollectionProd = 34; + const ticketCollectionSalesPerson = 35; + const previaTicketSalesPerson = 36; + const previaTicketProd = 37; + const notEditableError = 'This ticket is not editable.'; + + const ctx = getCtx(developerId); + let tx; + let opts; + + function getCtx(userId, active = false) { + const accessToken = {userId}; + const headers = {origin: 'localhost:5000'}; + if (!active) return {req: {accessToken, headers, __: () => {}}}; + return {active: {accessToken, http: {req: {headers}}}}; } + beforeEach(async() => { + tx = await models.Sale.beginTransaction({}); + opts = {transaction: tx}; + }); + + afterEach(async() => await tx.rollback()); + describe('quantity field ', () => { it('should add quantity if the quantity is greater than it should be and is role advanced', async() => { const saleId = 17; - const buyerId = 35; - const ctx = { - req: { - accessToken: {userId: buyerId}, - headers: {origin: 'localhost:5000'}, - __: () => {} - } - }; - const tx = await models.Sale.beginTransaction({}); - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(buyerId)); - spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, options) => { + const ctx = getCtx(buyerId); + + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(buyerId, true)); + spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, opts) => { if (sqlStatement.includes('catalog_calcFromItem')) { sqlStatement = `CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY SELECT 100 as available;`; params = null; } - return models.Ticket.rawSql(sqlStatement, params, options); + return models.Ticket.rawSql(sqlStatement, params, opts); }); - try { - const options = {transaction: tx}; + const isRoleAdvanced = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*'); - const isRoleAdvanced = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*'); + expect(isRoleAdvanced).toEqual(true); - expect(isRoleAdvanced).toEqual(true); + const originalLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, opts); - const originalLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, options); + expect(originalLine.quantity).toEqual(30); - expect(originalLine.quantity).toEqual(30); + const newQuantity = originalLine.quantity + 1; + await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts); - const newQuantity = originalLine.quantity + 1; - await models.Sale.updateQuantity(ctx, saleId, newQuantity, options); + const modifiedLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, opts); - const modifiedLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, options); - - expect(modifiedLine.quantity).toEqual(newQuantity); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(modifiedLine.quantity).toEqual(newQuantity); }); it('should update the quantity of a given sale current line', async() => { - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(9)); + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(developerId, true)); - const tx = await models.Sale.beginTransaction({}); const saleId = 25; const newQuantity = 4; - try { - const options = {transaction: tx}; + const originalLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, opts); - const originalLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, options); + expect(originalLine.quantity).toEqual(20); - expect(originalLine.quantity).toEqual(20); + await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts); - await models.Sale.updateQuantity(ctx, saleId, newQuantity, options); + const modifiedLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, opts); - const modifiedLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, options); - - expect(modifiedLine.quantity).toEqual(newQuantity); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(modifiedLine.quantity).toEqual(newQuantity); }); it('should throw an error if the quantity is negative and it is not a refund ticket', async() => { - const ctx = { - req: { - accessToken: {userId: 1}, - headers: {origin: 'localhost:5000'}, - __: () => {} - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(1)); + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(employeeId, true)); const saleId = 17; const newQuantity = -10; - const tx = await models.Sale.beginTransaction({}); - - let error; try { - const options = {transaction: tx}; - - await models.Sale.updateQuantity(ctx, saleId, newQuantity, options); - - await tx.rollback(); + await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts); } catch (e) { - await tx.rollback(); - error = e; + expect(e).toEqual(new Error('You can only add negative amounts in refund tickets')); } - - expect(error).toEqual(new Error('You can only add negative amounts in refund tickets')); }); it('should update a negative quantity when is a ticket refund', async() => { - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(9)); + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(developerId, true)); - const tx = await models.Sale.beginTransaction({}); const saleId = 32; const newQuantity = -10; - try { - const options = {transaction: tx}; + await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts); - await models.Sale.updateQuantity(ctx, saleId, newQuantity, options); + const modifiedLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, opts); - const modifiedLine = await models.Sale.findOne({where: {id: saleId}, fields: ['quantity']}, options); - - expect(modifiedLine.quantity).toEqual(newQuantity); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(modifiedLine.quantity).toEqual(newQuantity); }); it('should throw an error if the quantity is less than the minimum quantity of the item', async() => { - const ctx = { - req: { - accessToken: {userId: 1}, - headers: {origin: 'localhost:5000'}, - __: () => {} - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(1)); + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(employeeId, true)); - const tx = await models.Sale.beginTransaction({}); - const itemId = 2; const saleId = 17; - const minQuantity = 30; - const newQuantity = minQuantity - 1; + const newQuantity = 1; - let error; try { - const options = {transaction: tx}; - - const item = await models.Item.findById(itemId, null, options); - await item.updateAttribute('minQuantity', minQuantity, options); - spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, options) => { + spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, opts) => { if (sqlStatement.includes('catalog_calcFromItem')) { sqlStatement = `CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY SELECT 100 as available;`; params = null; } - return models.Ticket.rawSql(sqlStatement, params, options); + return models.Ticket.rawSql(sqlStatement, params, opts); }); - await models.Sale.updateQuantity(ctx, saleId, newQuantity, options); - - await tx.rollback(); + await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts); } catch (e) { - await tx.rollback(); - error = e; + expect(e).toEqual(new Error('The amount cannot be less than the minimum')); } - - expect(error).toEqual(new Error('The amount cannot be less than the minimum')); }); it('should change quantity if has minimum quantity and new quantity is equal than item available', async() => { - const ctx = { - req: { - accessToken: {userId: 1}, - headers: {origin: 'localhost:5000'}, - __: () => {} - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(1)); + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(employeeId, true)); - const tx = await models.Sale.beginTransaction({}); - const itemId = 2; const saleId = 17; - const minQuantity = 30; - const newQuantity = minQuantity - 1; + const newQuantity = 8; - try { - const options = {transaction: tx}; - - const item = await models.Item.findById(itemId, null, options); - await item.updateAttribute('minQuantity', minQuantity, options); - - spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, options) => { - if (sqlStatement.includes('catalog_calcFromItem')) { - sqlStatement = `CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY + spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, opts) => { + if (sqlStatement.includes('catalog_calcFromItem')) { + sqlStatement = `CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY SELECT ${newQuantity} as available;`; - params = null; - } - return models.Ticket.rawSql(sqlStatement, params, options); - }); + params = null; + } + return models.Ticket.rawSql(sqlStatement, params, opts); + }); - await models.Sale.updateQuantity(ctx, saleId, newQuantity, options); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts); }); describe('newPrice', () => { it('should increase quantity if you have enough available and the new price is the same as the previous one', async() => { - const ctx = { - req: { - accessToken: {userId: 1}, - headers: {origin: 'localhost:5000'}, - __: () => {} - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(1)); + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(employeeId, true)); - const tx = await models.Sale.beginTransaction({}); - const itemId = 2; const saleId = 17; - const minQuantity = 30; const newQuantity = 31; - try { - const options = {transaction: tx}; - - const item = await models.Item.findById(itemId, null, options); - await item.updateAttribute('minQuantity', minQuantity, options); - spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, options) => { - if (sqlStatement.includes('catalog_calcFromItem')) { - sqlStatement = ` + spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, opts) => { + if (sqlStatement.includes('catalog_calcFromItem')) { + sqlStatement = ` CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY SELECT ${newQuantity} as available; CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY SELECT 1 as grouping, 7.07 as price;`; - params = null; - } - return models.Ticket.rawSql(sqlStatement, params, options); - }); + params = null; + } + return models.Ticket.rawSql(sqlStatement, params, opts); + }); - await models.Sale.updateQuantity(ctx, saleId, newQuantity, options); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts); }); it('should increase quantity when the new price is lower than the previous one', async() => { - const ctx = { - req: { - accessToken: {userId: 1}, - headers: {origin: 'localhost:5000'}, - __: () => {} - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(1)); + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(employeeId, true)); - const tx = await models.Sale.beginTransaction({}); - const itemId = 2; const saleId = 17; - const minQuantity = 30; const newQuantity = 31; - try { - const options = {transaction: tx}; - - const item = await models.Item.findById(itemId, null, options); - await item.updateAttribute('minQuantity', minQuantity, options); - spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, options) => { - if (sqlStatement.includes('catalog_calcFromItem')) { - sqlStatement = ` + spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, opts) => { + if (sqlStatement.includes('catalog_calcFromItem')) { + sqlStatement = ` CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY SELECT ${newQuantity} as available; CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY SELECT 1 as grouping, 1 as price;`; - params = null; - } - return models.Ticket.rawSql(sqlStatement, params, options); - }); + params = null; + } + return models.Ticket.rawSql(sqlStatement, params, opts); + }); - await models.Sale.updateQuantity(ctx, saleId, newQuantity, options); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts); }); it('should throw error when increase quantity and the new price is higher than the previous one', async() => { - const ctx = { - req: { - accessToken: {userId: 1}, - headers: {origin: 'localhost:5000'}, - __: () => {} - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getActiveCtx(1)); + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(employeeId, true)); - const tx = await models.Sale.beginTransaction({}); - const itemId = 2; const saleId = 17; - const minQuantity = 30; const newQuantity = 31; - let error; try { - const options = {transaction: tx}; - - const item = await models.Item.findById(itemId, null, options); - await item.updateAttribute('minQuantity', minQuantity, options); - spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, options) => { + spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, opts) => { if (sqlStatement.includes('catalog_calcFromItem')) { sqlStatement = ` CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY SELECT ${newQuantity} as available; CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY SELECT 1 as grouping, 100000 as price;`; params = null; } - return models.Ticket.rawSql(sqlStatement, params, options); + return models.Ticket.rawSql(sqlStatement, params, opts); }); - await models.Sale.updateQuantity(ctx, saleId, newQuantity, options); - - await tx.rollback(); + await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts); } catch (e) { - await tx.rollback(); - error = e; + expect(e).toEqual(new Error('The price of the item changed')); } + }); - expect(error).toEqual(new Error('The price of the item changed')); + it('should throw an error if the quantity is lower than the minimum quantity of the item and is in range', async() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(employeeId, true)); + + const saleId = 25; + const newQuantity = 5; + + try { + spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, opts) => { + if (sqlStatement.includes('catalog_calcFromItem')) { + sqlStatement = ` + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY SELECT ${newQuantity} as available; + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY SELECT 1 as grouping, 100000 as price;`; + params = null; + } + return models.Ticket.rawSql(sqlStatement, params, opts); + }); + + await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts); + } catch (e) { + expect(e).toEqual(new Error('The amount cannot be less than the minimum')); + } + }); + + it('should update the quantity if the quantity is lower than the minimum quantity of the item and is out of the range', async() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(employeeId, true)); + + const saleId = 17; + const newQuantity = 8; + + spyOn(models.Sale, 'rawSql').and.callFake((sqlStatement, params, opts) => { + if (sqlStatement.includes('catalog_calcFromItem')) { + sqlStatement = ` + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem ENGINE = MEMORY SELECT ${newQuantity} as available; + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY SELECT 1 as grouping, 100000 as price;`; + params = null; + } + return models.Ticket.rawSql(sqlStatement, params, opts); + }); + + await models.Sale.updateQuantity(ctx, saleId, newQuantity, opts); }); }); }); + + describe('add a sale from a collection or previa ticket', () => { + it('if is allocated to them and alert level higher than 0 as Production role', async() => { + const ctx = getCtx(productionId); + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(productionId, true)); + + const beforeSalesCollection = await models.Sale.count({ticketFk: ticketCollectionProd}, opts); + await models.Ticket.addSale(ctx, ticketCollectionProd, barcode, 20, opts); + const afterSalesCollection = await models.Sale.count({ticketFk: ticketCollectionProd}, opts); + + expect(afterSalesCollection).toEqual(beforeSalesCollection + 1); + + const beforeSalesPrevia = await models.Sale.count({ticketFk: previaTicketProd}, opts); + await models.Ticket.addSale(ctx, previaTicketProd, barcode, 20, opts); + const afterSalesPrevia = await models.Sale.count({ticketFk: previaTicketProd}, opts); + + expect(afterSalesPrevia).toEqual(beforeSalesPrevia + 1); + }); + + it('should throw an error if is not allocated to them and alert level higher than 0 as Production role', async() => { + const ctx = getCtx(productionId); + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(productionId, true)); + + try { + await models.Ticket.addSale(ctx, ticketCollectionSalesPerson, barcode, 20, opts); + } catch ({message}) { + expect(message).toEqual(notEditableError); + } + + try { + await models.Ticket.addSale(ctx, previaTicketSalesPerson, barcode, 20, opts); + } catch ({message}) { + expect(message).toEqual(notEditableError); + } + }); + + it('if is allocated to them and alert level higher than 0 as salesPerson role', async() => { + const ctx = getCtx(salesPersonId); + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(salesPersonId, true)); + + const beforeSalesCollection = await models.Sale.count({ticketFk: ticketCollectionSalesPerson}, opts); + await models.Ticket.addSale(ctx, ticketCollectionSalesPerson, barcode, 20, opts); + const afterSalesCollection = await models.Sale.count({ticketFk: ticketCollectionSalesPerson}, opts); + + expect(afterSalesCollection).toEqual(beforeSalesCollection + 1); + + const beforeSalesPrevia = await models.Sale.count({ticketFk: previaTicketSalesPerson}, opts); + await models.Ticket.addSale(ctx, previaTicketSalesPerson, barcode, 20, opts); + const afterSalesPrevia = await models.Sale.count({ticketFk: previaTicketSalesPerson}, opts); + + expect(afterSalesPrevia).toEqual(beforeSalesPrevia + 1); + }); + + it('should throw an error if is not allocated to them and alert level higher than 0 as salesPerson role', async() => { + const ctx = getCtx(salesPersonId); + + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(salesPersonId, true)); + + try { + await models.Ticket.addSale(ctx, ticketCollectionProd, barcode, 20, opts); + } catch ({message}) { + expect(message).toEqual(notEditableError); + } + }); + + it('if is a reviewer', async() => { + const ctx = getCtx(reviewerId); + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue(getCtx(reviewerId, true)); + + const beforeSalesCollection = await models.Sale.count({ticketFk: ticketCollectionSalesPerson}, opts); + await models.Ticket.addSale(ctx, ticketCollectionSalesPerson, barcode, 20, opts); + const afterSalesCollection = await models.Sale.count({ticketFk: ticketCollectionSalesPerson}, opts); + + expect(afterSalesCollection).toEqual(beforeSalesCollection + 1); + + const beforeSalesPrevia = await models.Sale.count({ticketFk: previaTicketSalesPerson}, opts); + await models.Ticket.addSale(ctx, previaTicketSalesPerson, barcode, 20, opts); + const afterSalesPrevia = await models.Sale.count({ticketFk: previaTicketSalesPerson}, opts); + + expect(afterSalesPrevia).toEqual(beforeSalesPrevia + 1); + }); + }); }); diff --git a/modules/ticket/back/models/specs/ticket-packaging.spec.js b/modules/ticket/back/models/specs/ticket-packaging.spec.js index 6d59456a3..5e0ca82db 100644 --- a/modules/ticket/back/models/specs/ticket-packaging.spec.js +++ b/modules/ticket/back/models/specs/ticket-packaging.spec.js @@ -1,20 +1,7 @@ const app = require('vn-loopback/server/server'); -const LoopBackContext = require('loopback-context'); describe('ticket model TicketTracking', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); let ticketTrackingId; afterAll(async() => { diff --git a/modules/ticket/back/models/ticket-log.json b/modules/ticket/back/models/ticket-log.json index d75589f11..7b3f8b466 100644 --- a/modules/ticket/back/models/ticket-log.json +++ b/modules/ticket/back/models/ticket-log.json @@ -40,6 +40,9 @@ }, "changedModelValue": { "type": "string" + }, + "summaryId": { + "type":"string" } } } diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index 0ae2ce3b4..7fe968b26 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -26,15 +26,13 @@ module.exports = function(Self) { require('../methods/ticket/isLocked')(Self); require('../methods/ticket/freightCost')(Self); require('../methods/ticket/getComponentsSum')(Self); - require('../methods/ticket/refund')(Self); + require('../methods/ticket/cloneAll')(Self); require('../methods/ticket/deliveryNotePdf')(Self); require('../methods/ticket/deliveryNoteEmail')(Self); require('../methods/ticket/deliveryNoteCsv')(Self); require('../methods/ticket/deliveryNoteCsvEmail')(Self); require('../methods/ticket/closeAll')(Self); require('../methods/ticket/closeByTicket')(Self); - require('../methods/ticket/closeByAgency')(Self); - require('../methods/ticket/closeByRoute')(Self); require('../methods/ticket/getTicketsFuture')(Self); require('../methods/ticket/merge')(Self); require('../methods/ticket/getTicketsAdvance')(Self); @@ -46,6 +44,5 @@ module.exports = function(Self) { require('../methods/ticket/invoiceTicketsAndPdf')(Self); require('../methods/ticket/docuwareDownload')(Self); require('../methods/ticket/myLastModified')(Self); - require('../methods/ticket/addSaleByCode')(Self); - require('../methods/ticket/clone')(Self); + require('../methods/ticket/setWeight')(Self); }; diff --git a/modules/ticket/back/models/ticket-request.js b/modules/ticket/back/models/ticket-request.js index 622cd7696..30d6a5454 100644 --- a/modules/ticket/back/models/ticket-request.js +++ b/modules/ticket/back/models/ticket-request.js @@ -19,7 +19,7 @@ module.exports = function(Self) { instance.requesterFk = worker.id; const httpCtx = {req: loopBackContext.active}; - const httpRequest = httpCtx.req.http .req; + const httpRequest = httpCtx.req.http.req; const $t = httpRequest.__; if (attenderFk) { diff --git a/modules/ticket/back/models/ticket.json b/modules/ticket/back/models/ticket.json index 248c0312f..3f073806e 100644 --- a/modules/ticket/back/models/ticket.json +++ b/modules/ticket/back/models/ticket.json @@ -69,6 +69,9 @@ }, "cmrFk": { "type": "number" + }, + "problem": { + "type": "string" } }, "relations": { @@ -77,6 +80,11 @@ "model": "Client", "foreignKey": "clientFk" }, + "user": { + "type": "belongsTo", + "model": "VnUser", + "foreignKey": "clientFk" + }, "warehouse": { "type": "belongsTo", "model": "Warehouse", @@ -147,6 +155,11 @@ "type": "belongsTo", "model": "Cmr", "foreignKey": "cmrFk" + }, + "ticketCollections": { + "type": "hasMany", + "model": "TicketCollection", + "foreignKey": "ticketFk" } } } diff --git a/modules/ticket/front/advance/index.html b/modules/ticket/front/advance/index.html index ca4d994d0..69db96bc1 100644 --- a/modules/ticket/front/advance/index.html +++ b/modules/ticket/front/advance/index.html @@ -39,14 +39,8 @@ - - Destination - {{model.userParams.dateToAdvance| date: 'dd/MM/yyyy'}} - - - Origin - {{model.userParams.dateFuture | date: 'dd/MM/yyyy'}} - + Destination + Origin @@ -56,14 +50,16 @@ check-field="checked"> - - + ID IPT + + Preparation + State @@ -125,6 +121,7 @@ {{::ticket.ipt | dashIfEmpty}} + {{::ticket.preparation | dashIfEmpty}} @@ -165,7 +162,6 @@ {{::(ticket.futureTotalWithVat ? ticket.futureTotalWithVat : 0) | currency: 'EUR': 2}} - diff --git a/modules/ticket/front/advance/index.js b/modules/ticket/front/advance/index.js index 1f47d8242..15ad303e3 100644 --- a/modules/ticket/front/advance/index.js +++ b/modules/ticket/front/advance/index.js @@ -62,8 +62,11 @@ export default class Controller extends Section { setDefaultFilter() { let today = Date.vnNew(); + today.setHours(0, 0, 0, 0); const tomorrow = new Date(today); tomorrow.setDate(tomorrow.getDate() + 1); + tomorrow.setHours(23, 59, 59, 999); + this.$http.get(`UserConfigs/getUserConfig`) .then(res => { this.filterParams = { @@ -86,15 +89,6 @@ export default class Controller extends Section { return checkedLines; } - dateRange(value) { - const minHour = new Date(value); - minHour.setHours(0, 0, 0, 0); - const maxHour = new Date(value); - maxHour.setHours(23, 59, 59, 59); - - return [minHour, maxHour]; - } - totalPriceColor(totalWithVat) { return this.isLessThan50(totalWithVat) ? 'warning' : ''; } diff --git a/modules/ticket/front/advance/index.spec.js b/modules/ticket/front/advance/index.spec.js index 883993c1c..5caca742c 100644 --- a/modules/ticket/front/advance/index.spec.js +++ b/modules/ticket/front/advance/index.spec.js @@ -36,24 +36,6 @@ describe('Component vnTicketAdvance', () => { }); }); - describe('dateRange()', () => { - it('should return two dates with the hours at the start and end of the given date', () => { - const now = Date.vnNew(); - - const today = now.getDate(); - - const dateRange = controller.dateRange(now); - const start = dateRange[0].toString(); - const end = dateRange[1].toString(); - - expect(start).toContain(today); - expect(start).toContain('00:00:00'); - - expect(end).toContain(today); - expect(end).toContain('23:59:59'); - }); - }); - describe('moveTicketsAdvance()', () => { it('should make an HTTP Post query', () => { jest.spyOn(controller.$.model, 'refresh'); diff --git a/modules/ticket/front/card/index.js b/modules/ticket/front/card/index.js index fa4ad4e39..34ab109c5 100644 --- a/modules/ticket/front/card/index.js +++ b/modules/ticket/front/card/index.js @@ -1,5 +1,6 @@ import ngModule from '../module'; import ModuleCard from 'salix/components/module-card'; +import UserError from 'core/lib/user-error'; class Controller extends ModuleCard { reload() { @@ -59,6 +60,10 @@ class Controller extends ModuleCard { ], }; + if (!this.$params.id) { + this.$state.go('ticket.index'); + throw new UserError(`You must select a ticket`); + } return this.$http.get(`Tickets/${this.$params.id}`, {filter}) .then(res => this.onData(res.data)); } diff --git a/modules/ticket/front/component/index.html b/modules/ticket/front/component/index.html index 39b54b461..2a3a80f3e 100644 --- a/modules/ticket/front/component/index.html +++ b/modules/ticket/front/component/index.html @@ -51,7 +51,7 @@ ng-repeat="saleComponent in sale.components track by saleComponent.componentFk" class="components"> - {{::saleComponent.component.componentType.type}} + {{::saleComponent.component.componentType.name}} {{::saleComponent.component.name}} diff --git a/modules/ticket/front/component/index.js b/modules/ticket/front/component/index.js index 3f262f457..aa755e808 100644 --- a/modules/ticket/front/component/index.js +++ b/modules/ticket/front/component/index.js @@ -20,7 +20,7 @@ class Controller extends Section { include: { relation: 'componentType', scope: { - fields: ['type', 'isBase'] + fields: ['name', 'isBase'] } } } diff --git a/modules/ticket/front/descriptor-menu/index.html b/modules/ticket/front/descriptor-menu/index.html index cb7eeb8ee..b861b0c0e 100644 --- a/modules/ticket/front/descriptor-menu/index.html +++ b/modules/ticket/front/descriptor-menu/index.html @@ -6,7 +6,7 @@ @@ -152,7 +152,7 @@ @@ -349,13 +349,6 @@ message="Recalculate components"> - - - - { const [refundTicket] = res.data; - this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { + this.vnApp.showSuccess(this.$t('The following refund ticket has been created', { ticketId: refundTicket.id })); this.$state.go('ticket.card.sale', {id: refundTicket.id}); + }) + .catch(error => { + this.vnApp.showError(this.$t('Error creating refund ticket', { + error: error.data?.error?.message || 'Unknown error' + })); }); } diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js index 94a991db8..cffbad62e 100644 --- a/modules/ticket/front/descriptor-menu/index.spec.js +++ b/modules/ticket/front/descriptor-menu/index.spec.js @@ -217,24 +217,6 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { }); }); - describe('refund()', () => { - it('should make a query and go to ticket.card.sale', () => { - controller.$state.go = jest.fn(); - - controller._id = ticket.id; - - const params = { - ticketsIds: [16] - }; - const response = {id: 99}; - $httpBackend.expectPOST('Tickets/refund', params).respond([response]); - controller.refund(); - $httpBackend.flush(); - - expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', response); - }); - }); - describe('sendChangesSms()', () => { it('should make a query and open the sms dialog', () => { controller.$.sms = {open: () => {}}; diff --git a/modules/ticket/front/descriptor/index.html b/modules/ticket/front/descriptor/index.html index 75bcd2801..32a30833b 100644 --- a/modules/ticket/front/descriptor/index.html +++ b/modules/ticket/front/descriptor/index.html @@ -58,7 +58,7 @@ + ng-if="$ctrl.ticket.problem.includes('hasRisk')">
@@ -9,13 +9,13 @@ @@ -59,7 +59,7 @@ @@ -69,7 +69,7 @@ diff --git a/modules/ticket/front/future/index.js b/modules/ticket/front/future/index.js index f18dfa17e..a7d579681 100644 --- a/modules/ticket/front/future/index.js +++ b/modules/ticket/front/future/index.js @@ -65,8 +65,8 @@ export default class Controller extends Section { this.$http.get(`UserConfigs/getUserConfig`) .then(res => { this.filterParams = { - originDated: today, - futureDated: today, + originScopeDays: today, + futureScopeDays: today, warehouseFk: res.data.warehouseFk }; this.$.model.applyFilter(null, this.filterParams); diff --git a/modules/ticket/front/future/locale/es.yml b/modules/ticket/front/future/locale/es.yml index 9fceea111..3645ad8ac 100644 --- a/modules/ticket/front/future/locale/es.yml +++ b/modules/ticket/front/future/locale/es.yml @@ -14,3 +14,4 @@ Success: Tickets movidos correctamente IPT: Encajado Origin Date: Fecha origen Destination Date: Fecha destino +Preparation: Preparación diff --git a/modules/ticket/front/locale/es.yml b/modules/ticket/front/locale/es.yml index 748ba210f..2f448c034 100644 --- a/modules/ticket/front/locale/es.yml +++ b/modules/ticket/front/locale/es.yml @@ -64,6 +64,7 @@ You are going to delete this ticket: Vas a eliminar este ticket Ticket deleted. You can undo this action within the first hour: Ticket eliminado. Puedes deshacer esta acción durante la primera hora Search ticket by id or alias: Buscar tickets por identificador o alias ticket: ticket +You must select a ticket: Debes seleccionar un ticket #sections List: Listado diff --git a/modules/ticket/front/sale-tracking/index.html b/modules/ticket/front/sale-tracking/index.html index f05cf15fb..3bf35ae39 100644 --- a/modules/ticket/front/sale-tracking/index.html +++ b/modules/ticket/front/sale-tracking/index.html @@ -6,16 +6,6 @@ order="concept ASC, quantity DESC" auto-load="true"> - - - - @@ -208,7 +198,7 @@ - + diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 1cd5560a4..4f8494ed0 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -214,7 +214,7 @@ class Controller extends Section { const params = {ticketId: this.ticket.id, sales: sales}; this.resetChanges(); this.$http.post(`Claims/createFromSales`, params) - .then(res => this.$state.go('claim.card.basicData', {id: res.data.id})); + .then(async res => window.location.href = await this.vnApp.getUrl(`claim/${res.data.id}/basic-data`)); } showTransferPopover(event) { @@ -476,7 +476,7 @@ class Controller extends Section { */ addSale(sale) { const data = { - itemId: sale.itemFk, + barcode: sale.itemFk, quantity: sale.quantity }; const query = `tickets/${this.ticket.id}/addSale`; @@ -558,6 +558,10 @@ class Controller extends Section { changedModelId: saleId }); } + + async goToLilium(section, id) { + window.location.href = await this.vnApp.getUrl(`claim/${id}/${section}`); + } } ngModule.vnComponent('vnTicketSale', { diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index fb1c925d4..931776619 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -295,20 +295,26 @@ describe('Ticket', () => { describe('onCreateClaimAccepted()', () => { it('should perform a query and call window open', () => { jest.spyOn(controller, 'resetChanges').mockReturnThis(); - jest.spyOn(controller.$state, 'go').mockReturnThis(); + jest.spyOn(controller.vnApp, 'getUrl').mockReturnThis(); + Object.defineProperty(window, 'location', { + value: { + href: () => {} + }, + }); + jest.spyOn(controller.window.location, 'href'); const newEmptySale = {quantity: 10}; controller.sales.push(newEmptySale); const firstSale = controller.sales[0]; + const claimId = 1; firstSale.checked = true; const expectedParams = {ticketId: 1, sales: [firstSale]}; - $httpBackend.expect('POST', `Claims/createFromSales`, expectedParams).respond(200, {id: 1}); + $httpBackend.expect('POST', `Claims/createFromSales`, expectedParams).respond(200, {id: claimId}); controller.onCreateClaimAccepted(); $httpBackend.flush(); expect(controller.resetChanges).toHaveBeenCalledWith(); - expect(controller.$state.go).toHaveBeenCalledWith('claim.card.basicData', {id: 1}); }); }); @@ -659,7 +665,7 @@ describe('Ticket', () => { jest.spyOn(controller, 'resetChanges').mockReturnThis(); const newSale = {itemFk: 4, quantity: 10}; - const expectedParams = {itemId: 4, quantity: 10}; + const expectedParams = {barcode: 4, quantity: 10}; const expectedResult = { id: 30, quantity: 10, diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html index 025078d36..7ee260f74 100644 --- a/modules/ticket/front/summary/index.html +++ b/modules/ticket/front/summary/index.html @@ -152,13 +152,13 @@ - + - + { model: model }, myOptions); - await Self.rawSql(` - INSERT INTO travelThermograph(thermographFk, warehouseFk, temperatureFk, created) - VALUES (?, ?, ?, ?) - `, [thermograph.id, warehouseId, temperatureFk, date], myOptions); + const travelThermograph = await models.TravelThermograph.create({ + thermographFk: thermograph.id, + warehouseFk: warehouseId, + temperatureFk: temperatureFk, + created: date + }, myOptions); if (tx) await tx.commit(); - return thermograph; + return travelThermograph; } catch (err) { if (tx) await tx.rollback(); throw err; diff --git a/modules/travel/back/methods/thermograph/specs/createThermograph.spec.js b/modules/travel/back/methods/thermograph/specs/createThermograph.spec.js index 90855bf81..f9b2a19f9 100644 --- a/modules/travel/back/methods/thermograph/specs/createThermograph.spec.js +++ b/modules/travel/back/methods/thermograph/specs/createThermograph.spec.js @@ -5,48 +5,43 @@ describe('Termograph createThermograph()', () => { const model = 'DISPOSABLE'; const temperatureFk = 'COOL'; const warehouseId = 1; - const ctx = {req: {accessToken: {userId: 9}}}; + const ctx = beforeAll.getCtx(); + let tx; + + beforeEach(async() => { + tx = await models.Thermograph.beginTransaction({}); + }); + + afterEach(async() => { + await tx.rollback(); + }); it(`should create a thermograph which is saved in both thermograph and travelThermograph`, async() => { - const tx = await models.Thermograph.beginTransaction({}); + const options = {transaction: tx}; - try { - const options = {transaction: tx}; + const createdThermograph = await models.Thermograph.createThermograph( + ctx, thermographId, model, temperatureFk, warehouseId, options); - const createdThermograph = await models.Thermograph.createThermograph(ctx, thermographId, model, temperatureFk, warehouseId, options); + expect(createdThermograph.thermographFk).toEqual(thermographId); - expect(createdThermograph.id).toEqual(thermographId); - expect(createdThermograph.model).toEqual(model); + const createdTravelThermograph = + await models.TravelThermograph.findOne({where: {thermographFk: thermographId}}, options); - const createdTravelThermograpth = await models.TravelThermograph.findOne({where: {thermographFk: thermographId}}, options); - - expect(createdTravelThermograpth.warehouseFk).toEqual(warehouseId); - expect(createdTravelThermograpth.temperatureFk).toEqual(temperatureFk); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(createdTravelThermograph.warehouseFk).toEqual(warehouseId); + expect(createdTravelThermograph.temperatureFk).toEqual(temperatureFk); }); - it(`should throw an error when trying to created repeated thermograph`, async() => { - const tx = await models.Thermograph.beginTransaction({}); - - let error; - + it(`should throw an error when trying to create a repeated thermograph`, async() => { try { const options = {transaction: tx}; - await models.Thermograph.createThermograph(ctx, thermographId, model, temperatureFk, warehouseId, options); - await models.Thermograph.createThermograph(ctx, thermographId, model, temperatureFk, warehouseId, options); - - await tx.rollback(); + await models.Thermograph.createThermograph( + ctx, thermographId, model, temperatureFk, warehouseId, options); + await models.Thermograph.createThermograph( + ctx, thermographId, model, temperatureFk, warehouseId, options); + fail('Expected an error to be thrown when trying to create a repeated thermograph'); } catch (e) { - await tx.rollback(); - error = e; + expect(e.message).toBe('This thermograph id already exists'); } - - expect(error.message).toBe('This thermograph id already exists'); }); }); diff --git a/modules/travel/back/methods/travel/cloneWithEntries.js b/modules/travel/back/methods/travel/cloneWithEntries.js index e5eb0b06c..12afad6e2 100644 --- a/modules/travel/back/methods/travel/cloneWithEntries.js +++ b/modules/travel/back/methods/travel/cloneWithEntries.js @@ -26,18 +26,17 @@ module.exports = Self => { Self.cloneWithEntries = async(ctx, id, options) => { const conn = Self.dataSource.connector; + let tx; const myOptions = {}; - let tx = options?.transaction; + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } try { - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - const travel = await Self.findById(id, { fields: [ 'id', @@ -89,6 +88,8 @@ module.exports = Self => { 'ref' ] }, myOptions); + + if (tx) await tx.commit(); return newTravel.id; } catch (e) { if (tx) await tx.rollback(); diff --git a/modules/travel/back/methods/travel/createThermograph.js b/modules/travel/back/methods/travel/createThermograph.js deleted file mode 100644 index aac3a22b9..000000000 --- a/modules/travel/back/methods/travel/createThermograph.js +++ /dev/null @@ -1,103 +0,0 @@ -const UserError = require('vn-loopback/util/user-error'); - -module.exports = Self => { - Self.remoteMethodCtx('createThermograph', { - description: 'Creates a new travel thermograph', - accessType: 'WRITE', - accepts: [{ - arg: 'id', - type: 'number', - description: 'The travel id', - http: {source: 'path'} - }, - { - arg: 'thermographId', - type: 'string', - description: 'The thermograph id', - required: true - }, - { - arg: 'state', - type: 'string', - required: true - }, - { - arg: 'warehouseId', - type: 'number', - description: 'The warehouse id', - required: true - }, - { - arg: 'companyId', - type: 'number', - description: 'The company id', - required: true - }, - { - arg: 'dmsTypeId', - type: 'number', - description: 'The dms type id', - required: true - }, - { - arg: 'reference', - type: 'string', - required: true - }, - { - arg: 'description', - type: 'string', - required: true - }], - returns: { - type: 'object', - root: true - }, - http: { - path: `/:id/createThermograph`, - verb: 'POST' - } - }); - - Self.createThermograph = async(ctx, id, thermographId, state, options) => { - const models = Self.app.models; - let tx; - const myOptions = {}; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - - try { - const travelThermograph = await models.TravelThermograph.findOne({ - where: { - thermographFk: thermographId, - travelFk: null - } - }, myOptions); - - if (!travelThermograph) - throw new UserError('No valid travel thermograph found'); - - const uploadedFiles = await models.Dms.uploadFile(ctx, myOptions); - const firstDms = uploadedFiles[0]; - - await travelThermograph.updateAttributes({ - dmsFk: firstDms.id, - travelFk: id, - result: state - }, myOptions); - - if (tx) await tx.commit(); - - return travelThermograph; - } catch (err) { - if (tx) await tx.rollback(); - throw err; - } - }; -}; diff --git a/modules/travel/back/methods/travel/extraCommunityFilter.js b/modules/travel/back/methods/travel/extraCommunityFilter.js index 488297318..dcb704ff5 100644 --- a/modules/travel/back/methods/travel/extraCommunityFilter.js +++ b/modules/travel/back/methods/travel/extraCommunityFilter.js @@ -138,7 +138,19 @@ module.exports = Self => { b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 ) as DECIMAL(10,0) - ) as volumeKg + ) as volumeKg, + GREATEST( + CAST(SUM(b.weight * b.stickers) AS INT), + CAST( + SUM(vc.aerealVolumetricDensity * + b.stickers * + IF(pkg.volume, + pkg.volume, + pkg.width * pkg.depth * pkg.height + ) / 1000000 + ) AS INT + ) + / t.kg * 100, 0) percentageKg FROM travel t LEFT JOIN supplier s ON s.id = t.cargoSupplierFk LEFT JOIN entry e ON e.travelFk = t.id diff --git a/modules/travel/back/methods/travel/filter.js b/modules/travel/back/methods/travel/filter.js index 3fa1d65f9..e24a7659c 100644 --- a/modules/travel/back/methods/travel/filter.js +++ b/modules/travel/back/methods/travel/filter.js @@ -71,7 +71,19 @@ module.exports = Self => { arg: 'continent', type: 'string', description: 'The continent code' - }, + }, { + arg: 'shipmentHour', + type: 'string', + description: 'The shipment hour' + }, { + arg: 'landingHour', + type: 'string', + description: 'The landing hour' + }, { + arg: 'daysOnward', + type: 'number', + description: 'The days onward' + } ], returns: { type: ['Object'], @@ -84,8 +96,11 @@ module.exports = Self => { }); Self.filter = async(ctx, filter) => { - let conn = Self.dataSource.connector; - let where = buildFilter(ctx.args, (param, value) => { + const conn = Self.dataSource.connector; + const today = Date.vnNew(); + const future = Date.vnNew(); + + const where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': return /^\d+$/.test(value) @@ -101,6 +116,12 @@ module.exports = Self => { return {'t.landed': {gte: value}}; case 'landedTo': return {'t.landed': {lte: value}}; + case 'daysOnward': + + today.setHours(0, 0, 0, 0); + future.setDate(today.getDate() + value); + future.setHours(23, 59, 59, 999); + return {'t.landed': {between: [today, future]}}; case 'id': case 'agencyModeFk': case 'warehouseOutFk': @@ -130,6 +151,8 @@ module.exports = Self => { t.isReceived, t.m3, t.kg, + t.shipmentHour, + t.landingHour, t.cargoSupplierFk, t.totalEntries, am.name agencyModeName, diff --git a/modules/travel/back/methods/travel/saveThermograph.js b/modules/travel/back/methods/travel/saveThermograph.js new file mode 100644 index 000000000..6f7e1c8bf --- /dev/null +++ b/modules/travel/back/methods/travel/saveThermograph.js @@ -0,0 +1,132 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('saveThermograph', { + description: 'Creates or updates a travel thermograph', + accessType: 'WRITE', + accepts: [{ + arg: 'id', + type: 'number', + description: 'The travel id', + http: {source: 'path'} + }, + { + arg: 'travelThermographFk', + type: 'number', + description: 'The travel thermograph id', + required: true + }, + { + arg: 'state', + type: 'string', + required: true + }, + { + arg: 'maxTemperature', + type: 'number', + description: 'The maximum temperature' + }, + { + arg: 'minTemperature', + type: 'number', + description: 'The minimum temperature' + }, + { + arg: 'temperatureFk', + type: 'string', + description: 'Range of temperature' + }, { + arg: 'warehouseId', + type: 'Number', + description: 'The warehouse id' + }, { + arg: 'companyId', + type: 'Number', + description: 'The company id' + }, { + arg: 'dmsTypeId', + type: 'Number', + description: 'The dms type id' + }, { + arg: 'reference', + type: 'String' + }, { + arg: 'description', + type: 'String' + }, { + arg: 'hasFileAttached', + type: 'Boolean', + description: 'True if has an attached file' + }], + returns: {type: 'object', root: true}, + http: {path: `/:id/saveThermograph`, verb: 'POST'} + }); + + Self.saveThermograph = async( + ctx, + id, + travelThermographFk, + state, + maxTemperature, + minTemperature, + temperatureFk, + warehouseId, + companyId, + dmsTypeId, + reference, + description, + hasFileAttached, + options + ) => { + const models = Self.app.models; + let tx; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + let dmsFk; + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const travelThermograph = await models.TravelThermograph.findById( + travelThermographFk, + {fields: ['id', 'dmsFk', 'warehouseFk']}, + myOptions + ); + + if (!travelThermograph) + throw new UserError('No valid travel thermograph found'); + + if (travelThermograph.dmsFk) { + await models.Dms.updateFile(ctx, travelThermograph.dmsFk, myOptions); + dmsFk = travelThermograph.dmsFk; + } else { + const uploadedFiles = await models.Dms.uploadFile(ctx, myOptions); + const firstDms = uploadedFiles[0]; + dmsFk = firstDms.id; + } + + await travelThermograph.updateAttributes({ + dmsFk, + travelFk: id, + result: state, + maxTemperature, + minTemperature, + temperatureFk, + warehouseFk: warehouseId, + }, myOptions); + + if (tx) await tx.commit(); + + return travelThermograph; + } catch (err) { + if (tx) await tx.rollback(); + throw err; + } + }; +}; diff --git a/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js b/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js index 950da7bb1..8b3638db9 100644 --- a/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js +++ b/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js @@ -7,19 +7,22 @@ describe('Travel cloneWithEntries()', () => { const ctx = {req: {accessToken: {userId: currentUserId}}}; let newTravelId; it(`should clone the travel and the containing entries`, async() => { - const tx = await models.Travel.beginTransaction({ - }); + const tx = await models.Travel.beginTransaction({}); const warehouseThree = 3; const agencyModeOne = 1; + let travelRemoved; + try { const options = {transaction: tx}; + newTravelId = await models.Travel.cloneWithEntries(ctx, travelId, options); const travelEntries = await models.Entry.find({ where: { travelFk: newTravelId } }, options); - const newTravel = await models.Travel.findById(travelId); + const newTravel = await models.Travel.findById(travelId, null, options); + travelRemoved = await models.Travel.findById(newTravelId); expect(newTravelId).not.toEqual(travelId); expect(newTravel.ref).toEqual('fifth travel'); @@ -27,14 +30,9 @@ describe('Travel cloneWithEntries()', () => { expect(newTravel.warehouseOutFk).toEqual(warehouseThree); expect(newTravel.agencyModeFk).toEqual(agencyModeOne); expect(travelEntries.length).toBeGreaterThan(0); - await models.Entry.destroyAll({ - travelFk: newTravelId - }, options); - await models.Travel.destroyById(newTravelId, options); - await tx.rollback(); - const travelRemoved = await models.Travel.findById(newTravelId, options); - expect(travelRemoved).toBeNull(); + + await tx.rollback(); } catch (e) { if (tx) await tx.rollback(); throw e; diff --git a/modules/travel/back/methods/travel/specs/createThermograph.spec.js b/modules/travel/back/methods/travel/specs/createThermograph.spec.js deleted file mode 100644 index e812eae70..000000000 --- a/modules/travel/back/methods/travel/specs/createThermograph.spec.js +++ /dev/null @@ -1,64 +0,0 @@ -const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); - -describe('Travel createThermograph()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); - const travelId = 3; - const currentUserId = 1102; - const thermographId = '138350-0'; - const ctx = {req: {accessToken: {userId: currentUserId}}, args: {dmsTypeId: 1}}; - - it(`should set the travelFk and dmsFk properties to the travel thermograph`, async() => { - const tx = await models.Travel.beginTransaction({}); - - try { - const options = {transaction: tx}; - - spyOn(models.Dms, 'uploadFile').and.returnValue([{id: 5}]); - - travelThermographBefore = await models.TravelThermograph.findOne({ - where: { - thermographFk: thermographId, - travelFk: null - } - }, options); - - await models.Travel.createThermograph(ctx, travelId, thermographId, options); - - const travelThermographAfter = await models.TravelThermograph.findOne({ - where: { - thermographFk: thermographId, - travelFk: travelId - } - }, options); - - expect(models.Dms.uploadFile).toHaveBeenCalledWith(ctx, jasmine.any(Object)); - - expect(travelThermographBefore).toBeDefined(); - expect(travelThermographBefore.thermographFk).toEqual(thermographId); - expect(travelThermographBefore.travelFk).toBeNull(); - expect(travelThermographAfter).toBeDefined(); - - expect(travelThermographAfter.thermographFk).toEqual(thermographId); - expect(travelThermographAfter.travelFk).toEqual(travelId); - expect(travelThermographAfter.dmsFk).toEqual(5); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); -}); diff --git a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js index 599851b55..7e90c7681 100644 --- a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js +++ b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js @@ -79,7 +79,7 @@ describe('Travel extraCommunityFilter()', () => { const result = await app.models.Travel.extraCommunityFilter(ctx, filter); - expect(result.length).toEqual(8); + expect(result.length).toEqual(9); }); it('should return the travel matching "cargoSupplierFk"', async() => { @@ -110,6 +110,6 @@ describe('Travel extraCommunityFilter()', () => { const result = await app.models.Travel.extraCommunityFilter(ctx, filter); - expect(result.length).toEqual(1); + expect(result.length).toEqual(2); }); }); diff --git a/modules/travel/back/methods/travel/specs/filter.spec.js b/modules/travel/back/methods/travel/specs/filter.spec.js index 1a6ee895c..a608a980e 100644 --- a/modules/travel/back/methods/travel/specs/filter.spec.js +++ b/modules/travel/back/methods/travel/specs/filter.spec.js @@ -50,7 +50,7 @@ describe('Travel filter()', () => { const result = await app.models.Travel.filter(ctx); - expect(result.length).toEqual(5); + expect(result.length).toEqual(6); }); it('should return the routes matching "shipped from" and "shipped to"', async() => { @@ -80,6 +80,6 @@ describe('Travel filter()', () => { const result = await app.models.Travel.filter(ctx); - expect(result.length).toEqual(5); + expect(result.length).toEqual(6); }); }); diff --git a/modules/travel/back/methods/travel/specs/saveThermograph.spec.js b/modules/travel/back/methods/travel/specs/saveThermograph.spec.js new file mode 100644 index 000000000..c2da4234e --- /dev/null +++ b/modules/travel/back/methods/travel/specs/saveThermograph.spec.js @@ -0,0 +1,69 @@ +const models = require('vn-loopback/server/server').models; + +describe('Thermograph saveThermograph()', () => { + const ctx = beforeAll.getCtx(); + const travelFk = 1; + const thermographId = '138350-0'; + const warehouseFk = 1; + const state = 'COMPLETED'; + const maxTemperature = 30; + const minTemperature = 10; + const temperatureFk = 'COOL'; + let tx; + let options; + + beforeEach(async() => { + options = {transaction: tx}; + tx = await models.Sale.beginTransaction({}); + options.transaction = tx; + }); + + afterEach(async() => { + await tx.rollback(); + }); + + it('should update an existing travel thermograph', async() => { + const dmsFk = 5; + spyOn(models.Dms, 'uploadFile').and.returnValue([{id: dmsFk}]); + + const travelThermograph = await models.TravelThermograph.create({ + travelFk, + thermographFk: thermographId, + temperatureFk, + warehouseFk, + }, options); + + const updatedThermograph = await models.Travel.saveThermograph( + ctx, + travelFk, + travelThermograph.id, + state, + maxTemperature, + minTemperature, + temperatureFk, + warehouseFk, + null, + null, + null, + null, + null, options + ); + + expect(updatedThermograph.result).toEqual(state); + expect(updatedThermograph.maxTemperature).toEqual(maxTemperature); + expect(updatedThermograph.minTemperature).toEqual(minTemperature); + expect(updatedThermograph.temperatureFk).toEqual(temperatureFk); + expect(updatedThermograph.dmsFk).toEqual(dmsFk); + }); + + it('should throw an error if no valid travel thermograph is found', async() => { + try { + await models.Travel.saveThermograph( + ctx, null, 'notExists', state, maxTemperature, minTemperature, temperatureFk, options + ); + fail('Expected an error to be thrown when no valid travel thermograph is found'); + } catch (e) { + expect(e.message).toBe('No valid travel thermograph found'); + } + }); +}); diff --git a/modules/travel/back/methods/travel/updateThermograph.js b/modules/travel/back/methods/travel/updateThermograph.js deleted file mode 100644 index d89725920..000000000 --- a/modules/travel/back/methods/travel/updateThermograph.js +++ /dev/null @@ -1,83 +0,0 @@ -const UserError = require('vn-loopback/util/user-error'); - -module.exports = Self => { - Self.remoteMethodCtx('updateThermograph', { - description: 'Updates a travel thermograph', - accessType: 'WRITE', - accepts: [{ - arg: 'id', - type: 'Number', - description: 'The travel id', - http: {source: 'path'} - }, { - arg: 'thermographId', - type: 'String', - description: 'The thermograph id', - required: true - }, { - arg: 'state', - type: 'String', - required: true - }, { - arg: 'warehouseId', - type: 'Number', - description: 'The warehouse id' - }, { - arg: 'companyId', - type: 'Number', - description: 'The company id' - }, { - arg: 'dmsTypeId', - type: 'Number', - description: 'The dms type id' - }, { - arg: 'reference', - type: 'String' - }, { - arg: 'description', - type: 'String' - }, { - arg: 'hasFileAttached', - type: 'Boolean', - description: 'True if has an attached file' - }], - returns: { - type: 'Object', - root: true - }, - http: { - path: `/:id/updateThermograph`, - verb: 'POST' - } - }); - - Self.updateThermograph = async(ctx, id, thermographId, state) => { - const models = Self.app.models; - const tx = await Self.beginTransaction({}); - - try { - const options = {transaction: tx}; - const travelThermograph = await models.TravelThermograph.findOne({ - where: { - thermographFk: thermographId, - travelFk: id - } - }, options); - - if (!travelThermograph) - throw new UserError('No valid travel thermograph found'); - - const dmsFk = travelThermograph.dmsFk; - await models.Dms.updateFile(ctx, dmsFk, options); - await travelThermograph.updateAttributes({ - result: state - }, options); - - await tx.commit(); - return travelThermograph; - } catch (e) { - await tx.rollback(); - throw e; - } - }; -}; diff --git a/modules/travel/back/model-config.json b/modules/travel/back/model-config.json index ed5c071b3..952ce0d20 100644 --- a/modules/travel/back/model-config.json +++ b/modules/travel/back/model-config.json @@ -11,6 +11,9 @@ "Thermograph": { "dataSource": "vn" }, + "TravelKgPercentage": { + "dataSource": "vn" + }, "TravelThermograph": { "dataSource": "vn" }, @@ -20,4 +23,4 @@ "Temperature": { "dataSource": "vn" } -} +} \ No newline at end of file diff --git a/modules/travel/back/models/travel-kg-percentage.json b/modules/travel/back/models/travel-kg-percentage.json new file mode 100644 index 000000000..e99a88999 --- /dev/null +++ b/modules/travel/back/models/travel-kg-percentage.json @@ -0,0 +1,21 @@ +{ + "name": "TravelKgPercentage", + "base": "VnModel", + "mixins": { + "Loggable": true + }, + "options": { + "mysql": { + "table": "travelKgPercentage" + } + }, + "properties": { + "value": { + "type": "number", + "id": true + }, + "className": { + "type": "string" + } + } +} \ No newline at end of file diff --git a/modules/travel/back/models/travel-thermograph.json b/modules/travel/back/models/travel-thermograph.json index cc8e60aaf..cb0a9b4f8 100644 --- a/modules/travel/back/models/travel-thermograph.json +++ b/modules/travel/back/models/travel-thermograph.json @@ -28,6 +28,14 @@ "warehouseFk": { "type": "number", "required": true + }, + "maxTemperature": { + "type": "number", + "description": "Maximum temperature" + }, + "minTemperature": { + "type": "number", + "description": "Minimum temperature" } }, "relations": { diff --git a/modules/travel/back/models/travel.js b/modules/travel/back/models/travel.js index 4bcf7b31d..369be7919 100644 --- a/modules/travel/back/models/travel.js +++ b/modules/travel/back/models/travel.js @@ -4,9 +4,8 @@ module.exports = Self => { require('../methods/travel/getTravel')(Self); require('../methods/travel/getEntries')(Self); require('../methods/travel/filter')(Self); - require('../methods/travel/createThermograph')(Self); require('../methods/travel/deleteThermograph')(Self); - require('../methods/travel/updateThermograph')(Self); + require('../methods/travel/saveThermograph')(Self); require('../methods/travel/extraCommunityFilter')(Self); require('../methods/travel/getAverageDays')(Self); require('../methods/travel/cloneWithEntries')(Self); diff --git a/modules/travel/back/models/travel.json b/modules/travel/back/models/travel.json index 701894a76..0ebf683e7 100644 --- a/modules/travel/back/models/travel.json +++ b/modules/travel/back/models/travel.json @@ -44,6 +44,12 @@ }, "agencyModeFk": { "type": "number" + }, + "shipmentHour": { + "type": "string" + }, + "landingHour": { + "type": "string" } }, "relations": { @@ -64,3 +70,4 @@ } } } + diff --git a/modules/travel/front/basic-data/index.html b/modules/travel/front/basic-data/index.html deleted file mode 100644 index 783208d9a..000000000 --- a/modules/travel/front/basic-data/index.html +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/travel/front/basic-data/index.js b/modules/travel/front/basic-data/index.js deleted file mode 100644 index 581fd71e5..000000000 --- a/modules/travel/front/basic-data/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - onSubmit() { - return this.$.watcher.submit().then(() => - this.card.reload() - ); - } -} - -ngModule.vnComponent('vnTravelBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - travel: '<' - }, - require: { - card: '^vnTravelCard' - } -}); diff --git a/modules/travel/front/basic-data/index.spec.js b/modules/travel/front/basic-data/index.spec.js deleted file mode 100644 index 11894d6e0..000000000 --- a/modules/travel/front/basic-data/index.spec.js +++ /dev/null @@ -1,28 +0,0 @@ -import './index.js'; - -describe('Travel Component vnTravelBasicData', () => { - let controller; - - beforeEach(angular.mock.module('travel', $translateProvider => { - $translateProvider.translations('en', {}); - })); - - beforeEach(inject($componentController => { - const $element = angular.element(''); - controller = $componentController('vnTravelBasicData', {$element}); - controller.card = {reload: () => {}}; - controller.$.watcher = {submit: () => {}}; - })); - - describe('onSubmit()', () => { - it('should call the card reload method after the watcher submits', done => { - jest.spyOn(controller.card, 'reload'); - jest.spyOn(controller.$.watcher, 'submit').mockReturnValue(Promise.resolve()); - - controller.onSubmit().then(() => { - expect(controller.card.reload).toHaveBeenCalledWith(); - done(); - }).catch(done.fail); - }); - }); -}); diff --git a/modules/travel/front/basic-data/locale/es.yml b/modules/travel/front/basic-data/locale/es.yml deleted file mode 100644 index d95675612..000000000 --- a/modules/travel/front/basic-data/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Undo changes: Deshacer cambios diff --git a/modules/travel/front/card/index.html b/modules/travel/front/card/index.html deleted file mode 100644 index 91964be21..000000000 --- a/modules/travel/front/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/travel/front/card/index.js b/modules/travel/front/card/index.js deleted file mode 100644 index d46244cb5..000000000 --- a/modules/travel/front/card/index.js +++ /dev/null @@ -1,31 +0,0 @@ -import ngModule from '../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - let filter = { - include: [ - { - relation: 'warehouseIn', - scope: { - fields: ['id', 'name'] - } - }, { - relation: 'warehouseOut', - scope: { - fields: ['id', 'name'] - } - } - ] - }; - - this.$http.get(`Travels/${this.$params.id}`, {filter}) - .then(response => this.travel = response.data); - } -} - -ngModule.vnComponent('vnTravelCard', { - template: require('./index.html'), - controller: Controller -}); - diff --git a/modules/travel/front/create/index.html b/modules/travel/front/create/index.html deleted file mode 100644 index 593887a22..000000000 --- a/modules/travel/front/create/index.html +++ /dev/null @@ -1,61 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/travel/front/create/index.js b/modules/travel/front/create/index.js deleted file mode 100644 index a85917ca8..000000000 --- a/modules/travel/front/create/index.js +++ /dev/null @@ -1,48 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - $onChanges() { - if (this.$params && this.$params.q) - this.travel = JSON.parse(this.$params.q); - } - - onShippedChange(value) { - let hasFilledProperties; - let hasAgencyMode; - if (this.travel) { - hasAgencyMode = Boolean(this.travel.agencyModeFk); - hasFilledProperties = this.travel.landed || this.travel.warehouseInFk || this.travel.warehouseOutFk; - } - if (!hasAgencyMode || hasFilledProperties) - return; - - const query = `travels/getAverageDays`; - const params = { - agencyModeFk: this.travel.agencyModeFk - }; - this.$http.get(query, {params}).then(res => { - if (!res.data) - return; - - const landed = new Date(value); - const futureDate = landed.getDate() + res.data.dayDuration; - landed.setDate(futureDate); - - this.travel.landed = landed; - this.travel.warehouseInFk = res.data.warehouseInFk; - this.travel.warehouseOutFk = res.data.warehouseOutFk; - }); - } - - onSubmit() { - return this.$.watcher.submit().then( - res => this.$state.go('travel.card.basicData', {id: res.data.id}) - ); - } -} - -ngModule.vnComponent('vnTravelCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/travel/front/create/index.spec.js b/modules/travel/front/create/index.spec.js deleted file mode 100644 index cdff8cfb9..000000000 --- a/modules/travel/front/create/index.spec.js +++ /dev/null @@ -1,88 +0,0 @@ -import './index'; -import watcher from 'core/mocks/watcher'; - -describe('Travel Component vnTravelCreate', () => { - let $scope; - let $state; - let controller; - let $httpBackend; - - beforeEach(ngModule('travel')); - - beforeEach(inject(($componentController, $rootScope, _$state_, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - $state = _$state_; - $scope.watcher = watcher; - const $element = angular.element(''); - controller = $componentController('vnTravelCreate', {$element, $scope}); - })); - - describe('onSubmit()', () => { - it(`should call submit() on the watcher then expect a callback`, () => { - jest.spyOn($state, 'go'); - - controller.onSubmit(); - - expect(controller.$state.go).toHaveBeenCalledWith('travel.card.basicData', {id: 1234}); - }); - }); - - describe('$onChanges()', () => { - it('should update the travel data when $params.q is defined', () => { - controller.$params = {q: '{"ref": 1,"agencyModeFk": 1}'}; - - const params = {q: '{"ref": 1, "agencyModeFk": 1}'}; - const json = JSON.parse(params.q); - - controller.$onChanges(); - - expect(controller.travel).toEqual(json); - }); - }); - - describe('onShippedChange()', () => { - it(`should do nothing if there's no agencyModeFk in the travel.`, () => { - controller.travel = {}; - controller.onShippedChange(); - - expect(controller.travel.landed).toBeUndefined(); - expect(controller.travel.warehouseInFk).toBeUndefined(); - expect(controller.travel.warehouseOutFk).toBeUndefined(); - }); - - it(`should do nothing if there's no response data.`, () => { - controller.travel = {agencyModeFk: 4}; - const tomorrow = Date.vnNew(); - - const query = `travels/getAverageDays?agencyModeFk=${controller.travel.agencyModeFk}`; - $httpBackend.expectGET(query).respond(undefined); - controller.onShippedChange(tomorrow); - $httpBackend.flush(); - - expect(controller.travel.warehouseInFk).toBeUndefined(); - expect(controller.travel.warehouseOutFk).toBeUndefined(); - expect(controller.travel.dayDuration).toBeUndefined(); - }); - - it(`should fill the fields when it's selected a date and agency.`, () => { - controller.travel = {agencyModeFk: 1}; - const tomorrow = Date.vnNew(); - tomorrow.setDate(tomorrow.getDate() + 9); - const expectedResponse = { - id: 8, - dayDuration: 9, - warehouseInFk: 5, - warehouseOutFk: 1 - }; - - const query = `travels/getAverageDays?agencyModeFk=${controller.travel.agencyModeFk}`; - $httpBackend.expectGET(query).respond(expectedResponse); - controller.onShippedChange(tomorrow); - $httpBackend.flush(); - - expect(controller.travel.warehouseInFk).toEqual(expectedResponse.warehouseInFk); - expect(controller.travel.warehouseOutFk).toEqual(expectedResponse.warehouseOutFk); - }); - }); -}); diff --git a/modules/travel/front/descriptor-menu/index.html b/modules/travel/front/descriptor-menu/index.html deleted file mode 100644 index 9b408994f..000000000 --- a/modules/travel/front/descriptor-menu/index.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - Clone travel - - - Clone travel and his entries - - - Delete travel - -
- Add entry - -
-
- - - - - - - - - - - - diff --git a/modules/travel/front/descriptor-menu/index.js b/modules/travel/front/descriptor-menu/index.js deleted file mode 100644 index 0630bb618..000000000 --- a/modules/travel/front/descriptor-menu/index.js +++ /dev/null @@ -1,90 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - } - - get travelId() { - return this._travelId; - } - - set travelId(value) { - this._travelId = value; - - if (value) this.loadData(); - } - - loadData() { - const filter = { - fields: [ - 'id', - 'ref', - 'shipped', - 'landed', - 'totalEntries', - 'agencyModeFk', - 'warehouseInFk', - 'warehouseOutFk', - 'cargoSupplierFk' - ], - include: [ - { - relation: 'warehouseIn', - scope: { - fields: ['name'] - } - }, { - relation: 'warehouseOut', - scope: { - fields: ['name'] - } - } - ] - }; - this.$http.get(`Travels/${this.travelId}`, {filter}) - .then(res => this.travel = res.data); - - this.$http.get(`Travels/${this.travelId}/getEntries`) - .then(res => this.entries = res.data); - } - - get isBuyer() { - return this.aclService.hasAny(['buyer']); - } - - onDeleteAccept() { - this.$http.delete(`Travels/${this.travelId}`) - .then(() => this.$state.go('travel.index')) - .then(() => this.vnApp.showSuccess(this.$t('Travel deleted'))); - } - - onCloneAccept() { - const params = JSON.stringify({ - ref: this.travel.ref, - agencyModeFk: this.travel.agencyModeFk, - shipped: this.travel.shipped, - landed: this.travel.landed, - warehouseInFk: this.travel.warehouseInFk, - warehouseOutFk: this.travel.warehouseOutFk - }); - this.$state.go('travel.create', {q: params}); - } - - onCloneWithEntriesAccept() { - this.$http.post(`Travels/${this.travelId}/cloneWithEntries`) - .then(res => this.$state.go('travel.card.basicData', {id: res.data})); - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnTravelDescriptorMenu', { - template: require('./index.html'), - controller: Controller, - bindings: { - travelId: '<', - } -}); diff --git a/modules/travel/front/descriptor-menu/index.spec.js b/modules/travel/front/descriptor-menu/index.spec.js deleted file mode 100644 index 40319e8e2..000000000 --- a/modules/travel/front/descriptor-menu/index.spec.js +++ /dev/null @@ -1,71 +0,0 @@ -import './index.js'; - -describe('Travel Component vnTravelDescriptorMenu', () => { - let controller; - let $httpBackend; - beforeEach(ngModule('travel')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - const $element = angular.element(''); - controller = $componentController('vnTravelDescriptorMenu', {$element}); - controller._travelId = 5; - })); - - describe('onCloneAccept()', () => { - it('should call state.go with the travel data', () => { - jest.spyOn(controller.$state, 'go').mockReturnValue('ok'); - - controller.travel = { - ref: 'the ref', - agencyModeFk: 'the agency', - shipped: 'the shipped date', - landed: 'the landing date', - warehouseInFk: 'the receiver warehouse', - warehouseOutFk: 'the sender warehouse' - }; - - controller.onCloneAccept(); - - const params = JSON.stringify({ - ref: controller.travel.ref, - agencyModeFk: controller.travel.agencyModeFk, - shipped: controller.travel.shipped, - landed: controller.travel.landed, - warehouseInFk: controller.travel.warehouseInFk, - warehouseOutFk: controller.travel.warehouseOutFk - }); - - expect(controller.$state.go).toHaveBeenCalledWith('travel.create', {'q': params}); - }); - }); - - describe('onDeleteAccept()', () => { - it('should perform a delete query', () => { - jest.spyOn(controller.$state, 'go').mockReturnValue('ok'); - controller.travelId = 1; - - $httpBackend.when('GET', `Travels/${controller.travelId}`).respond(200); - $httpBackend.when('GET', `Travels/${controller.travelId}/getEntries`).respond(200); - $httpBackend.expect('DELETE', `Travels/${controller.travelId}`).respond(200); - controller.onDeleteAccept(); - $httpBackend.flush(); - - expect(controller.$state.go).toHaveBeenCalledWith('travel.index'); - }); - }); - - describe('onCloneWithEntriesAccept()', () => { - it('should make an HTTP query and then call to the $state.go method with the returned id', () => { - jest.spyOn(controller.$state, 'go').mockReturnValue('ok'); - - $httpBackend.expect('POST', `Travels/${controller.travelId}/cloneWithEntries`).respond(200, 9); - controller.onCloneWithEntriesAccept(); - $httpBackend.flush(); - - expect(controller.$state.go).toHaveBeenCalledWith('travel.card.basicData', { - id: jasmine.any(Number) - }); - }); - }); -}); diff --git a/modules/travel/front/descriptor-menu/locale/es.yml b/modules/travel/front/descriptor-menu/locale/es.yml deleted file mode 100644 index e019d1769..000000000 --- a/modules/travel/front/descriptor-menu/locale/es.yml +++ /dev/null @@ -1,8 +0,0 @@ -Clone travel: Clonar envío -Add entry: Añadir entrada -Clone travel and his entries: Clonar travel y sus entradas -Do you want to clone this travel and all containing entries?: ¿Quieres clonar este travel y todas las entradas que contiene? -Delete travel: Eliminar envío -The travel will be deleted: El envío será eliminado -Do you want to delete this travel?: ¿Quieres eliminar este envío? -Travel deleted: Envío eliminado \ No newline at end of file diff --git a/modules/travel/front/descriptor-menu/style.scss b/modules/travel/front/descriptor-menu/style.scss deleted file mode 100644 index beab9335e..000000000 --- a/modules/travel/front/descriptor-menu/style.scss +++ /dev/null @@ -1,24 +0,0 @@ -@import "./effects"; -@import "variables"; - -vn-travel-descriptor-menu { - & > vn-icon-button[icon="more_vert"] { - display: flex; - min-width: 45px; - height: 45px; - box-sizing: border-box; - align-items: center; - justify-content: center; - } - & > vn-icon-button[icon="more_vert"] { - @extend %clickable; - color: inherit; - - & > vn-icon { - padding: 10px; - } - vn-icon { - font-size: 1.75rem; - } - } -} \ No newline at end of file diff --git a/modules/travel/front/descriptor-popover/index.html b/modules/travel/front/descriptor-popover/index.html deleted file mode 100644 index 376423bbc..000000000 --- a/modules/travel/front/descriptor-popover/index.html +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/modules/travel/front/descriptor-popover/index.js b/modules/travel/front/descriptor-popover/index.js deleted file mode 100644 index 12c5908ca..000000000 --- a/modules/travel/front/descriptor-popover/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import ngModule from '../module'; -import DescriptorPopover from 'salix/components/descriptor-popover'; - -class Controller extends DescriptorPopover {} - -ngModule.vnComponent('vnTravelDescriptorPopover', { - slotTemplate: require('./index.html'), - controller: Controller -}); diff --git a/modules/travel/front/descriptor/index.html b/modules/travel/front/descriptor/index.html deleted file mode 100644 index bbf5721fd..000000000 --- a/modules/travel/front/descriptor/index.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - -
- - - - - - - - - - -
- -
-
- - - \ No newline at end of file diff --git a/modules/travel/front/descriptor/index.js b/modules/travel/front/descriptor/index.js deleted file mode 100644 index b1f2f53be..000000000 --- a/modules/travel/front/descriptor/index.js +++ /dev/null @@ -1,63 +0,0 @@ -import ngModule from '../module'; -import Descriptor from 'salix/components/descriptor'; - -class Controller extends Descriptor { - get travel() { - return this.entity; - } - - set travel(value) { - this.entity = value; - } - - get travelFilter() { - let travelFilter; - const travel = this.travel; - - if (travel && travel.agencyModeFk) { - travelFilter = this.travel && JSON.stringify({ - agencyModeFk: this.travel.agencyModeFk - }); - } - return travelFilter; - } - - loadData() { - const filter = { - fields: [ - 'id', - 'ref', - 'shipped', - 'landed', - 'totalEntries', - 'warehouseInFk', - 'warehouseOutFk', - 'cargoSupplierFk' - ], - include: [ - { - relation: 'warehouseIn', - scope: { - fields: ['name'] - } - }, { - relation: 'warehouseOut', - scope: { - fields: ['name'] - } - } - ] - }; - - return this.getData(`Travels/${this.id}`, {filter}) - .then(res => this.entity = res.data); - } -} - -ngModule.vnComponent('vnTravelDescriptor', { - template: require('./index.html'), - controller: Controller, - bindings: { - travel: '<' - } -}); diff --git a/modules/travel/front/descriptor/index.spec.js b/modules/travel/front/descriptor/index.spec.js deleted file mode 100644 index 0a88c8607..000000000 --- a/modules/travel/front/descriptor/index.spec.js +++ /dev/null @@ -1,26 +0,0 @@ -import './index.js'; - -describe('vnTravelDescriptor', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('travel')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnTravelDescriptor', {$element: null}); - })); - - describe('loadData()', () => { - it(`should perform a get query to store the worker data into the controller`, () => { - const id = 1; - const response = 'foo'; - - $httpBackend.expectRoute('GET', `Travels/${id}`).respond(response); - controller.id = id; - $httpBackend.flush(); - - expect(controller.travel).toEqual(response); - }); - }); -}); diff --git a/modules/travel/front/descriptor/locale/es.yml b/modules/travel/front/descriptor/locale/es.yml deleted file mode 100644 index 3e6d62735..000000000 --- a/modules/travel/front/descriptor/locale/es.yml +++ /dev/null @@ -1,6 +0,0 @@ -Reference: Referencia -Wh. In: Alm. entrada -Wh. Out: Alm. salida -Shipped: F. envío -Landed: F. entrega -Total entries: Entradas totales \ No newline at end of file diff --git a/modules/travel/front/extra-community-search-panel/index.html b/modules/travel/front/extra-community-search-panel/index.html deleted file mode 100644 index c0d726718..000000000 --- a/modules/travel/front/extra-community-search-panel/index.html +++ /dev/null @@ -1,92 +0,0 @@ -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/modules/travel/front/extra-community-search-panel/index.js b/modules/travel/front/extra-community-search-panel/index.js deleted file mode 100644 index 1add11dce..000000000 --- a/modules/travel/front/extra-community-search-panel/index.js +++ /dev/null @@ -1,31 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -class Controller extends SearchPanel { - constructor($, $element) { - super($, $element); - - this.filter = this.$.filter; - } - - get shippedFrom() { - return this.filter.shippedFrom; - } - - set shippedFrom(value) { - this.filter.shippedFrom = value; - } - - get landedTo() { - return this.filter.landedTo; - } - - set landedTo(value) { - this.filter.landedTo = value; - } -} - -ngModule.vnComponent('vnExtraCommunitySearchPanel', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/travel/front/extra-community/index.html b/modules/travel/front/extra-community/index.html deleted file mode 100644 index 8132bddb1..000000000 --- a/modules/travel/front/extra-community/index.html +++ /dev/null @@ -1,189 +0,0 @@ - - - - - - - - - -
- - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Id - - Supplier - - Agency - - Amount - - Reference - - Packages - - Bl. KG - - Phy. KG - - Vol. KG - - Wh. Out - - W. Shipped - - Wh. In - - W. Landed -
- - {{::travel.id}} - - - - {{::travel.cargoSupplierNickname}} - - {{::travel.agencyModeName}} - - {{travel.ref}} - - - - - - {{::travel.stickers}} - - {{travel.kg}} - - - - - - {{::travel.loadedKg}}{{::travel.volumeKg}}{{::travel.warehouseOutName}}{{::travel.shipped | date: 'dd/MM/yyyy'}}{{::travel.warehouseInName}}{{::travel.landed | date: 'dd/MM/yyyy'}}
- - {{::entry.id}} - - - - {{::entry.supplierName}} - - {{::entry.invoiceAmount | currency: 'EUR': 2}}{{::entry.reference}}{{::entry.stickers}}{{::entry.loadedkg}}{{::entry.volumeKg}}
-
-
-
- - - - - - diff --git a/modules/travel/front/extra-community/index.js b/modules/travel/front/extra-community/index.js deleted file mode 100644 index 6e9c39f43..000000000 --- a/modules/travel/front/extra-community/index.js +++ /dev/null @@ -1,162 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $, vnReport) { - super($element, $); - - this.vnReport = vnReport; - - const draggable = this.element.querySelector('.travel-list'); - draggable.addEventListener('dragstart', - event => this.dragStart(event)); - draggable.addEventListener('dragend', - event => this.dragEnd(event)); - - draggable.addEventListener('dragover', - event => this.dragOver(event)); - draggable.addEventListener('dragenter', - event => this.dragEnter(event)); - draggable.addEventListener('dragleave', - event => this.dragLeave(event)); - - this.draggableElement = 'tr[draggable]'; - this.droppableElement = 'tbody[vn-droppable]'; - - const twoDays = 2; - const shippedFrom = Date.vnNew(); - shippedFrom.setDate(shippedFrom.getDate() - twoDays); - shippedFrom.setHours(0, 0, 0, 0); - - const sevenDays = 7; - const landedTo = Date.vnNew(); - landedTo.setDate(landedTo.getDate() + sevenDays); - landedTo.setHours(23, 59, 59, 59); - - this.defaultFilter = { - shippedFrom: shippedFrom, - landedTo: landedTo, - continent: 'AM' - }; - - this.smartTableOptions = {}; - } - - onDragInterval() { - if (this.dragClientY > 0 && this.dragClientY < 75) - this.$window.scrollTo(0, this.$window.scrollY - 10); - - const maxHeight = window.screen.availHeight - (window.outerHeight - window.innerHeight); - if (this.dragClientY > maxHeight - 75 && this.dragClientY < maxHeight) - this.$window.scrollTo(0, this.$window.scrollY + 10); - } - - findDraggable($event) { - const target = $event.target; - const draggable = target.closest(this.draggableElement); - - return draggable; - } - - findDroppable($event) { - const target = $event.target; - const droppable = target.closest(this.droppableElement); - - return droppable; - } - - dragStart($event) { - const draggable = this.findDraggable($event); - draggable.classList.add('dragging'); - - const id = parseInt(draggable.id); - this.entryId = id; - this.entry = draggable; - this.interval = setInterval(() => this.onDragInterval(), 50); - } - - dragEnd($event) { - const draggable = this.findDraggable($event); - draggable.classList.remove('dragging'); - this.entryId = null; - this.entry = null; - - clearInterval(this.interval); - } - - onDrop($event) { - const model = this.$.model; - const droppable = this.findDroppable($event); - const travelId = parseInt(droppable.id); - - const currentDroppable = this.entry.closest(this.droppableElement); - - if (currentDroppable == droppable) return; - - if (this.entryId && travelId) { - const path = `Entries/${this.entryId}`; - this.$http.patch(path, {travelFk: travelId}) - .then(() => model.refresh()) - .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); - } - } - - undrop() { - if (!this.dropping) return; - this.dropping.classList.remove('dropping'); - this.dropping = null; - } - - dragOver($event) { - this.dragClientY = $event.clientY; - $event.preventDefault(); - } - - dragEnter($event) { - let element = this.findDroppable($event); - if (element) this.dropCount++; - - if (element != this.dropping) { - this.undrop(); - if (element) element.classList.add('dropping'); - this.dropping = element; - } - } - - dragLeave($event) { - let element = this.findDroppable($event); - - if (element) { - this.dropCount--; - if (this.dropCount == 0) this.undrop(); - } - } - - save(id, data) { - const endpoint = `Travels/${id}`; - this.$http.patch(endpoint, data) - .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); - } - - get reportParams() { - const userParams = this.$.model.userParams; - const currentFilter = this.$.model.currentFilter; - - return Object.assign({ - authorization: this.vnToken.tokenMultimedia, - filter: currentFilter - }, userParams); - } - - showReport() { - this.vnReport.show(`Travels/extra-community-pdf`, this.reportParams); - } -} - -Controller.$inject = ['$element', '$scope', 'vnReport']; - -ngModule.vnComponent('vnTravelExtraCommunity', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/travel/front/extra-community/index.spec.js b/modules/travel/front/extra-community/index.spec.js deleted file mode 100644 index 18ddee665..000000000 --- a/modules/travel/front/extra-community/index.spec.js +++ /dev/null @@ -1,128 +0,0 @@ -import './index.js'; - -describe('Travel Component vnTravelExtraCommunity', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('travel')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - const $element = angular.element('
'); - controller = $componentController('vnTravelExtraCommunity', {$element}); - controller.$.model = {}; - controller.$.model.refresh = jest.fn(); - })); - - describe('findDraggable()', () => { - it('should find the draggable element', () => { - const draggable = document.createElement('tr'); - draggable.setAttribute('draggable', true); - - const $event = new Event('dragstart'); - const target = document.createElement('div'); - draggable.appendChild(target); - target.dispatchEvent($event); - - const result = controller.findDraggable($event); - - expect(result).toEqual(draggable); - }); - }); - - describe('findDroppable()', () => { - it('should find the droppable element', () => { - const droppable = document.createElement('tbody'); - droppable.setAttribute('vn-droppable', true); - - const $event = new Event('drop'); - const target = document.createElement('div'); - droppable.appendChild(target); - target.dispatchEvent($event); - - const result = controller.findDroppable($event); - - expect(result).toEqual(droppable); - }); - }); - - describe('dragStart()', () => { - it(`should add the class "dragging" to the draggable element - and then set the entryId controller property`, () => { - const draggable = document.createElement('tr'); - draggable.setAttribute('draggable', true); - draggable.setAttribute('id', 3); - - jest.spyOn(controller, 'findDraggable').mockReturnValue(draggable); - - const $event = new Event('dragStart'); - controller.dragStart($event); - - const firstClass = draggable.classList[0]; - - expect(firstClass).toEqual('dragging'); - expect(controller.entryId).toEqual(3); - expect(controller.entry).toEqual(draggable); - }); - }); - - describe('dragEnd()', () => { - it(`should remove the class "dragging" from the draggable element - and then set the entryId controller property to null`, () => { - const draggable = document.createElement('tr'); - draggable.setAttribute('draggable', true); - draggable.setAttribute('id', 3); - draggable.classList.add('dragging'); - - jest.spyOn(controller, 'findDraggable').mockReturnValue(draggable); - - const $event = new Event('dragStart'); - controller.dragEnd($event); - - const classList = draggable.classList; - - expect(classList.length).toEqual(0); - expect(controller.entryId).toBeNull(); - expect(controller.entry).toBeNull(); - }); - }); - - describe('onDrop()', () => { - it('should make an HTTP patch query', () => { - const droppable = document.createElement('tbody'); - droppable.setAttribute('vn-droppable', true); - droppable.setAttribute('id', 1); - - jest.spyOn(controller, 'findDroppable').mockReturnValue(droppable); - - const oldDroppable = document.createElement('tbody'); - oldDroppable.setAttribute('vn-droppable', true); - const entry = document.createElement('div'); - oldDroppable.appendChild(entry); - - controller.entryId = 3; - controller.entry = entry; - - const $event = new Event('drop'); - const expectedData = {travelFk: 1}; - $httpBackend.expect('PATCH', `Entries/3`, expectedData).respond(200); - controller.onDrop($event); - $httpBackend.flush(); - }); - }); - - describe('save()', () => { - it('should make an HTTP query', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - - const travelId = 1; - const data = {ref: 'New reference'}; - const expectedData = {ref: 'New reference'}; - $httpBackend.expect('PATCH', `Travels/${travelId}`, expectedData).respond(200); - controller.save(travelId, data); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); - }); - }); -}); diff --git a/modules/travel/front/extra-community/locale/es.yml b/modules/travel/front/extra-community/locale/es.yml deleted file mode 100644 index ed6179c91..000000000 --- a/modules/travel/front/extra-community/locale/es.yml +++ /dev/null @@ -1,11 +0,0 @@ -Family: Familia -Extra community: Extra comunitarios -Freighter: Transitario -Bl. KG: KG Bloq. -Phy. KG: KG físico -Vol. KG: KG Vol. -Search by travel id or reference: Buscar por id de travel o referencia -Search by extra community travel: Buscar por envío extra comunitario -Continent Out: Cont. salida -W. Shipped: F. envío -W. Landed: F. llegada diff --git a/modules/travel/front/extra-community/style.scss b/modules/travel/front/extra-community/style.scss deleted file mode 100644 index fb64822f9..000000000 --- a/modules/travel/front/extra-community/style.scss +++ /dev/null @@ -1,67 +0,0 @@ -@import "variables"; - -vn-travel-extra-community { - .header { - margin-bottom: 16px; - line-height: 1; - padding: 7px; - padding-bottom: 7px; - padding-bottom: 4px; - font-weight: lighter; - background-color: $color-bg; - color: white; - border-bottom: 1px solid #f7931e; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - cursor: pointer; - .multi-line{ - padding-top: 15px; - padding-bottom: 15px; - } - } - - table[vn-droppable] { - border-radius: 0; - } - - tr[draggable] { - transition: all .5s; - cursor: move; - overflow: auto; - outline: 0; - height: 65px; - pointer-events: fill; - user-select: all; - } - - tr[draggable] *::selection { - background-color: transparent; - } - - tr[draggable]:hover { - background-color: $color-hover-cd; - } - - tr[draggable].dragging { - background-color: $color-primary-light; - color: $color-font-light; - font-weight: bold; - } - - - .multi-line{ - max-width: 200px; - word-wrap: normal; - white-space: normal; - } - - vn-td-editable text { - background-color: transparent; - padding: 0; - border: 0; - border-bottom: 1px dashed $color-active; - border-radius: 0; - color: $color-active - } -} diff --git a/modules/travel/front/index.js b/modules/travel/front/index.js index e4375c59d..a7209a0bd 100644 --- a/modules/travel/front/index.js +++ b/modules/travel/front/index.js @@ -1,18 +1,3 @@ export * from './module'; import './main'; -import './index/'; -import './search-panel'; -import './descriptor'; -import './card'; -import './summary'; -import './basic-data'; -import './log'; -import './create'; -import './thermograph/index/'; -import './thermograph/create/'; -import './thermograph/edit/'; -import './descriptor-popover'; -import './descriptor-menu'; -import './extra-community'; -import './extra-community-search-panel'; diff --git a/modules/travel/front/index/index.html b/modules/travel/front/index/index.html deleted file mode 100644 index a768e4a29..000000000 --- a/modules/travel/front/index/index.html +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - - - - - - - Reference - Agency - Warehouse Out - Shipped - - Warehouse In - Landed - - Total entries - - - - - - {{::travel.ref}} - {{::travel.agencyModeName}} - {{::travel.warehouseOutName}} - - - {{::travel.shipped | date:'dd/MM/yyyy'}} - - - - - - - {{::travel.warehouseInName}} - - - {{::travel.landed | date:'dd/MM/yyyy'}} - - - - - - - {{::travel.totalEntries}} - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/travel/front/index/index.js b/modules/travel/front/index/index.js deleted file mode 100644 index a570146fe..000000000 --- a/modules/travel/front/index/index.js +++ /dev/null @@ -1,39 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -export default class Controller extends Section { - preview(travel) { - this.travelSelected = travel; - this.$.summary.show(); - } - - onCloneAccept(travel) { - const params = JSON.stringify({ - ref: travel.ref, - agencyModeFk: travel.agencyModeFk, - shipped: travel.shipped, - landed: travel.landed, - warehouseInFk: travel.warehouseInFk, - warehouseOutFk: travel.warehouseOutFk - }); - this.$state.go('travel.create', {q: params}); - } - - compareDate(date) { - let today = Date.vnNew(); - today.setHours(0, 0, 0, 0); - - date = new Date(date); - date.setHours(0, 0, 0, 0); - - const timeDifference = today - date; - if (timeDifference == 0) return 'warning'; - if (timeDifference < 0) return 'success'; - } -} - -ngModule.vnComponent('vnTravelIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/travel/front/index/index.spec.js b/modules/travel/front/index/index.spec.js deleted file mode 100644 index 9083c4519..000000000 --- a/modules/travel/front/index/index.spec.js +++ /dev/null @@ -1,78 +0,0 @@ -import './index.js'; - -describe('Travel Component vnTravelIndex', () => { - let controller; - let travel = { - id: 1, - warehouseInFk: 1, - totalEntries: 3, - isDelivered: false - }; - - beforeEach(ngModule('travel')); - - beforeEach(inject($componentController => { - const $element = angular.element(''); - controller = $componentController('vnTravelIndex', {$element}); - controller.$.summary = {show: jasmine.createSpy('show')}; - })); - - describe('preview()', () => { - it('should show the dialog summary', () => { - let event = new MouseEvent('click', { - bubbles: true, - cancelable: true - }); - controller.preview(event, travel); - - expect(controller.$.summary.show).toHaveBeenCalledWith(); - }); - }); - - describe('onCloneAccept()', () => { - it('should call go() then update travelSelected in the controller', () => { - jest.spyOn(controller.$state, 'go'); - - const travel = { - ref: 1, - agencyModeFk: 1 - }; - const travelParams = { - ref: travel.ref, - agencyModeFk: travel.agencyModeFk - }; - const queryParams = JSON.stringify(travelParams); - controller.onCloneAccept(travel); - - expect(controller.$state.go).toHaveBeenCalledWith('travel.create', {q: queryParams}); - }); - }); - - describe('compareDate()', () => { - it('should return warning if the date passed to compareDate() is todays', () => { - const today = Date.vnNew(); - - const result = controller.compareDate(today); - - expect(result).toEqual('warning'); - }); - - it('should return success if the date passed to compareDate() is in the future', () => { - const tomorrow = Date.vnNew(); - tomorrow.setDate(tomorrow.getDate() + 1); - - const result = controller.compareDate(tomorrow); - - expect(result).toEqual('success'); - }); - - it('should return undefined if the date passed to compareDate() is in the past', () => { - const yesterday = Date.vnNew(); - yesterday.setDate(yesterday.getDate() - 1); - - const result = controller.compareDate(yesterday); - - expect(result).toBeUndefined(); - }); - }); -}); diff --git a/modules/travel/front/index/locale/es.yml b/modules/travel/front/index/locale/es.yml deleted file mode 100644 index 5ce4c502f..000000000 --- a/modules/travel/front/index/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Do you want to clone this travel?: ¿Desea clonar este envio? -All it's properties will be copied: Todas sus propiedades serán copiadas -Clone: Clonar \ No newline at end of file diff --git a/modules/travel/front/index/style.scss b/modules/travel/front/index/style.scss deleted file mode 100644 index ca1cf538b..000000000 --- a/modules/travel/front/index/style.scss +++ /dev/null @@ -1,11 +0,0 @@ -@import "variables"; - -vn-travel-index { - vn-icon { - color: $color-font-secondary - } - - vn-icon.active { - color: $color-success - } -} diff --git a/modules/travel/front/log/index.html b/modules/travel/front/log/index.html deleted file mode 100644 index fc4622e5a..000000000 --- a/modules/travel/front/log/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/modules/travel/front/log/index.js b/modules/travel/front/log/index.js deleted file mode 100644 index 7af601b5c..000000000 --- a/modules/travel/front/log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnTravelLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/travel/front/main/index.html b/modules/travel/front/main/index.html index 131d9409e..e69de29bb 100644 --- a/modules/travel/front/main/index.html +++ b/modules/travel/front/main/index.html @@ -1,6 +0,0 @@ - - - - - - diff --git a/modules/travel/front/main/index.js b/modules/travel/front/main/index.js index 6a153f21a..37dcbb0dc 100644 --- a/modules/travel/front/main/index.js +++ b/modules/travel/front/main/index.js @@ -5,6 +5,10 @@ export default class Travel extends ModuleMain { constructor() { super(); } + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`travel/`); + } } ngModule.vnComponent('vnTravel', { diff --git a/modules/travel/front/routes.json b/modules/travel/front/routes.json index b2e438c6d..6891a46cf 100644 --- a/modules/travel/front/routes.json +++ b/modules/travel/front/routes.json @@ -27,80 +27,6 @@ "state": "travel.index", "component": "vn-travel-index", "description": "Travels" - }, { - "url": "/:id", - "state": "travel.card", - "abstract": true, - "component": "vn-travel-card" - }, { - "url": "/summary", - "state": "travel.card.summary", - "component": "vn-travel-summary", - "description": "Summary", - "params": { - "travel": "$ctrl.travel" - } - }, { - "url": "/basic-data", - "state": "travel.card.basicData", - "component": "vn-travel-basic-data", - "description": "Basic data", - "acl": ["buyer","logistic"], - "params": { - "travel": "$ctrl.travel" - } - }, { - "url" : "/log", - "state": "travel.card.log", - "component": "vn-travel-log", - "description": "Log" - }, { - "url": "/create?q", - "state": "travel.create", - "component": "vn-travel-create", - "description": "New travel" - }, { - "url": "/thermograph", - "state": "travel.card.thermograph", - "abstract": true, - "component": "ui-view" - }, { - "url" : "/index", - "state": "travel.card.thermograph.index", - "component": "vn-travel-thermograph-index", - "description": "Thermographs", - "params": { - "travel": "$ctrl.travel" - }, - "acl": ["buyer"] - }, { - "url" : "/create", - "state": "travel.card.thermograph.create", - "component": "vn-travel-thermograph-create", - "description": "Add thermograph", - "params": { - "travel": "$ctrl.travel" - }, - "acl": ["buyer"] - }, { - "url" : "/:thermographId/edit", - "state": "travel.card.thermograph.edit", - "component": "vn-travel-thermograph-edit", - "description": "Edit thermograph", - "params": { - "travel": "$ctrl.travel" - }, - "acl": ["buyer"] - }, - { - "url": "/extra-community?q", - "state": "travel.extraCommunity", - "component": "vn-travel-extra-community", - "description": "Extra community", - "acl": ["buyer"], - "params": { - "travel": "$ctrl.travel" - } } ] -} \ No newline at end of file +} diff --git a/modules/travel/front/search-panel/index.html b/modules/travel/front/search-panel/index.html deleted file mode 100644 index dd8d98af1..000000000 --- a/modules/travel/front/search-panel/index.html +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - Id/{{$ctrl.$t('Reference')}}: {{$ctrl.filter.search}} - - - {{$ctrl.$t('Agency')}}: {{agency.selection.name}} - - - {{$ctrl.$t('Warehouse Out')}}: {{warehouseOut.selection.name}} - - - {{$ctrl.$t('Warehouse In')}}: {{warehouseIn.selection.name}} - - - {{$ctrl.$t('Days onward')}}: {{$ctrl.filter.scopeDays}} - - - {{$ctrl.$t('Landed from')}}: {{$ctrl.filter.landedFrom | date:'dd/MM/yyyy'}} - - - {{$ctrl.$t('Landed to')}}: {{$ctrl.filter.landedTo | date:'dd/MM/yyyy'}} - - - {{$ctrl.$t('Continent Out')}}: {{continent.selection.name}} - - - {{$ctrl.$t('Total entries')}}: {{$ctrl.filter.totalEntries}} - -
-
diff --git a/modules/travel/front/search-panel/index.js b/modules/travel/front/search-panel/index.js deleted file mode 100644 index 5969a8c3f..000000000 --- a/modules/travel/front/search-panel/index.js +++ /dev/null @@ -1,72 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; -import './style.scss'; - -class Controller extends SearchPanel { - constructor($, $element) { - super($, $element); - this.initFilter(); - this.fetchData(); - } - - $onChanges() { - if (this.model) - this.applyFilters(); - } - - fetchData() { - this.$http.get('AgencyModes').then(res => { - this.agencyModes = res.data; - }); - this.$http.get('Warehouses').then(res => { - this.warehouses = res.data; - }); - this.$http.get('Continents').then(res => { - this.continents = res.data; - }); - } - - initFilter() { - this.filter = {}; - if (this.$params.q) { - this.filter = JSON.parse(this.$params.q); - this.search = this.filter.search; - this.totalEntries = this.filter.totalEntries; - } - if (!this.filter.scopeDays) this.filter.scopeDays = 7; - } - - applyFilters(param) { - if (this.filter?.search) - delete this.filter.scopeDays; - - this.model.applyFilter({}, this.filter) - .then(() => { - if (param && this.model._orgData.length === 1) - this.$state.go('travel.card.summary', {id: this.model._orgData[0].id}); - else - this.$state.go(this.$state.current.name, {q: JSON.stringify(this.filter)}, {location: 'replace'}); - }); - } - - removeParamFilter(param) { - if (this[param]) delete this[param]; - delete this.filter[param]; - this.applyFilters(); - } - - onKeyPress($event, param) { - if ($event.key === 'Enter') { - this.filter[param] = this[param]; - this.applyFilters(param === 'search'); - } - } -} - -ngModule.vnComponent('vnTravelSearchPanel', { - template: require('./index.html'), - controller: Controller, - bindings: { - model: '<' - } -}); diff --git a/modules/travel/front/search-panel/index.spec.js b/modules/travel/front/search-panel/index.spec.js deleted file mode 100644 index 488143e80..000000000 --- a/modules/travel/front/search-panel/index.spec.js +++ /dev/null @@ -1,38 +0,0 @@ -import './index'; - -describe('Travel Component vnTravelSearchPanel', () => { - let controller; - - beforeEach(ngModule('travel')); - - beforeEach(inject($componentController => { - controller = $componentController('vnTravelSearchPanel', {$element: null}); - controller.$t = () => {}; - })); - - describe('applyFilters()', () => { - it('should apply filters', async() => { - controller.filter = {foo: 'bar'}; - controller.model = { - applyFilter: jest.fn().mockResolvedValue(), - _orgData: [{id: 1}] - }; - controller.$state = { - current: { - name: 'foo' - }, - go: jest.fn() - }; - - await controller.applyFilters(true); - - expect(controller.model.applyFilter).toHaveBeenCalledWith({}, controller.filter); - expect(controller.$state.go).toHaveBeenCalledWith('travel.card.summary', {id: 1}); - - await controller.applyFilters(false); - - expect(controller.$state.go).toHaveBeenCalledWith(controller.$state.current.name, - {q: JSON.stringify(controller.filter)}, {location: 'replace'}); - }); - }); -}); diff --git a/modules/travel/front/search-panel/locale/es.yml b/modules/travel/front/search-panel/locale/es.yml deleted file mode 100644 index 1f892a742..000000000 --- a/modules/travel/front/search-panel/locale/es.yml +++ /dev/null @@ -1,7 +0,0 @@ -Ticket id: Id ticket -Client id: Id cliente -Nickname: Alias -From: Desde -To: Hasta -Agency: Agencia -Warehouse: Almacén \ No newline at end of file diff --git a/modules/travel/front/search-panel/style.scss b/modules/travel/front/search-panel/style.scss deleted file mode 100644 index 0da52408a..000000000 --- a/modules/travel/front/search-panel/style.scss +++ /dev/null @@ -1,37 +0,0 @@ -@import "variables"; - -vn-travel-search-panel vn-side-menu { - .menu { - min-width: $menu-width; - } - & > div { - .input { - padding-left: $spacing-md; - padding-right: $spacing-md; - border-color: $color-spacer; - border-bottom: $border-thin; - } - .horizontal { - padding-left: $spacing-md; - padding-right: $spacing-md; - grid-auto-flow: column; - grid-column-gap: $spacing-sm; - align-items: center; - } - .chips { - display: flex; - flex-wrap: wrap; - padding: $spacing-md; - overflow: hidden; - max-width: 100%; - border-color: $color-spacer; - } - - .or { - align-self: center; - font-weight: bold; - font-size: 26px; - color: $color-font-secondary; - } - } -} diff --git a/modules/travel/front/summary/index.html b/modules/travel/front/summary/index.html deleted file mode 100644 index d9dbb0f90..000000000 --- a/modules/travel/front/summary/index.html +++ /dev/null @@ -1,167 +0,0 @@ - -
- - - - {{$ctrl.travelData.id}} - {{$ctrl.travelData.ref}} - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Entries

- - - - Confirmed - Entry Id - Supplier - Reference - HB - Freight - Package - CC - Pallet - - - - - - - - - - - - - {{entry.id}} - - - {{entry.supplierName}} - {{entry.reference}} - {{entry.hb}} - {{entry.freightValue | currency: 'EUR': 2}} - {{entry.packageValue | currency: 'EUR': 2}} - {{entry.cc}} - {{entry.pallet}} - {{entry.m3}} - - - - - - - - - - - - - {{$ctrl.total('hb')}} - {{$ctrl.total('freightValue') | currency: 'EUR': 2}} - {{$ctrl.total('packageValue') | currency: 'EUR': 2}} - {{$ctrl.total('cc') | number:2}} - {{$ctrl.total('pallet') | number:2}} - {{$ctrl.total('m3') | number:2}} - - - - -
- -

- - Thermograph - -

-

- Thermograph -

- - - - Code - Temperature - State - Destination - Created - - - - - {{thermograph.thermographFk}} - {{thermograph.temperatureFk}} - {{thermograph.result}} - {{thermograph.warehouse.name}} - {{thermograph.created | date: 'dd/MM/yyyy'}} - - - -
-
-
- - diff --git a/modules/travel/front/summary/index.js b/modules/travel/front/summary/index.js deleted file mode 100644 index 5144a0bb5..000000000 --- a/modules/travel/front/summary/index.js +++ /dev/null @@ -1,71 +0,0 @@ -import ngModule from '../module'; -import Summary from 'salix/components/summary'; -import './style.scss'; - -class Controller extends Summary { - $onInit() { - this.entries = []; - } - - get travel() { - return this._travel; - } - - set travel(value) { - this._travel = value; - - if (value && value.id) { - this.getTravel(); - this.getEntries(); - this.getThermographs(); - } - } - - getTravel() { - return this.$http.get(`Travels/${this.travel.id}/getTravel`) - .then(res => this.travelData = res.data); - } - - getEntries() { - return this.$http.get(`Travels/${this.travel.id}/getEntries`) - .then(res => this.entries = res.data); - } - - getThermographs() { - const filter = { - include: { - relation: 'warehouse', - scope: { - fields: ['id', 'name'] - } - }, - where: { - travelFk: this.travel.id - } - }; - - return this.$http.get(`TravelThermographs`, {filter}) - .then(res => this.travelThermographs = res.data); - } - - total(field) { - let total = 0; - - for (let entry of this.entries) - total += entry[field]; - - return total; - } - - get isBuyer() { - return this.aclService.hasAny(['buyer']); - } -} - -ngModule.vnComponent('vnTravelSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - travel: '<' - } -}); diff --git a/modules/travel/front/summary/index.spec.js b/modules/travel/front/summary/index.spec.js deleted file mode 100644 index b1b750689..000000000 --- a/modules/travel/front/summary/index.spec.js +++ /dev/null @@ -1,86 +0,0 @@ -import './index'; - -describe('component vnTravelSummary', () => { - let controller; - let $httpBackend; - let $scope; - let $httpParamSerializer; - - beforeEach(angular.mock.module('travel', $translateProvider => { - $translateProvider.translations('en', {}); - })); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - $scope = $rootScope.$new(); - const $element = angular.element(``); - controller = $componentController('vnTravelSummary', {$element, $scope}); - })); - - describe('travel setter/getter', () => { - it('should return the travel and then call both getTravel() and getEntries()', () => { - jest.spyOn(controller, 'getTravel'); - jest.spyOn(controller, 'getEntries'); - jest.spyOn(controller, 'getThermographs'); - controller.travel = {id: 99}; - - expect(controller._travel.id).toEqual(99); - expect(controller.getTravel).toHaveBeenCalledWith(); - expect(controller.getEntries).toHaveBeenCalledWith(); - expect(controller.getThermographs).toHaveBeenCalledWith(); - }); - }); - - describe('getTravel()', () => { - it('should perform a get and then store data on the controller', () => { - controller._travel = {id: 999}; - - const query = `Travels/${controller._travel.id}/getTravel`; - $httpBackend.expectGET(query).respond('I am the travelData'); - controller.getTravel(); - $httpBackend.flush(); - - expect(controller.travelData).toEqual('I am the travelData'); - }); - }); - - describe('getEntries()', () => { - it('should call the getEntries method to get the entries data', () => { - controller._travel = {id: 999}; - - const query = `Travels/${controller._travel.id}/getEntries`; - $httpBackend.expectGET(query).respond('I am the entries'); - controller.getEntries(); - $httpBackend.flush(); - - expect(controller.entries).toEqual('I am the entries'); - }); - }); - - describe('getThermographs()', () => { - it('should call the getThermographs method to get the thermographs', () => { - controller._travel = {id: 2}; - - $httpBackend.expectGET(`TravelThermographs`).respond('I am the thermographs'); - controller.getThermographs(); - $httpBackend.flush(); - - expect(controller.travelThermographs).toEqual('I am the thermographs'); - }); - }); - - describe('total()', () => { - it('should calculate the total amount of a given property for every row', () => { - controller.entries = [ - {id: 1, freightValue: 1, packageValue: 2, cc: 0.01}, - {id: 2, freightValue: 1, packageValue: 2, cc: 0.01}, - {id: 3, freightValue: 1, packageValue: 2, cc: 0.01} - ]; - - expect(controller.total('freightValue')).toEqual(3); - expect(controller.total('packageValue')).toEqual(6); - expect(controller.total('cc')).toEqual(0.03); - }); - }); -}); diff --git a/modules/travel/front/summary/locale/es.yml b/modules/travel/front/summary/locale/es.yml deleted file mode 100644 index aa6adc938..000000000 --- a/modules/travel/front/summary/locale/es.yml +++ /dev/null @@ -1,18 +0,0 @@ -Reference: Referencia -Warehouse In: Alm. entrada -Warehouse Out: Alm. salida -Shipped: F. envío -Landed: F. entrega -Total entries: Ent. totales -Delivered: Enviada -Received: Recibida -Agency: Agencia -Entries: Entradas -Confirmed: Confirmada -Entry Id: Id entrada -Supplier: Proveedor -Pallet: Pallet -Freight: Porte -Package: Embalaje -Half box: Media caja -Go to the travel: Ir al envío diff --git a/modules/travel/front/summary/style.scss b/modules/travel/front/summary/style.scss deleted file mode 100644 index dd4cfa72d..000000000 --- a/modules/travel/front/summary/style.scss +++ /dev/null @@ -1,6 +0,0 @@ -@import "variables"; - - -vn-travel-summary .summary { - max-width: $width-lg; -} \ No newline at end of file diff --git a/modules/travel/front/thermograph/create/index.html b/modules/travel/front/thermograph/create/index.html deleted file mode 100644 index 41709e1fb..000000000 --- a/modules/travel/front/thermograph/create/index.html +++ /dev/null @@ -1,177 +0,0 @@ - - - - - - - - -
-
- - - - - {{thermographFk}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/travel/front/thermograph/create/index.js b/modules/travel/front/thermograph/create/index.js deleted file mode 100644 index fa2c1261a..000000000 --- a/modules/travel/front/thermograph/create/index.js +++ /dev/null @@ -1,122 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import UserError from 'core/lib/user-error'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.dms = {files: [], state: 'Ok'}; - } - - get travel() { - return this._travel; - } - - set travel(value) { - this._travel = value; - - if (value) { - this.setDefaultParams(); - this.getAllowedContentTypes(); - } - } - - getAllowedContentTypes() { - this.$http.get('DmsContainers/allowedContentTypes').then(res => { - const contentTypes = res.data.join(', '); - this.allowedContentTypes = contentTypes; - }); - } - - get contentTypesInfo() { - return this.$t('ContentTypesInfo', { - allowedContentTypes: this.allowedContentTypes - }); - } - - setDefaultParams() { - const params = {filter: { - where: {code: 'miscellaneous'} - }}; - this.$http.get('DmsTypes/findOne', {params}).then(res => { - const dmsTypeId = res.data && res.data.id; - const companyId = this.vnConfig.companyFk; - const warehouseId = this.vnConfig.warehouseFk; - const defaultParams = { - reference: this.travel.id, - warehouseId: warehouseId, - companyId: companyId, - dmsTypeId: dmsTypeId, - description: this.$t('TravelFileDescription', { - travelId: this.travel.id - }).toUpperCase() - }; - - this.dms = Object.assign(this.dms, defaultParams); - }); - } - - onAddThermographClick(event) { - const defaultTemperature = 'cool'; - const defaultModel = 'DISPOSABLE'; - - event.preventDefault(); - this.newThermograph = { - thermographId: this.thermographId, - warehouseId: this.warehouseId, - temperatureFk: defaultTemperature, - model: defaultModel - }; - - this.$.modelsModel.refresh(); - this.$.newThermographDialog.show(); - } - - onNewThermographAccept() { - const hasMissingField = - !this.newThermograph.thermographId || - !this.newThermograph.warehouseId || - !this.newThermograph.temperatureFk || - !this.newThermograph.model; - - if (hasMissingField) - throw new UserError(`Some fields are invalid`); - - return this.$http.post(`Thermographs/createThermograph`, this.newThermograph) - .then(res => this.dms.thermographId = res.data.id); - } - - onSubmit() { - const query = `Travels/${this.travel.id}/createThermograph`; - const options = { - method: 'POST', - url: query, - params: this.dms, - headers: { - 'Content-Type': undefined - }, - transformRequest: files => { - const formData = new FormData(); - - for (let i = 0; i < files.length; i++) - formData.append(files[i].name, files[i]); - - return formData; - }, - data: this.dms.files - }; - this.$http(options).then(res => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.$.watcher.updateOriginalData(); - this.$state.go('travel.card.thermograph.index'); - }); - } -} - -ngModule.vnComponent('vnTravelThermographCreate', { - template: require('./index.html'), - controller: Controller, - bindings: { - travel: '<' - } -}); diff --git a/modules/travel/front/thermograph/create/index.spec.js b/modules/travel/front/thermograph/create/index.spec.js deleted file mode 100644 index 1ad263d31..000000000 --- a/modules/travel/front/thermograph/create/index.spec.js +++ /dev/null @@ -1,108 +0,0 @@ -import './index'; - -describe('Ticket', () => { - describe('Component vnTravelThermographCreate', () => { - let controller; - let $httpBackend; - let $httpParamSerializer; - const travelId = 3; - const dmsTypeId = 5; - - beforeEach(ngModule('travel')); - - beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => { - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - const $element = angular.element(''); - controller = $componentController('vnTravelThermographCreate', {$element}); - controller._travel = { - id: travelId - }; - })); - - describe('travel() setter', () => { - it('should set the travel data and then call setDefaultParams() and getAllowedContentTypes()', () => { - jest.spyOn(controller, 'setDefaultParams'); - jest.spyOn(controller, 'getAllowedContentTypes'); - controller.travel = { - id: travelId - }; - - expect(controller.travel).toBeDefined(); - expect(controller.setDefaultParams).toHaveBeenCalledWith(); - expect(controller.getAllowedContentTypes).toHaveBeenCalledWith(); - }); - }); - - describe('setDefaultParams()', () => { - it('should perform a GET query and define the dms property on controller', () => { - const params = {filter: { - where: {code: 'miscellaneous'} - }}; - let serializedParams = $httpParamSerializer(params); - $httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: dmsTypeId, code: 'miscellaneous'}); - controller.setDefaultParams(); - $httpBackend.flush(); - - expect(controller.dms).toBeDefined(); - expect(controller.dms.reference).toEqual(travelId); - expect(controller.dms.dmsTypeId).toEqual(dmsTypeId); - }); - }); - - describe('getAllowedContentTypes()', () => { - it('should make an HTTP GET request to get the allowed content types', () => { - const expectedResponse = ['application/pdf', 'image/png', 'image/jpg']; - $httpBackend.expect('GET', `DmsContainers/allowedContentTypes`).respond(expectedResponse); - controller.getAllowedContentTypes(); - $httpBackend.flush(); - - expect(controller.allowedContentTypes).toBeDefined(); - expect(controller.allowedContentTypes).toEqual('application/pdf, image/png, image/jpg'); - }); - }); - - describe('onAddThermographClick()', () => { - it('should call the show() function of the create thermograph dialog', () => { - controller.$.newThermographDialog = {show: jest.fn()}; - controller.$.modelsModel = {refresh: jest.fn()}; - controller.$.temperaturesModel = {refresh: jest.fn()}; - - const event = new Event('click'); - jest.spyOn(event, 'preventDefault'); - - controller.onAddThermographClick(event); - - expect(event.preventDefault).toHaveBeenCalledTimes(1); - expect(controller.$.newThermographDialog.show).toHaveBeenCalledTimes(1); - }); - }); - - describe('onNewThermographAccept()', () => { - it('should set the created thermograph data on to the controller for the autocomplete to use it', () => { - const id = 'the created id'; - const warehouseId = 1; - const temperatureId = 'cool'; - const model = 'my model'; - - controller.newThermograph = { - thermographId: id, - warehouseId: warehouseId, - temperatureFk: temperatureId, - model: model - }; - const response = { - id: id, - warehouseId: warehouseId, - temperatureFk: temperatureId, - model: model - }; - $httpBackend.when('POST', `Thermographs/createThermograph`).respond(response); - controller.onNewThermographAccept(); - $httpBackend.flush(); - - expect(controller.dms.thermographId).toEqual(response.id); - }); - }); - }); -}); diff --git a/modules/travel/front/thermograph/edit/index.html b/modules/travel/front/thermograph/edit/index.html deleted file mode 100644 index 3fe448b56..000000000 --- a/modules/travel/front/thermograph/edit/index.html +++ /dev/null @@ -1,87 +0,0 @@ - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/modules/travel/front/thermograph/edit/index.js b/modules/travel/front/thermograph/edit/index.js deleted file mode 100644 index a8df3142d..000000000 --- a/modules/travel/front/thermograph/edit/index.js +++ /dev/null @@ -1,98 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - get travel() { - return this._travel; - } - - set travel(value) { - this._travel = value; - - if (value) { - this.setDefaultParams(); - this.getAllowedContentTypes(); - } - } - - getAllowedContentTypes() { - this.$http.get('DmsContainers/allowedContentTypes').then(res => { - const contentTypes = res.data.join(', '); - this.allowedContentTypes = contentTypes; - }); - } - - get contentTypesInfo() { - return this.$t('ContentTypesInfo', { - allowedContentTypes: this.allowedContentTypes - }); - } - - setDefaultParams() { - const filterObj = {include: {relation: 'dms'}}; - const filter = encodeURIComponent(JSON.stringify(filterObj)); - const path = `TravelThermographs/${this.$params.thermographId}?filter=${filter}`; - this.$http.get(path).then(res => { - const thermograph = res.data && res.data; - this.thermograph = { - thermographId: thermograph.thermographFk, - state: thermograph.result, - reference: thermograph.dms.reference, - warehouseId: thermograph.dms.warehouseFk, - companyId: thermograph.dms.companyFk, - dmsTypeId: thermograph.dms.dmsTypeFk, - description: thermograph.dms.description, - hasFile: thermograph.dms.hasFile, - hasFileAttached: false, - files: [] - }; - }); - } - - onSubmit() { - const query = `travels/${this.$params.id}/updateThermograph`; - const options = { - method: 'POST', - url: query, - params: this.thermograph, - headers: { - 'Content-Type': undefined - }, - transformRequest: files => { - const formData = new FormData(); - - for (let i = 0; i < files.length; i++) - formData.append(files[i].name, files[i]); - - return formData; - }, - data: this.thermograph.files - }; - this.$http(options).then(res => { - if (res) { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.$.watcher.updateOriginalData(); - this.$state.go('travel.card.thermograph.index'); - } - }); - } - - onFileChange(files) { - let hasFileAttached = false; - if (files.length > 0) - hasFileAttached = true; - - this.$.$applyAsync(() => { - this.thermograph.hasFileAttached = hasFileAttached; - }); - } -} - -ngModule.vnComponent('vnTravelThermographEdit', { - template: require('./index.html'), - controller: Controller, - bindings: { - travel: '<' - } -}); diff --git a/modules/travel/front/thermograph/edit/index.spec.js b/modules/travel/front/thermograph/edit/index.spec.js deleted file mode 100644 index c0b044a8d..000000000 --- a/modules/travel/front/thermograph/edit/index.spec.js +++ /dev/null @@ -1,120 +0,0 @@ -import './index'; -import watcher from 'core/mocks/watcher.js'; - -describe('Worker', () => { - describe('Component vnTravelThermographEdit', () => { - let controller; - let $scope; - let $httpBackend; - let $httpParamSerializer; - - beforeEach(ngModule('travel')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { - $scope = $rootScope.$new(); - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - const $element = angular.element(` { - it('should set the travel data and then call setDefaultParams() and getAllowedContentTypes()', () => { - jest.spyOn(controller, 'setDefaultParams'); - jest.spyOn(controller, 'getAllowedContentTypes'); - controller._travel = undefined; - controller.travel = { - id: 3 - }; - - expect(controller.setDefaultParams).toHaveBeenCalledWith(); - expect(controller.travel).toBeDefined(); - expect(controller.getAllowedContentTypes).toHaveBeenCalledWith(); - }); - }); - - describe('setDefaultParams()', () => { - it('should perform a GET query and define the dms property on controller', () => { - const thermographId = 6; - const expectedResponse = { - thermographFk: 6, - result: 'Ok', - dms: { - reference: '123456-01', - warehouseFk: 1, - companyFk: 442, - dmsTypeFk: 3, - description: 'Test' - } - }; - - const filterObj = {include: {relation: 'dms'}}; - const filter = encodeURIComponent(JSON.stringify(filterObj)); - const query = `TravelThermographs/${thermographId}?filter=${filter}`; - $httpBackend.expect('GET', query).respond(expectedResponse); - controller.setDefaultParams(); - $httpBackend.flush(); - - expect(controller.thermograph).toBeDefined(); - expect(controller.thermograph.reference).toEqual('123456-01'); - expect(controller.thermograph.dmsTypeId).toEqual(3); - expect(controller.thermograph.state).toEqual('Ok'); - }); - }); - - describe('onFileChange()', () => { - it('should set dms hasFileAttached property to true if has any files', () => { - const files = [{id: 1, name: 'MyFile'}]; - controller.thermograph = {hasFileAttached: false}; - controller.onFileChange(files); - $scope.$apply(); - - expect(controller.thermograph.hasFileAttached).toBeTruthy(); - }); - }); - - describe('getAllowedContentTypes()', () => { - it('should make an HTTP GET request to get the allowed content types', () => { - const expectedResponse = ['image/png', 'image/jpg']; - $httpBackend.expect('GET', `DmsContainers/allowedContentTypes`).respond(expectedResponse); - controller.getAllowedContentTypes(); - $httpBackend.flush(); - - expect(controller.allowedContentTypes).toBeDefined(); - expect(controller.allowedContentTypes).toEqual('image/png, image/jpg'); - }); - }); - - describe('contentTypesInfo()', () => { - it('should return a description with a list of allowed content types', () => { - controller.allowedContentTypes = ['image/png', 'image/jpg']; - const expectedTypes = controller.allowedContentTypes.join(', '); - - const expectedResult = `Allowed content types: ${expectedTypes}`; - jest.spyOn(controller.$translate, 'instant').mockReturnValue(expectedResult); - - const result = controller.contentTypesInfo; - - expect(result).toEqual(expectedResult); - }); - }); - - describe('onSubmit()', () => { - it('should make an HTTP POST request to save the form data', () => { - jest.spyOn(controller.$.watcher, 'updateOriginalData'); - - const files = [{id: 1, name: 'MyFile'}]; - controller.thermograph = {files}; - const serializedParams = $httpParamSerializer(controller.thermograph); - const query = `travels/${controller.$params.id}/updateThermograph?${serializedParams}`; - - $httpBackend.expect('POST', query).respond({}); - controller.onSubmit(); - $httpBackend.flush(); - }); - }); - }); -}); diff --git a/modules/travel/front/thermograph/edit/style.scss b/modules/travel/front/thermograph/edit/style.scss deleted file mode 100644 index 73f136fc1..000000000 --- a/modules/travel/front/thermograph/edit/style.scss +++ /dev/null @@ -1,7 +0,0 @@ -vn-ticket-request { - .vn-textfield { - margin: 0!important; - max-width: 100px; - } -} - diff --git a/modules/travel/front/thermograph/index/index.html b/modules/travel/front/thermograph/index/index.html deleted file mode 100644 index 4d711613d..000000000 --- a/modules/travel/front/thermograph/index/index.html +++ /dev/null @@ -1,70 +0,0 @@ - - - -
- - - - - Code - Temperature - State - Destination - Created - - - - - - {{::thermograph.thermographFk}} - {{::thermograph.temperatureFk}} - {{::thermograph.result}} - {{::thermograph.warehouse.name}} - {{::thermograph.created | date: 'dd/MM/yyyy'}} - - - - - - - - - - - - - - - - -
-
- - - - - - - \ No newline at end of file diff --git a/modules/travel/front/thermograph/index/index.js b/modules/travel/front/thermograph/index/index.js deleted file mode 100644 index f8b239cfe..000000000 --- a/modules/travel/front/thermograph/index/index.js +++ /dev/null @@ -1,51 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $, vnFile) { - super($element, $); - this.vnFile = vnFile; - this.filter = { - include: - {relation: 'warehouse', - scope: { - fields: ['id', 'name'] - } - } - }; - } - - showDeleteConfirm(index) { - this.thermographIndex = index; - this.$.confirm.show(); - } - - deleteThermograph() { - const data = this.travelThermographs; - const thermographId = data[this.thermographIndex].id; - const query = `Travels/deleteThermograph?id=${thermographId}`; - this.$http.delete(query).then(() => { - this.vnApp.showSuccess(this.$t('Thermograph deleted')); - this.$.model.remove(this.thermographIndex); - this.thermographIndex = null; - }); - } - - downloadFile(dmsId) { - this.vnFile.download(`api/dms/${dmsId}/downloadFile`); - } -} - -Controller.$inject = ['$element', '$scope', 'vnFile']; - -ngModule.vnComponent('vnTravelThermographIndex', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnTravelCard' - }, - bindings: { - travel: '<' - } -}); diff --git a/modules/travel/front/thermograph/index/style.scss b/modules/travel/front/thermograph/index/style.scss deleted file mode 100644 index 2c287ed9d..000000000 --- a/modules/travel/front/thermograph/index/style.scss +++ /dev/null @@ -1,6 +0,0 @@ -@import "variables"; - -vn-route-tickets form{ - margin: 0 auto; - max-width: $width-lg; -} \ No newline at end of file diff --git a/modules/travel/front/thermograph/locale/es.yml b/modules/travel/front/thermograph/locale/es.yml deleted file mode 100644 index 1fdb98c8e..000000000 --- a/modules/travel/front/thermograph/locale/es.yml +++ /dev/null @@ -1,20 +0,0 @@ -Code: Código -Temperature: Temperatura -State: Estado -Destination: Destino -Created: Creado -Remove thermograph: Eliminar termógrafo -Upload file: Subir fichero -Edit file: Editar fichero -Upload: Subir -File: Fichero -TravelFileDescription: Travel id {{travelId}} -ContentTypesInfo: 'Tipos de archivo permitidos: {{allowedContentTypes}}' -Are you sure you want to continue?: ¿Seguro que quieres continuar? -Add thermograph: Añadir termógrafo -Edit thermograph: Editar termógrafo -Thermograph deleted: Termógrafo eliminado -Thermograph: Termógrafo -New thermograph: Nuevo termógrafo -Are you sure you want to remove the thermograph?: ¿Seguro que quieres quitar el termógrafo? -Identifier: Identificador \ No newline at end of file diff --git a/modules/wagon/back/methods/wagonType/createWagonType.js b/modules/wagon/back/methods/wagonType/createWagonType.js deleted file mode 100644 index fed915b28..000000000 --- a/modules/wagon/back/methods/wagonType/createWagonType.js +++ /dev/null @@ -1,57 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('createWagonType', { - description: 'Creates a new wagon type', - accessType: 'WRITE', - accepts: [ - { - arg: 'name', - type: 'String', - required: true - }, - { - arg: 'divisible', - type: 'boolean', - required: true - }, { - arg: 'trays', - type: 'any', - required: true - } - ], - http: { - path: `/createWagonType`, - verb: 'PATCH' - } - }); - - Self.createWagonType = async(ctx, options) => { - const args = ctx.args; - const models = Self.app.models; - const myOptions = {}; - let tx; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - - try { - const newWagonType = await models.WagonType.create({name: args.name, divisible: args.divisible}, myOptions); - args.trays.forEach(async tray => { - await models.WagonTypeTray.create({ - typeFk: newWagonType.id, - height: tray.position, - colorFk: tray.color.id - }, myOptions); - }); - - if (tx) await tx.commit(); - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - }; -}; diff --git a/modules/wagon/back/methods/wagonType/deleteWagonType.js b/modules/wagon/back/methods/wagonType/deleteWagonType.js deleted file mode 100644 index 46b65e32f..000000000 --- a/modules/wagon/back/methods/wagonType/deleteWagonType.js +++ /dev/null @@ -1,43 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('deleteWagonType', { - description: 'Deletes a wagon type', - accessType: 'WRITE', - accepts: [ - { - arg: 'id', - type: 'Number', - required: true - } - ], - http: { - path: `/deleteWagonType`, - verb: 'DELETE' - } - }); - - Self.deleteWagonType = async(ctx, options) => { - const args = ctx.args; - const models = Self.app.models; - const myOptions = {}; - let tx; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - - try { - await models.Wagon.destroyAll({typeFk: args.id}, myOptions); - await models.WagonTypeTray.destroyAll({typeFk: args.id}, myOptions); - await models.WagonType.destroyAll({id: args.id}, myOptions); - - if (tx) await tx.commit(); - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - }; -}; diff --git a/modules/wagon/back/methods/wagonType/editWagonType.js b/modules/wagon/back/methods/wagonType/editWagonType.js deleted file mode 100644 index bd5ad1f16..000000000 --- a/modules/wagon/back/methods/wagonType/editWagonType.js +++ /dev/null @@ -1,64 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('editWagonType', { - description: 'Edits a new wagon type', - accessType: 'WRITE', - accepts: [ - { - arg: 'id', - type: 'String', - required: true - }, - { - arg: 'name', - type: 'String', - required: true - }, - { - arg: 'divisible', - type: 'boolean', - required: true - }, { - arg: 'trays', - type: 'any', - required: true - } - ], - http: { - path: `/editWagonType`, - verb: 'PATCH' - } - }); - - Self.editWagonType = async(ctx, options) => { - const args = ctx.args; - const models = Self.app.models; - const myOptions = {}; - let tx; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - - try { - const wagonType = await models.WagonType.findById(args.id, null, myOptions); - wagonType.updateAttributes({name: args.name, divisible: args.divisible}, myOptions); - models.WagonTypeTray.destroyAll({typeFk: args.id}, myOptions); - args.trays.forEach(async tray => { - await models.WagonTypeTray.create({ - typeFk: args.id, - height: tray.position, - colorFk: tray.color.id - }, myOptions); - }); - - if (tx) await tx.commit(); - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - }; -}; diff --git a/modules/wagon/back/methods/wagonType/specs/crudWagonType.spec.js b/modules/wagon/back/methods/wagonType/specs/crudWagonType.spec.js index 92ac61060..96f0980f9 100644 --- a/modules/wagon/back/methods/wagonType/specs/crudWagonType.spec.js +++ b/modules/wagon/back/methods/wagonType/specs/crudWagonType.spec.js @@ -1,58 +1,16 @@ const models = require('vn-loopback/server/server').models; describe('WagonType crudWagonType()', () => { - const ctx = { - args: { - name: 'Mock wagon type', - divisible: true, - trays: [{position: 0, color: {id: 1}}, - {position: 50, color: {id: 2}}, - {position: 100, color: {id: 3}}] - } - }; - it(`should create, edit and delete a new wagon type and its trays`, async() => { const tx = await models.WagonType.beginTransaction({}); try { const options = {transaction: tx}; - // create - await models.WagonType.createWagonType(ctx, options); + const wagonType = await models.WagonType.create({name: 'Mock wagon type'}, options); + const newWagonTrays = await models.WagonTypeTray.findOne({where: {typeFk: wagonType.id}}, options); - const newWagonType = await models.WagonType.findOne({where: {name: ctx.args.name}}, options); - const newWagonTrays = await models.WagonTypeTray.find({where: {typeFk: newWagonType.id}}, options); - - expect(newWagonType).not.toEqual(null); - expect(newWagonType.name).toEqual(ctx.args.name); - expect(newWagonType.divisible).toEqual(ctx.args.divisible); - expect(newWagonTrays.length).toEqual(ctx.args.trays.length); - - ctx.args = { - id: newWagonType.id, - name: 'Edited wagon type', - divisible: false, - trays: [{position: 0, color: {id: 1}}] - }; - - // edit - await models.WagonType.editWagonType(ctx, options); - - const editedWagonType = await models.WagonType.findById(newWagonType.id, null, options); - const editedWagonTrays = await models.WagonTypeTray.find({where: {typeFk: newWagonType.id}}, options); - - expect(editedWagonType.name).toEqual(ctx.args.name); - expect(editedWagonType.divisible).toEqual(ctx.args.divisible); - expect(editedWagonTrays.length).toEqual(ctx.args.trays.length); - - // delete - await models.WagonType.deleteWagonType(ctx, options); - - const deletedWagonType = await models.WagonType.findById(newWagonType.id, null, options); - const deletedWagonTrays = await models.WagonTypeTray.find({where: {typeFk: newWagonType.id}}, options); - - expect(deletedWagonType).toEqual(null); - expect(deletedWagonTrays).toEqual([]); + expect(newWagonTrays).toBeDefined(); await tx.rollback(); } catch (e) { diff --git a/modules/wagon/back/methods/wagonType/specs/wagonTray.spec.js b/modules/wagon/back/methods/wagonType/specs/wagonTray.spec.js new file mode 100644 index 000000000..783c1a621 --- /dev/null +++ b/modules/wagon/back/methods/wagonType/specs/wagonTray.spec.js @@ -0,0 +1,58 @@ +const models = require('vn-loopback/server/server').models; + +describe('WagonTray max height()', () => { + it(`should throw an error if the tray's height is above the maximum of the wagon`, async() => { + const tx = await models.WagonTypeTray.beginTransaction({}); + + let error; + try { + const options = {transaction: tx}; + + await models.WagonTypeTray.create({height: 210, wagonTypeFk: 1, wagonTypeColorFk: 4}, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).toBe('The maximum height of the wagon is 200cm'); + }); + + it(`should throw an error if the tray's height is already in the wagon`, async() => { + const tx = await models.WagonTypeTray.beginTransaction({}); + + let error; + try { + const options = {transaction: tx}; + + await models.WagonTypeTray.create({height: 50, wagonTypeFk: 1, wagonTypeColorFk: 2}, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).toBe('There is already a tray with the same height'); + }); + + it(`should throw an error if the tray's height is below the minimum between the trays`, async() => { + const tx = await models.WagonTypeTray.beginTransaction({}); + + let error; + try { + const options = {transaction: tx}; + + await models.WagonTypeTray.create({height: 40, wagonTypeFk: 1, wagonTypeColorFk: 4}, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).toBe('The height must be greater than 50cm'); + }); +}); + diff --git a/modules/wagon/back/models/wagon-config.json b/modules/wagon/back/models/wagon-config.json index 3d96e2864..d76558564 100644 --- a/modules/wagon/back/models/wagon-config.json +++ b/modules/wagon/back/models/wagon-config.json @@ -25,6 +25,19 @@ }, "maxTrays": { "type": "number" + }, + "defaultHeight": { + "type": "number" + }, + "defaultTrayColorFk": { + "type": "number" } + }, + "relations": { + "WagonTypeColor": { + "type": "belongsTo", + "model": "WagonTypeColor", + "foreignKey": "defaultTrayColorFk" + } } } diff --git a/modules/wagon/back/models/wagon-type-tray.js b/modules/wagon/back/models/wagon-type-tray.js new file mode 100644 index 000000000..219f20bfb --- /dev/null +++ b/modules/wagon/back/models/wagon-type-tray.js @@ -0,0 +1,25 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.observe('before save', async ctx => { + if (ctx.isNewInstance) { + const models = Self.app.models; + const {wagonTypeFk, height} = ctx.instance; + const trays = await models.WagonTypeTray.find({where: {wagonTypeFk}}); + + const config = await models.WagonConfig.findOne(); + const tray = await models.WagonTypeTray.find({where: {wagonTypeFk, height}}); + + if (!trays.length) return; + + if (tray.length) + throw new UserError('There is already a tray with the same height'); + + if (height < config.minHeightBetweenTrays) + throw new UserError('The height must be greater than 50cm'); + + if (height > config.maxWagonHeight) + throw new UserError('The maximum height of the wagon is 200cm'); + } + }); +}; diff --git a/modules/wagon/back/models/wagon-type-tray.json b/modules/wagon/back/models/wagon-type-tray.json index b61510bcf..61b32694d 100644 --- a/modules/wagon/back/models/wagon-type-tray.json +++ b/modules/wagon/back/models/wagon-type-tray.json @@ -11,13 +11,13 @@ "id": true, "type": "number" }, - "typeFk": { + "wagonTypeFk": { "type": "number" }, "height": { "type": "number" }, - "colorFk": { + "wagonTypeColorFk": { "type": "number" } }, @@ -25,12 +25,12 @@ "type": { "type": "belongsTo", "model": "WagonType", - "foreignKey": "typeFk" + "foreignKey": "wagonTypeFk" }, "color": { "type": "belongsTo", "model": "WagonTypeColor", - "foreignKey": "colorFk" + "foreignKey": "wagonTypeColorFk" } } } diff --git a/modules/wagon/back/models/wagon-type.js b/modules/wagon/back/models/wagon-type.js index bebf7a9d9..0610adcb4 100644 --- a/modules/wagon/back/models/wagon-type.js +++ b/modules/wagon/back/models/wagon-type.js @@ -1,5 +1,14 @@ module.exports = Self => { - require('../methods/wagonType/createWagonType')(Self); - require('../methods/wagonType/editWagonType')(Self); - require('../methods/wagonType/deleteWagonType')(Self); + Self.observe('after save', async ctx => { + if (ctx.isNewInstance) { + const models = Self.app.models; + const config = await models.WagonConfig.findOne(); + + await models.WagonTypeTray.create({ + wagonTypeFk: ctx.instance.id, + height: config.defaultHeight, + wagonTypeColorFk: config.defaultTrayColorFk + }, ctx.options); + } + }); }; diff --git a/modules/worker/back/locale/worker-time-control/en.yml b/modules/worker/back/locale/worker-time-control/en.yml new file mode 100644 index 000000000..f1de66474 --- /dev/null +++ b/modules/worker/back/locale/worker-time-control/en.yml @@ -0,0 +1,7 @@ +name: time control +columns: + direction: direction + isSendMail: sent mail + logExclude: excluded log + manual: manual + timed: timed diff --git a/modules/worker/back/locale/worker-time-control/es.yml b/modules/worker/back/locale/worker-time-control/es.yml new file mode 100644 index 000000000..1739c487c --- /dev/null +++ b/modules/worker/back/locale/worker-time-control/es.yml @@ -0,0 +1,7 @@ +name: control horario +columns: + direction: dirección + isSendMail: correo enviado + logExclude: registro excluido + manual: manual + timed: fichada \ No newline at end of file diff --git a/modules/worker/back/locale/worker/en.yml b/modules/worker/back/locale/worker/en.yml index 8438c15cf..ae3053af1 100644 --- a/modules/worker/back/locale/worker/en.yml +++ b/modules/worker/back/locale/worker/en.yml @@ -14,7 +14,6 @@ columns: hasMachineryAuthorized: machinery authorized seniority: seniority isTodayRelative: today relative - isF11Allowed: F11 allowed sectorFk: sector maritalStatus: marital status labelerFk: labeler diff --git a/modules/worker/back/locale/worker/es.yml b/modules/worker/back/locale/worker/es.yml index 96616d7d2..330d266c8 100644 --- a/modules/worker/back/locale/worker/es.yml +++ b/modules/worker/back/locale/worker/es.yml @@ -14,7 +14,6 @@ columns: hasMachineryAuthorized: maquinaria autorizada seniority: antigüedad isTodayRelative: relativo hoy - isF11Allowed: F11 autorizado sectorFk: sector maritalStatus: estado civil labelerFk: etiquetadora diff --git a/modules/worker/back/methods/calendar/specs/absences.spec.js b/modules/worker/back/methods/calendar/specs/absences.spec.js index b27c9549c..f369d1dca 100644 --- a/modules/worker/back/methods/calendar/specs/absences.spec.js +++ b/modules/worker/back/methods/calendar/specs/absences.spec.js @@ -1,6 +1,7 @@ const app = require('vn-loopback/server/server'); describe('Worker absences()', () => { + const ctx = beforeAll.getCtx(); it('should get the absence calendar for a full year contract', async() => { const ctx = {req: {accessToken: {userId: 1106}}}; const workerId = 1106; @@ -20,7 +21,6 @@ describe('Worker absences()', () => { it('should get the absence calendar for a permanent contract', async() => { const businessId = 1106; - const ctx = {req: {accessToken: {userId: 9}}}; const now = Date.vnNew(); const year = now.getFullYear(); diff --git a/modules/worker/back/methods/department/specs/getLeaves.spec.js b/modules/worker/back/methods/department/specs/getLeaves.spec.js index fb7c84ff4..2feb6b461 100644 --- a/modules/worker/back/methods/department/specs/getLeaves.spec.js +++ b/modules/worker/back/methods/department/specs/getLeaves.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('department getLeaves()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; + const ctx = beforeAll.getCtx(); it('should return the department and the childs containing the search value', async() => { let result = await models.Department.getLeaves(ctx, null, 'INFORMATICA'); diff --git a/modules/worker/back/methods/device/handle-user.js b/modules/worker/back/methods/device/handle-user.js new file mode 100644 index 000000000..abafffd55 --- /dev/null +++ b/modules/worker/back/methods/device/handle-user.js @@ -0,0 +1,118 @@ + +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('handleUser', { + description: 'Manage various aspects related to a user with the app', + accepts: [ + { + arg: 'androidId', + type: 'String', + description: 'Android id' + }, + { + arg: 'deviceId', + type: 'String', + description: 'Device id' + }, + { + arg: 'versionApp', + type: 'String', + description: 'Version app' + }, { + arg: 'nameApp', + type: 'String', + description: 'Version app' + }, + + ], + returns: { + type: 'object', + root: true + }, + http: { + path: `/handleUser`, + verb: 'POST' + } + }); + + Self.handleUser = async(ctx, androidId, deviceId, versionApp, nameApp, options) => { + const models = Self.app.models; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const accessToken = ctx.req.accessToken; + let user = await models.VnUser.findById(accessToken.userId); + + const [[{vIsAuthorized, vMessage}]] = + await Self.rawSql('CALL vn.device_checkLogin(?, ?);', + [user.id, androidId], myOptions); + + if (!vIsAuthorized) + throw new UserError('Not authorized'); + + const isUserInOperator = await models.Operator.findOne({ + where: { + workerFk: user.id + } + }, myOptions); + + if (!isUserInOperator) { + await models.Operator.create({ + 'workerFk': user.id, + 'isOnReservationMode': false + }); + } + + const whereCondition = deviceId ? {id: deviceId} : {android_id: androidId}; + const serialNumber = + (await models.DeviceProduction.findOne({where: whereCondition}, myOptions))?.serialNumber ?? ''; + + await models.DeviceLog.create({ + 'android_id': androidId, + 'userFk': user.id, + 'nameApp': nameApp, + 'versionApp': versionApp, + 'serialNumber': serialNumber + }, myOptions); + const getDataUser = await models.VnUser.getCurrentUserData(ctx); + + const getDataOperator = await models.Operator.findOne({ + where: {workerFk: user.id}, + fields: ['numberOfWagons', 'warehouseFk', 'itemPackingTypeFk', 'sectorFk', 'sector', + 'trainFk', 'train', 'labelerFk', 'printer', 'isOnReservationMode'], + include: [ + { + relation: 'sector', + scope: { + fields: ['warehouseFk', 'description', 'isOnReservationMode'], + } + }, { + relation: 'printer', + scope: { + fields: ['name'], + } + }, { + relation: 'train', + scope: { + fields: ['name'], + } + } + + ] + }, myOptions); + + const getVersion = await models.MobileAppVersionControl.getVersion(ctx, nameApp); + + const combinedResult = { + ...getDataOperator.toObject(), + ...getDataUser.toObject(), + ...getVersion, + message: vMessage, + serialNumber, + }; + return combinedResult; + }; +}; diff --git a/modules/worker/back/methods/device/specs/handle-user.spec.js b/modules/worker/back/methods/device/specs/handle-user.spec.js new file mode 100644 index 000000000..c4cd37e33 --- /dev/null +++ b/modules/worker/back/methods/device/specs/handle-user.spec.js @@ -0,0 +1,16 @@ +const {models} = require('vn-loopback/server/server'); + +describe('Device handleUser()', () => { + const ctx = {req: {accessToken: {userId: 9}}}; + + it('should return data from user', async() => { + const androidId = 'androidid11234567890'; + const deviceId = 1; + const nameApp = 'warehouse'; + const versionApp = '10'; + + const data = await models.Device.handleUser(ctx, androidId, deviceId, versionApp, nameApp); + + expect(data.numberOfWagons).toBe(2); + }); +}); diff --git a/modules/worker/back/methods/worker-dms/filter.js b/modules/worker/back/methods/worker-dms/filter.js index b7802a689..597084e60 100644 --- a/modules/worker/back/methods/worker-dms/filter.js +++ b/modules/worker/back/methods/worker-dms/filter.js @@ -8,19 +8,19 @@ module.exports = Self => { accepts: [ { arg: 'id', - type: 'Number', + type: 'number', description: 'The worker id', http: {source: 'path'} }, { arg: 'filter', - type: 'Object', + type: 'object', description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', http: {source: 'query'} } ], returns: { - type: ['Object'], + type: ['object'], root: true }, http: { @@ -36,38 +36,50 @@ module.exports = Self => { // Get ids alloweds const account = await models.VnUser.findById(userId); + const stmt = new ParameterizedSQL( `SELECT d.id, d.id dmsFk - FROM workerDocument wd - JOIN dms d ON d.id = wd.document + FROM workerDms wd + JOIN dms d ON d.id = wd.dmsFk JOIN dmsType dt ON dt.id = d.dmsTypeFk - LEFT JOIN account.roleRole rr ON rr.inheritsFrom = dt.readRoleFk AND rr.role = ? + LEFT JOIN account.roleRole rr ON rr.inheritsFrom = dt.readRoleFk + AND rr.role = ? `, [account.roleFk] ); - const yourOwnDms = {and: [{isReadableByWorker: true}, {worker: userId}]}; - const where = { - or: [yourOwnDms, { - role: { - neq: null - } - }] + const yourOwnDms = { + or: [ + {and: [ + {isReadableByWorker: true}, + {'wd.workerFk': userId} + ]}, + { + role: { + neq: null + } + }] }; - stmt.merge(conn.makeSuffix(mergeWhere(filter.where, where))); - // Get workerDms alloweds + const where = mergeWhere(filter.where, yourOwnDms); + stmt.merge(conn.makeSuffix({where})); const dmsIds = await conn.executeStmt(stmt); + const allowedIds = dmsIds.map(dms => dms.id); const allowedFilter = mergeFilters(filter, {where: {dmsFk: {inq: allowedIds}, workerFk: id}}); - let workerDms = await models.WorkerDms.find(allowedFilter); - // Get docuware info - const docuware = await models.Docuware.findOne({ - fields: ['dmsTypeFk'], - where: {code: 'hr', action: 'find'} - }); - const docuwareDmsType = docuware.dmsTypeFk; - let workerDocuware = []; - if (!filter.skip && (!docuwareDmsType || (docuwareDmsType && await models.DmsType.hasReadRole(ctx, docuwareDmsType)))) { + const workerDms = await models.WorkerDms.find(allowedFilter); + + const workerDocuware = filter.skip ? [] : await getDocuware(ctx, id); + return workerDms.concat(workerDocuware); + + async function getDocuware(ctx, id) { + const {dmsTypeFk} = await models.Docuware.findOne({ + fields: ['dmsTypeFk'], + where: {code: 'hr', action: 'find'} + }); + + if (!await models.DmsType.hasReadRole(ctx, dmsTypeFk)) return []; + + let workerDocuware = []; const worker = await models.Worker.findById(id, {fields: ['fi', 'firstName', 'lastName']}); const docuwareParse = { 'Filename': 'dmsFk', @@ -80,7 +92,7 @@ module.exports = Self => { }; workerDocuware = - await models.Docuware.getById('hr', worker.lastName + ' ' + worker.firstName, docuwareParse) ?? []; + await models.Docuware.getById('hr', worker.lastName + ' ' + worker.firstName, docuwareParse) ?? []; const url = (await Self.app.models.Url.getUrl('docuware')) + 'WebClient'; for (document of workerDocuware) { const docuwareId = document.id; @@ -105,7 +117,7 @@ module.exports = Self => { }; Object.assign(document, defaultData); } + return workerDocuware; } - return workerDms.concat(workerDocuware); }; }; diff --git a/modules/worker/back/methods/worker-time-control/getMailStates.js b/modules/worker/back/methods/worker-time-control/getMailStates.js index 855b5adc3..d55c185a5 100644 --- a/modules/worker/back/methods/worker-time-control/getMailStates.js +++ b/modules/worker/back/methods/worker-time-control/getMailStates.js @@ -1,3 +1,5 @@ +const UserError = require('vn-loopback/util/user-error'); + module.exports = Self => { Self.remoteMethodCtx('getMailStates', { description: 'Get the states of a month about time control mail', @@ -36,6 +38,8 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); + if (!await models.Worker.isSubordinate(ctx, workerId)) throw new UserError(`You don't have enough privileges`); + const times = await models.Time.find({ fields: ['week'], where: { diff --git a/modules/worker/back/methods/worker-time-control/resendWeeklyHourEmail.js b/modules/worker/back/methods/worker-time-control/resendWeeklyHourEmail.js index 885637118..ed6b4e6ab 100644 --- a/modules/worker/back/methods/worker-time-control/resendWeeklyHourEmail.js +++ b/modules/worker/back/methods/worker-time-control/resendWeeklyHourEmail.js @@ -1,4 +1,5 @@ const moment = require('moment'); +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('resendWeeklyHourEmail', { @@ -34,6 +35,11 @@ module.exports = Self => { const yearNumber = dated.getFullYear(); const weekNumber = moment(dated).isoWeek(); + const isSubordinate = await models.Worker.isSubordinate(ctx, workerId, myOptions); + const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); + + if (!isSubordinate || (workerId === ctx.req.accessToken.userId && !isTeamBoss)) + throw new UserError(`You don't have enough privileges`); const workerTimeControlMail = await models.WorkerTimeControlMail.findOne({ where: { diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index e43f4a8ab..2e1e00d83 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -165,8 +165,8 @@ module.exports = Self => { const sql = ParameterizedSQL.join(stmts, ';'); const days = await conn.executeStmt(sql, myOptions); - let previousWorkerFk = days[index][0].workerFk; - let previousReceiver = days[index][0].receiver; + let previousWorkerFk = days[index][0]?.workerFk; + let previousReceiver = days[index][0]?.receiver; const workerTimeControlConfig = await models.WorkerTimeControlConfig.findOne(null, myOptions); diff --git a/modules/worker/back/methods/worker-time-control/specs/getMailStates.spec.js b/modules/worker/back/methods/worker-time-control/specs/getMailStates.spec.js index cbad32323..083236ec6 100644 --- a/modules/worker/back/methods/worker-time-control/specs/getMailStates.spec.js +++ b/modules/worker/back/methods/worker-time-control/specs/getMailStates.spec.js @@ -1,28 +1,36 @@ const models = require('vn-loopback/server/server').models; describe('workerTimeControl getMailStates()', () => { - const workerId = 9; - const ctx = {args: { - month: 12, - year: 2000 - }}; + const developerId = 9; + const developerBossId = 120; + const employeeId = 1; + + let ctx; + let tx; + let opts; + + beforeEach(async() => { + ctx = {req: {accessToken: {userId: developerBossId}}, args: {month: 12, year: 2000}}; + tx = await models.WorkerTimeControl.beginTransaction({}); + opts = {transaction: tx}; + }); + + afterEach(async() => await tx.rollback()); it('should get the states of a month about time control mail', async() => { - const tx = await models.WorkerTimeControl.beginTransaction({}); + const response = await models.WorkerTimeControl.getMailStates(ctx, developerId, opts); + expect(response[0].state).toEqual('REVISE'); + expect(response[1].state).toEqual('SENDED'); + expect(response[2].state).toEqual('CONFIRMED'); + }); + + it('should throw an error if they are not subordinates', async() => { + ctx.req.accessToken.userId = employeeId; try { - const options = {transaction: tx}; - - const response = await models.WorkerTimeControl.getMailStates(ctx, workerId, options); - - expect(response[0].state).toEqual('REVISE'); - expect(response[1].state).toEqual('SENDED'); - expect(response[2].state).toEqual('CONFIRMED'); - - await tx.rollback(); + await models.WorkerTimeControl.getMailStates(ctx, developerId, opts); } catch (e) { - await tx.rollback(); - throw e; + expect(e.message).toEqual('You don\'t have enough privileges'); } }); }); diff --git a/modules/worker/back/methods/worker-time-control/specs/updateWorkerTimeControlMail.spec.js b/modules/worker/back/methods/worker-time-control/specs/updateMailState.spec.js similarity index 82% rename from modules/worker/back/methods/worker-time-control/specs/updateWorkerTimeControlMail.spec.js rename to modules/worker/back/methods/worker-time-control/specs/updateMailState.spec.js index 3b5b2b73f..151b6ca94 100644 --- a/modules/worker/back/methods/worker-time-control/specs/updateWorkerTimeControlMail.spec.js +++ b/modules/worker/back/methods/worker-time-control/specs/updateMailState.spec.js @@ -1,10 +1,11 @@ const models = require('vn-loopback/server/server').models; -describe('updateWorkerTimeControlMail()', () => { +describe('updateMailState()', () => { + const developerId = 9; + const employeeId = 1; it('should update WorkerTimeControlMail if exist record', async() => { const tx = await models.WorkerTimeControlMail.beginTransaction({}); const args = { - workerId: 9, week: 50, year: 2000, state: 'CONFIRMED' @@ -15,15 +16,15 @@ describe('updateWorkerTimeControlMail()', () => { const options = {transaction: tx}; const beforeMail = await models.WorkerTimeControlMail.findOne({ where: { - workerFk: args.workerId, + workerFk: developerId, year: args.year, week: args.week, } }, options); - await models.WorkerTimeControl.updateWorkerTimeControlMail(ctx, options); + await models.WorkerTimeControl.updateMailState(ctx, developerId, options); const afterMail = await models.WorkerTimeControlMail.findOne({ where: { - workerFk: args.workerId, + workerFk: developerId, year: args.year, week: args.week, } @@ -42,7 +43,6 @@ describe('updateWorkerTimeControlMail()', () => { it('should insert WorkerTimeControlMail if exist record', async() => { const tx = await models.WorkerTimeControlMail.beginTransaction({}); const args = { - workerId: 1, week: 51, year: 2000, state: 'SENDED' @@ -53,15 +53,15 @@ describe('updateWorkerTimeControlMail()', () => { const options = {transaction: tx}; const beforeMail = await models.WorkerTimeControlMail.find({ where: { - workerFk: args.workerId, + workerFk: employeeId, year: args.year, week: args.week, } }, options); - await models.WorkerTimeControl.updateWorkerTimeControlMail(ctx, options); + await models.WorkerTimeControl.updateMailState(ctx, employeeId, options); const afterMail = await models.WorkerTimeControlMail.find({ where: { - workerFk: args.workerId, + workerFk: employeeId, year: args.year, week: args.week, } @@ -80,7 +80,7 @@ describe('updateWorkerTimeControlMail()', () => { it('should throw error if not exist any record in this week', async() => { const tx = await models.WorkerTimeControlMail.beginTransaction({}); const ctx = {args: { - workerId: 1, + workerId: employeeId, week: 1, year: 0, state: 'SENDED' @@ -89,7 +89,7 @@ describe('updateWorkerTimeControlMail()', () => { let error; try { const options = {transaction: tx}; - await models.WorkerTimeControl.updateWorkerTimeControlMail(ctx, options); + await models.WorkerTimeControl.updateMailState(ctx, employeeId, options); await tx.rollback(); } catch (e) { diff --git a/modules/worker/back/methods/worker-time-control/updateWorkerTimeControlMail.js b/modules/worker/back/methods/worker-time-control/updateMailState.js similarity index 84% rename from modules/worker/back/methods/worker-time-control/updateWorkerTimeControlMail.js rename to modules/worker/back/methods/worker-time-control/updateMailState.js index 3594f05fe..c3bacaac0 100644 --- a/modules/worker/back/methods/worker-time-control/updateWorkerTimeControlMail.js +++ b/modules/worker/back/methods/worker-time-control/updateMailState.js @@ -1,12 +1,13 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethodCtx('updateWorkerTimeControlMail', { + Self.remoteMethodCtx('updateMailState', { description: 'Updates the state of WorkerTimeControlMail', accessType: 'WRITE', accepts: [{ - arg: 'workerId', + arg: 'id', type: 'number', - required: true + description: 'The worker id', + http: {source: 'path'} }, { arg: 'year', @@ -32,12 +33,12 @@ module.exports = Self => { root: true }, http: { - path: `/updateWorkerTimeControlMail`, + path: `/:id/updateMailState`, verb: 'POST' } }); - Self.updateWorkerTimeControlMail = async(ctx, options) => { + Self.updateMailState = async(ctx, id, options) => { const models = Self.app.models; const args = ctx.args; const myOptions = {}; @@ -59,14 +60,14 @@ module.exports = Self => { { year: args.year, week: args.week, - workerFk: args.workerId + workerFk: id }, { state: args.state, - reason: args.workerId, + reason: args.reason, year: args.year, week: args.week, - workerFk: args.workerId + workerFk: id }, myOptions); diff --git a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js index 816a1d22b..e352eb3cb 100644 --- a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js +++ b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js @@ -35,7 +35,7 @@ module.exports = Self => { root: true }, http: { - path: '/weekly-hour-hecord-email', + path: '/weekly-hour-record-email', verb: 'POST' } }); @@ -61,7 +61,7 @@ module.exports = Self => { const url = `${salix.url}worker/${args.workerId}/time-control?timestamp=${timestamp}`; ctx.args.url = url; - await models.WorkerTimeControl.updateWorkerTimeControlMail(ctx, myOptions); + await models.WorkerTimeControl.updateMailState(ctx, ctx.args.workerId, myOptions); return Self.sendTemplate(ctx, 'weekly-hour-record'); }; diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 2de1d6e4d..0397886cf 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -110,8 +110,7 @@ module.exports = Self => { workCenterFk: workCenter.workCenterFk } }); - - if (holiday && isFestive) + if ((holiday && isFestive) && (workCenter.workcenterFk === holiday.workCenterFk)) throw new UserError(`Cannot add holidays on this day`); const absence = await models.Calendar.create({ diff --git a/modules/worker/back/methods/worker/filter.js b/modules/worker/back/methods/worker/filter.js index 2f328d28f..52c60572a 100644 --- a/modules/worker/back/methods/worker/filter.js +++ b/modules/worker/back/methods/worker/filter.js @@ -67,6 +67,12 @@ module.exports = Self => { type: 'String', description: 'The worker user name', http: {source: 'query'} + }, + { + arg: 'email', + type: 'String', + description: 'The user email', + http: {source: 'query'} } ], returns: { @@ -99,6 +105,8 @@ module.exports = Self => { return {'w.firstName': {like: `%${value}%`}}; case 'lastName': return {'w.lastName': {like: `%${value}%`}}; + case 'nickname': + return {'u.nickname': {like: `%${value}%`}}; case 'extension': return {'p.extension': value}; case 'fi': @@ -107,6 +115,8 @@ module.exports = Self => { return {'d.id': value}; case 'userName': return {'u.name': {like: `%${value}%`}}; + case 'email': + return {'eu.email': {like: `%${value}%`}}; } }); @@ -116,15 +126,23 @@ module.exports = Self => { let stmt; stmt = new ParameterizedSQL( - `SELECT w.id, u.email, p.extension, u.name as userName, - d.name AS department, w.lastName, u.nickname, mu.email + `SELECT w.id, + w.lastName, + w.firstName, + u.email, + u.nickname, + p.extension, + u.name as userName, + d.name AS department, + eu.email, + c.fi FROM worker w LEFT JOIN workerDepartment wd ON wd.workerFk = w.id LEFT JOIN department d ON d.id = wd.departmentFk LEFT JOIN client c ON c.id = w.id LEFT JOIN account.user u ON u.id = w.id LEFT JOIN pbx.sip p ON p.user_id = u.id - LEFT JOIN account.emailUser mu ON mu.userFk = u.id` + LEFT JOIN account.emailUser eu ON eu.userFk = u.id` ); stmt.merge(conn.makeSuffix(filter)); diff --git a/modules/worker/back/methods/worker/new.js b/modules/worker/back/methods/worker/new.js index 5316daf01..7da8a8da2 100644 --- a/modules/worker/back/methods/worker/new.js +++ b/modules/worker/back/methods/worker/new.js @@ -5,108 +5,80 @@ module.exports = Self => { Self.remoteMethodCtx('new', { description: 'Creates a new worker and returns the id', accessType: 'WRITE', - accepts: [ - { - arg: 'fi', - type: 'string', - description: `The worker fi`, - required: true, - }, - { - arg: 'name', - type: 'string', - description: `The user name`, - required: true, - }, - { - arg: 'firstName', - type: 'string', - description: `The worker firstname`, - required: true, - }, - { - arg: 'lastNames', - type: 'string', - description: `The worker lastnames`, - required: true, - }, - { - arg: 'email', - type: 'string', - description: `The worker email`, - required: true, - }, - { - arg: 'street', - type: 'string', - description: `The worker address`, - required: true, - }, - { - arg: 'city', - type: 'string', - description: `The worker city`, - required: true, - }, - { - arg: 'provinceFk', - type: 'number', - description: `The worker province`, - required: true, - }, - { - arg: 'companyFk', - type: 'number', - description: `The worker company`, - required: true, - }, - { - arg: 'postcode', - type: 'string', - description: `The worker postcode`, - required: true, - }, - { - arg: 'phone', - type: 'string', - description: `The worker phone`, - required: true, - }, - { - arg: 'code', - type: 'string', - description: `The worker code`, - required: true, - }, - { - arg: 'bossFk', - type: 'number', - description: `The worker boss`, - required: true, - }, - { - arg: 'birth', - type: 'date', - description: `The worker birth`, - required: true, - }, - { - arg: 'payMethodFk', - type: 'number', - description: `The client payMethod`, - required: true, - }, - { - arg: 'iban', - type: 'string', - description: `The client iban`, - }, - { - arg: 'bankEntityFk', - type: 'number', - description: `The client bank entity`, - } - ], + accepts: [{ + arg: 'fi', + type: 'string', + description: `The worker fi`, + }, { + arg: 'name', + type: 'string', + description: `The user name`, + }, { + arg: 'firstName', + type: 'string', + description: `The worker firstname`, + }, { + arg: 'lastNames', + type: 'string', + description: `The worker lastnames`, + }, { + arg: 'email', + type: 'string', + description: `The worker email`, + required: true, + }, { + arg: 'street', + type: 'string', + description: `The worker address`, + }, { + arg: 'city', + type: 'string', + description: `The worker city`, + }, { + arg: 'provinceFk', + type: 'number', + description: `The worker province`, + }, { + arg: 'companyFk', + type: 'number', + description: `The worker company`, + }, { + arg: 'postcode', + type: 'string', + description: `The worker postcode`, + }, { + arg: 'phone', + type: 'string', + description: `The worker phone`, + }, { + arg: 'code', + type: 'string', + description: `The worker code`, + }, { + arg: 'bossFk', + type: 'number', + description: `The worker boss`, + required: true, + }, { + arg: 'birth', + type: 'date', + description: `The worker birth`, + }, { + arg: 'payMethodFk', + type: 'number', + description: `The client payMethod`, + }, { + arg: 'iban', + type: 'string', + description: `The client iban`, + }, { + arg: 'bankEntityFk', + type: 'number', + description: `The client bank entity`, + }, { + arg: 'isFreelance', + type: 'boolean', + }], returns: { type: 'number', root: true, @@ -117,11 +89,30 @@ module.exports = Self => { }, }); - Self.new = async(ctx, options) => { + Self.new = async( + ctx, + fi, + name, + firstName, + lastNames, + email, + street, + city, + provinceFk, + companyFk, + postcode, + phone, + code, + bossFk, + birth, + payMethodFk, + iban, + bankEntityFk, + isFreelance, + options + ) => { const models = Self.app.models; const myOptions = {userId: ctx.req.accessToken.userId}; - const args = ctx.args; - let tx; if (typeof options == 'object') Object.assign(myOptions, options); @@ -132,132 +123,109 @@ module.exports = Self => { } let client; - + let user; try { - client = await models.Client.findOne( - { - where: {fi: args.fi}, - }, - myOptions - ); + client = await models.Client.findOne({where: {fi}}, myOptions); + const nickname = firstName.concat(' ', lastNames); + const {roleFk, businessTypeFk} = await models.WorkerConfig.findOne({fields: ['roleFk', 'businessTypeFk']}); - if (!client) { - const nickname = args.firstName.concat(' ', args.lastNames); - const workerConfig = await models.WorkerConfig.findOne({fields: ['roleFk', 'businessTypeFk']}); - const [randomPassword] = await models.Worker.rawSql( - 'SELECT account.passwordGenerate() as password;' - ); + if (!isFreelance && !payMethodFk) throw new UserError('Payment method is required'); - const user = await models.VnUser.create( - { - name: args.name, - nickname, - password: randomPassword.password, - email: args.email, - roleFk: workerConfig.roleFk, - }, - myOptions - ); + if (isFreelance || !client) { + const [{password}] = await models.Worker.rawSql('SELECT account.passwordGenerate() as password;'); + const freelancer = isFreelance && await models.VnRole.findOne({fields: ['id'], where: {name: 'freelancer'}}); - await models.Account.create( - { - id: user.id, - }, - myOptions - ); + user = await models.VnUser.create({ + name, + nickname, + password, + email, + roleFk: freelancer ? freelancer.id : roleFk, + }, myOptions); - const payMethod = await models.PayMethod.findById(args.payMethodFk, {fields: ['isIbanRequiredForClients']}); - if (payMethod.isIbanRequiredForClients && !args.iban) - throw new UserError(`That payment method requires an IBAN`); + await models.Account.create({ + id: user.id + }, myOptions); + } else if (client) user = await models.VnUser.findById(client.id, null, myOptions); - await models.Worker.rawSql( - 'CALL vn.client_create(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', + if (!client && !isFreelance) { + const payMethod = await models.PayMethod.findById(payMethodFk, {fields: ['isIbanRequiredForClients']}); + if (payMethod.isIbanRequiredForClients && !iban) throw new UserError('That payment method requires an IBAN'); + + await models.Worker.rawSql('CALL vn.client_create(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [ - args.firstName, - args.lastNames, - args.fi, - args.street, - args.postcode, - args.city, - args.provinceFk, - args.companyFk, - args.phone, - args.email, + firstName, + lastNames, + fi, + street, + postcode, + city, + provinceFk, + companyFk, + phone, + email, user.id, ], - myOptions - ); + myOptions); - const address = await models.Address.create( - { - clientFk: user.id, - street: args.street, - city: args.city, - provinceFk: args.provinceFk, - postalCode: args.postcode, - mobile: args.phone, - nickname: nickname, - isDefaultAddress: true, - }, - myOptions - ); + const address = await models.Address.create({ + clientFk: user.id, + street: street, + city, + provinceFk, + postalCode: postcode, + mobile: phone, + nickname: nickname, + isDefaultAddress: true, + }, myOptions); - client = await models.Client.findById( - user.id, - {fields: ['id', 'name', 'socialName', 'street', 'city', 'iban', 'bankEntityFk', 'defaultAddressFk', 'businessTypeFk', 'fi']}, - myOptions - ); + client = await models.Client.findById(user.id, { + fields: ['id', 'name', 'socialName', 'street', 'city', 'iban', 'bankEntityFk', 'defaultAddressFk', 'businessTypeFk', 'fi'] + }, myOptions); - await client.updateAttributes( - { - payMethod: args.payMethod, - iban: args.iban, - bankEntityFk: args.bankEntityFk, - defaultAddressFk: address.id, - businessTypeFk: workerConfig.businessTypeFk, - }, - myOptions - ); + await client.updateAttributes({ + payMethod: payMethodFk, + iban, + bankEntityFk, + defaultAddressFk: address.id, + businessTypeFk, + }, myOptions); } - const user = await models.VnUser.findById(client.id, null, myOptions); - await user.updateAttribute('email', args.email, myOptions); - + await user.updateAttribute('email', email, myOptions); + let countryFk; + if (provinceFk) { + const province = await Self.app.models.Province.findById(provinceFk, { + fields: ['countryFk'] + }); + countryFk = province.countryFk; + } await models.Worker.create({ - id: client.id, - code: args.code, - firstName: args.firstName, - lastName: args.lastNames, - bossFk: args.bossFk, - fi: args.fi, - birth: args.birth, - + id: user.id, + firstName, + lastName: lastNames, + code, + bossFk, + fi, + birth, + originCountryFk: countryFk }, myOptions); if (tx) await tx.commit(); - } catch (error) { + } catch (e) { if (tx) await tx.rollback(); - const code = error.code; - const message = error.sqlMessage; + const code = e.code; + const message = e.sqlMessage; - if (error.message && error.message.includes(`Email already exists`)) - throw new UserError(`This personal mail already exists`); - - if (code === 'ER_DUP_ENTRY' && message.includes(`CodigoTrabajador_UNIQUE`)) - throw new UserError(`This worker code already exists`); - - if (code === 'ER_DUP_ENTRY' && message.includes(`PRIMARY`)) - throw new UserError(`This worker already exists`); - - throw error; + if (e.message && e.message.includes('Invalid email')) throw new UserError('Invalid email'); + if (e.message && e.message.includes(`Email already exists`)) throw new UserError(`This personal mail already exists`); + if (code === 'ER_DUP_ENTRY' && message.includes(`CodigoTrabajador_UNIQUE`)) throw new UserError(`This worker code already exists`); + if (code === 'ER_DUP_ENTRY' && message.includes(`PRIMARY`)) throw new UserError(`This worker already exists`); + throw e; } - await models.VnUser.resetPassword({ - email: args.email, - emailTemplate: 'worker-welcome', - id: client.id - }); + await models.VnUser.resetPassword({email, emailTemplate: 'worker-welcome', id: user.id}); - return {id: client.id}; + return {id: user.id}; }; }; diff --git a/modules/worker/back/methods/worker/specs/createAbsence.spec.js b/modules/worker/back/methods/worker/specs/createAbsence.spec.js index aadaca99b..fcb1c1633 100644 --- a/modules/worker/back/methods/worker/specs/createAbsence.spec.js +++ b/modules/worker/back/methods/worker/specs/createAbsence.spec.js @@ -133,7 +133,8 @@ describe('Worker createAbsence()', () => { expect(error.message).toEqual(`Cannot add holidays on this day`); }); - it(`should throw an error when adding a absence if the worker has hours recorded that day and not is a half absence`, async() => { + it(`should throw an error when adding a absence if the worker ` + + `has hours recorded that day and not is a half absence`, async() => { const ctx = { req: {accessToken: {userId: 19}}, args: { diff --git a/modules/worker/back/methods/worker/specs/mySubordinates.spec.js b/modules/worker/back/methods/worker/specs/mySubordinates.spec.js index 7eb118d9c..7443827ce 100644 --- a/modules/worker/back/methods/worker/specs/mySubordinates.spec.js +++ b/modules/worker/back/methods/worker/specs/mySubordinates.spec.js @@ -1,8 +1,8 @@ const app = require('vn-loopback/server/server'); describe('worker mySubordinates()', () => { + const ctx = beforeAll.getCtx(); it('should return an array of subordinates greather than 1', async() => { - let ctx = {req: {accessToken: {userId: 9}}}; let result = await app.models.Worker.mySubordinates(ctx); expect(result.length).toBeGreaterThan(1); diff --git a/modules/worker/back/methods/worker/specs/new.spec.js b/modules/worker/back/methods/worker/specs/new.spec.js index 66959e0a7..d9e843064 100644 --- a/modules/worker/back/methods/worker/specs/new.spec.js +++ b/modules/worker/back/methods/worker/specs/new.spec.js @@ -1,189 +1,110 @@ -const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); +const {models} = require('vn-loopback/server/server'); describe('Worker new', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); - + const developerId = 9; const employeeId = 1; - const defaultWorker = { - fi: '78457139E', - name: 'defaulterworker', - firstName: 'DEFAULT', - lastNames: 'WORKER', - email: 'defaultWorker@mydomain.com', - street: 'S/ DEFAULTWORKERSTREET', - city: 'defaultWorkerCity', - provinceFk: 1, - companyFk: 442, - postcode: '46680', - phone: '123456789', - code: 'DWW', - bossFk: 9, - birth: '2022-12-11T23:00:00.000Z', - payMethodFk: 1, - roleFk: 1 - }; + const bruceWayneId = 1101; + const accessToken = {accessToken: {userId: developerId}}; + const ctx = {req: accessToken}; + let tx; + let opts; - const req = {accessToken: {userId: 9}}; + beforeAll.mockLoopBackContext(); - it('should return error if personal mail already exists', async() => { - const user = await models.VnUser.findById(employeeId, {fields: ['email']}); - - const tx = await models.Worker.beginTransaction({}); - - let error; - try { - const options = {transaction: tx}; - const ctx = { - args: Object.assign({}, defaultWorker, {email: user.email}), - req - }; - - await models.Worker.new(ctx, options); - - await tx.rollback(); - } catch (e) { - error = e; - await tx.rollback(); - } - - expect(error.message).toEqual('This personal mail already exists'); - }); - - it('should return error if worker code already exists', async() => { - const worker = await models.Worker.findById(employeeId, {fields: ['code']}); - - const tx = await models.Worker.beginTransaction({}); - - let error; - try { - const options = {transaction: tx}; - const ctx = { - args: Object.assign({}, defaultWorker, {code: worker.code}), - req - }; - - await models.Worker.new(ctx, options); - - await tx.rollback(); - } catch (e) { - error = e; - await tx.rollback(); - } - - expect(error.message).toEqual('This worker code already exists'); - }); - - it('should return error if worker already exists', async() => { - const worker = await models.Client.findById(employeeId, {fields: ['fi']}); - - const tx = await models.Worker.beginTransaction({}); - - let error; - try { - const options = {transaction: tx}; - const ctx = { - args: Object.assign({}, defaultWorker, {fi: worker.fi}), - req - }; - await models.Worker.new(ctx, options); - - await tx.rollback(); - } catch (e) { - error = e; - await tx.rollback(); - } - - expect(error.message).toEqual('This worker already exists'); - }); - - it('should return error if payMethod require iban', async() => { - const payMethodIbanRequired = await models.PayMethod.findOne({ - where: { - isIbanRequiredForClients: true - }, - fields: ['id'] + describe('should return error', () => { + beforeEach(async() => { + tx = await models.Worker.beginTransaction({}); + opts = {transaction: tx}; }); - const tx = await models.Worker.beginTransaction({}); + afterEach(async() => await tx.rollback()); - let error; - try { - const options = {transaction: tx}; - const ctx = { - args: Object.assign({}, defaultWorker, {payMethodFk: payMethodIbanRequired.id}), - req - }; - await models.Worker.new(ctx, options); + it('if personal mail already exists', async() => { + const user = await models.VnUser.findById(employeeId, {fields: ['email']}); + try { + await createWorker(ctx, opts, {email: user.email}); + } catch (e) { + expect(e.message).toEqual('This personal mail already exists'); + } + }); - await tx.rollback(); - } catch (e) { - error = e; - await tx.rollback(); - } + it('if worker code already exists', async() => { + const worker = await models.Worker.findById(employeeId, {fields: ['code']}); + try { + await createWorker(ctx, opts, {code: worker.code}); + } catch (e) { + expect(e.message).toEqual('This worker code already exists'); + } + }); - expect(error.message).toEqual('That payment method requires an IBAN'); + it('if worker already exists', async() => { + const worker = await models.Client.findById(employeeId, {fields: ['fi']}); + try { + await createWorker(ctx, opts, {fi: worker.fi}); + } catch (e) { + expect(e.message).toEqual('This worker already exists'); + } + }); + + it('if payMethod require iban', async() => { + const payMethodIbanRequired = await models.PayMethod.findOne({ + fields: ['id'], where: {isIbanRequiredForClients: true} + }); + + try { + await createWorker(ctx, opts, {payMethodFk: payMethodIbanRequired.id}); + } catch (e) { + expect(e.message).toEqual('That payment method requires an IBAN'); + } + }); }); it('should create a new worker', async() => { let newWorker; try { - newWorker = await models.Worker.new({args: defaultWorker, req}); + newWorker = await createWorker(ctx); + + expect(newWorker.id).toBeDefined(); } finally { await removeWorker(newWorker.id); } - - expect(newWorker.id).toBeDefined(); }); it('should create a new client', async() => { let newWorker; - let client; try { - newWorker = await models.Worker.new({args: defaultWorker, req}); - client = await models.Client.findById(newWorker.id); + newWorker = await createWorker(ctx); + let client = await models.Client.findById(newWorker.id); + + expect(client).toBeDefined(); } finally { await removeWorker(newWorker.id); } - - expect(client).toBeDefined(); }); it('should create a new worker in client', async() => { - const bruceWayneId = 1101; const client = await models.Client.findById(bruceWayneId, {fields: ['fi', 'email']}); - - const newWorkerData = { - args: Object.assign( - {}, - defaultWorker, - { - fi: client.fi, - email: client.email - }), - req - }; let newWorker; try { - newWorker = await models.Worker.new(newWorkerData); + newWorker = await createWorker(ctx, undefined, {fi: client.fi, email: client.email}); + + expect(newWorker.id).toEqual(bruceWayneId); } finally { await models.Worker.destroyById(newWorker.id); } + }); - expect(newWorker.id).toEqual(bruceWayneId); + it('should create a new external worker', async() => { + let newWorker; + try { + newWorker = await createWorker(ctx, undefined, {isFreelance: true}); + const client = await models.Client.findById(newWorker.id); + + expect(newWorker.id).toBeDefined(); + expect(client).toBeNull(); + } finally { + await removeWorker(newWorker.id); + } }); }); @@ -194,3 +115,28 @@ async function removeWorker(id) { await models.Client.destroyById(id); await models.VnUser.destroyById(id); } + +async function createWorker(ctx, opts = undefined, params = {}) { + return models.Worker.new( + ctx, + params.fi ?? '78457139E', + params.name ?? 'defaulterworker', + params.firstName ?? 'DEFAULT', + params.lastNames ?? 'WORKER', + params.email ?? 'defaultWorker@mydomain.com', + params.street ?? 'S/ DEFAULTWORKERSTREET', + params.city ?? 'defaultWorkerCity', + params.provinceFk ?? 1, + params.companyFk ?? 442, + params.postcode ?? '46680', + params.phone ?? '123456789', + params.code ?? 'DWW', + params.bossFk ?? 9, + params.birth ?? '2022-12-11T23:00:00.000Z', + params.payMethodFk ?? 1, + undefined, + undefined, + params.isFreelance ?? false, + opts + ); +} diff --git a/modules/worker/back/methods/worker/specs/setPassword.spec.js b/modules/worker/back/methods/worker/specs/setPassword.spec.js index 8d152bdd1..b9b20ce94 100644 --- a/modules/worker/back/methods/worker/specs/setPassword.spec.js +++ b/modules/worker/back/methods/worker/specs/setPassword.spec.js @@ -42,7 +42,9 @@ describe('worker setPassword()', () => { await tx.rollback(); } catch (e) { - expect(e.message).toEqual(`This password can only be changed by the user themselves`); + expect(e.message).toEqual( + 'Through this procedure, it is not possible to modify the password of users with verified email' + ); await tx.rollback(); } }); diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index b7c355511..7bfc667ac 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -124,6 +124,27 @@ }, "Locker": { "dataSource": "vn" + }, + "MedicalReview": { + "dataSource": "vn" + }, + "MedicalCenter": { + "dataSource": "vn" + }, + "PayrollComponent": { + "dataSource": "vn" + }, + "WorkerIncome": { + "dataSource": "vn" + }, + "TrainingCourse": { + "dataSource": "vn" + }, + "TrainingCourseType": { + "dataSource": "vn" + }, + "TrainingCenter": { + "dataSource": "vn" } } diff --git a/modules/worker/back/models/calendar.json b/modules/worker/back/models/calendar.json index 40d29c519..4c68c7793 100644 --- a/modules/worker/back/models/calendar.json +++ b/modules/worker/back/models/calendar.json @@ -1,9 +1,8 @@ { "name": "Calendar", "base": "VnModel", - "log": { - "model": "WorkerLog", - "relation": "labour" + "mixins": { + "Loggable": true }, "options": { "mysql": { diff --git a/modules/worker/back/models/device-production-user.js b/modules/worker/back/models/device-production-user.js index 81af484d3..8eead58e0 100644 --- a/modules/worker/back/models/device-production-user.js +++ b/modules/worker/back/models/device-production-user.js @@ -3,6 +3,9 @@ module.exports = Self => { Self.rewriteDbError(function(err) { if (err.code === 'ER_DUP_ENTRY') return new UserError(`This PDA is already assigned to another user`); + + if (err.code === 'ER_SIGNAL_EXCEPTION' && err.sqlMessage === 'You can only have one active PDA') + return new UserError(err.sqlMessage); return err; }); }; diff --git a/modules/worker/back/models/device.js b/modules/worker/back/models/device.js index cda7a958f..6a7d5dba5 100644 --- a/modules/worker/back/models/device.js +++ b/modules/worker/back/models/device.js @@ -1,6 +1,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { + require('../methods/device/handle-user')(Self); Self.rewriteDbError(function(err) { if (err.code === 'ER_DUP_ENTRY') return new UserError(``); diff --git a/modules/worker/back/models/medical-center.json b/modules/worker/back/models/medical-center.json new file mode 100644 index 000000000..5f0a3bbd7 --- /dev/null +++ b/modules/worker/back/models/medical-center.json @@ -0,0 +1,19 @@ +{ + "name": "MedicalCenter", + "base": "VnModel", + "options": { + "mysql": { + "table": "medicalCenter" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "name": { + "type": "string" + } + } +} diff --git a/modules/worker/back/models/medical-review.json b/modules/worker/back/models/medical-review.json new file mode 100644 index 000000000..6fe7d7a01 --- /dev/null +++ b/modules/worker/back/models/medical-review.json @@ -0,0 +1,52 @@ +{ + "name": "MedicalReview", + "base": "VnModel", + "options": { + "mysql": { + "table": "medicalReview" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "workerFk": { + "type": "number" + }, + "centerFk": { + "type": "number" + }, + "date": { + "type": "date" + }, + "time": { + "type": "string" + }, + "isFit": { + "type": "boolean" + }, + "amount": { + "type": "number" + }, + "invoice": { + "type": "string" + }, + "remark": { + "type": "string" + } + }, + "relations": { + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "center": { + "type": "belongsTo", + "model": "MedicalCenter", + "foreignKey": "centerFk" + } + } +} diff --git a/modules/worker/back/models/operator.js b/modules/worker/back/models/operator.js index d46f3d934..70e20af5b 100644 --- a/modules/worker/back/models/operator.js +++ b/modules/worker/back/models/operator.js @@ -20,7 +20,7 @@ module.exports = Self => { const notifications = await models.NotificationQueue.find( {where: {created: {gte: new Date(Date.vnNow() - (backupPrinterNotificationDelay * 1000))}, notificationFk: notificationName, - status: 'sent' + status: {neq: 'error'} } }); diff --git a/modules/worker/back/models/operator.json b/modules/worker/back/models/operator.json index a2f3ee01c..d4832bccf 100644 --- a/modules/worker/back/models/operator.json +++ b/modules/worker/back/models/operator.json @@ -26,29 +26,33 @@ }, "labelerFk": { "type": "number" + }, + "isOnReservationMode": { + "type": "boolean", + "required": true } - }, + }, "relations": { - "sector": { - "type": "belongsTo", - "model": "Sector", - "foreignKey": "sectorFk" - }, + "sector": { + "type": "belongsTo", + "model": "Sector", + "foreignKey": "sectorFk" + }, "train": { - "type": "belongsTo", - "model": "Train", - "foreignKey": "trainFk" - }, + "type": "belongsTo", + "model": "Train", + "foreignKey": "trainFk" + }, "printer": { - "type": "belongsTo", - "model": "Printer", - "foreignKey": "labelerFk" - }, + "type": "belongsTo", + "model": "Printer", + "foreignKey": "labelerFk" + }, "itemPackingType": { - "type": "belongsTo", - "model": "ItemPackingType", - "foreignKey": "itemPackingTypeFk", + "type": "belongsTo", + "model": "ItemPackingType", + "foreignKey": "itemPackingTypeFk", "primaryKey": "code" - } - } -} + } + } +} \ No newline at end of file diff --git a/modules/worker/back/models/payroll-component.json b/modules/worker/back/models/payroll-component.json new file mode 100644 index 000000000..92b6c3835 --- /dev/null +++ b/modules/worker/back/models/payroll-component.json @@ -0,0 +1,27 @@ +{ + "name": "PayrollComponent", + "base": "VnModel", + "options": { + "mysql": { + "table": "payrollComponent" + } + }, + "properties": { + "id": { + "id": true, + "type": "number" + }, + "name": { + "type": "string" + }, + "isSalaryAgreed": { + "type": "number" + }, + "isVariable": { + "type": "number" + }, + "isException": { + "type": "number" + } + } +} diff --git a/modules/worker/back/models/specs/locker.spec.js b/modules/worker/back/models/specs/locker.spec.js index 32abb830e..96fca2405 100644 --- a/modules/worker/back/models/specs/locker.spec.js +++ b/modules/worker/back/models/specs/locker.spec.js @@ -6,8 +6,9 @@ describe('locker model ', () => { const hrId = 37; const jessicaJonesId = 1110; const bruceBannerId = 1109; - const lockerMaleId = 1; - const lockerFemaleId = 147; + const lockerMaleId = 3; + const lockerFemaleId = 5; + const lockerNewFemaleId = 6; let ctx; let options; let tx; @@ -46,11 +47,13 @@ describe('locker model ', () => { }); it('should change a locker', async() => { - const locker = await models.Locker.findById(148, null, options); - await locker.updateAttributes({workerFk: jessicaJonesId}, options); const oldLocker = await models.Locker.findById(lockerFemaleId, null, options); + const locker = await models.Locker.findById(lockerNewFemaleId, null, options); + await locker.updateAttributes({workerFk: jessicaJonesId}, options); + const oldNowLocker = await models.Locker.findById(lockerFemaleId, null, options); + expect(oldLocker.workerFk).toEqual(jessicaJonesId); expect(locker.workerFk).toEqual(jessicaJonesId); - expect(oldLocker.workerFk).toEqual(null); + expect(oldNowLocker.workerFk).toEqual(null); }); }); diff --git a/modules/worker/back/models/trainingCenter.json b/modules/worker/back/models/trainingCenter.json new file mode 100644 index 000000000..8c5e47873 --- /dev/null +++ b/modules/worker/back/models/trainingCenter.json @@ -0,0 +1,21 @@ +{ + "name": "TrainingCenter", + "base": "VnModel", + "options": { + "mysql": { + "table": "trainingCenter" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "name": { + "type": "string", + "required": true + } + + } +} diff --git a/modules/worker/back/models/trainingCourse.json b/modules/worker/back/models/trainingCourse.json new file mode 100644 index 000000000..af466e13e --- /dev/null +++ b/modules/worker/back/models/trainingCourse.json @@ -0,0 +1,66 @@ +{ + "name": "TrainingCourse", + "description": "List of workers who have completed training", + "base": "VnModel", + "options": { + "mysql": { + "table": "trainingCourse" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "workerFk": { + "type": "number", + "required": true + }, + "trainingCourseTypeFk": { + "type": "number", + "required": true + }, + "centerFk": { + "type" : "number" + }, + "started": { + "type" : "date" + }, + "ended": { + "type" : "date" + }, + "invoice": { + "type" : "string" + }, + "amount": { + "type" : "number" + }, + "remark": { + "type" : "boolean" + }, + "hasDiscount": { + "type" : "boolean" + }, + "hasDiploma": { + "type" : "boolean" + } + }, + "relations": { + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "trainingCourseType": { + "type": "belongsTo", + "model": "TrainingCourseType", + "foreignKey": "trainingCourseTypeFk" + }, + "trainingCenter": { + "type": "belongsTo", + "model": "TrainingCenter", + "foreignKey": "centerFk" + } + } +} diff --git a/modules/worker/back/models/trainingCourseType.json b/modules/worker/back/models/trainingCourseType.json new file mode 100644 index 000000000..9bf8fc671 --- /dev/null +++ b/modules/worker/back/models/trainingCourseType.json @@ -0,0 +1,21 @@ +{ + "name": "TrainingCourseType", + "description": "List of trainings", + "base": "VnModel", + "options": { + "mysql": { + "table": "trainingCourseType" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "name": { + "type": "string", + "required": true + } + } +} diff --git a/modules/worker/back/models/worker-dms.json b/modules/worker/back/models/worker-dms.json index a5c0f30b2..ef5684025 100644 --- a/modules/worker/back/models/worker-dms.json +++ b/modules/worker/back/models/worker-dms.json @@ -6,7 +6,7 @@ }, "options": { "mysql": { - "table": "workerDocument" + "table": "workerDms" } }, "properties": { @@ -16,17 +16,11 @@ }, "dmsFk": { "type": "number", - "required": true, - "mysql": { - "columnName": "document" - } + "required": true }, "workerFk": { "type": "number", - "required": true, - "mysql": { - "columnName": "worker" - } + "required": true }, "isReadableByWorker": { "type": "boolean" diff --git a/modules/worker/back/models/worker-income.json b/modules/worker/back/models/worker-income.json new file mode 100644 index 000000000..3a7f3407a --- /dev/null +++ b/modules/worker/back/models/worker-income.json @@ -0,0 +1,45 @@ +{ + "name": "WorkerIncome", + "base": "VnModel", + "options": { + "mysql": { + "table": "workerIncome" + } + }, + "properties": { + "id": { + "id": true, + "type": "number" + }, + "debit": { + "type": "number" + }, + "credit": { + "type": "number" + }, + "incomeTypeFk": { + "type": "number" + }, + "paymentDate": { + "type": "date" + }, + "workerFk": { + "type": "number" + }, + "concept": { + "type": "string" + } + }, + "relations": { + "payrollComponent": { + "type": "belongsTo", + "model": "PayrollComponent", + "foreignKey": "id" + }, + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + } + } +} diff --git a/modules/worker/back/models/worker-time-control-mail.json b/modules/worker/back/models/worker-time-control-mail.json index 87eae9217..192178c2d 100644 --- a/modules/worker/back/models/worker-time-control-mail.json +++ b/modules/worker/back/models/worker-time-control-mail.json @@ -32,13 +32,5 @@ "sendedCounter": { "type": "number" } - }, - "acls": [ - { - "accessType": "READ", - "principalType": "ROLE", - "principalId": "employee", - "permission": "ALLOW" - } - ] -} + } +} \ No newline at end of file diff --git a/modules/worker/back/models/worker-time-control.js b/modules/worker/back/models/worker-time-control.js index 1457c7a46..92f1bacf0 100644 --- a/modules/worker/back/models/worker-time-control.js +++ b/modules/worker/back/models/worker-time-control.js @@ -6,7 +6,7 @@ module.exports = Self => { require('../methods/worker-time-control/deleteTimeEntry')(Self); require('../methods/worker-time-control/updateTimeEntry')(Self); require('../methods/worker-time-control/sendMail')(Self); - require('../methods/worker-time-control/updateWorkerTimeControlMail')(Self); + require('../methods/worker-time-control/updateMailState')(Self); require('../methods/worker-time-control/weeklyHourRecordEmail')(Self); require('../methods/worker-time-control/getMailStates')(Self); require('../methods/worker-time-control/resendWeeklyHourEmail')(Self); diff --git a/modules/worker/back/models/worker-time-control.json b/modules/worker/back/models/worker-time-control.json index e2b74875a..3d408c18f 100644 --- a/modules/worker/back/models/worker-time-control.json +++ b/modules/worker/back/models/worker-time-control.json @@ -36,15 +36,24 @@ "model": "VnUser", "foreignKey": "userFk" }, - "worker": { - "type": "hasOne", - "model": "Worker", - "foreignKey": "id" + "worker": { + "type": "hasOne", + "model": "Worker", + "foreignKey": "id" }, "warehouse": { "type": "belongsTo", "model": "Warehouse", "foreignKey": "warehouseFk" } - } -} + }, + "acls": [ + { + "property": "updateMailState", + "accessType": "WRITE", + "permission": "ALLOW", + "principalType": "ROLE", + "principalId": "$owner" + } + ] +} \ No newline at end of file diff --git a/modules/worker/back/models/worker.js b/modules/worker/back/models/worker.js index 0b0e043f2..3351c348c 100644 --- a/modules/worker/back/models/worker.js +++ b/modules/worker/back/models/worker.js @@ -27,11 +27,10 @@ module.exports = Self => { }); async function tinIsValid(err, done) { - const filter = { + const country = await Self.app.models.Country.findOne({ fields: ['code'], - where: {id: this.countryFk} - }; - const country = await Self.app.models.Country.findOne(filter); + where: {id: this.originCountryFk} + }); const code = country ? country.code.toLowerCase() : null; if (!this.fi || !validateTin(this.fi, code)) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 4e7617aab..c334c0d05 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -25,43 +25,41 @@ "required": true }, "phone": { - "type" : "string" + "type": "string" }, "bossFk": { - "type" : "number" + "type": "number" }, "maritalStatus": { - "type" : "string" + "type": "string" }, "originCountryFk": { - "type" : "number" + "type": "number" }, "educationLevelFk": { - "type" : "number" + "type": "number" }, "SSN": { - "type" : "string" + "type": "string" }, "mobileExtension": { - "type" : "number" + "type": "number" }, "code": { - "type" : "string" + "type": "string", + "required": true }, "fi": { - "type" : "string" + "type": "string" }, "birth": { - "type" : "date" - }, - "isF11Allowed": { - "type" : "boolean" + "type": "date" }, "sex": { - "type" : "string" + "type": "string" }, "isFreelance": { - "type" : "boolean" + "type": "boolean" }, "fiDueDate": { "type": "date" @@ -78,7 +76,6 @@ "isSsDiscounted": { "type": "boolean" } - }, "relations": { "user": { @@ -115,15 +112,175 @@ "type": "hasMany", "model": "Locker", "foreignKey": "workerFk" + }, + "medicalReview": { + "type": "hasMany", + "model": "MedicalReview", + "foreignKey": "workerFk" + }, + "incomes": { + "type": "hasMany", + "model": "WorkerIncome", + "foreignKey": "workerFk" + }, + "trainingCourse": { + "type": "hasMany", + "model": "TrainingCourse", + "foreignKey": "workerFk" + }, + "mail": { + "type": "hasMany", + "model": "WorkerTimeControlMail", + "foreignKey": "workerFk" } }, - "acls":[ + "acls": [ { "property": "__get__locker", "accessType": "READ", "permission": "ALLOW", "principalType": "ROLE", "principalId": "$owner" + }, + { + "property": "__get__mail", + "accessType": "READ", + "permission": "ALLOW", + "principalType": "ROLE", + "principalId": "$owner" } - ] -} + ], + "scopes": { + "descriptor": { + "fields": [ + "id", + "phone" + ], + "include": [ + { + "relation": "user", + "scope": { + "fields": [ + "name", + "nickname" + ], + "include": { + "relation": "emailUser", + "scope": { + "fields": [ + "email" + ] + } + } + } + }, + { + "relation": "department", + "scope": { + "fields": [ + "departmentFk" + ], + "include": [ + { + "relation": "department", + "scope": { + "fields": [ + "id", + "name" + ] + } + } + ] + } + }, + { + "relation": "sip", + "scope": { + "fields": [ + "extension" + ] + } + } + ] + }, + "summary": { + "include": [ + { + "relation": "user", + "scope": { + "fields": [ + "name", + "nickname", + "roleFk" + ], + "include": [ + { + "relation": "role", + "scope": { + "fields": [ + "name" + ] + } + }, + { + "relation": "emailUser", + "scope": { + "fields": [ + "email" + ] + } + } + ] + } + }, + { + "relation": "department", + "scope": { + "include": { + "relation": "department", + "scope": { + "fields": [ + "name" + ] + } + } + } + }, + { + "relation": "boss" + }, + { + "relation": "client" + }, + { + "relation": "sip", + "scope": { + "include": { + "relation": "queueMember", + "scope": { + "fields": [ + "queue", + "extension" + ] + } + } + } + } + ] + }, + "advancedSummary": { + "fields": [ + "id", + "fiDueDate", + "sex", + "seniority", + "fi", + "isFreelance", + "isSsDiscounted", + "hasMachineryAuthorized", + "isDisable", + "birth" + ] + } + } +} \ No newline at end of file diff --git a/modules/worker/front/basic-data/index.html b/modules/worker/front/basic-data/index.html deleted file mode 100644 index aa3f6ca79..000000000 --- a/modules/worker/front/basic-data/index.html +++ /dev/null @@ -1,93 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/worker/front/basic-data/index.js b/modules/worker/front/basic-data/index.js deleted file mode 100644 index ea75d7b97..000000000 --- a/modules/worker/front/basic-data/index.js +++ /dev/null @@ -1,27 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.maritalStatus = [ - {code: 'M', name: this.$t('Married')}, - {code: 'S', name: this.$t('Single')} - ]; - } - onSubmit() { - return this.$.watcher.submit() - .then(() => this.card.reload()); - } -} - -ngModule.vnComponent('vnWorkerBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - worker: '<' - }, - require: { - card: '^vnWorkerCard' - } -}); diff --git a/modules/worker/front/basic-data/locale/es.yml b/modules/worker/front/basic-data/locale/es.yml deleted file mode 100644 index edf08de90..000000000 --- a/modules/worker/front/basic-data/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Marital status: Estado civil -Origin country: País origen -Education level: Nivel educación -SSN: NSS -Married: Casado/a -Single: Soltero/a -Business phone: Teléfono de empresa -Mobile extension: Extensión móvil -Locker: Taquilla diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html deleted file mode 100644 index 1b0608633..000000000 --- a/modules/worker/front/calendar/index.html +++ /dev/null @@ -1,114 +0,0 @@ - - -
-
- - - - - - -
-
-
- Autonomous worker -
- -
-
-
{{'Contract' | translate}} #{{$ctrl.businessId}}
-
- {{'Used' | translate}} {{$ctrl.contractHolidays.holidaysEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.contractHolidays.totalHolidays || 0}} {{'days' | translate}} -
-
- {{'Spent' | translate}} {{$ctrl.contractHolidays.hoursEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.contractHolidays.totalHours || 0}} {{'hours' | translate}} -
-
- {{'Paid holidays' | translate}} {{$ctrl.contractHolidays.payedHolidays || 0}} {{'days' | translate}} -
-
- -
-
{{'Year' | translate}} {{$ctrl.year}}
-
- {{'Used' | translate}} {{$ctrl.yearHolidays.holidaysEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.yearHolidays.totalHolidays || 0}} {{'days' | translate}} -
-
- {{'Spent' | translate}} {{$ctrl.yearHolidays.hoursEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.yearHolidays.totalHours || 0}} {{'hours' | translate}} -
-
- -
- - - - -
#{{businessFk}}
-
- {{started | date: 'dd/MM/yyyy'}} - {{ended ? (ended | date: 'dd/MM/yyyy') : 'Indef.'}} -
-
-
-
-
- - - - - - {{absenceType.name}} - -
-
- - - - Festive - - - - - Current day - -
-
-
- - - - diff --git a/modules/worker/front/calendar/index.js b/modules/worker/front/calendar/index.js deleted file mode 100644 index 5606ad0ce..000000000 --- a/modules/worker/front/calendar/index.js +++ /dev/null @@ -1,302 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.date = Date.vnNew(); - this.events = {}; - this.buildYearFilter(); - } - - get year() { - return this.date.getFullYear(); - } - - set year(value) { - const newYear = Date.vnNew(); - newYear.setFullYear(value); - - this.date = newYear; - - this.refresh() - .then(() => this.repaint()) - .then(() => this.getContractHolidays()) - .then(() => this.getYearHolidays()); - } - - get businessId() { - return this._businessId; - } - - set businessId(value) { - if (!this.card.hasWorkCenter) return; - - this._businessId = value; - if (value) { - this.refresh() - .then(() => this.repaint()) - .then(() => this.getContractHolidays()) - .then(() => this.getYearHolidays()); - } - } - - get date() { - return this._date; - } - - set date(value) { - this._date = value; - value.setHours(0, 0, 0, 0); - - this.months = new Array(12); - - for (let i = 0; i < this.months.length; i++) { - const now = new Date(value.getTime()); - now.setDate(1); - now.setMonth(i); - this.months[i] = now; - } - } - - get worker() { - return this._worker; - } - - set worker(value) { - this._worker = value; - if (value) { - this.getIsSubordinate(); - this.getActiveContract(); - } - } - - buildYearFilter() { - const now = Date.vnNew(); - now.setFullYear(now.getFullYear() + 1); - - const maxYear = now.getFullYear(); - const minRange = maxYear - 5; - - const years = []; - for (let i = maxYear; i > minRange; i--) - years.push({year: i}); - - this.yearFilter = years; - } - - getIsSubordinate() { - this.$http.get(`Workers/${this.worker.id}/isSubordinate`) - .then(res => this.isSubordinate = res.data); - } - - getActiveContract() { - this.$http.get(`Workers/${this.worker.id}/activeContract`) - .then(res => { - if (res.data) this.businessId = res.data.businessFk; - }); - } - - getContractHolidays() { - this.getHolidays({ - businessFk: this.businessId, - year: this.year - }, data => this.contractHolidays = data); - } - - getYearHolidays() { - this.getHolidays({ - year: this.year - }, data => this.yearHolidays = data); - } - - getHolidays(params, cb) { - this.$http.get(`Workers/${this.worker.id}/holidays`, {params}) - .then(res => cb(res.data)); - } - - onData(data) { - this.events = {}; - this.calendar = data.calendar; - - let addEvent = (day, newEvent) => { - const timestamp = new Date(day).getTime(); - const event = this.events[timestamp]; - - if (event) { - const oldName = event.name; - Object.assign(event, newEvent); - event.name = `${oldName}, ${event.name}`; - } else - this.events[timestamp] = newEvent; - }; - - if (data.holidays) { - data.holidays.forEach(holiday => { - const holidayDetail = holiday.detail && holiday.detail.name; - const holidayType = holiday.type && holiday.type.name; - const holidayName = holidayDetail || holidayType; - - addEvent(holiday.dated, { - name: holidayName, - className: 'festive' - }); - }); - } - if (data.absences) { - data.absences.forEach(absence => { - let type = absence.absenceType; - addEvent(absence.dated, { - name: type.name, - color: type.rgb, - type: type.code, - absenceId: absence.id - }); - }); - } - } - - repaint() { - let calendars = this.element.querySelectorAll('vn-calendar'); - for (let calendar of calendars) - calendar.$ctrl.repaint(); - } - - formatDay(day, element) { - let event = this.events[day.getTime()]; - if (!event) return; - - let dayNumber = element.firstElementChild; - dayNumber.title = event.name; - dayNumber.style.backgroundColor = event.color; - - if (event.border) - dayNumber.style.border = event.border; - - if (event.className) - dayNumber.classList.add(event.className); - } - - pick(absenceType) { - if (!this.isSubordinate) return; - if (absenceType == this.absenceType) - absenceType = null; - - this.absenceType = absenceType; - } - - onSelection($event, $days) { - if (!this.absenceType) - return this.vnApp.showMessage(this.$t('Choose an absence type from the right menu')); - - const day = $days[0]; - const stamp = day.getTime(); - const event = this.events[stamp]; - const calendar = $event.target.closest('vn-calendar').$ctrl; - - if (event && event.absenceId) { - if (event.type == this.absenceType.code) - this.delete(calendar, day, event); - else - this.edit(calendar, event); - } else - this.create(calendar, day); - } - - create(calendar, dated) { - const absenceType = this.absenceType; - const params = { - dated: dated, - absenceTypeId: absenceType.id, - businessFk: this.businessId - }; - - const path = `Workers/${this.$params.id}/createAbsence`; - this.$http.post(path, params).then(res => { - const newEvent = res.data; - this.events[dated.getTime()] = { - name: absenceType.name, - color: absenceType.rgb, - type: absenceType.code, - absenceId: newEvent.id - }; - - this.repaintCanceller(() => - this.refresh() - .then(calendar.repaint()) - .then(() => this.getContractHolidays()) - .then(() => this.getYearHolidays()) - .then(() => this.repaint()) - ); - }); - } - - edit(calendar, event) { - const absenceType = this.absenceType; - const params = { - absenceId: event.absenceId, - absenceTypeId: absenceType.id - }; - const path = `Workers/${this.$params.id}/updateAbsence`; - this.$http.patch(path, params).then(() => { - event.color = absenceType.rgb; - event.name = absenceType.name; - event.type = absenceType.code; - - this.repaintCanceller(() => - this.refresh() - .then(calendar.repaint()) - .then(() => this.getContractHolidays()) - .then(() => this.getYearHolidays()) - ); - }); - } - - delete(calendar, day, event) { - const params = {absenceId: event.absenceId}; - const path = `Workers/${this.$params.id}/deleteAbsence`; - this.$http.delete(path, {params}).then(() => { - delete this.events[day.getTime()]; - - this.repaintCanceller(() => - this.refresh() - .then(calendar.repaint()) - .then(() => this.getContractHolidays()) - .then(() => this.getYearHolidays()) - .then(() => this.repaint()) - ); - }); - } - - repaintCanceller(cb) { - if (this.canceller) { - clearTimeout(this.canceller); - this.canceller = null; - } - - this.canceller = setTimeout( - () => cb(), 500); - } - - refresh() { - const params = { - workerFk: this.$params.id, - businessFk: this.businessId, - year: this.year - }; - return this.$http.get(`Calendars/absences`, {params}) - .then(res => this.onData(res.data)); - } -} - -ngModule.vnComponent('vnWorkerCalendar', { - template: require('./index.html'), - controller: Controller, - bindings: { - worker: '<' - }, - require: { - card: '^vnWorkerCard' - } -}); diff --git a/modules/worker/front/calendar/index.spec.js b/modules/worker/front/calendar/index.spec.js deleted file mode 100644 index 5d7ae0795..000000000 --- a/modules/worker/front/calendar/index.spec.js +++ /dev/null @@ -1,346 +0,0 @@ -import './index'; - -describe('Worker', () => { - describe('Component vnWorkerCalendar', () => { - let $httpBackend; - let $httpParamSerializer; - let $scope; - let controller; - let year = Date.vnNew().getFullYear(); - - beforeEach(ngModule('worker')); - - beforeEach(inject(($componentController, $rootScope, _$httpParamSerializer_, _$httpBackend_) => { - $scope = $rootScope.$new(); - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - const $element = angular.element(''); - controller = $componentController('vnWorkerCalendar', {$element, $scope}); - controller.isSubordinate = true; - controller.absenceType = {id: 1, name: 'Holiday', code: 'holiday', rgb: 'red'}; - controller.$params.id = 1106; - controller._worker = {id: 1106}; - controller.card = { - hasWorkCenter: true - }; - })); - - describe('year() getter', () => { - it(`should return the year number of the calendar date`, () => { - expect(controller.year).toEqual(year); - }); - }); - - describe('year() setter', () => { - it(`should set the year of the calendar date`, () => { - jest.spyOn(controller, 'refresh').mockReturnValue(Promise.resolve()); - - const previousYear = year - 1; - controller.year = previousYear; - - expect(controller.year).toEqual(previousYear); - expect(controller.date.getFullYear()).toEqual(previousYear); - expect(controller.refresh).toHaveBeenCalledWith(); - }); - }); - - describe('businessId() setter', () => { - it(`should set the contract id and then call to the refresh method`, () => { - jest.spyOn(controller, 'refresh').mockReturnValue(Promise.resolve()); - - controller.businessId = 1106; - - expect(controller.refresh).toHaveBeenCalledWith(); - }); - }); - - describe('months property', () => { - it(`should return an array of twelve months length`, () => { - const started = new Date(year, 0, 1); - const ended = new Date(year, 11, 1); - - expect(controller.months.length).toEqual(12); - expect(controller.months[0]).toEqual(started); - expect(controller.months[11]).toEqual(ended); - }); - }); - - describe('worker() setter', () => { - it(`should perform a get query and set the reponse data on the model`, () => { - controller.getIsSubordinate = jest.fn(); - controller.getActiveContract = jest.fn(); - - let today = Date.vnNew(); - let tomorrow = new Date(today.getTime()); - tomorrow.setDate(tomorrow.getDate() + 1); - - let yesterday = new Date(today.getTime()); - yesterday.setDate(yesterday.getDate() - 1); - - controller.worker = {id: 1107}; - - expect(controller.getIsSubordinate).toHaveBeenCalledWith(); - expect(controller.getActiveContract).toHaveBeenCalledWith(); - }); - }); - - describe('getIsSubordinate()', () => { - it(`should return whether the worker is a subordinate`, () => { - $httpBackend.expect('GET', `Workers/1106/isSubordinate`).respond(true); - controller.getIsSubordinate(); - $httpBackend.flush(); - - expect(controller.isSubordinate).toBe(true); - }); - }); - - describe('getActiveContract()', () => { - it(`should return the current contract and then set the businessId property`, () => { - jest.spyOn(controller, 'refresh').mockReturnValue(Promise.resolve()); - - $httpBackend.expect('GET', `Workers/1106/activeContract`).respond({businessFk: 1106}); - controller.getActiveContract(); - $httpBackend.flush(); - - expect(controller.businessId).toEqual(1106); - }); - }); - - describe('getContractHolidays()', () => { - it(`should return the worker holidays amount and then set the contractHolidays property`, () => { - const today = Date.vnNew(); - const year = today.getFullYear(); - - const serializedParams = $httpParamSerializer({year}); - $httpBackend.expect('GET', `Workers/1106/holidays?${serializedParams}`).respond({totalHolidays: 28}); - controller.getContractHolidays(); - $httpBackend.flush(); - - expect(controller.contractHolidays).toEqual({totalHolidays: 28}); - }); - }); - - describe('formatDay()', () => { - it(`should set the day element style`, () => { - const today = Date.vnNew(); - - controller.events[today.getTime()] = { - name: 'Holiday', - color: '#000' - }; - - const dayElement = angular.element('
')[0]; - const dayNumber = dayElement.firstElementChild; - - controller.formatDay(today, dayElement); - - expect(dayNumber.title).toEqual('Holiday'); - expect(dayNumber.style.backgroundColor).toEqual('rgb(0, 0, 0)'); - }); - }); - - describe('pick()', () => { - it(`should set the absenceType property to null if they match with the current one`, () => { - const absenceType = {id: 1, name: 'Holiday'}; - controller.absenceType = absenceType; - controller.pick(absenceType); - - expect(controller.absenceType).toBeNull(); - }); - - it(`should set the absenceType property`, () => { - const absenceType = {id: 1, name: 'Holiday'}; - const expectedAbsence = {id: 2, name: 'Leave of absence'}; - controller.absenceType = absenceType; - controller.pick(expectedAbsence); - - expect(controller.absenceType).toEqual(expectedAbsence); - }); - }); - - describe('onSelection()', () => { - it(`should show an snackbar message if no absence type is selected`, () => { - jest.spyOn(controller.vnApp, 'showMessage').mockReturnThis(); - - const $event = {}; - const $days = []; - controller.absenceType = null; - controller.onSelection($event, $days); - - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Choose an absence type from the right menu'); - }); - - it(`should call to the create() method`, () => { - jest.spyOn(controller, 'create').mockReturnThis(); - - const selectedDay = Date.vnNew(); - const $event = { - target: { - closest: () => { - return {$ctrl: {}}; - } - } - }; - const $days = [selectedDay]; - controller.absenceType = {id: 1}; - controller.onSelection($event, $days); - - expect(controller.create).toHaveBeenCalledWith(jasmine.any(Object), selectedDay); - }); - - it(`should call to the delete() method`, () => { - jest.spyOn(controller, 'delete').mockReturnThis(); - - const selectedDay = Date.vnNew(); - const expectedEvent = { - dated: selectedDay, - type: 'holiday', - absenceId: 1 - }; - const $event = { - target: { - closest: () => { - return {$ctrl: {}}; - } - } - }; - const $days = [selectedDay]; - controller.events[selectedDay.getTime()] = expectedEvent; - controller.absenceType = {id: 1, code: 'holiday'}; - controller.onSelection($event, $days); - - expect(controller.delete).toHaveBeenCalledWith(jasmine.any(Object), selectedDay, expectedEvent); - }); - - it(`should call to the edit() method`, () => { - jest.spyOn(controller, 'edit').mockReturnThis(); - - const selectedDay = Date.vnNew(); - const expectedEvent = { - dated: selectedDay, - type: 'leaveOfAbsence', - absenceId: 1 - }; - const $event = { - target: { - closest: () => { - return {$ctrl: {}}; - } - } - }; - const $days = [selectedDay]; - controller.events[selectedDay.getTime()] = expectedEvent; - controller.absenceType = {id: 1, code: 'holiday'}; - controller.onSelection($event, $days); - - expect(controller.edit).toHaveBeenCalledWith(jasmine.any(Object), expectedEvent); - }); - }); - - describe('create()', () => { - it(`should make a HTTP POST query and then call to the repaintCanceller() method`, () => { - jest.spyOn(controller, 'repaintCanceller').mockReturnThis(); - - const dated = Date.vnNew(); - const calendarElement = {}; - const expectedResponse = {id: 10}; - - $httpBackend.expect('POST', `Workers/1106/createAbsence`).respond(200, expectedResponse); - controller.create(calendarElement, dated); - $httpBackend.flush(); - - const createdEvent = controller.events[dated.getTime()]; - const absenceType = controller.absenceType; - - expect(createdEvent.absenceId).toEqual(expectedResponse.id); - expect(createdEvent.color).toEqual(absenceType.rgb); - expect(controller.repaintCanceller).toHaveBeenCalled(); - }); - }); - - describe('edit()', () => { - it(`should make a HTTP PATCH query and then call to the repaintCanceller() method`, () => { - jest.spyOn(controller, 'repaintCanceller').mockReturnThis(); - - const event = {absenceId: 10}; - const calendarElement = {}; - const newAbsenceType = { - id: 2, - name: 'Leave of absence', - code: 'leaveOfAbsence', - rgb: 'purple' - }; - controller.absenceType = newAbsenceType; - - const expectedParams = {absenceId: 10, absenceTypeId: 2}; - $httpBackend.expect('PATCH', `Workers/1106/updateAbsence`, expectedParams).respond(200); - controller.edit(calendarElement, event); - $httpBackend.flush(); - - expect(event.name).toEqual(newAbsenceType.name); - expect(event.color).toEqual(newAbsenceType.rgb); - expect(event.type).toEqual(newAbsenceType.code); - expect(controller.repaintCanceller).toHaveBeenCalled(); - }); - }); - - describe('delete()', () => { - it(`should make a HTTP DELETE query and then call to the repaintCanceller() method`, () => { - jest.spyOn(controller, 'repaintCanceller').mockReturnThis(); - - const expectedParams = {absenceId: 10}; - const calendarElement = {}; - const selectedDay = Date.vnNew(); - const expectedEvent = { - dated: selectedDay, - type: 'leaveOfAbsence', - absenceId: 10 - }; - - controller.events[selectedDay.getTime()] = expectedEvent; - - const serializedParams = $httpParamSerializer(expectedParams); - $httpBackend.expect('DELETE', `Workers/1106/deleteAbsence?${serializedParams}`).respond(200); - controller.delete(calendarElement, selectedDay, expectedEvent); - $httpBackend.flush(); - - const event = controller.events[selectedDay.getTime()]; - - expect(event).toBeUndefined(); - expect(controller.repaintCanceller).toHaveBeenCalled(); - }); - }); - - describe('repaintCanceller()', () => { - it(`should cancell the callback execution timer`, () => { - jest.spyOn(window, 'clearTimeout'); - jest.spyOn(window, 'setTimeout'); - - const timeoutId = 90; - controller.canceller = timeoutId; - - controller.repaintCanceller(() => { - return 'My callback'; - }); - - expect(window.clearTimeout).toHaveBeenCalledWith(timeoutId); - expect(window.setTimeout).toHaveBeenCalledWith(jasmine.any(Function), 500); - }); - }); - - describe('refresh()', () => { - it(`should make a HTTP GET query and then call to the onData() method`, () => { - jest.spyOn(controller, 'onData').mockReturnThis(); - - const expecteResponse = [{id: 1}]; - const expectedParams = {workerFk: controller.worker.id, year: year}; - const serializedParams = $httpParamSerializer(expectedParams); - $httpBackend.expect('GET', `Calendars/absences?${serializedParams}`).respond(200, expecteResponse); - controller.refresh(); - $httpBackend.flush(); - - expect(controller.onData).toHaveBeenCalledWith(expecteResponse); - }); - }); - }); -}); diff --git a/modules/worker/front/calendar/locale/es.yml b/modules/worker/front/calendar/locale/es.yml deleted file mode 100644 index 50bb4bb52..000000000 --- a/modules/worker/front/calendar/locale/es.yml +++ /dev/null @@ -1,15 +0,0 @@ -Calendar: Calendario -Contract: Contrato -Festive: Festivo -Used: Utilizados -Spent: Utilizadas -Year: Año -of: de -days: días -hours: horas -Choose an absence type from the right menu: Elige un tipo de ausencia desde el menú de la derecha -To start adding absences, click an absence type from the right menu and then on the day you want to add an absence: Para empezar a añadir ausencias, haz clic en un tipo de ausencia desde el menu de la derecha y después en el día que quieres añadir la ausencia -You can just add absences within the current year: Solo puedes añadir ausencias dentro del año actual -Current day: Día actual -Paid holidays: Vacaciones pagadas -Autonomous worker: Trabajador autónomo diff --git a/modules/worker/front/calendar/style.scss b/modules/worker/front/calendar/style.scss deleted file mode 100644 index e99f64689..000000000 --- a/modules/worker/front/calendar/style.scss +++ /dev/null @@ -1,65 +0,0 @@ -@import "variables"; - -vn-worker-calendar { - .calendars { - position: relative; - display: flex; - flex-wrap: wrap; - justify-content: center; - align-items: center; - box-sizing: border-box; - padding: $spacing-md; - - & > vn-calendar { - border: $border-thin; - margin: $spacing-md; - padding: $spacing-xs; - max-width: 288px; - } - } - - vn-chip.selectable { - cursor: pointer - } - - vn-chip.selectable:hover { - opacity: 0.8 - } - - vn-chip vn-avatar { - text-align: center; - color: white - } - - vn-icon[icon="info"] { - position: absolute; - top: 16px; - right: 16px - } - - vn-side-menu div > .input { - border-bottom: $border-thin; - } - - .festive, - vn-avatar.today { - color: $color-font; - width: 24px; - min-width: 24px; - height: 24px - } - - .festive { - border: 2px solid $color-alert - } - - vn-avatar.today { - border: 2px solid $color-font-link - } - - .check { - margin-top: 0.5px; - margin-left: -3px; - font-size: 125%; - } -} diff --git a/modules/worker/front/create/index.html b/modules/worker/front/create/index.html deleted file mode 100644 index 3030ffecd..000000000 --- a/modules/worker/front/create/index.html +++ /dev/null @@ -1,198 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - {{code}} - {{town.name}} ({{town.province.name}}, - {{town.province.country.name}}) - - - - - - - - {{name}} ({{country.name}}) - - - - - - {{name}}, {{province.name}} - ({{province.country.name}}) - - - - - - - - - - - - - - - - - - - - - - - - {{bic}} {{name}} - - - - - - - - - - - - - -
- - - diff --git a/modules/worker/front/create/index.js b/modules/worker/front/create/index.js deleted file mode 100644 index e6d65221f..000000000 --- a/modules/worker/front/create/index.js +++ /dev/null @@ -1,141 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.worker = {companyFk: this.vnConfig.user.companyFk}; - this.$http.get(`WorkerConfigs/findOne`, {field: ['payMethodFk']}).then(res => { - if (res.data) this.worker.payMethodFk = res.data.payMethodFk; - }); - } - - onSubmit() { - if (!this.worker.iban && !this.worker.bankEntityFk) { - delete this.worker.iban; - delete this.worker.bankEntityFk; - } - - return this.$.watcher.submit().then(json => { - this.$state.go('worker.card.basicData', {id: json.data.id}); - }); - } - - get ibanCountry() { - if (!this.worker || !this.worker.iban) return false; - - let countryCode = this.worker.iban.substr(0, 2); - - return countryCode; - } - - autofillBic() { - if (!this.worker || !this.worker.iban) return; - - let bankEntityId = parseInt(this.worker.iban.substr(4, 4)); - let filter = {where: {id: bankEntityId}}; - - this.$http.get(`BankEntities`, {filter}).then(response => { - const hasData = response.data && response.data[0]; - - if (hasData) - this.worker.bankEntityFk = response.data[0].id; - else if (!hasData) - this.worker.bankEntityFk = null; - }); - } - - generateCodeUser() { - if (!this.worker.firstName || !this.worker.lastNames) return; - - const totalName = this.worker.firstName.concat(' ' + this.worker.lastNames).toLowerCase(); - const totalNameArray = totalName.split(' '); - let newCode = ''; - - for (let part of totalNameArray) - newCode += part.charAt(0); - - this.worker.code = newCode.toUpperCase().slice(0, 3); - this.worker.name = totalNameArray[0] + newCode.slice(1); - - if (!this.worker.companyFk) - this.worker.companyFk = this.vnConfig.user.companyFk; - } - - get province() { - return this._province; - } - - // Province auto complete - set province(selection) { - this._province = selection; - - if (!selection) return; - - const country = selection.country; - - if (!this.worker.countryFk) - this.worker.countryFk = country.id; - } - - get town() { - return this._town; - } - - // Town auto complete - set town(selection) { - this._town = selection; - - if (!selection) return; - - const province = selection.province; - const country = province.country; - const postcodes = selection.postcodes; - - if (!this.worker.provinceFk) - this.worker.provinceFk = province.id; - - if (!this.worker.countryFk) - this.worker.countryFk = country.id; - - if (postcodes.length === 1) - this.worker.postcode = postcodes[0].code; - } - - get postcode() { - return this._postcode; - } - - // Postcode auto complete - set postcode(selection) { - this._postcode = selection; - - if (!selection) return; - - const town = selection.town; - const province = town.province; - const country = province.country; - - if (!this.worker.city) - this.worker.city = town.name; - - if (!this.worker.provinceFk) - this.worker.provinceFk = province.id; - - if (!this.worker.countryFk) - this.worker.countryFk = country.id; - } - - onResponse(response) { - this.worker.postcode = response.code; - this.worker.city = response.city; - this.worker.provinceFk = response.provinceFk; - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnWorkerCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/worker/front/create/index.spec.js b/modules/worker/front/create/index.spec.js deleted file mode 100644 index c2e9acce0..000000000 --- a/modules/worker/front/create/index.spec.js +++ /dev/null @@ -1,133 +0,0 @@ -import './index'; - -describe('Worker', () => { - describe('Component vnWorkerCreate', () => { - let $scope; - let $state; - let controller; - - beforeEach(ngModule('worker')); - - beforeEach(inject(($componentController, $rootScope, _$state_) => { - $scope = $rootScope.$new(); - $state = _$state_; - $scope.watcher = { - submit: () => { - return { - then: callback => { - callback({data: {id: '1234'}}); - } - }; - } - }; - const $element = angular.element(''); - controller = $componentController('vnWorkerCreate', {$element, $scope}); - controller.worker = {}; - controller.vnConfig = {user: {companyFk: 1}}; - })); - - describe('onSubmit()', () => { - it(`should call submit() on the watcher then expect a callback`, () => { - jest.spyOn($state, 'go'); - controller.onSubmit(); - - expect(controller.$state.go).toHaveBeenCalledWith('worker.card.basicData', {id: '1234'}); - }); - }); - - describe('province() setter', () => { - it(`should set countryFk property`, () => { - controller.worker.countryFk = null; - controller.province = { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }; - - expect(controller.worker.countryFk).toEqual(2); - }); - }); - - describe('town() setter', () => { - it(`should set provinceFk property`, () => { - controller.town = { - provinceFk: 1, - code: 46001, - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }, - postcodes: [] - }; - - expect(controller.worker.provinceFk).toEqual(1); - }); - - it(`should set provinceFk property and fill the postalCode if there's just one`, () => { - controller.town = { - provinceFk: 1, - code: 46001, - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }, - postcodes: [{code: '46001'}] - }; - - expect(controller.worker.provinceFk).toEqual(1); - expect(controller.worker.postcode).toEqual('46001'); - }); - }); - - describe('postcode() setter', () => { - it(`should set the town, provinceFk and contryFk properties`, () => { - controller.postcode = { - townFk: 1, - code: 46001, - town: { - id: 1, - name: 'New York', - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - } - } - }; - - expect(controller.worker.city).toEqual('New York'); - expect(controller.worker.provinceFk).toEqual(1); - expect(controller.worker.countryFk).toEqual(2); - }); - }); - - describe('generateCodeUser()', () => { - it(`should generate worker code, name and company `, () => { - controller.worker = { - firstName: 'default', - lastNames: 'generate worker' - }; - - controller.generateCodeUser(); - - expect(controller.worker.code).toEqual('DGW'); - expect(controller.worker.name).toEqual('defaultgw'); - expect(controller.worker.companyFk).toEqual(controller.vnConfig.user.companyFk); - }); - }); - }); -}); diff --git a/modules/worker/front/create/locale/es.yml b/modules/worker/front/create/locale/es.yml deleted file mode 100644 index 4e8d2df1e..000000000 --- a/modules/worker/front/create/locale/es.yml +++ /dev/null @@ -1,13 +0,0 @@ -Firstname: Nombre -Lastname: Apellidos -Fi: DNI/NIF/NIE -Birth: Fecha de nacimiento -Worker code: Código de trabajador -Province: Provincia -City: Población -ProfileType: Tipo de perfil -Street: Dirección -Postcode: Código postal -Web user: Usuario Web -Access permission: Permiso de acceso -Pay method: Método de pago diff --git a/modules/worker/front/descriptor/index.html b/modules/worker/front/descriptor/index.html index 73332efac..a77f986ed 100644 --- a/modules/worker/front/descriptor/index.html +++ b/modules/worker/front/descriptor/index.html @@ -11,7 +11,7 @@ ? 'Click to allow the user to be disabled' : 'Click to exclude the user from getting disabled'}} - + Change password diff --git a/modules/worker/front/descriptor/index.js b/modules/worker/front/descriptor/index.js index 75265acb4..4860163c1 100644 --- a/modules/worker/front/descriptor/index.js +++ b/modules/worker/front/descriptor/index.js @@ -36,42 +36,8 @@ 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' - } - } - } - ] - }; - - return this.getData(`Workers/${this.id}`, {filter}) - .then(res => this.entity = res.data); + return this.getData('Workers/descriptor', {filter: {where: {id: this.id}}}) + .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..8797c8b4a 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/descriptor').respond(response); controller.id = id; $httpBackend.flush(); - expect(controller.worker).toEqual(response); + expect(controller.worker).toEqual(response[0]); }); }); diff --git a/modules/worker/front/dms/create/index.html b/modules/worker/front/dms/create/index.html deleted file mode 100644 index 0f2d51dd3..000000000 --- a/modules/worker/front/dms/create/index.html +++ /dev/null @@ -1,94 +0,0 @@ - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/modules/worker/front/dms/create/index.js b/modules/worker/front/dms/create/index.js deleted file mode 100644 index ff6112211..000000000 --- a/modules/worker/front/dms/create/index.js +++ /dev/null @@ -1,113 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.dms = { - files: [], - hasFile: false, - hasFileAttached: false - }; - } - - get worker() { - return this._worker; - } - - set worker(value) { - this._worker = value; - - if (value) { - this.setDefaultParams(); - this.getAllowedContentTypes(); - } - } - - getAllowedContentTypes() { - this.$http.get('DmsContainers/allowedContentTypes').then(res => { - const contentTypes = res.data.join(', '); - this.allowedContentTypes = contentTypes; - }); - } - - get contentTypesInfo() { - return this.$t('ContentTypesInfo', { - allowedContentTypes: this.allowedContentTypes - }); - } - - setDefaultParams() { - const params = {filter: { - where: {code: 'hhrrData'} - }}; - this.$http.get('DmsTypes/findOne', {params}).then(res => { - const dmsType = res.data && res.data; - const companyId = this.vnConfig.companyFk; - const warehouseId = this.vnConfig.warehouseFk; - const defaultParams = { - reference: this.worker.id, - warehouseId: warehouseId, - companyId: companyId, - dmsTypeId: dmsType.id, - description: this.$t('WorkerFileDescription', { - dmsTypeName: dmsType.name, - workerId: this.worker.id, - workerName: this.worker.name - }).toUpperCase() - }; - - this.dms = Object.assign(this.dms, defaultParams); - }); - } - - onSubmit() { - const query = `Workers/${this.worker.id}/uploadFile`; - const options = { - method: 'POST', - url: query, - params: this.dms, - headers: { - 'Content-Type': undefined - }, - transformRequest: files => { - const formData = new FormData(); - - for (let i = 0; i < files.length; i++) - formData.append(files[i].name, files[i]); - - return formData; - }, - data: this.dms.files - }; - this.$http(options).then(res => { - if (res) { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.$.watcher.updateOriginalData(); - this.$state.go('worker.card.dms.index'); - } - }); - } - - onFileChange(files) { - let hasFileAttached = false; - - if (files.length > 0) - hasFileAttached = true; - - this.$.$applyAsync(() => { - this.dms.hasFileAttached = hasFileAttached; - }); - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnWorkerDmsCreate', { - template: require('./index.html'), - controller: Controller, - bindings: { - worker: '<' - } -}); diff --git a/modules/worker/front/dms/create/index.spec.js b/modules/worker/front/dms/create/index.spec.js deleted file mode 100644 index 08a2a5981..000000000 --- a/modules/worker/front/dms/create/index.spec.js +++ /dev/null @@ -1,77 +0,0 @@ -import './index'; - -describe('Client', () => { - describe('Component vnWorkerDmsCreate', () => { - let $element; - let controller; - let $scope; - let $httpBackend; - let $httpParamSerializer; - - beforeEach(ngModule('worker')); - - beforeEach(inject(($compile, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { - $scope = $rootScope.$new(); - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - $element = $compile(``)($rootScope); - controller = $element.controller('vnWorkerDmsCreate'); - controller._worker = {id: 1101, name: 'Bruce wayne'}; - $httpBackend.whenRoute('GET', `Warehouses?filter=%7B%7D`).respond([{$oldData: {}}]); - })); - - describe('worker() setter', () => { - it('should set the worker data and then call setDefaultParams() and getAllowedContentTypes()', () => { - jest.spyOn(controller, 'setDefaultParams'); - jest.spyOn(controller, 'getAllowedContentTypes'); - controller.worker = { - id: 15, - name: 'Bruce wayne' - }; - - expect(controller.worker).toBeDefined(); - expect(controller.setDefaultParams).toHaveBeenCalledWith(); - expect(controller.getAllowedContentTypes).toHaveBeenCalledWith(); - }); - }); - - describe('setDefaultParams()', () => { - it('should perform a GET query and define the dms property on controller', () => { - $httpBackend.whenRoute('GET', `DmsTypes`).respond({id: 12, code: 'hhrrData'}); - const params = {filter: { - where: {code: 'hhrrData'} - }}; - let serializedParams = $httpParamSerializer(params); - $httpBackend.when('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: 12, code: 'hhrrData'}); - controller.setDefaultParams(); - $httpBackend.flush(); - - expect(controller.dms).toBeDefined(); - expect(controller.dms.reference).toEqual(1101); - expect(controller.dms.dmsTypeId).toEqual(12); - }); - }); - - describe('onFileChange()', () => { - it('should set dms hasFileAttached property to true if has any files', () => { - const files = [{id: 1, name: 'MyFile'}]; - controller.onFileChange(files); - $scope.$apply(); - - expect(controller.dms.hasFileAttached).toBeTruthy(); - }); - }); - - describe('getAllowedContentTypes()', () => { - it('should make an HTTP GET request to get the allowed content types', () => { - const expectedResponse = ['image/png', 'image/jpg']; - $httpBackend.expect('GET', `DmsContainers/allowedContentTypes`).respond(expectedResponse); - controller.getAllowedContentTypes(); - $httpBackend.flush(); - - expect(controller.allowedContentTypes).toBeDefined(); - expect(controller.allowedContentTypes).toEqual('image/png, image/jpg'); - }); - }); - }); -}); diff --git a/modules/worker/front/dms/create/style.scss b/modules/worker/front/dms/create/style.scss deleted file mode 100644 index 73f136fc1..000000000 --- a/modules/worker/front/dms/create/style.scss +++ /dev/null @@ -1,7 +0,0 @@ -vn-ticket-request { - .vn-textfield { - margin: 0!important; - max-width: 100px; - } -} - diff --git a/modules/worker/front/dms/edit/index.html b/modules/worker/front/dms/edit/index.html deleted file mode 100644 index 39d4af801..000000000 --- a/modules/worker/front/dms/edit/index.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/modules/worker/front/dms/edit/index.js b/modules/worker/front/dms/edit/index.js deleted file mode 100644 index 31d4c2853..000000000 --- a/modules/worker/front/dms/edit/index.js +++ /dev/null @@ -1,94 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - get worker() { - return this._worker; - } - - set worker(value) { - this._worker = value; - - if (value) { - this.setDefaultParams(); - this.getAllowedContentTypes(); - } - } - - getAllowedContentTypes() { - this.$http.get('DmsContainers/allowedContentTypes').then(res => { - const contentTypes = res.data.join(', '); - this.allowedContentTypes = contentTypes; - }); - } - - get contentTypesInfo() { - return this.$t('ContentTypesInfo', { - allowedContentTypes: this.allowedContentTypes - }); - } - - setDefaultParams() { - const path = `Dms/${this.$params.dmsId}`; - this.$http.get(path).then(res => { - const dms = res.data && res.data; - this.dms = { - reference: dms.reference, - warehouseId: dms.warehouseFk, - companyId: dms.companyFk, - dmsTypeId: dms.dmsTypeFk, - description: dms.description, - hasFile: dms.hasFile, - hasFileAttached: false, - files: [] - }; - }); - } - - onSubmit() { - const query = `dms/${this.$params.dmsId}/updateFile`; - const options = { - method: 'POST', - url: query, - params: this.dms, - headers: { - 'Content-Type': undefined - }, - transformRequest: files => { - const formData = new FormData(); - - for (let i = 0; i < files.length; i++) - formData.append(files[i].name, files[i]); - - return formData; - }, - data: this.dms.files - }; - this.$http(options).then(res => { - if (res) { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.$.watcher.updateOriginalData(); - this.$state.go('worker.card.dms.index'); - } - }); - } - - onFileChange(files) { - let hasFileAttached = false; - if (files.length > 0) - hasFileAttached = true; - - this.$.$applyAsync(() => { - this.dms.hasFileAttached = hasFileAttached; - }); - } -} - -ngModule.vnComponent('vnWorkerDmsEdit', { - template: require('./index.html'), - controller: Controller, - bindings: { - worker: '<' - } -}); diff --git a/modules/worker/front/dms/edit/index.spec.js b/modules/worker/front/dms/edit/index.spec.js deleted file mode 100644 index 0b69f2894..000000000 --- a/modules/worker/front/dms/edit/index.spec.js +++ /dev/null @@ -1,82 +0,0 @@ -import './index'; - -describe('Worker', () => { - describe('Component vnClientDmsEdit', () => { - let controller; - let $scope; - let $element; - let $httpBackend; - - beforeEach(ngModule('worker')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $scope = $rootScope.$new(); - $httpBackend = _$httpBackend_; - $element = angular.element(` { - it('should set the worker data and then call setDefaultParams() and getAllowedContentTypes()', () => { - jest.spyOn(controller, 'setDefaultParams'); - jest.spyOn(controller, 'getAllowedContentTypes'); - controller._worker = undefined; - controller.worker = { - id: 1106 - }; - - expect(controller.setDefaultParams).toHaveBeenCalledWith(); - expect(controller.worker).toBeDefined(); - expect(controller.getAllowedContentTypes).toHaveBeenCalledWith(); - }); - }); - - describe('setDefaultParams()', () => { - it('should perform a GET query and define the dms property on controller', () => { - const dmsId = 4; - const expectedResponse = { - reference: 1101, - warehouseFk: 1, - companyFk: 442, - dmsTypeFk: 3, - description: 'Test', - hasFile: false, - hasFileAttached: false - }; - - $httpBackend.expect('GET', `Dms/${dmsId}`).respond(expectedResponse); - controller.setDefaultParams(); - $httpBackend.flush(); - - expect(controller.dms).toBeDefined(); - expect(controller.dms.reference).toEqual(1101); - expect(controller.dms.dmsTypeId).toEqual(3); - }); - }); - - describe('onFileChange()', () => { - it('should set dms hasFileAttached property to true if has any files', () => { - const files = [{id: 1, name: 'MyFile'}]; - controller.dms = {hasFileAttached: false}; - controller.onFileChange(files); - $scope.$apply(); - - expect(controller.dms.hasFileAttached).toBeTruthy(); - }); - }); - - describe('getAllowedContentTypes()', () => { - it('should make an HTTP GET request to get the allowed content types', () => { - const expectedResponse = ['image/png', 'image/jpg']; - $httpBackend.expect('GET', `DmsContainers/allowedContentTypes`).respond(expectedResponse); - controller.getAllowedContentTypes(); - $httpBackend.flush(); - - expect(controller.allowedContentTypes).toBeDefined(); - expect(controller.allowedContentTypes).toEqual('image/png, image/jpg'); - }); - }); - }); -}); diff --git a/modules/worker/front/dms/edit/style.scss b/modules/worker/front/dms/edit/style.scss deleted file mode 100644 index 73f136fc1..000000000 --- a/modules/worker/front/dms/edit/style.scss +++ /dev/null @@ -1,7 +0,0 @@ -vn-ticket-request { - .vn-textfield { - margin: 0!important; - max-width: 100px; - } -} - diff --git a/modules/worker/front/dms/index/index.html b/modules/worker/front/dms/index/index.html deleted file mode 100644 index 310fb95d1..000000000 --- a/modules/worker/front/dms/index/index.html +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - Id - Order - Reference - Description - Original - File - Created - - - - - - - - {{::document.id}} - - - {{::document.dms.hardCopyNumber}} - - - - - {{::document.dms.reference}} - - - - - {{::document.dms.description}} - - - - - - - - - {{::document.dms.file}} - - - - {{::document.dms.created | date:'dd/MM/yyyy HH:mm'}} - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/worker/front/dms/index/index.js b/modules/worker/front/dms/index/index.js deleted file mode 100644 index 6fdc46dbb..000000000 --- a/modules/worker/front/dms/index/index.js +++ /dev/null @@ -1,75 +0,0 @@ -import ngModule from '../../module'; -import Component from 'core/lib/component'; -import './style.scss'; - -class Controller extends Component { - constructor($element, $, vnFile) { - super($element, $); - this.vnFile = vnFile; - this.filter = { - include: { - relation: 'dms', - scope: { - fields: [ - 'dmsTypeFk', - 'reference', - 'hardCopyNumber', - 'workerFk', - 'description', - 'hasFile', - 'file', - 'created', - 'companyFk', - 'warehouseFk', - ], - include: [ - { - relation: 'dmsType', - scope: { - fields: ['name'], - }, - }, - { - relation: 'worker', - scope: { - fields: ['id'], - include: { - relation: 'user', - scope: { - fields: ['name'], - }, - }, - }, - }, - ], - }, - }, - }; - } - - deleteDms(index) { - const workerDmsId = this.workerDms[index].dmsFk; - return this.$http.post(`WorkerDms/${workerDmsId}/removeFile`) - .then(() => { - this.$.model.remove(index); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - downloadFile(dmsId, isDocuware) { - if (isDocuware) return this.vnFile.download(`api/workerDms/${dmsId}/docuwareDownload`); - this.vnFile.download(`api/workerDms/${dmsId}/downloadFile`); - } - - async openDocuware() { - const url = await this.vnApp.getUrl(`WebClient`, 'docuware'); - if (url) window.open(url).focus(); - } -} - -Controller.$inject = ['$element', '$scope', 'vnFile']; - -ngModule.vnComponent('vnWorkerDmsIndex', { - template: require('./index.html'), - controller: Controller, -}); diff --git a/modules/worker/front/dms/index/index.spec.js b/modules/worker/front/dms/index/index.spec.js deleted file mode 100644 index 9c1e87011..000000000 --- a/modules/worker/front/dms/index/index.spec.js +++ /dev/null @@ -1,37 +0,0 @@ -import './index'; -import crudModel from 'core/mocks/crud-model'; - -describe('Worker', () => { - describe('Component vnWorkerDmsIndex', () => { - let $scope; - let $httpBackend; - let controller; - - beforeEach(ngModule('worker')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - controller = $componentController('vnWorkerDmsIndex', {$element: null, $scope}); - controller.$.model = crudModel; - })); - - describe('deleteDms()', () => { - it('should make an HTTP Post query', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - jest.spyOn(controller.$.model, 'remove'); - - const workerDmsId = 4; - const dmsIndex = 0; - controller.workerDms = [{id: 1, dmsFk: 4}]; - - $httpBackend.expectPOST(`WorkerDms/${workerDmsId}/removeFile`).respond(); - controller.deleteDms(dmsIndex); - $httpBackend.flush(); - - expect(controller.$.model.remove).toHaveBeenCalledWith(dmsIndex); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - }); -}); diff --git a/modules/worker/front/dms/index/locale/es.yml b/modules/worker/front/dms/index/locale/es.yml deleted file mode 100644 index b6feb4206..000000000 --- a/modules/worker/front/dms/index/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Are you sure?: Estas seguro? -Download file: Descargar fichero -File: Fichero -File deleted: Fichero eliminado -Hard copy: Copia -My documentation: Mi documentacion -Remove file: Eliminar fichero -This file will be deleted: Este fichero va a ser borrado -Type: Tipo \ No newline at end of file diff --git a/modules/worker/front/dms/index/style.scss b/modules/worker/front/dms/index/style.scss deleted file mode 100644 index a6758e2e6..000000000 --- a/modules/worker/front/dms/index/style.scss +++ /dev/null @@ -1,6 +0,0 @@ -vn-client-risk-index { - .totalBox { - display: table; - float: right; - } -} \ No newline at end of file diff --git a/modules/worker/front/dms/locale/en.yml b/modules/worker/front/dms/locale/en.yml deleted file mode 100644 index 766853fca..000000000 --- a/modules/worker/front/dms/locale/en.yml +++ /dev/null @@ -1,2 +0,0 @@ -ClientFileDescription: "{{dmsTypeName}} from client {{clientName}} id {{clientId}}" -ContentTypesInfo: Allowed file types {{allowedContentTypes}} \ No newline at end of file diff --git a/modules/worker/front/dms/locale/es.yml b/modules/worker/front/dms/locale/es.yml deleted file mode 100644 index fa4178d35..000000000 --- a/modules/worker/front/dms/locale/es.yml +++ /dev/null @@ -1,20 +0,0 @@ -Reference: Referencia -Description: Descripción -Company: Empresa -Upload file: Subir fichero -Edit file: Editar fichero -Upload: Subir -File: Fichero -WorkerFileDescription: "{{dmsTypeName}} del empleado {{workerName}} id {{workerId}}" -ContentTypesInfo: "Tipos de archivo permitidos: {{allowedContentTypes}}" -Generate identifier for original file: Generar identificador para archivo original -Are you sure you want to continue?: ¿Seguro que quieres continuar? -File management: Gestión documental -Hard copy: Copia -This file will be deleted: Este fichero va a ser borrado -Are you sure?: ¿Seguro? -File deleted: Fichero eliminado -Remove file: Eliminar fichero -Download file: Descargar fichero -Created: Creado -Employee: Empleado \ No newline at end of file diff --git a/modules/worker/front/index.js b/modules/worker/front/index.js index 5c03dc8de..26cb403bb 100644 --- a/modules/worker/front/index.js +++ b/modules/worker/front/index.js @@ -1,24 +1,9 @@ export * from './module'; import './main'; -import './index/'; import './summary'; import './card'; -import './create'; import './descriptor'; import './descriptor-popover'; -import './search-panel'; -import './basic-data'; -import './pbx'; -import './pda'; import './department'; -import './calendar'; -import './time-control'; -import './log'; -import './dms/index'; -import './dms/create'; -import './dms/edit'; -import './note/index'; -import './note/create'; -import './notifications'; diff --git a/modules/worker/front/index/index.html b/modules/worker/front/index/index.html deleted file mode 100644 index 7044ca551..000000000 --- a/modules/worker/front/index/index.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - diff --git a/modules/worker/front/index/index.js b/modules/worker/front/index/index.js deleted file mode 100644 index 77dd872e1..000000000 --- a/modules/worker/front/index/index.js +++ /dev/null @@ -1,31 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - preview(event, worker) { - if (event.defaultPrevented) return; - - event.preventDefault(); - event.stopPropagation(); - - this.selectedWorker = worker; - this.$.preview.show(); - } - - goToTimeControl(event, workerId) { - if (event.defaultPrevented) return; - - event.preventDefault(); - event.stopPropagation(); - this.$state.go('worker.card.timeControl', {id: workerId}, {absolute: true}); - } - - onMoreChange(callback) { - callback.call(this); - } -} - -ngModule.vnComponent('vnWorkerIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/worker/front/index/locale/es.yml b/modules/worker/front/index/locale/es.yml deleted file mode 100644 index df6383273..000000000 --- a/modules/worker/front/index/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -New worker: Nuevo trabajador diff --git a/modules/worker/front/log/index.html b/modules/worker/front/log/index.html deleted file mode 100644 index 090dbf2e3..000000000 --- a/modules/worker/front/log/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/modules/worker/front/log/index.js b/modules/worker/front/log/index.js deleted file mode 100644 index e30ce7e22..000000000 --- a/modules/worker/front/log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnWorkerLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/worker/front/main/index.html b/modules/worker/front/main/index.html index 376c8f534..e69de29bb 100644 --- a/modules/worker/front/main/index.html +++ b/modules/worker/front/main/index.html @@ -1,18 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/modules/worker/front/main/index.js b/modules/worker/front/main/index.js index d97a2d636..29da1bcc1 100644 --- a/modules/worker/front/main/index.js +++ b/modules/worker/front/main/index.js @@ -1,7 +1,15 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; -export default class Worker extends ModuleMain {} +export default class Worker extends ModuleMain { + constructor($element, $) { + super($element, $); + } + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`worker/`); + } +} ngModule.vnComponent('vnWorker', { controller: Worker, diff --git a/modules/worker/front/note/create/index.html b/modules/worker/front/note/create/index.html deleted file mode 100644 index d09fc2da5..000000000 --- a/modules/worker/front/note/create/index.html +++ /dev/null @@ -1,30 +0,0 @@ - - -
- - - - - - - - - - - - -
\ No newline at end of file diff --git a/modules/worker/front/note/create/index.js b/modules/worker/front/note/create/index.js deleted file mode 100644 index 81ee247db..000000000 --- a/modules/worker/front/note/create/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.note = { - workerFk: parseInt(this.$params.id), - text: null - }; - } - - cancel() { - this.$state.go('worker.card.note.index', {id: this.$params.id}); - } -} - -ngModule.vnComponent('vnNoteWorkerCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/worker/front/note/create/index.spec.js b/modules/worker/front/note/create/index.spec.js deleted file mode 100644 index d900c8ee0..000000000 --- a/modules/worker/front/note/create/index.spec.js +++ /dev/null @@ -1,22 +0,0 @@ -import './index'; - -describe('Worker', () => { - describe('Component vnNoteWorkerCreate', () => { - let $state; - let controller; - - beforeEach(ngModule('worker')); - - beforeEach(inject(($componentController, _$state_) => { - $state = _$state_; - $state.params.id = '1234'; - const $element = angular.element(''); - controller = $componentController('vnNoteWorkerCreate', {$element, $state}); - })); - - it('should define workerFk using $state.params.id', () => { - expect(controller.note.workerFk).toBe(1234); - expect(controller.note.worker).toBe(undefined); - }); - }); -}); diff --git a/modules/worker/front/note/create/locale/es.yml b/modules/worker/front/note/create/locale/es.yml deleted file mode 100644 index bfe773f48..000000000 --- a/modules/worker/front/note/create/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -New note: Nueva nota -Note: Nota \ No newline at end of file diff --git a/modules/worker/front/note/index/index.html b/modules/worker/front/note/index/index.html deleted file mode 100644 index 9f5c27008..000000000 --- a/modules/worker/front/note/index/index.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - -
- - {{::note.user.nickname}} - {{::note.created | date:'dd/MM/yyyy HH:mm'}} - - - {{::note.text}} - -
-
-
- - - diff --git a/modules/worker/front/note/index/index.js b/modules/worker/front/note/index/index.js deleted file mode 100644 index d20971413..000000000 --- a/modules/worker/front/note/index/index.js +++ /dev/null @@ -1,22 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.filter = { - order: 'created DESC', - }; - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnWorkerNote', { - template: require('./index.html'), - controller: Controller, - bindings: { - worker: '<' - } -}); diff --git a/modules/worker/front/note/index/style.scss b/modules/worker/front/note/index/style.scss deleted file mode 100644 index 5ff6baf4f..000000000 --- a/modules/worker/front/note/index/style.scss +++ /dev/null @@ -1,5 +0,0 @@ -vn-worker-note { - .note:last-child { - margin-bottom: 0; - } -} \ No newline at end of file diff --git a/modules/worker/front/notifications/index.html b/modules/worker/front/notifications/index.html deleted file mode 100644 index 7fb3b870e..000000000 --- a/modules/worker/front/notifications/index.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/modules/worker/front/notifications/index.js b/modules/worker/front/notifications/index.js deleted file mode 100644 index 622892979..000000000 --- a/modules/worker/front/notifications/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - } - - async $onInit() { - const url = await this.vnApp.getUrl(`worker/${this.$params.id}/notifications`); - window.open(url).focus(); - } -} - -ngModule.vnComponent('vnWorkerNotifications', { - template: require('./index.html'), - controller: Controller, - bindings: { - ticket: '<' - } -}); diff --git a/modules/worker/front/pbx/index.html b/modules/worker/front/pbx/index.html deleted file mode 100644 index e1ca61a4a..000000000 --- a/modules/worker/front/pbx/index.html +++ /dev/null @@ -1,28 +0,0 @@ - - -
- - - - - - - - - - - - - - -
diff --git a/modules/worker/front/pbx/index.js b/modules/worker/front/pbx/index.js deleted file mode 100644 index 3b6443d3c..000000000 --- a/modules/worker/front/pbx/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - onSubmit() { - const sip = this.worker.sip; - const params = { - userFk: this.worker.id, - extension: sip.extension - }; - this.$.watcher.check(); - this.$http.patch('Sips', params).then(() => { - this.$.watcher.updateOriginalData(); - this.vnApp.showSuccess(this.$t('Data saved! User must access web')); - }); - } -} - -ngModule.vnComponent('vnWorkerPbx', { - template: require('./index.html'), - controller: Controller, - bindings: { - worker: '<' - } -}); diff --git a/modules/worker/front/pda/index.js b/modules/worker/front/pda/index.js deleted file mode 100644 index c3616b41e..000000000 --- a/modules/worker/front/pda/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - } - - async $onInit() { - const url = await this.vnApp.getUrl(`worker/${this.$params.id}/pda`); - this.$state.go('worker.card.summary', {id: this.$params.id}); - window.location.href = url; - } -} - -ngModule.vnComponent('vnWorkerPda', { - controller: Controller -}); diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json index 489b4346a..9b3a50230 100644 --- a/modules/worker/front/routes.json +++ b/modules/worker/front/routes.json @@ -9,23 +9,6 @@ {"state": "worker.index", "icon": "icon-worker"}, {"state": "worker.department", "icon": "work"} ], - "card": [ - {"state": "worker.card.basicData", "icon": "settings"}, - {"state": "worker.card.note.index", "icon": "insert_drive_file"}, - {"state": "worker.card.timeControl", "icon": "access_time"}, - {"state": "worker.card.calendar", "icon": "icon-calendar"}, - {"state": "worker.card.pda", "icon": "phone_android"}, - {"state": "worker.card.notifications", "icon": "notifications"}, - {"state": "worker.card.pbx", "icon": "icon-pbx"}, - {"state": "worker.card.dms.index", "icon": "cloud_upload"}, - { - "icon": "icon-wiki", - "external":true, - "url": "http://wiki.verdnatura.es", - "description": "Wikipedia" - }, - {"state": "worker.card.workerLog", "icon": "history"} - ], "department": [ {"state": "worker.department.card.basicData", "icon": "settings"} ] @@ -43,12 +26,14 @@ "abstract": true, "component": "vn-worker", "description": "Workers" - }, { + }, + { "url": "/index?q", "state": "worker.index", "component": "vn-worker-index", "description": "Workers" - }, { + }, + { "url" : "/summary", "state": "worker.card.summary", "component": "vn-worker-summary", @@ -56,91 +41,14 @@ "params": { "worker": "$ctrl.worker" } - }, { - "url": "/:id", - "state": "worker.card", - "component": "vn-worker-card", - "abstract": true, - "description": "Detail" - }, { - "url": "/basic-data", - "state": "worker.card.basicData", - "component": "vn-worker-basic-data", - "description": "Basic data", - "params": { - "worker": "$ctrl.worker" - }, - "acl": ["hr"] - }, { - "url" : "/log", - "state": "worker.card.workerLog", - "component": "vn-worker-log", - "description": "Log", - "acl": ["hr"] - }, { - "url": "/note", - "state": "worker.card.note", - "component": "ui-view", - "abstract": true - }, { - "url": "/index", - "state": "worker.card.note.index", - "component": "vn-worker-note", - "description": "Notes", - "params": { - "worker": "$ctrl.worker" - }, - "acl": ["hr"] - }, { - "url": "/create", - "state": "worker.card.note.create", - "component": "vn-note-worker-create", - "description": "New note" - }, { - "url": "/pbx", - "state": "worker.card.pbx", - "component": "vn-worker-pbx", - "description": "Private Branch Exchange", - "params": { - "worker": "$ctrl.worker" - }, - "acl": ["hr"] - }, { - "url": "/calendar", - "state": "worker.card.calendar", - "component": "vn-worker-calendar", - "description": "Calendar", - "params": { - "worker": "$ctrl.worker" - } - }, { - "url": "/notifications", - "state": "worker.card.notifications", - "component": "vn-worker-notifications", - "description": "Notifications", - "params": { - "worker": "$ctrl.worker" - } - }, { - "url": "/time-control?timestamp", - "state": "worker.card.timeControl", - "component": "vn-worker-time-control", - "description": "Time control", - "params": { - "worker": "$ctrl.worker" - } - }, { + }, + { "url": "/department?q", "state": "worker.department", "component": "vn-worker-department", "description":"Departments" - }, { - "url": "/:id", - "state": "worker.department.card", - "component": "vn-worker-department-card", - "abstract": true, - "description": "Detail" - }, { + }, + { "url" : "/summary", "state": "worker.department.card.summary", "component": "vn-worker-department-summary", @@ -148,62 +56,6 @@ "params": { "department": "$ctrl.department" } - }, - { - "url": "/basic-data", - "state": "worker.department.card.basicData", - "component": "vn-worker-department-basic-data", - "description": "Basic data", - "params": { - "department": "$ctrl.department" - } - }, - { - "url": "/dms", - "state": "worker.card.dms", - "abstract": true, - "component": "ui-view" - }, - { - "url": "/index", - "state": "worker.card.dms.index", - "component": "vn-worker-dms-index", - "description": "My documentation", - "acl": ["employee"] - }, - { - "url": "/create", - "state": "worker.card.dms.create", - "component": "vn-worker-dms-create", - "description": "Upload file", - "params": { - "worker": "$ctrl.worker" - }, - "acl": ["hr"] - }, - { - "url": "/:dmsId/edit", - "state": "worker.card.dms.edit", - "component": "vn-worker-dms-edit", - "description": "Edit file", - "params": { - "worker": "$ctrl.worker" - }, - "acl": ["hr"] - }, - { - "url": "/create", - "state": "worker.create", - "component": "vn-worker-create", - "description": "New worker", - "acl": ["hr"] - }, - { - "url": "/pda", - "state": "worker.card.pda", - "component": "vn-worker-pda", - "description": "PDA", - "acl": ["hr", "productionAssi"] } ] } diff --git a/modules/worker/front/search-panel/index.html b/modules/worker/front/search-panel/index.html deleted file mode 100644 index c93eef78b..000000000 --- a/modules/worker/front/search-panel/index.html +++ /dev/null @@ -1,67 +0,0 @@ -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/modules/worker/front/search-panel/index.js b/modules/worker/front/search-panel/index.js deleted file mode 100644 index ac7405e78..000000000 --- a/modules/worker/front/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.vnComponent('vnWorkerSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/worker/front/time-control/index.html b/modules/worker/front/time-control/index.html deleted file mode 100644 index c34a1e3ca..000000000 --- a/modules/worker/front/time-control/index.html +++ /dev/null @@ -1,219 +0,0 @@ - - -
- - - - - -
{{::$ctrl.weekdayNames[$index].name}}
-
- {{::weekday.dated | date: 'dd'}} - - {{::weekday.dated | date: 'MMMM'}} - -
- - - -
- {{::weekday.event.name}} -
-
-
-
-
- - - -
- - - - - - - - {{::hour.timed | date: 'HH:mm'}} - -
-
-
-
- - - - {{$ctrl.formatHours(weekday.workedHours)}} h. - - - - - - - - - -
-
- - -
- - - - - - -
- - -
-
- - -
-
-
Hours
- - - - -
- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
-
- - - - -
- - - - Are you sure you want to send it? - - - - - - diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js deleted file mode 100644 index 9a4c4b559..000000000 --- a/modules/worker/front/time-control/index.js +++ /dev/null @@ -1,508 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; -import UserError from 'core/lib/user-error'; - -class Controller extends Section { - constructor($element, $, vnWeekDays, moment) { - super($element, $); - this.weekDays = []; - this.weekdayNames = vnWeekDays.locales; - this.moment = moment; - this.entryDirections = [ - {code: 'in', description: this.$t('In')}, - {code: 'middle', description: this.$t('Intermediate')}, - {code: 'out', description: this.$t('Out')} - ]; - } - - $postLink() { - const timestamp = this.$params.timestamp; - let initialDate = Date.vnNew(); - - if (timestamp) { - initialDate = new Date(timestamp * 1000); - this.$.calendar.defaultDate = initialDate; - } - - this.date = initialDate; - - this.getMailStates(this.date); - } - - get isHr() { - return this.aclService.hasAny(['hr']); - } - - get isHimSelf() { - const userId = window.localStorage.currentUserWorkerId; - return userId == this.$params.id; - } - - get worker() { - return this._worker; - } - - get weekNumber() { - return this.getWeekNumber(this.date); - } - - set weekNumber(value) { - this._weekNumber = value; - } - - set worker(value) { - this._worker = value; - this.fetchHours(); - if (this.date) - this.getWeekData(); - } - - /** - * Worker hours data - */ - get hours() { - return this._hours; - } - - set hours(value) { - this._hours = value; - - for (const weekDay of this.weekDays) { - if (value) { - let day = weekDay.dated.getDay(); - weekDay.hours = value - .filter(hour => new Date(hour.timed).getDay() == day) - .sort((a, b) => new Date(a.timed) - new Date(b.timed)); - } else - weekDay.hours = null; - } - } - - /** - * The current selected date - */ - get date() { - return this._date; - } - - set date(value) { - this._date = value; - value.setHours(0, 0, 0, 0); - - let weekOffset = value.getDay() - 1; - if (weekOffset < 0) weekOffset = 6; - - let started = new Date(value.getTime()); - started.setDate(started.getDate() - weekOffset); - this.started = started; - - let ended = new Date(started.getTime()); - ended.setHours(23, 59, 59, 59); - ended.setDate(ended.getDate() + 6); - this.ended = ended; - - this.weekDays = []; - let dayIndex = new Date(started.getTime()); - - while (dayIndex < ended) { - this.weekDays.push({ - dated: new Date(dayIndex.getTime()) - }); - dayIndex.setDate(dayIndex.getDate() + 1); - } - - if (this.worker) { - this.fetchHours(); - this.getWeekData(); - } - } - - set weekTotalHours(totalHours) { - this._weekTotalHours = this.formatHours(totalHours); - } - - get weekTotalHours() { - return this._weekTotalHours; - } - - getWeekData() { - const filter = { - where: { - workerFk: this.$params.id, - year: this._date.getFullYear(), - week: this.getWeekNumber(this._date) - }, - }; - this.$http.get('WorkerTimeControlMails', {filter}) - .then(res => { - if (!res.data.length) { - this.state = null; - return; - } - const [mail] = res.data; - this.state = mail.state; - this.reason = mail.reason; - }); - this.canBeResend(); - } - - canBeResend() { - this.canResend = false; - const filter = { - where: { - year: this._date.getFullYear(), - week: this.getWeekNumber(this._date) - }, - limit: 1 - }; - this.$http.get('WorkerTimeControlMails', {filter}) - .then(res => { - if (res.data.length) - this.canResend = true; - }); - } - - fetchHours() { - if (!this.worker || !this.date) return; - - const params = {workerFk: this.$params.id}; - const filter = { - where: {and: [ - {timed: {gte: this.started}}, - {timed: {lte: this.ended}} - ]} - }; - this.$.model.applyFilter(filter, params).then(() => { - this.getWorkedHours(this.started, this.ended); - this.getAbsences(); - }); - } - - getWorkedHours(from, to) { - this.weekTotalHours = null; - let weekTotalHours = 0; - let params = { - id: this.$params.id, - from: from, - to: to - }; - const query = `Workers/${this.$params.id}/getWorkedHours`; - return this.$http.get(query, {params}).then(res => { - const workDays = res.data; - const map = new Map(); - - for (const workDay of workDays) { - workDay.dated = new Date(workDay.dated); - map.set(workDay.dated, workDay); - weekTotalHours += workDay.workedHours; - } - - for (const weekDay of this.weekDays) { - const workDay = workDays.find(day => { - let from = new Date(day.dated); - from.setHours(0, 0, 0, 0); - - let to = new Date(day.dated); - to.setHours(23, 59, 59, 59); - - return weekDay.dated >= from && weekDay.dated <= to; - }); - - if (workDay) { - weekDay.expectedHours = workDay.expectedHours; - weekDay.workedHours = workDay.workedHours; - } - } - this.weekTotalHours = weekTotalHours; - }); - } - - getAbsences() { - const fullYear = this.started.getFullYear(); - let params = { - workerFk: this.$params.id, - businessFk: null, - year: fullYear - }; - - return this.$http.get(`Calendars/absences`, {params}) - .then(res => this.onData(res.data)); - } - - hasEvents(day) { - return day >= this.started && day < this.ended; - } - - onData(data) { - const events = {}; - - const addEvent = (day, event) => { - events[new Date(day).getTime()] = event; - }; - - if (data.holidays) { - data.holidays.forEach(holiday => { - const holidayDetail = holiday.detail && holiday.detail.description; - const holidayType = holiday.type && holiday.type.name; - const holidayName = holidayDetail || holidayType; - - addEvent(holiday.dated, { - name: holidayName, - color: '#ff0' - }); - }); - } - if (data.absences) { - data.absences.forEach(absence => { - const type = absence.absenceType; - addEvent(absence.dated, { - name: type.name, - color: type.rgb - }); - }); - } - - this.weekDays.forEach(day => { - const timestamp = day.dated.getTime(); - if (events[timestamp]) - day.event = events[timestamp]; - }); - } - - getFinishTime() { - if (!this.weekDays) return; - - let today = Date.vnNew(); - today.setHours(0, 0, 0, 0); - - let todayInWeek = this.weekDays.find(day => day.dated.getTime() === today.getTime()); - - if (todayInWeek && todayInWeek.hours && todayInWeek.hours.length) { - const remainingTime = todayInWeek.workedHours ? - ((todayInWeek.expectedHours - todayInWeek.workedHours) * 1000) : null; - const lastKnownEntry = todayInWeek.hours[todayInWeek.hours.length - 1]; - const lastKnownTime = new Date(lastKnownEntry.timed).getTime(); - const finishTimeStamp = lastKnownTime && remainingTime ? lastKnownTime + remainingTime : null; - - if (finishTimeStamp) { - let finishDate = new Date(finishTimeStamp); - let hour = finishDate.getHours(); - let minute = finishDate.getMinutes(); - - if (hour < 10) hour = `0${hour}`; - if (minute < 10) minute = `0${minute}`; - - return `${hour}:${minute} h.`; - } - } - } - - formatHours(timestamp = 0) { - let hour = Math.floor(timestamp / 3600); - let min = Math.floor(timestamp / 60 - 60 * hour); - - if (hour < 10) hour = `0${hour}`; - if (min < 10) min = `0${min}`; - - return `${hour}:${min}`; - } - - showAddTimeDialog(weekday) { - const timed = new Date(weekday.dated.getTime()); - timed.setHours(0, 0, 0, 0); - - this.newTimeEntry = { - workerFk: this.$params.id, - timed: timed - }; - this.selectedWeekday = weekday; - this.$.addTimeDialog.show(); - } - - addTime() { - try { - const entry = this.newTimeEntry; - if (!entry.direction) - throw new Error(`The entry type can't be empty`); - - const query = `WorkerTimeControls/${this.worker.id}/addTimeEntry`; - this.$http.post(query, entry) - .then(() => { - this.fetchHours(); - this.getMailStates(this.date); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } - - return true; - } - - showDeleteDialog($event, hour) { - $event.preventDefault(); - - this.timeEntryToDelete = hour; - this.$.deleteEntryDialog.show(); - } - - deleteTimeEntry() { - const entryId = this.timeEntryToDelete.id; - - this.$http.post(`WorkerTimeControls/${entryId}/deleteTimeEntry`).then(() => { - this.fetchHours(); - this.getMailStates(this.date); - this.vnApp.showSuccess(this.$t('Entry removed')); - }); - } - - edit($event, hour) { - if ($event.defaultPrevented) return; - - this.selectedRow = hour; - this.$.editEntry.show($event); - } - - getWeekNumber(date) { - const tempDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())); - return this.moment(tempDate).isoWeek(); - } - - isSatisfied() { - this.updateWorkerTimeControlMail('CONFIRMED'); - } - - isUnsatisfied() { - if (!this.reason) throw new UserError(`You must indicate a reason`); - this.updateWorkerTimeControlMail('REVISE', this.reason); - } - - updateWorkerTimeControlMail(state, reason) { - const params = { - workerId: this.worker.id, - year: this.date.getFullYear(), - week: this.weekNumber, - state - }; - - if (reason) - params.reason = reason; - - const query = `WorkerTimeControls/updateWorkerTimeControlMail`; - this.$http.post(query, params).then(() => { - this.getMailStates(this.date); - this.getWeekData(); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - state(state, reason) { - this.state = state; - this.reason = reason; - this.repaint(); - } - - save() { - try { - const entry = this.selectedRow; - if (!entry.direction) - throw new Error(`The entry type can't be empty`); - - const query = `WorkerTimeControls/${entry.id}/updateTimeEntry`; - if (entry.direction !== entry.$orgRow.direction) { - this.$http.post(query, {direction: entry.direction}) - .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))) - .then(() => this.$.editEntry.hide()) - .then(() => this.fetchHours()) - .then(() => this.getMailStates(this.date)); - } - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - } - } - - resendEmail() { - const params = { - recipient: this.worker.user.emailUser.email, - week: this.weekNumber, - year: this.date.getFullYear(), - workerId: this.worker.id, - state: 'SENDED' - }; - this.$http.post(`WorkerTimeControls/weekly-hour-hecord-email`, params) - .then(() => { - this.getMailStates(this.date); - this.vnApp.showSuccess(this.$t('Email sended')); - }); - } - - getTime(timeString) { - const [hours, minutes, seconds] = timeString.split(':'); - return [parseInt(hours), parseInt(minutes), parseInt(seconds)]; - } - - getMailStates(date) { - const params = { - month: date.getMonth() + 1, - year: date.getFullYear() - }; - const query = `WorkerTimeControls/${this.$params.id}/getMailStates`; - this.$http.get(query, {params}) - .then(res => { - this.workerTimeControlMails = res.data; - this.repaint(); - }); - } - - formatWeek($element) { - const weekNumberHTML = $element.firstElementChild; - const weekNumberValue = weekNumberHTML.innerHTML; - - if (!this.workerTimeControlMails) return; - const workerTimeControlMail = this.workerTimeControlMails.find( - workerTimeControlMail => workerTimeControlMail.week == weekNumberValue - ); - - if (!workerTimeControlMail) return; - const state = workerTimeControlMail.state; - - if (state == 'CONFIRMED') { - weekNumberHTML.classList.remove('revise'); - weekNumberHTML.classList.remove('sended'); - - weekNumberHTML.classList.add('confirmed'); - weekNumberHTML.setAttribute('title', 'Conforme'); - } - if (state == 'REVISE') { - weekNumberHTML.classList.remove('confirmed'); - weekNumberHTML.classList.remove('sended'); - - weekNumberHTML.classList.add('revise'); - weekNumberHTML.setAttribute('title', 'No conforme'); - } - if (state == 'SENDED') { - weekNumberHTML.classList.add('sended'); - weekNumberHTML.setAttribute('title', 'Pendiente'); - } - } - - repaint() { - let calendars = this.element.querySelectorAll('vn-calendar'); - for (let calendar of calendars) - calendar.$ctrl.repaint(); - } -} - -Controller.$inject = ['$element', '$scope', 'vnWeekDays', 'moment']; - -ngModule.vnComponent('vnWorkerTimeControl', { - template: require('./index.html'), - controller: Controller, - bindings: { - worker: '<' - }, - require: { - card: '^vnWorkerCard' - } -}); diff --git a/modules/worker/front/time-control/index.spec.js b/modules/worker/front/time-control/index.spec.js deleted file mode 100644 index 8610da46e..000000000 --- a/modules/worker/front/time-control/index.spec.js +++ /dev/null @@ -1,286 +0,0 @@ -import './index.js'; - -describe('Component vnWorkerTimeControl', () => { - let $httpBackend; - let $scope; - let $element; - let controller; - let $httpParamSerializer; - - beforeEach(ngModule('worker')); - - beforeEach(inject(($componentController, $rootScope, $stateParams, _$httpBackend_, _$httpParamSerializer_) => { - $stateParams.id = 1; - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - $scope = $rootScope.$new(); - $element = angular.element(''); - controller = $componentController('vnWorkerTimeControl', {$element, $scope}); - controller.card = { - hasWorkCenter: true - }; - })); - - describe('date() setter', () => { - it(`should set the weekDays and the date in the controller`, () => { - let today = Date.vnNew(); - jest.spyOn(controller, 'fetchHours').mockReturnThis(); - - controller.date = today; - - expect(controller._date).toEqual(today); - expect(controller.started).toBeDefined(); - expect(controller.ended).toBeDefined(); - expect(controller.weekDays.length).toEqual(7); - }); - }); - - describe('hours() setter', () => { - it(`should set hours data at it's corresponding week day`, () => { - let today = Date.vnNew(); - jest.spyOn(controller, 'fetchHours').mockReturnThis(); - - controller.date = today; - - let hours = [ - { - id: 1, - timed: controller.started.toJSON(), - userFk: 1 - }, { - id: 2, - timed: controller.ended.toJSON(), - userFk: 1 - }, { - id: 3, - timed: controller.ended.toJSON(), - userFk: 1 - } - ]; - - controller.hours = hours; - - expect(controller.weekDays.length).toEqual(7); - expect(controller.weekDays[0].hours.length).toEqual(1); - expect(controller.weekDays[6].hours.length).toEqual(2); - }); - }); - - describe('getWorkedHours() ', () => { - it('should set the weekdays expected and worked hours plus the total worked hours', () => { - let today = Date.vnNew(); - jest.spyOn(controller, 'fetchHours').mockReturnThis(); - - controller.date = today; - - let sixHoursInSeconds = 6 * 60 * 60; - let tenHoursInSeconds = 10 * 60 * 60; - let response = [ - { - dated: today, - expectedHours: sixHoursInSeconds, - workedHours: tenHoursInSeconds, - - }, - ]; - $httpBackend.whenRoute('GET', 'Workers/:id/getWorkedHours') - .respond(response); - - $httpBackend.whenRoute('GET', 'WorkerTimeControlMails') - .respond([]); - - today.setHours(0, 0, 0, 0); - - let weekOffset = today.getDay() - 1; - if (weekOffset < 0) weekOffset = 6; - - let started = new Date(today.getTime()); - started.setDate(started.getDate() - weekOffset); - controller.started = started; - - let ended = new Date(started.getTime()); - ended.setHours(23, 59, 59, 59); - ended.setDate(ended.getDate() + 6); - controller.ended = ended; - - controller.getWorkedHours(controller.started, controller.ended); - $httpBackend.flush(); - - expect(controller.weekDays.length).toEqual(7); - expect(controller.weekDays[weekOffset].expectedHours).toEqual(response[0].expectedHours); - expect(controller.weekDays[weekOffset].workedHours).toEqual(response[0].workedHours); - expect(controller.weekTotalHours).toEqual('10:00'); - }); - - describe('formatHours() ', () => { - it(`should format a passed timestamp to hours and minutes`, () => { - const result = controller.formatHours(3600); - - expect(result).toEqual('01:00'); - }); - }); - - describe('save() ', () => { - it(`should make a query an then call to the fetchHours() method`, () => { - const today = Date.vnNew(); - - jest.spyOn(controller, 'getWeekData').mockReturnThis(); - jest.spyOn(controller, 'getMailStates').mockReturnThis(); - - controller.$.model = {applyFilter: jest.fn().mockReturnValue(Promise.resolve())}; - controller.date = today; - controller.fetchHours = jest.fn(); - controller.selectedRow = {id: 1, timed: Date.vnNew(), direction: 'in', $orgRow: {direction: null}}; - controller.$.editEntry = { - hide: () => {} - }; - const expectedParams = {direction: 'in'}; - $httpBackend.expect('POST', 'WorkerTimeControls/1/updateTimeEntry', expectedParams).respond(200); - controller.save(); - $httpBackend.flush(); - - expect(controller.fetchHours).toHaveBeenCalledWith(); - }); - }); - - describe('$postLink() ', () => { - it(`should set the controller date as today if no timestamp is defined`, () => { - controller.$.model = {applyFilter: jest.fn().mockReturnValue(Promise.resolve())}; - controller.$params = {timestamp: undefined}; - controller.$postLink(); - - expect(controller.date).toEqual(jasmine.any(Date)); - }); - - it(`should set the controller date using the received timestamp`, () => { - const timestamp = 1; - const date = new Date(timestamp); - - controller.$.model = {applyFilter: jest.fn().mockReturnValue(Promise.resolve())}; - controller.$.calendar = {}; - controller.$params = {timestamp: timestamp}; - - controller.$postLink(); - - expect(controller.date.toDateString()).toEqual(date.toDateString()); - }); - }); - - describe('getWeekData() ', () => { - it(`should make a query an then update the state and reason`, () => { - const today = Date.vnNew(); - const response = [ - { - state: 'SENDED', - reason: null - } - ]; - - controller._date = today; - - $httpBackend.whenRoute('GET', 'WorkerTimeControlMails') - .respond(response); - - controller.getWeekData(); - $httpBackend.flush(); - - expect(controller.state).toBe('SENDED'); - expect(controller.reason).toBe(null); - }); - }); - - describe('isSatisfied() ', () => { - it(`should make a query an then call three methods`, () => { - const today = Date.vnNew(); - jest.spyOn(controller, 'getWeekData').mockReturnThis(); - jest.spyOn(controller, 'getMailStates').mockReturnThis(); - jest.spyOn(controller.vnApp, 'showSuccess'); - - controller.$.model = {applyFilter: jest.fn().mockReturnValue(Promise.resolve())}; - controller.worker = {id: 1}; - controller.date = today; - controller.weekNumber = 1; - - $httpBackend.expect('POST', 'WorkerTimeControls/updateWorkerTimeControlMail').respond(); - controller.isSatisfied(); - $httpBackend.flush(); - - expect(controller.getMailStates).toHaveBeenCalledWith(controller.date); - expect(controller.getWeekData).toHaveBeenCalled(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('isUnsatisfied() ', () => { - it(`should throw an error is reason is empty`, () => { - let error; - try { - controller.isUnsatisfied(); - } catch (e) { - error = e; - } - - expect(error).toBeDefined(); - expect(error.message).toBe(`You must indicate a reason`); - }); - - it(`should make a query an then call three methods`, () => { - const today = Date.vnNew(); - jest.spyOn(controller, 'getWeekData').mockReturnThis(); - jest.spyOn(controller, 'getMailStates').mockReturnThis(); - jest.spyOn(controller.vnApp, 'showSuccess'); - - controller.$.model = {applyFilter: jest.fn().mockReturnValue(Promise.resolve())}; - controller.worker = {id: 1}; - controller.date = today; - controller.weekNumber = 1; - controller.reason = 'reason'; - - $httpBackend.expect('POST', 'WorkerTimeControls/updateWorkerTimeControlMail').respond(); - controller.isSatisfied(); - $httpBackend.flush(); - - expect(controller.getMailStates).toHaveBeenCalledWith(controller.date); - expect(controller.getWeekData).toHaveBeenCalled(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('resendEmail() ', () => { - it(`should make a query an then call showSuccess method`, () => { - const today = Date.vnNew(); - - jest.spyOn(controller, 'getWeekData').mockReturnThis(); - jest.spyOn(controller, 'getMailStates').mockReturnThis(); - jest.spyOn(controller.vnApp, 'showSuccess'); - - controller.$.model = {applyFilter: jest.fn().mockReturnValue(Promise.resolve())}; - controller.worker = {id: 1}; - controller.worker = {user: {emailUser: {email: 'employee@verdnatura.es'}}}; - controller.date = today; - controller.weekNumber = 1; - - $httpBackend.expect('POST', 'WorkerTimeControls/weekly-hour-hecord-email').respond(); - controller.resendEmail(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('getMailStates() ', () => { - it(`should make a query an then call showSuccess method`, () => { - const today = Date.vnNew(); - jest.spyOn(controller, 'repaint').mockReturnThis(); - - controller.$params = {id: 1}; - - $httpBackend.expect('GET', `WorkerTimeControls/1/getMailStates?month=1&year=2001`).respond(); - controller.getMailStates(today); - $httpBackend.flush(); - - expect(controller.repaint).toHaveBeenCalled(); - }); - }); - }); -}); diff --git a/modules/worker/front/time-control/locale/es.yml b/modules/worker/front/time-control/locale/es.yml deleted file mode 100644 index 091c01baa..000000000 --- a/modules/worker/front/time-control/locale/es.yml +++ /dev/null @@ -1,22 +0,0 @@ -In: Entrada -Out: Salida -Intermediate: Intermedio -Hour: Hora -Hours: Horas -Add time: Añadir hora -Week total: Total semana -Current week: Semana actual -This time entry will be deleted: Se eliminará la hora fichada -Are you sure you want to delete this entry?: ¿Seguro que quieres eliminarla? -Finish at: Termina a las -Entry removed: Fichada borrada -The entry type can't be empty: El tipo de fichada no puede quedar vacía -Satisfied: Conforme -Not satisfied: No conforme -Reason: Motivo -Resend: Reenviar -Email sended: Email enviado -You must indicate a reason: Debes indicar un motivo -Send time control email: Enviar email control horario -Are you sure you want to send it?: ¿Seguro que quieres enviarlo? -Resend email of this week to the user: Reenviar email de esta semana al usuario diff --git a/modules/worker/front/time-control/style.scss b/modules/worker/front/time-control/style.scss deleted file mode 100644 index 9d7545aaf..000000000 --- a/modules/worker/front/time-control/style.scss +++ /dev/null @@ -1,52 +0,0 @@ -@import "variables"; - -vn-worker-time-control { - vn-thead > vn-tr > vn-td > div.weekday { - margin-bottom: 5px; - color: $color-main - } - vn-td.hours { - min-width: 100px; - vertical-align: top; - - & > section { - display: flex; - align-items: center; - justify-content: center; - padding: 4px 0; - - & > vn-icon { - color: $color-font-secondary; - padding-right: 1px; - } - } - } - .totalBox { - max-width: none - } - -} - -.reasonDialog{ - min-width: 500px; -} - -.edit-time-entry { - width: 200px -} - -.right { - float: right; - } - -.confirmed { - color: #97B92F; -} - -.revise { - color: #f61e1e; -} - -.sended { - color: #d19b25; -} diff --git a/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js b/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js index f760559cb..931a5c707 100644 --- a/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js +++ b/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js @@ -1,8 +1,8 @@ const app = require('vn-loopback/server/server'); describe('Agency getAgenciesWithWarehouse()', () => { + const ctx = beforeAll.getCtx(); const today = Date.vnNew(); - const ctx = {req: {accessToken: {userId: 9}}}; it('should return the agencies that can handle the given delivery request', async() => { const tx = await app.models.Zone.beginTransaction({}); diff --git a/modules/zone/back/methods/agency/specs/landsThatDay.spec.js b/modules/zone/back/methods/agency/specs/landsThatDay.spec.js index 1ec675071..cd587a329 100644 --- a/modules/zone/back/methods/agency/specs/landsThatDay.spec.js +++ b/modules/zone/back/methods/agency/specs/landsThatDay.spec.js @@ -1,7 +1,7 @@ const {models} = require('vn-loopback/server/server'); describe('Agency landsThatDay()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; + const ctx = beforeAll.getCtx(); const today = Date.vnNew(); it('should return a list of agencies that can land a shipment on a day for an address', async() => { const tx = await models.Agency.beginTransaction({}); diff --git a/modules/zone/back/methods/zone/specs/clone.spec.js b/modules/zone/back/methods/zone/specs/clone.spec.js index 1b7393912..3a8783f21 100644 --- a/modules/zone/back/methods/zone/specs/clone.spec.js +++ b/modules/zone/back/methods/zone/specs/clone.spec.js @@ -1,20 +1,7 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('agency clone()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); it('should clone a zone', async() => { const tx = await models.Zone.beginTransaction({}); diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js index 968685fec..08dafd181 100644 --- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js +++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js @@ -5,6 +5,7 @@ describe('zone deletezone()', () => { const userId = 9; const activeCtx = { accessToken: {userId: userId}, + __: value => value }; const ctx = {req: activeCtx}; const zoneId = 9; @@ -15,19 +16,15 @@ describe('zone deletezone()', () => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ active: activeCtx }); - try { - const originalTickets = await models.Ticket.find({ - where: { - zoneFk: zoneId - } - }); - ticketIDs = originalTickets.map(ticket => ticket.id); - originalTicketStates = await models.TicketState.find({where: { - ticketFk: {inq: ticketIDs}, - code: 'FIXING'}}); - } catch (error) { - console.error(error); - } + const originalTickets = await models.Ticket.find({ + where: { + zoneFk: zoneId + } + }); + ticketIDs = originalTickets.map(ticket => ticket.id); + originalTicketStates = await models.TicketState.find({where: { + ticketFk: {inq: ticketIDs}, + code: 'FIXING'}}); }); it('should delete a zone and update their tickets', async() => { diff --git a/modules/zone/back/methods/zone/specs/exclusionGeo.spec.js b/modules/zone/back/methods/zone/specs/exclusionGeo.spec.js index fbe96fc5f..bd4438204 100644 --- a/modules/zone/back/methods/zone/specs/exclusionGeo.spec.js +++ b/modules/zone/back/methods/zone/specs/exclusionGeo.spec.js @@ -1,20 +1,7 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); describe('zone exclusionGeo()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); const zoneId = 1; const today = Date.vnNew(); diff --git a/modules/zone/back/methods/zone/specs/getEvents.spec.js b/modules/zone/back/methods/zone/specs/getEvents.spec.js index c1dee3e0f..80388d009 100644 --- a/modules/zone/back/methods/zone/specs/getEvents.spec.js +++ b/modules/zone/back/methods/zone/specs/getEvents.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('zone getEvents()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; + const ctx = beforeAll.getCtx(); it('should return all events for the specified geo and agency mode', async() => { const tx = await models.Zone.beginTransaction({}); diff --git a/modules/zone/back/methods/zone/specs/getLeaves.spec.js b/modules/zone/back/methods/zone/specs/getLeaves.spec.js index 9342a0b50..fde56be35 100644 --- a/modules/zone/back/methods/zone/specs/getLeaves.spec.js +++ b/modules/zone/back/methods/zone/specs/getLeaves.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('zone getLeaves()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; + const ctx = beforeAll.getCtx(); it('should return the country and the childs containing the search value', async() => { const tx = await models.Zone.beginTransaction({}); diff --git a/modules/zone/back/methods/zone/specs/getUpcomingDeliveries.spec.js b/modules/zone/back/methods/zone/specs/getUpcomingDeliveries.spec.js index fe542fbf3..08d8601bc 100644 --- a/modules/zone/back/methods/zone/specs/getUpcomingDeliveries.spec.js +++ b/modules/zone/back/methods/zone/specs/getUpcomingDeliveries.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('zone getUpcomingDeliveries()', () => { - const ctx = {req: {accessToken: {userId: 9}}}; + const ctx = beforeAll.getCtx(); it('should check returns data', async() => { const tx = await models.Zone.beginTransaction({}); diff --git a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js index 2da176330..81d02193e 100644 --- a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js +++ b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js @@ -1,19 +1,7 @@ const models = require('vn-loopback/server/server').models; -const LoopBackContext = require('loopback-context'); + describe('zone toggleIsIncluded()', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); + beforeAll.mockLoopBackContext(); it('should return the created location with isIncluded true', async() => { const tx = await models.Zone.beginTransaction({}); diff --git a/modules/zone/back/models/agency-mode.json b/modules/zone/back/models/agency-mode.json index 99ed43b97..6033e26c6 100644 --- a/modules/zone/back/models/agency-mode.json +++ b/modules/zone/back/models/agency-mode.json @@ -60,6 +60,11 @@ "type": "hasMany", "model": "Zone", "foreignKey": "agencyModeFk" + }, + "mrwService": { + "type": "belongsTo", + "model": "MrwService", + "foreignKey": "code" } }, "acls": [ diff --git a/modules/zone/back/models/zone.json b/modules/zone/back/models/zone.json index cf7371053..5b25e40d1 100644 --- a/modules/zone/back/models/zone.json +++ b/modules/zone/back/models/zone.json @@ -42,6 +42,9 @@ }, "itemMaxSize": { "type": "number" + }, + "itemMaxLength": { + "type": "number" } }, "relations": { diff --git a/modules/zone/front/basic-data/index.html b/modules/zone/front/basic-data/index.html deleted file mode 100644 index 5070a3aea..000000000 --- a/modules/zone/front/basic-data/index.html +++ /dev/null @@ -1,114 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/zone/front/basic-data/index.js b/modules/zone/front/basic-data/index.js deleted file mode 100644 index 402b471fc..000000000 --- a/modules/zone/front/basic-data/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - onSubmit() { - this.$.watcher.submit().then(() => - this.card.reload() - ); - } -} - -ngModule.vnComponent('vnZoneBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - zone: '<' - }, - require: { - card: '^vnZoneCard' - } -}); diff --git a/modules/zone/front/calendar/index.html b/modules/zone/front/calendar/index.html deleted file mode 100644 index cfcebf359..000000000 --- a/modules/zone/front/calendar/index.html +++ /dev/null @@ -1,33 +0,0 @@ - -
- - -
- {{$ctrl.firstDay | date:'MMMM'}} - {{$ctrl.firstDay | date:'yyyy'}} - - {{$ctrl.lastDay | date:'MMMM'}} - {{$ctrl.lastDay | date:'yyyy'}} -
- - -
-
- - -
-
\ No newline at end of file diff --git a/modules/zone/front/calendar/index.js b/modules/zone/front/calendar/index.js deleted file mode 100644 index 288a8f328..000000000 --- a/modules/zone/front/calendar/index.js +++ /dev/null @@ -1,191 +0,0 @@ -import ngModule from '../module'; -import Component from 'core/lib/component'; -import './style.scss'; - -class Controller extends Component { - constructor($element, $, vnWeekDays) { - super($element, $); - this.vnWeekDays = vnWeekDays; - this.nMonths = 4; - - let date = Date.vnNew(); - date.setDate(1); - date.setHours(0, 0, 0, 0); - this.date = date; - } - - get date() { - return this._date; - } - - set date(value) { - this._date = value; - let stamp = value.getTime(); - - let firstDay = new Date(stamp); - firstDay.setDate(1); - this.firstDay = firstDay; - - let lastDay = new Date(stamp); - lastDay.setMonth(lastDay.getMonth() + this.nMonths); - lastDay.setDate(0); - this.lastDay = lastDay; - - this.months = []; - for (let i = 0; i < this.nMonths; i++) { - let monthDate = new Date(stamp); - monthDate.setMonth(value.getMonth() + i); - this.months.push(monthDate); - } - - this.refreshEvents(); - } - - step(direction) { - let date = new Date(this.date.getTime()); - date.setMonth(date.getMonth() + (this.nMonths * direction)); - this.date = date; - - this.emit('step'); - } - - get data() { - return this._data; - } - - set data(value) { - this._data = value; - - value = value || {}; - - this.events = value.events; - - function toStamp(date) { - return date && new Date(date).setHours(0, 0, 0, 0); - } - - this.exclusions = {}; - let exclusions = value.exclusions; - - if (exclusions) { - for (let exclusion of exclusions) { - let stamp = toStamp(exclusion.dated); - if (!this.exclusions[stamp]) this.exclusions[stamp] = []; - this.exclusions[stamp].push(exclusion); - } - } - - this.geoExclusions = {}; - let geoExclusions = value.geoExclusions; - - if (geoExclusions) { - for (let geoExclusion of geoExclusions) { - let stamp = toStamp(geoExclusion.dated); - if (!this.geoExclusions[stamp]) this.geoExclusions[stamp] = []; - this.geoExclusions[stamp].push(geoExclusion); - } - } - - let events = value.events; - - if (events) { - for (let event of events) { - event.dated = toStamp(event.dated); - event.ended = toStamp(event.ended); - event.started = toStamp(event.started); - event.wdays = this.vnWeekDays.fromSet(event.weekDays); - } - } - - this.refreshEvents(); - - let calendars = this.element.querySelectorAll('vn-calendar'); - for (let calendar of calendars) - calendar.$ctrl.repaint(); - } - - refreshEvents() { - this.days = {}; - if (!this.data) return; - - let day = new Date(this.firstDay.getTime()); - - while (day <= this.lastDay) { - let stamp = day.getTime(); - let wday = day.getDay(); - let dayEvents = []; - let exclusions = this.exclusions[stamp] || []; - - if (this.events) { - for (let event of this.events) { - let match; - - switch (event.type) { - case 'day': - match = event.dated == stamp; - break; - default: - match = event.wdays[wday] - && (!event.started || stamp >= event.started) - && (!event.ended || stamp <= event.ended); - break; - } - - if (match && !exclusions.find(e => e.zoneFk == event.zoneFk)) - dayEvents.push(event); - } - } - - if (dayEvents.length) - this.days[stamp] = dayEvents; - - day.setDate(day.getDate() + 1); - } - } - - onSelection($event, $days, $type, $weekday) { - let $events = []; - let $exclusions = []; - let $geoExclusions = []; - - for (let day of $days) { - let stamp = day.getTime(); - $events = $events.concat(this.days[stamp] || []); - $exclusions = $exclusions.concat(this.exclusions[stamp] || []); - $geoExclusions = $geoExclusions.concat(this.geoExclusions[stamp] || []); - } - - this.emit('selection', { - $event, - $days, - $type, - $weekday, - $events, - $exclusions, - $geoExclusions - }); - } - - hasEvents(day) { - let stamp = day.getTime(); - return this.days[stamp] || this.exclusions[stamp] || this.geoExclusions[stamp]; - } - - getClass(day) { - let stamp = day.getTime(); - if (this.geoExclusions[stamp]) - return 'geoExcluded'; - else if (this.exclusions[stamp]) - return 'excluded'; - else return ''; - } -} -Controller.$inject = ['$element', '$scope', 'vnWeekDays']; - -ngModule.vnComponent('vnZoneCalendar', { - template: require('./index.html'), - controller: Controller, - bindings: { - data: ' { - let $scope; - let controller; - - beforeEach(ngModule('zone')); - - beforeEach(inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - const $element = angular.element(``); - controller = $componentController('vnZoneCalendar', {$element, $scope}); - controller.$.model = crudModel; - controller.zone = {id: 1}; - controller.days = []; - controller.exclusions = []; - controller.geoExclusions = []; - })); - - describe('date() setter', () => { - it('should set the month property and then call the refreshEvents() method', () => { - jest.spyOn(controller, 'refreshEvents').mockReturnThis(); - - controller.date = Date.vnNew(); - - expect(controller.refreshEvents).toHaveBeenCalledWith(); - expect(controller.months.length).toEqual(4); - }); - }); - - describe('step()', () => { - it('should set the date month to 4 months backwards', () => { - const now = Date.vnNew(); - now.setDate(15); - now.setMonth(now.getMonth() - 4); - - controller.step(-1); - - const expectedMonth = now.getMonth(); - const currentMonth = controller.date.getMonth(); - - expect(currentMonth).toEqual(expectedMonth); - }); - - it('should set the date month to 4 months forwards', () => { - const now = Date.vnNew(); - now.setDate(15); - now.setMonth(now.getMonth() + 4); - - controller.step(1); - - const expectedMonth = now.getMonth(); - const currentMonth = controller.date.getMonth(); - - expect(currentMonth).toEqual(expectedMonth); - }); - }); - - describe('data() setter', () => { - it('should set the events, exclusions and geoExclusions and then call the refreshEvents() method', () => { - jest.spyOn(controller, 'refreshEvents').mockReturnThis(); - - controller.data = { - exclusions: [{ - dated: Date.vnNew() - }], - events: [{ - dated: Date.vnNew() - }], - geoExclusions: [{ - dated: Date.vnNew() - }], - }; - - expect(controller.refreshEvents).toHaveBeenCalledWith(); - expect(controller.events).toBeDefined(); - expect(controller.events.length).toEqual(1); - expect(controller.exclusions).toBeDefined(); - expect(controller.geoExclusions).toBeDefined(); - expect(Object.keys(controller.exclusions).length).toEqual(1); - }); - }); - - describe('refreshEvents()', () => { - it('should fill the days property with the events.', () => { - controller.data = []; - controller.firstDay = Date.vnNew(); - - const lastDay = Date.vnNew(); - lastDay.setDate(lastDay.getDate() + 10); - controller.lastDay = lastDay; - - const firstEventStamp = controller.firstDay.getTime(); - const lastEventStamp = controller.lastDay.getTime(); - controller.events = [{ - type: 'day', - dated: firstEventStamp - }, - { - type: 'day', - dated: lastEventStamp - }]; - - controller.refreshEvents(); - const expectedDays = Object.keys(controller.days); - - expect(expectedDays.length).toEqual(2); - }); - }); - - describe('onSelection()', () => { - it('should call the emit() method', () => { - jest.spyOn(controller, 'emit'); - - const $event = {}; - const $days = [Date.vnNew()]; - const $type = 'day'; - const $weekday = 1; - - controller.onSelection($event, $days, $type, $weekday); - - expect(controller.emit).toHaveBeenCalledWith('selection', - { - $days: $days, - $event: {}, - $events: [], - $exclusions: [], - $type: 'day', - $weekday: 1, - $geoExclusions: [], - } - ); - }); - }); - - describe('hasEvents()', () => { - it('should return true for an existing event on a date', () => { - const dated = Date.vnNew(); - - controller.days[dated.getTime()] = true; - - const result = controller.hasEvents(dated); - - expect(result).toBeTruthy(); - }); - }); - - describe('getClass()', () => { - it('should return the className "excluded" for an excluded date', () => { - const dated = Date.vnNew(); - - controller.exclusions = []; - controller.exclusions[dated.getTime()] = true; - - const result = controller.getClass(dated); - - expect(result).toEqual('excluded'); - }); - - it('should return the className "geoExcluded" for a date with geo excluded', () => { - const dated = Date.vnNew(); - - controller.geoExclusions = []; - controller.geoExclusions[dated.getTime()] = true; - - const result = controller.getClass(dated); - - expect(result).toEqual('geoExcluded'); - }); - }); -}); diff --git a/modules/zone/front/calendar/style.scss b/modules/zone/front/calendar/style.scss deleted file mode 100644 index 38491af58..000000000 --- a/modules/zone/front/calendar/style.scss +++ /dev/null @@ -1,43 +0,0 @@ -@import "variables"; - -vn-zone-calendar { - display: block; - - & > vn-card { - & > .header { - display: flex; - align-items: center; - justify-content: space-between; - background-color: $color-main; - color: white; - font-weight: bold; - height: 45px; - - & > .vn-button { - color: inherit; - height: 100%; - } - } - & > .calendars { - display: flex; - flex-wrap: wrap; - justify-content: space-evenly; - - & > .vn-calendar { - max-width: 288px; - - #days-container .day { - &.event .day-number { - background-color: $color-success; - } - &.excluded .day-number { - background-color: $color-alert; - } - &.geoExcluded .day-number { - background-color: $color-main; - } - } - } - } - } -} \ No newline at end of file diff --git a/modules/zone/front/card/index.html b/modules/zone/front/card/index.html deleted file mode 100644 index ae6a7f10a..000000000 --- a/modules/zone/front/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/zone/front/card/index.js b/modules/zone/front/card/index.js deleted file mode 100644 index 4e8ac7e8c..000000000 --- a/modules/zone/front/card/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import ngModule from '../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - let filter = { - include: { - relation: 'agencyMode', - scope: {fields: ['name']} - } - }; - - this.$http.get(`Zones/${this.$params.id}`, {filter}) - .then(res => this.zone = res.data); - } -} - -ngModule.vnComponent('vnZoneCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/zone/front/card/index.spec.js b/modules/zone/front/card/index.spec.js deleted file mode 100644 index 64127990f..000000000 --- a/modules/zone/front/card/index.spec.js +++ /dev/null @@ -1,26 +0,0 @@ -import './index.js'; - -describe('Zone Component vnZoneCard', () => { - let controller; - let $httpBackend; - let data = {id: 1, name: 'fooName'}; - - beforeEach(ngModule('zone')); - - beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => { - $httpBackend = _$httpBackend_; - - let $element = angular.element('
'); - controller = $componentController('vnZoneCard', {$element}); - - $stateParams.id = data.id; - $httpBackend.whenRoute('GET', 'Zones/:id').respond(data); - })); - - it('should request data and set it on the controller', () => { - controller.reload(); - $httpBackend.flush(); - - expect(controller.zone).toEqual(data); - }); -}); diff --git a/modules/zone/front/create/index.html b/modules/zone/front/create/index.html deleted file mode 100644 index f8c7df391..000000000 --- a/modules/zone/front/create/index.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/zone/front/create/index.js b/modules/zone/front/create/index.js deleted file mode 100644 index db337a9a3..000000000 --- a/modules/zone/front/create/index.js +++ /dev/null @@ -1,24 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - this.zone = { - travelingDays: 0, - price: 0.20, - bonus: 0.20, - hour: Date.vnNew() - }; - } - - onSubmit() { - return this.$.watcher.submit().then(res => - this.$state.go('zone.card.location', {id: res.data.id}) - ); - } -} - -ngModule.vnComponent('vnZoneCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/zone/front/create/index.spec.js b/modules/zone/front/create/index.spec.js deleted file mode 100644 index fe0088225..000000000 --- a/modules/zone/front/create/index.spec.js +++ /dev/null @@ -1,40 +0,0 @@ -import './index'; -import watcher from 'core/mocks/watcher'; - -describe('Zone Component vnZoneCreate', () => { - let $scope; - let $state; - let controller; - - beforeEach(ngModule('zone')); - - beforeEach(inject(($componentController, $rootScope, _$state_) => { - $scope = $rootScope.$new(); - $state = _$state_; - $scope.watcher = watcher; - $scope.watcher.submit = () => { - return { - then: callback => { - callback({data: {id: 1234}}); - } - }; - }; - const $element = angular.element(''); - controller = $componentController('vnZoneCreate', {$element, $scope}); - })); - - describe('onSubmit()', () => { - it(`should call submit() on the watcher then expect a callback`, () => { - jest.spyOn($state, 'go'); - - controller.zone = { - name: 'Zone One' - }; - - controller.onSubmit(); - - expect(controller.$state.go).toHaveBeenCalledWith('zone.card.location', Object({id: 1234})); - }); - }); -}); - diff --git a/modules/zone/front/create/locale/es.yml b/modules/zone/front/create/locale/es.yml deleted file mode 100644 index 4827ced37..000000000 --- a/modules/zone/front/create/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Traveling days: Días de viaje -Closing hour: Hora de cierre -Bonus: Bonificación \ No newline at end of file diff --git a/modules/zone/front/delivery-days/index.html b/modules/zone/front/delivery-days/index.html deleted file mode 100644 index c47d89982..000000000 --- a/modules/zone/front/delivery-days/index.html +++ /dev/null @@ -1,102 +0,0 @@ -
- - -
- -
- - - - - - -
- {{code}} {{town.name}} -
-
- {{town.province.name}}, {{town.province.country.name}} -
-
-
- - - -
-
- - - -
-
Zones
- - - - - - Id - Name - Agency - Closing - Price - - - - - - {{::zone.id}} - {{::zone.name}} - {{::zone.agencyModeName}} - {{::zone.hour | date: 'HH:mm'}} - {{::zone.price | currency: 'EUR':2}} - - - - - - - - - - - -
-
- - - \ No newline at end of file diff --git a/modules/zone/front/delivery-days/index.js b/modules/zone/front/delivery-days/index.js deleted file mode 100644 index 71e8c8ab7..000000000 --- a/modules/zone/front/delivery-days/index.js +++ /dev/null @@ -1,95 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - $onInit() { - this.setParams(); - } - - $postLink() { - this.deliveryMethodFk = 'delivery'; - } - - setParams() { - const hasParams = this.$params.deliveryMethodFk || this.$params.geoFk || this.$params.agencyModeFk; - if (hasParams) { - if (this.$params.deliveryMethodFk) - this.deliveryMethodFk = this.$params.deliveryMethodFk; - - if (this.$params.geoFk) - this.geoFk = this.$params.geoFk; - - if (this.$params.agencyModeFk) - this.agencyModeFk = this.$params.agencyModeFk; - - this.fetchData(); - } - } - - fetchData() { - const params = { - deliveryMethodFk: this.deliveryMethodFk, - geoFk: this.geoFk, - agencyModeFk: this.agencyModeFk - }; - this.$.data = null; - this.$http.get(`Zones/getEvents`, {params}) - .then(res => { - let data = res.data; - this.$.data = data; - if (!data.events.length) - this.vnApp.showMessage(this.$t('No service for the specified zone')); - - this.$state.go(this.$state.current.name, params); - }); - } - - get deliveryMethodFk() { - return this._deliveryMethodFk; - } - - set deliveryMethodFk(value) { - this._deliveryMethodFk = value; - - let filter; - - if (value === 'pickUp') - filter = {where: {code: 'PICKUP'}}; - else - filter = {where: {code: {inq: ['DELIVERY', 'AGENCY']}}}; - - this.$http.get(`DeliveryMethods`, {filter}).then(res => { - const deliveryMethods = res.data.map(deliveryMethod => deliveryMethod.id); - this.agencyFilter = {deliveryMethodFk: {inq: deliveryMethods}}; - }); - } - - onSelection($event, $events, $days) { - if (!$events.length) return; - - const day = $days[0]; - const zoneIds = []; - for (let event of $events) - zoneIds.push(event.zoneFk); - - const params = { - zoneIds: zoneIds, - date: day - }; - - this.$http.post(`Zones/getZoneClosing`, params) - .then(res => this.zoneClosing = res.data) - .then(() => this.$.zoneEvents.show($event.target)); - } - - preview(zone) { - this.selectedZone = zone; - this.$.summary.show(); - } -} - -ngModule.vnComponent('vnZoneDeliveryDays', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/zone/front/delivery-days/index.spec.js b/modules/zone/front/delivery-days/index.spec.js deleted file mode 100644 index 28705880c..000000000 --- a/modules/zone/front/delivery-days/index.spec.js +++ /dev/null @@ -1,126 +0,0 @@ -import './index.js'; -import popover from 'core/mocks/popover'; -import crudModel from 'core/mocks/crud-model'; - -describe('Zone Component vnZoneDeliveryDays', () => { - let $httpBackend; - let controller; - let $element; - - beforeEach(ngModule('zone')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $element = angular.element(' { - it('should set the deliveryMethodFk property as pickup and then perform a query that sets the filter', () => { - $httpBackend.expect('GET', 'DeliveryMethods').respond([{id: 999}]); - controller.deliveryMethodFk = 'pickUp'; - $httpBackend.flush(); - - expect(controller.agencyFilter).toEqual({deliveryMethodFk: {inq: [999]}}); - }); - }); - - describe('setParams()', () => { - it('should do nothing when no params are received', () => { - controller.setParams(); - - expect(controller.deliveryMethodFk).toBeUndefined(); - expect(controller.geoFk).toBeUndefined(); - expect(controller.agencyModeFk).toBeUndefined(); - }); - - it('should set the controller properties when the params are provided', () => { - controller.$params = { - deliveryMethodFk: 3, - geoFk: 2, - agencyModeFk: 1 - }; - controller.setParams(); - - expect(controller.deliveryMethodFk).toEqual(controller.$params.deliveryMethodFk); - expect(controller.geoFk).toEqual(controller.$params.geoFk); - expect(controller.agencyModeFk).toEqual(controller.$params.agencyModeFk); - }); - }); - - describe('fetchData()', () => { - it('should make an HTTP GET query and then call the showMessage() method', () => { - jest.spyOn(controller.vnApp, 'showMessage'); - jest.spyOn(controller.$state, 'go'); - - controller.agencyModeFk = 1; - controller.deliveryMethodFk = 2; - controller.geoFk = 3; - controller.$state.current.name = 'myState'; - - const expectedData = {events: []}; - - const url = 'Zones/getEvents?agencyModeFk=1&deliveryMethodFk=2&geoFk=3'; - - $httpBackend.when('GET', 'DeliveryMethods').respond([]); - $httpBackend.expect('GET', url).respond({events: []}); - controller.fetchData(); - $httpBackend.flush(); - - expect(controller.$.data).toEqual(expectedData); - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('No service for the specified zone'); - expect(controller.$state.go).toHaveBeenCalledWith( - controller.$state.current.name, - { - agencyModeFk: 1, - deliveryMethodFk: 2, - geoFk: 3 - } - ); - }); - }); - - describe('onSelection()', () => { - it('should not call the show popover method if events array is empty', () => { - jest.spyOn(controller.$.zoneEvents, 'show'); - - const event = new Event('click'); - const target = document.createElement('div'); - target.dispatchEvent(event); - const events = []; - controller.onSelection(event, events); - - expect(controller.$.zoneEvents.show).not.toHaveBeenCalled(); - }); - - it('should call the show() method and call getZoneClosing() with the expected ids', () => { - jest.spyOn(controller.$.zoneEvents, 'show'); - - const event = new Event('click'); - const target = document.createElement('div'); - target.dispatchEvent(event); - - const day = Date.vnNew(); - const events = [ - {zoneFk: 1}, - {zoneFk: 2}, - {zoneFk: 8} - ]; - const params = { - zoneIds: [1, 2, 8], - date: [day][0] - }; - const response = [{id: 1, hour: ''}]; - - $httpBackend.when('POST', 'Zones/getZoneClosing', params).respond({response}); - controller.onSelection(event, events, [day]); - $httpBackend.flush(); - - expect(controller.$.zoneEvents.show).toHaveBeenCalledWith(target); - expect(controller.zoneClosing.id).toEqual(response.id); - }); - }); -}); diff --git a/modules/zone/front/delivery-days/style.scss b/modules/zone/front/delivery-days/style.scss deleted file mode 100644 index 3dd4abb7c..000000000 --- a/modules/zone/front/delivery-days/style.scss +++ /dev/null @@ -1,36 +0,0 @@ -@import "variables"; - -vn-zone-delivery-days { - vn-zone-calendar { - display: flex; - justify-content: center; - flex-wrap: wrap; - - & > vn-calendar { - min-width: 264px; - } - } - form { - display: flex; - flex-direction: column; - } -} - -.zoneEvents { - width: 700px; - max-height: 450px; - - vn-data-viewer { - margin-bottom: 0; - vn-pagination { - padding: 0 - } - } - - & > .header { - background-color: $color-main; - color: white; - font-weight: bold; - text-align: center - } -} \ No newline at end of file diff --git a/modules/zone/front/descriptor-popover/index.html b/modules/zone/front/descriptor-popover/index.html deleted file mode 100644 index 7e4e8f5d8..000000000 --- a/modules/zone/front/descriptor-popover/index.html +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/modules/zone/front/descriptor-popover/index.js b/modules/zone/front/descriptor-popover/index.js deleted file mode 100644 index a21232e41..000000000 --- a/modules/zone/front/descriptor-popover/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import ngModule from '../module'; -import DescriptorPopover from 'salix/components/descriptor-popover'; - -class Controller extends DescriptorPopover {} - -ngModule.vnComponent('vnZoneDescriptorPopover', { - slotTemplate: require('./index.html'), - controller: Controller -}); diff --git a/modules/zone/front/descriptor/index.html b/modules/zone/front/descriptor/index.html deleted file mode 100644 index a3432a99d..000000000 --- a/modules/zone/front/descriptor/index.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - Delete - - - Clone - - - -
- - - - - - - - - - -
-
-
- - - - - - - - \ No newline at end of file diff --git a/modules/zone/front/descriptor/index.js b/modules/zone/front/descriptor/index.js deleted file mode 100644 index 3f4863a60..000000000 --- a/modules/zone/front/descriptor/index.js +++ /dev/null @@ -1,65 +0,0 @@ -import ngModule from '../module'; -import Descriptor from 'salix/components/descriptor'; - -class Controller extends Descriptor { - get zone() { - return this.entity; - } - - set zone(value) { - this.entity = value; - } - - loadData() { - const filter = { - include: [ - { - relation: 'agencyMode', - scope: { - fields: ['name'], - } - } - ] - }; - - return this.getData(`Zones/${this.id}`, {filter}) - .then(res => this.entity = res.data); - } - - onDelete() { - const $t = this.$translate.instant; - const today = Date.vnNew(); - today.setHours(0, 0, 0, 0); - const filter = {where: {zoneFk: this.id, shipped: {gte: today}}}; - this.$http.get(`Tickets`, {filter}).then(res => { - const ticketsAmount = res.data.length; - if (ticketsAmount) { - const params = {ticketsAmount}; - const question = $t('This zone contains tickets', params, null, null, 'sanitizeParameters'); - this.$.deleteZone.question = question; - this.$.deleteZone.show(); - } else - this.deleteZone(); - }); - } - - deleteZone() { - return this.$http.post(`Zones/${this.id}/deleteZone`).then(() => { - this.$state.go('zone.index'); - this.vnApp.showSuccess(this.$t('Zone deleted')); - }); - } - - onCloneAccept() { - return this.$http.post(`Zones/${this.id}/clone`). - then(res => this.$state.go('zone.card.basicData', {id: res.data.id})); - } -} - -ngModule.vnComponent('vnZoneDescriptor', { - template: require('./index.html'), - controller: Controller, - bindings: { - zone: '<' - } -}); diff --git a/modules/zone/front/descriptor/index.spec.js b/modules/zone/front/descriptor/index.spec.js deleted file mode 100644 index 435a1d00f..000000000 --- a/modules/zone/front/descriptor/index.spec.js +++ /dev/null @@ -1,74 +0,0 @@ -import './index.js'; - -describe('Zone descriptor', () => { - let $httpBackend; - let controller; - let $element; - - beforeEach(ngModule('zone')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $element = angular.element(' {}, - show: () => {} - }; - })); - - describe('onDelete()', () => { - it('should make an HTTP POST query and then call the deleteZone show() method', () => { - jest.spyOn(controller.$.deleteZone, 'show'); - - const expectedData = [{id: 16}]; - $httpBackend.when('GET', 'Tickets').respond(expectedData); - controller.onDelete(); - $httpBackend.flush(); - - expect(controller.$.deleteZone.show).toHaveBeenCalledWith(); - }); - - it('should make an HTTP POST query and then call the deleteZone() method', () => { - jest.spyOn(controller, 'deleteZone').mockReturnThis(); - - const expectedData = []; - $httpBackend.when('GET', 'Tickets').respond(expectedData); - controller.onDelete(); - $httpBackend.flush(); - - expect(controller.deleteZone).toHaveBeenCalledWith(); - }); - }); - - describe('deleteZone()', () => { - it('should make an HTTP POST query and then call the showMessage() method', () => { - jest.spyOn(controller.$state, 'go').mockReturnThis(); - jest.spyOn(controller.vnApp, 'showSuccess'); - - const stateName = 'zone.index'; - $httpBackend.when('POST', 'Zones/1/deleteZone').respond(200); - controller.deleteZone(); - $httpBackend.flush(); - - expect(controller.$state.go).toHaveBeenCalledWith(stateName); - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Zone deleted'); - }); - }); - - describe('onCloneAccept()', () => { - it('should make an HTTP POST query and then call the state go() method', () => { - jest.spyOn(controller.$state, 'go').mockReturnThis(); - - const stateName = 'zone.card.basicData'; - const expectedData = {id: 1}; - $httpBackend.when('POST', 'Zones/1/clone').respond(expectedData); - controller.onCloneAccept(); - $httpBackend.flush(); - - expect(controller.$state.go).toHaveBeenCalledWith(stateName, expectedData); - }); - }); -}); diff --git a/modules/zone/front/descriptor/locale/es.yml b/modules/zone/front/descriptor/locale/es.yml deleted file mode 100644 index 0581ee93a..000000000 --- a/modules/zone/front/descriptor/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -This zone contains tickets: Esta zona contiene {{ticketsAmount}} tickets por servir. ¿Seguro que quieres eliminar esta zona? -Do you want to clone this zone?: ¿Quieres clonar esta zona? -All it's properties will be copied: Todas sus propiedades serán copiadas -Zone deleted: Zona eliminada \ No newline at end of file diff --git a/modules/zone/front/events/index.html b/modules/zone/front/events/index.html deleted file mode 100644 index 157b2a669..000000000 --- a/modules/zone/front/events/index.html +++ /dev/null @@ -1,277 +0,0 @@ - - - -
-
- Edit mode -
- - - - - - -
-
- Events -
- - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - -
- - - - -
-
-
-
- - - - - - - -
diff --git a/modules/zone/front/events/index.js b/modules/zone/front/events/index.js deleted file mode 100644 index b86330126..000000000 --- a/modules/zone/front/events/index.js +++ /dev/null @@ -1,316 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $, vnWeekDays) { - super($element, $); - this.vnWeekDays = vnWeekDays; - this.editMode = 'include'; - } - - $onInit() { - this.refresh(); - } - - get path() { - return `Zones/${this.$params.id}/events`; - } - - get exclusionsPath() { - return `Zones/${this.$params.id}/exclusions`; - } - - get checked() { - const geos = this.$.model.data || []; - const checkedLines = []; - for (let geo of geos) { - if (geo.checked) - checkedLines.push(geo); - } - return checkedLines; - } - - refresh() { - this.$.data = null; - this.$.$applyAsync(() => { - const params = { - zoneFk: this.$params.id, - started: this.$.calendar.firstDay, - ended: this.$.calendar.lastDay - }; - - this.$http.get(`Zones/getEventsFiltered`, {params}).then(res => { - const data = res.data; - this.$.data = data; - }); - }); - } - - formatWdays(weekDays) { - if (!weekDays) return; - - let abrWdays = weekDays - .split(',') - .map(wday => this.vnWeekDays.map[wday].localeAbr); - - return abrWdays.length < 7 - ? abrWdays.join(', ') - : this.$t('Everyday'); - } - - onSelection(days, type, weekday, events, exclusions, exclusionGeos) { - if (this.editMode == 'include') { - if (events.length) - return this.editInclusion(events[0]); - return this.createInclusion(type, days, weekday); - } else if (this.editMode == 'exclude') { - if (exclusions.length || exclusionGeos.length) - return this.editExclusion(exclusions[0] || {}, exclusionGeos); - return this.createExclusion(days); - } - } - - editExclusion(exclusion, exclusionGeos) { - this.isNew = false; - this.excludeSelected = angular.copy(exclusion); - this.excludeSelected.type = exclusionGeos.length ? - 'specificLocations' : 'all'; - - this.exclusionGeos = new Set(); - if (exclusionGeos.length) { - this.excludeSelected.id = exclusionGeos[0].zoneExclusionFk; - exclusionGeos.forEach(x => this.exclusionGeos.add(x.geoFk)); - } - - this.$.excludeDialog.show(); - } - - createExclusion(days) { - this.isNew = true; - this.excludeSelected = { - type: 'all', - dated: days[0] - }; - this.exclusionGeos = new Set(); - this.$.excludeDialog.show(); - } - - onEditClick(row, event) { - if (event.defaultPrevented) return; - this.editInclusion(row); - } - - editInclusion(row) { - this.isNew = false; - this.selected = angular.copy(row); - this.selected.wdays = this.vnWeekDays.fromSet(row.weekDays); - this.$.includeDialog.show(); - } - - createInclusion(type, days, weekday) { - this.isNew = true; - - if (type == 'weekday') { - let wdays = []; - if (weekday) wdays[weekday] = true; - - this.selected = { - type: 'indefinitely', - wdays - }; - } else { - this.selected = { - type: 'day', - dated: days[0] - }; - } - - this.$.includeDialog.show(); - } - - onIncludeResponse(response) { - switch (response) { - case 'accept': { - let selected = this.selected; - let type = selected.type; - - selected.weekDays = this.vnWeekDays.toSet(selected.wdays); - - if (type == 'day') - selected.weekDays = ''; - else - selected.dated = null; - - if (type != 'range') { - selected.started = null; - selected.ended = null; - } - - let req; - - if (this.isNew) - req = this.$http.post(this.path, selected); - else - req = this.$http.put(`${this.path}/${selected.id}`, selected); - - return req.then(() => { - this.selected = null; - this.isNew = null; - this.refresh(); - }); - } - case 'delete': - return this.onDelete(this.selected.id) - .then(response => response == 'accept'); - } - } - - onExcludeResponse(response) { - const type = this.excludeSelected.type; - switch (response) { - case 'accept': { - if (type == 'all') - return this.exclusionCreate(); - return this.exclusionGeoCreate(); - } - case 'delete': - return this.exclusionDelete(this.excludeSelected); - } - } - - onDeleteClick(id, event) { - if (event.defaultPrevented) return; - event.preventDefault(); - this.onDelete(id); - } - - onDelete(id) { - return this.$.confirm.show( - response => this.onDeleteResponse(response, id)); - } - - onDeleteResponse(response, id) { - if (response != 'accept' || !id) return; - return this.$http.delete(`${this.path}/${id}`) - .then(() => this.refresh()); - } - - exclusionCreate() { - const excludeSelected = this.excludeSelected; - const dated = excludeSelected.dated; - let req; - - if (this.isNew) - req = this.$http.post(this.exclusionsPath, [{dated}]); - if (!this.isNew) - req = this.$http.put(`${this.exclusionsPath}/${excludeSelected.id}`, {dated}); - - return req.then(() => { - this.refresh(); - }); - } - - exclusionGeoCreate() { - const excludeSelected = this.excludeSelected; - let req; - const geoIds = []; - this.exclusionGeos.forEach(id => geoIds.push(id)); - - if (this.isNew) { - const params = { - zoneFk: parseInt(this.$params.id), - date: excludeSelected.dated, - geoIds - }; - req = this.$http.post(`Zones/exclusionGeo`, params); - } else { - const params = { - zoneExclusionFk: this.excludeSelected.id, - geoIds - }; - req = this.$http.post(`Zones/updateExclusionGeo`, params); - } - return req.then(() => this.refresh()); - } - - exclusionDelete(exclusion) { - const path = `${this.exclusionsPath}/${exclusion.id}`; - return this.$http.delete(path) - .then(() => this.refresh()); - } - - set excludeSearch(value) { - this._excludeSearch = value; - if (!value) this.onSearch(); - } - - get excludeSearch() { - return this._excludeSearch; - } - - onKeyDown(event) { - if (event.key == 'Enter') { - event.preventDefault(); - this.onSearch(); - } - } - - onSearch() { - const params = {search: this._excludeSearch}; - if (this.excludeSelected.type == 'specificLocations') { - this.$.model.applyFilter({}, params).then(() => { - const data = this.$.model.data; - this.getChecked(data); - this.$.treeview.data = data; - }); - } - } - - onFetch(item) { - const params = item ? {parentId: item.id} : null; - return this.$.model.applyFilter({}, params).then(() => { - const data = this.$.model.data; - this.getChecked(data); - return data; - }); - } - - onSort(a, b) { - if (b.selected !== a.selected) { - if (a.selected == null) - return 1; - if (b.selected == null) - return -1; - return b.selected - a.selected; - } - - return a.name.localeCompare(b.name); - } - - getChecked(data) { - for (let geo of data) { - geo.checked = this.exclusionGeos.has(geo.id); - if (geo.childs) this.getChecked(geo.childs); - } - } - - onItemCheck(geoId, checked) { - if (checked) - this.exclusionGeos.add(geoId); - else - this.exclusionGeos.delete(geoId); - } -} -Controller.$inject = ['$element', '$scope', 'vnWeekDays']; - -ngModule.vnComponent('vnZoneEvents', { - template: require('./index.html'), - controller: Controller, - bindings: { - zone: '<' - }, - require: { - card: '^vnZoneCard' - } -}); diff --git a/modules/zone/front/events/index.spec.js b/modules/zone/front/events/index.spec.js deleted file mode 100644 index 558d97b6f..000000000 --- a/modules/zone/front/events/index.spec.js +++ /dev/null @@ -1,340 +0,0 @@ -import './index'; -import crudModel from 'core/mocks/crud-model'; - -describe('component vnZoneEvents', () => { - let $scope; - let controller; - let $httpBackend; - - beforeEach(ngModule('zone')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - const $element = angular.element(``); - controller = $componentController('vnZoneEvents', {$element, $scope}); - controller.$params = {id: 1}; - })); - - describe('refresh()', () => { - it('should set the zone and then call both getSummary() and getWarehouses()', () => { - const date = '2021-10-01'; - - controller.$params.id = 999; - controller.$.calendar = { - firstDay: date, - lastDay: date - }; - - const params = { - zoneFk: controller.$params.id, - started: date, - ended: date - }; - - const query = `Zones/getEventsFiltered?ended=${date}&started=${date}&zoneFk=${params.zoneFk}`; - const response = { - events: 'myEvents', - exclusions: 'myExclusions', - geoExclusions: 'myGeoExclusions', - }; - $httpBackend.whenGET(query).respond(response); - controller.refresh(); - $httpBackend.flush(); - - const data = controller.$.data; - - expect(data.events).toBeDefined(); - expect(data.exclusions).toBeDefined(); - }); - }); - - describe('onSelection()', () => { - it('should call the editInclusion() method', () => { - jest.spyOn(controller, 'editInclusion').mockReturnThis(); - - const weekday = {}; - const days = []; - const type = 'EventType'; - const events = [{name: 'Event'}]; - const exclusions = []; - const exclusionsGeo = []; - controller.editMode = 'include'; - controller.onSelection(days, type, weekday, events, exclusions, exclusionsGeo); - - expect(controller.editInclusion).toHaveBeenCalledWith({name: 'Event'}); - }); - - it('should call the createInclusion() method', () => { - jest.spyOn(controller, 'createInclusion').mockReturnThis(); - - const weekday = {dated: Date.vnNew()}; - const days = [weekday]; - const type = 'EventType'; - const events = []; - const exclusions = []; - const exclusionsGeo = []; - controller.editMode = 'include'; - controller.onSelection(days, type, weekday, events, exclusions, exclusionsGeo); - - expect(controller.createInclusion).toHaveBeenCalledWith(type, days, weekday); - }); - - it('should call the editExclusion() method with exclusions', () => { - jest.spyOn(controller, 'editExclusion').mockReturnThis(); - - const weekday = {}; - const days = []; - const type = 'EventType'; - const events = []; - const exclusions = [{name: 'Exclusion'}]; - const exclusionsGeo = []; - controller.editMode = 'exclude'; - controller.onSelection(days, type, weekday, events, exclusions, exclusionsGeo); - - expect(controller.editExclusion).toHaveBeenCalled(); - }); - - it('should call the editExclusion() method with exclusionsGeo', () => { - jest.spyOn(controller, 'editExclusion').mockReturnThis(); - - const weekday = {}; - const days = []; - const type = 'EventType'; - const events = []; - const exclusions = []; - const exclusionsGeo = [{name: 'GeoExclusion'}]; - controller.editMode = 'exclude'; - controller.onSelection(days, type, weekday, events, exclusions, exclusionsGeo); - - expect(controller.editExclusion).toHaveBeenCalled(); - }); - - it('should call the createExclusion() method', () => { - jest.spyOn(controller, 'createExclusion').mockReturnThis(); - - const weekday = {}; - const days = [{dated: Date.vnNew()}]; - const type = 'EventType'; - const events = []; - const exclusions = []; - const exclusionsGeo = []; - controller.editMode = 'exclude'; - controller.onSelection(days, type, weekday, events, exclusions, exclusionsGeo); - - expect(controller.createExclusion).toHaveBeenCalledWith(days); - }); - }); - - describe('editExclusion()', () => { - it('shoud set the excludeSelected.type = "specificLocations" and then call the excludeDialog show() method', () => { - controller.$.excludeDialog = {show: jest.fn()}; - - const exclusionGeos = [{id: 1}]; - const exclusions = []; - - controller.editExclusion(exclusions, exclusionGeos); - - expect(controller.excludeSelected.type).toEqual('specificLocations'); - expect(controller.$.excludeDialog.show).toHaveBeenCalledWith(); - }); - - it('shoud set the excludeSelected.type = "all" and then call the excludeDialog show() method', () => { - controller.$.excludeDialog = {show: jest.fn()}; - - const exclusionGeos = []; - const exclusions = [{id: 1}]; - - controller.editExclusion(exclusions, exclusionGeos); - - expect(controller.excludeSelected.type).toEqual('all'); - expect(controller.$.excludeDialog.show).toHaveBeenCalledWith(); - }); - }); - - describe('createExclusion()', () => { - it('shoud set the excludeSelected property and then call the excludeDialog show() method', () => { - controller.$.excludeDialog = {show: jest.fn()}; - - const days = [Date.vnNew()]; - controller.createExclusion(days); - - expect(controller.excludeSelected).toBeDefined(); - expect(controller.isNew).toBeTruthy(); - expect(controller.$.excludeDialog.show).toHaveBeenCalledWith(); - }); - }); - - describe('createInclusion()', () => { - it('shoud set the selected property and then call the includeDialog show() method', () => { - controller.$.includeDialog = {show: jest.fn()}; - - const type = 'weekday'; - const days = [Date.vnNew()]; - const weekday = 1; - controller.createInclusion(type, days, weekday); - - const selection = controller.selected; - const firstWeekday = selection.wdays[weekday]; - - expect(selection.type).toEqual('indefinitely'); - expect(firstWeekday).toBeTruthy(); - expect(controller.isNew).toBeTruthy(); - expect(controller.$.includeDialog.show).toHaveBeenCalledWith(); - }); - - it('shoud set the selected property with the first day and then call the includeDialog show() method', () => { - controller.$.includeDialog = {show: jest.fn()}; - - const type = 'nonListedType'; - const days = [Date.vnNew()]; - const weekday = 1; - controller.createInclusion(type, days, weekday); - - const selection = controller.selected; - - expect(selection.type).toEqual('day'); - expect(selection.dated).toEqual(days[0]); - expect(controller.isNew).toBeTruthy(); - expect(controller.$.includeDialog.show).toHaveBeenCalledWith(); - }); - }); - - describe('onIncludeResponse()', () => { - it('shoud call the onDelete() method', () => { - jest.spyOn(controller, 'onDelete').mockReturnValue( - new Promise(accept => accept()) - ); - - controller.selected = {id: 1}; - controller.onIncludeResponse('delete'); - - expect(controller.onDelete).toHaveBeenCalledWith(1); - }); - - it('shoud make an HTTP POST query to create a new one and then call the refresh() method', () => { - jest.spyOn(controller, 'refresh').mockReturnThis(); - - controller.selected = {id: 1}; - controller.isNew = true; - - $httpBackend.when('POST', `Zones/1/events`).respond(200); - controller.onIncludeResponse('accept'); - $httpBackend.flush(); - - expect(controller.refresh).toHaveBeenCalledWith(); - }); - - it('shoud make an HTTP PUT query and then call the refresh() method', () => { - jest.spyOn(controller, 'refresh').mockReturnThis(); - - controller.selected = {id: 1}; - controller.isNew = false; - - const eventId = 1; - $httpBackend.when('PUT', `Zones/1/events/${eventId}`).respond(200); - controller.onIncludeResponse('accept'); - $httpBackend.flush(); - - expect(controller.refresh).toHaveBeenCalledWith(); - }); - }); - - describe('onExcludeResponse()', () => { - it('should call the exclusionCreate() method', () => { - jest.spyOn(controller, 'exclusionCreate').mockReturnThis(); - - controller.excludeSelected = {type: 'all'}; - controller.onExcludeResponse('accept'); - - expect(controller.exclusionCreate).toHaveBeenCalledWith(); - }); - - it('should call the exclusionGeoCreate() method', () => { - jest.spyOn(controller, 'exclusionGeoCreate').mockReturnThis(); - - controller.excludeSelected = {type: 'specificLocations'}; - controller.onExcludeResponse('accept'); - - expect(controller.exclusionGeoCreate).toHaveBeenCalledWith(); - }); - - it('should call the exclusionDelete() method', () => { - jest.spyOn(controller, 'exclusionDelete').mockReturnThis(); - - controller.excludeSelected = {id: 1, type: 'all'}; - controller.onExcludeResponse('delete'); - - expect(controller.exclusionDelete).toHaveBeenCalledWith(controller.excludeSelected); - }); - }); - - describe('onDeleteResponse()', () => { - it('shoud make an HTTP DELETE query and then call the refresh() method', () => { - jest.spyOn(controller, 'refresh').mockReturnThis(); - - const eventId = 1; - $httpBackend.expect('DELETE', `Zones/1/events/1`).respond({id: 1}); - controller.onDeleteResponse('accept', eventId); - $httpBackend.flush(); - - expect(controller.refresh).toHaveBeenCalledWith(); - }); - }); - - describe('exclusionCreate()', () => { - it('shoud make an HTTP POST query and then call the refresh() method', () => { - jest.spyOn(controller, 'refresh').mockReturnThis(); - - controller.excludeSelected = {}; - controller.isNew = true; - $httpBackend.expect('POST', `Zones/1/exclusions`).respond({id: 1}); - controller.exclusionCreate(); - $httpBackend.flush(); - - expect(controller.refresh).toHaveBeenCalledWith(); - }); - }); - - describe('exclusionDelete()', () => { - it('shoud make an HTTP DELETE query once and then call the refresh() method', () => { - jest.spyOn(controller, 'refresh').mockReturnThis(); - - const exclusions = {id: 1}; - const firstExclusionId = 1; - $httpBackend.expectDELETE(`Zones/1/exclusions/${firstExclusionId}`).respond(200); - controller.exclusionDelete(exclusions); - $httpBackend.flush(); - - expect(controller.refresh).toHaveBeenCalledWith(); - }); - }); - - describe('onSearch()', () => { - it('should call the applyFilter() method and then set the data', () => { - jest.spyOn(controller, 'getChecked').mockReturnValue([1, 2, 3]); - - controller.$.treeview = {}; - controller.$.model = crudModel; - controller.excludeSelected = {type: 'specificLocations'}; - controller._excludeSearch = 'es'; - - controller.onSearch(); - const treeviewData = controller.$.treeview.data; - - expect(treeviewData).toBeDefined(); - expect(treeviewData.length).toEqual(3); - }); - }); - - describe('onFetch()', () => { - it('should call the applyFilter() method and then return the model data', () => { - jest.spyOn(controller, 'getChecked').mockReturnValue([1, 2, 3]); - - controller.$.model = crudModel; - const result = controller.onFetch(); - - expect(result.length).toEqual(3); - }); - }); -}); diff --git a/modules/zone/front/events/locale/es.yml b/modules/zone/front/events/locale/es.yml deleted file mode 100644 index d6eee9f67..000000000 --- a/modules/zone/front/events/locale/es.yml +++ /dev/null @@ -1,12 +0,0 @@ -Edit mode: Modo de edición -Include: Incluir -Exclude: Excluir -Events: Eventos -Add event: Añadir evento -Edit event: Editar evento -All: Todo -Specific locations: Localizaciones concretas -Locations where it is not distributed: Localizaciones en las que no se reparte -You must select a location: Debes seleccionar una localización -Add exclusion: Añadir exclusión -Edit exclusion: Editar exclusión diff --git a/modules/zone/front/events/style.scss b/modules/zone/front/events/style.scss deleted file mode 100644 index 49a6e87a6..000000000 --- a/modules/zone/front/events/style.scss +++ /dev/null @@ -1,11 +0,0 @@ -@import "variables"; - - .width{ - width: 600px - } - - .treeview{ - max-height: 300px; - overflow: auto; - } - diff --git a/modules/zone/front/index.js b/modules/zone/front/index.js index dc20eea47..a7209a0bd 100644 --- a/modules/zone/front/index.js +++ b/modules/zone/front/index.js @@ -1,19 +1,3 @@ export * from './module'; import './main'; -import './index/'; -import './delivery-days'; -import './summary'; -import './card'; -import './descriptor'; -import './descriptor-popover'; -import './search-panel'; -import './create'; -import './basic-data'; -import './warehouses'; -import './events'; -import './calendar'; -import './location'; -import './calendar'; -import './upcoming-deliveries'; -import './log'; diff --git a/modules/zone/front/index/index.html b/modules/zone/front/index/index.html deleted file mode 100644 index 78e3f2cd8..000000000 --- a/modules/zone/front/index/index.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - Id - Name - Agency - Closing - Price - - - - - - {{::zone.id}} - {{::zone.name}} - {{::zone.agencyMode.name}} - {{::zone.hour | date: 'HH:mm'}} - {{::zone.price | currency: 'EUR':2}} - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/zone/front/index/index.js b/modules/zone/front/index/index.js deleted file mode 100644 index ad54f7df4..000000000 --- a/modules/zone/front/index/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - preview(zone) { - this.selectedZone = zone; - this.$.summary.show(); - } - - onCloneAccept(zone) { - return this.$http.post(`Zones/${zone.id}/clone`) - .then(res => { - this.$state.go('zone.card.basicData', {id: res.data.id}); - }); - } -} - -ngModule.vnComponent('vnZoneIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/zone/front/index/locale/es.yml b/modules/zone/front/index/locale/es.yml deleted file mode 100644 index 14195e869..000000000 --- a/modules/zone/front/index/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Do you want to clone this zone?: ¿Seguro que quieres clonar esta zona? -All it's properties will be copied: Todas sus propiedades serán copiadas \ No newline at end of file diff --git a/modules/zone/front/locale/es.yml b/modules/zone/front/locale/es.yml index 7c9e783ab..4d528f37a 100644 --- a/modules/zone/front/locale/es.yml +++ b/modules/zone/front/locale/es.yml @@ -13,7 +13,7 @@ Indefinitely: Indefinido Inflation: Inflación Locations: Localizaciones Maximum m³: M³ máximo -Max m³: Medida máxima +Max m³: Medida máxima New zone: Nueva zona One day: Un día Pick up: Recogida @@ -32,4 +32,4 @@ Warehouses: Almacenes Week days: Días de la semana Zones: Zonas zone: zona -Go to the zone: Ir a la zona \ No newline at end of file +Go to the zone: Ir a la zona diff --git a/modules/zone/front/location/index.html b/modules/zone/front/location/index.html deleted file mode 100644 index b86c618b7..000000000 --- a/modules/zone/front/location/index.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - -
- - - - - - -
diff --git a/modules/zone/front/location/index.js b/modules/zone/front/location/index.js deleted file mode 100644 index 0f92f37de..000000000 --- a/modules/zone/front/location/index.js +++ /dev/null @@ -1,56 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - onSearch(params) { - this.$.model.applyFilter({}, params).then(() => { - const data = this.$.model.data; - this.$.treeview.data = data; - }); - } - - onFetch(item) { - const params = item ? {parentId: item.id} : null; - return this.$.model.applyFilter({}, params) - .then(() => this.$.model.data); - } - - onSort(a, b) { - if (b.selected !== a.selected) { - if (a.selected == null) - return 1; - if (b.selected == null) - return -1; - return b.selected - a.selected; - } - - return a.name.localeCompare(b.name); - } - - exprBuilder(param, value) { - switch (param) { - case 'search': - return {name: {like: `%${value}%`}}; - } - } - - onSelection(value, item) { - if (value == null) - value = undefined; - const params = {geoId: item.id, isIncluded: value}; - const path = `zones/${this.zone.id}/toggleIsIncluded`; - this.$http.post(path, params); - } -} - -ngModule.vnComponent('vnZoneLocation', { - template: require('./index.html'), - controller: Controller, - bindings: { - zone: '<' - }, - require: { - card: '^vnZoneCard' - } -}); diff --git a/modules/zone/front/location/index.spec.js b/modules/zone/front/location/index.spec.js deleted file mode 100644 index 30968209c..000000000 --- a/modules/zone/front/location/index.spec.js +++ /dev/null @@ -1,50 +0,0 @@ -import './index'; -import crudModel from 'core/mocks/crud-model'; - -describe('component vnZoneLocation', () => { - let $scope; - let controller; - let $httpBackend; - - beforeEach(ngModule('zone')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - const $element = angular.element(``); - controller = $componentController('vnZoneLocation', {$element, $scope}); - controller.$.model = crudModel; - controller.zone = {id: 1}; - })); - - describe('onSearch()', () => { - it('should call the applyFilter() method and then set the data', () => { - controller.$.treeview = {}; - controller.onSearch({}); - - const treeviewData = controller.$.treeview.data; - - expect(treeviewData).toBeDefined(); - expect(treeviewData.length).toEqual(3); - }); - }); - - describe('onFetch()', () => { - it('should call the applyFilter() method and then return the model data', () => { - const result = controller.onFetch(); - - expect(result.length).toEqual(3); - }); - }); - - describe('onSelection()', () => { - it('should make an HTTP POST query', () => { - const item = {id: 123}; - - const expectedParams = {geoId: 123, isIncluded: true}; - $httpBackend.expect('POST', `zones/1/toggleIsIncluded`, expectedParams).respond(200); - controller.onSelection(true, item); - $httpBackend.flush(); - }); - }); -}); diff --git a/modules/zone/front/location/style.scss b/modules/zone/front/location/style.scss deleted file mode 100644 index 24d685a51..000000000 --- a/modules/zone/front/location/style.scss +++ /dev/null @@ -1,21 +0,0 @@ -@import "variables"; - -vn-zone-location { - vn-treeview-child { - .content > .vn-check:not(.indeterminate):not(.checked) { - color: $color-alert; - - & > .btn { - border-color: $color-alert; - } - } - .content > .vn-check.checked { - color: $color-notice; - - & > .btn { - background-color: $color-notice; - border-color: $color-notice - } - } - } -} diff --git a/modules/zone/front/log/index.html b/modules/zone/front/log/index.html deleted file mode 100644 index 539afda82..000000000 --- a/modules/zone/front/log/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/modules/zone/front/log/index.js b/modules/zone/front/log/index.js deleted file mode 100644 index 8c3be2423..000000000 --- a/modules/zone/front/log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnZoneLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/zone/front/main/index.html b/modules/zone/front/main/index.html index 8dd6cdf78..e69de29bb 100644 --- a/modules/zone/front/main/index.html +++ b/modules/zone/front/main/index.html @@ -1,19 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/modules/zone/front/main/index.js b/modules/zone/front/main/index.js index 3be60c5a1..38896d418 100644 --- a/modules/zone/front/main/index.js +++ b/modules/zone/front/main/index.js @@ -4,25 +4,10 @@ import ModuleMain from 'salix/components/module-main'; export default class Zone extends ModuleMain { constructor($element, $) { super($element, $); - this.filter = { - include: { - relation: 'agencyMode', - scope: {fields: ['name']} - } - }; } - - exprBuilder(param, value) { - switch (param) { - case 'search': - return /^\d+$/.test(value) - ? {id: value} - : {name: {like: `%${value}%`}}; - case 'name': - return {[param]: {like: `%${value}%`}}; - case 'agencyModeFk': - return {[param]: value}; - } + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`zone/`); } } diff --git a/modules/zone/front/main/index.spec.js b/modules/zone/front/main/index.spec.js deleted file mode 100644 index 1e50cee80..000000000 --- a/modules/zone/front/main/index.spec.js +++ /dev/null @@ -1,30 +0,0 @@ -import './index.js'; - -describe('Zone Component vnZone', () => { - let controller; - - beforeEach(ngModule('zone')); - - beforeEach(inject($componentController => { - const $element = angular.element(''); - controller = $componentController('vnZone', {$element}); - })); - - describe('exprBuilder()', () => { - it('should return a formated object with the id in case of search', () => { - let param = 'search'; - let value = 1; - let result = controller.exprBuilder(param, value); - - expect(result).toEqual({id: 1}); - }); - - it('should return a formated object with the agencyModeFk in case of agencyModeFk', () => { - let param = 'agencyModeFk'; - let value = 'My Delivery'; - let result = controller.exprBuilder(param, value); - - expect(result).toEqual({agencyModeFk: 'My Delivery'}); - }); - }); -}); diff --git a/modules/zone/front/routes.json b/modules/zone/front/routes.json index 7f67260da..a4993007d 100644 --- a/modules/zone/front/routes.json +++ b/modules/zone/front/routes.json @@ -7,15 +7,6 @@ "menus": { "main": [ {"state": "zone.index", "icon": "icon-zone"}, - {"state": "zone.deliveryDays", "icon": "today"}, - {"state": "zone.upcomingDeliveries", "icon": "today"} - ], - "card": [ - {"state": "zone.card.basicData", "icon": "settings"}, - {"state": "zone.card.location", "icon": "my_location"}, - {"state": "zone.card.warehouses", "icon": "home"}, - {"state": "zone.card.log", "icon": "history"}, - {"state": "zone.card.events", "icon": "today"} ] }, "keybindings": [ @@ -34,79 +25,6 @@ "state": "zone.index", "component": "vn-zone-index", "description": "Zones" - }, - { - "url": "/delivery-days?q&deliveryMethodFk&geoFk&agencyModeFk", - "state": "zone.deliveryDays", - "component": "vn-zone-delivery-days", - "description": "Delivery days" - }, - { - "url": "/upcoming-deliveries", - "state": "zone.upcomingDeliveries", - "component": "vn-upcoming-deliveries", - "description": "Upcoming deliveries" - }, - { - "url": "/create", - "state": "zone.create", - "component": "vn-zone-create", - "description": "New zone" - }, - { - "url": "/:id", - "state": "zone.card", - "component": "vn-zone-card", - "abstract": true, - "description": "Detail" - }, - { - "url": "/summary", - "state": "zone.card.summary", - "component": "vn-zone-summary", - "description": "Summary", - "params": { - "zone": "$ctrl.zone" - } - }, - { - "url": "/basic-data", - "state": "zone.card.basicData", - "component": "vn-zone-basic-data", - "description": "Basic data", - "params": { - "zone": "$ctrl.zone" - } - }, - { - "url": "/warehouses", - "state": "zone.card.warehouses", - "component": "vn-zone-warehouses", - "description": "Warehouses" - }, - { - "url": "/events?q", - "state": "zone.card.events", - "component": "vn-zone-events", - "description": "Calendar", - "params": { - "zone": "$ctrl.zone" - } - }, - { - "url": "/location?q", - "state": "zone.card.location", - "component": "vn-zone-location", - "description": "Locations", - "params": { - "zone": "$ctrl.zone" - } - }, - { - "url" : "/log", - "state": "zone.card.log", - "component": "vn-zone-log", - "description": "Log" } ] -} \ No newline at end of file +} diff --git a/modules/zone/front/search-panel/index.html b/modules/zone/front/search-panel/index.html deleted file mode 100644 index bda8a946e..000000000 --- a/modules/zone/front/search-panel/index.html +++ /dev/null @@ -1,34 +0,0 @@ -
-
- - - - - - - - - - - - - - - -
-
\ No newline at end of file diff --git a/modules/zone/front/search-panel/index.js b/modules/zone/front/search-panel/index.js deleted file mode 100644 index 598af02b2..000000000 --- a/modules/zone/front/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.vnComponent('vnZoneSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/zone/front/summary/index.html b/modules/zone/front/summary/index.html deleted file mode 100644 index 2fe94388f..000000000 --- a/modules/zone/front/summary/index.html +++ /dev/null @@ -1,59 +0,0 @@ - -
- - - - #{{$ctrl.summary.id}} - {{$ctrl.summary.name}} -
- - - - - - - - - - - - - - - - - - - - - - -

- - Warehouse - -

- - - - Name - - - - - {{zoneWarehouse.warehouse.name}} - - - -
-
-
\ No newline at end of file diff --git a/modules/zone/front/summary/index.js b/modules/zone/front/summary/index.js deleted file mode 100644 index ad33f28be..000000000 --- a/modules/zone/front/summary/index.js +++ /dev/null @@ -1,56 +0,0 @@ -import ngModule from '../module'; -import Summary from 'salix/components/summary'; - -class Controller extends Summary { - get zone() { - return this._zone; - } - - set zone(value) { - this._zone = value; - - if (!value) return; - - this.getSummary(); - this.getWarehouses(); - } - - getSummary() { - const params = { - filter: { - include: { - relation: 'agencyMode', - fields: ['name'] - }, - where: { - id: this.zone.id - } - } - }; - this.$http.get(`Zones/findOne`, {params}).then(res => { - this.summary = res.data; - }); - } - - getWarehouses() { - const params = { - filter: { - include: { - relation: 'warehouse', - fields: ['name'] - } - } - }; - this.$http.get(`Zones/${this.zone.id}/warehouses`, {params}).then(res => { - this.zoneWarehouses = res.data; - }); - } -} - -ngModule.vnComponent('vnZoneSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - zone: '<' - } -}); diff --git a/modules/zone/front/summary/index.spec.js b/modules/zone/front/summary/index.spec.js deleted file mode 100644 index 7541ee795..000000000 --- a/modules/zone/front/summary/index.spec.js +++ /dev/null @@ -1,76 +0,0 @@ -import './index'; - -describe('component vnZoneSummary', () => { - let $scope; - let controller; - let $httpBackend; - let $httpParamSerializer; - - beforeEach(ngModule('zone')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - $scope = $rootScope.$new(); - const $element = angular.element(``); - controller = $componentController('vnZoneSummary', {$element, $scope}); - })); - - describe('zone setter', () => { - it('should set the zone and then call both getSummary() and getWarehouses()', () => { - jest.spyOn(controller, 'getSummary'); - jest.spyOn(controller, 'getWarehouses'); - - controller.zone = {id: 1}; - - expect(controller.getSummary).toHaveBeenCalledWith(); - expect(controller.getWarehouses).toHaveBeenCalledWith(); - }); - }); - - describe('getSummary()', () => { - it('should perform a get and then store data on the controller', () => { - controller._zone = {id: 1}; - let params = { - filter: { - include: { - relation: 'agencyMode', - fields: ['name'] - }, - where: { - id: controller._zone.id - } - } - }; - const serializedParams = $httpParamSerializer(params); - const query = `Zones/findOne?${serializedParams}`; - $httpBackend.expectGET(query).respond({id: 1}); - controller.getSummary(); - $httpBackend.flush(); - - expect(controller.summary).toBeDefined(); - }); - }); - - describe('getWarehouses()', () => { - it('should make an HTTP get query and then store data on the controller', () => { - controller._zone = {id: 1}; - const params = { - filter: { - include: { - relation: 'warehouse', - fields: ['name'] - } - } - }; - - const serializedParams = $httpParamSerializer(params); - const query = `Zones/1/warehouses?${serializedParams}`; - $httpBackend.expect('GET', query).respond([{id: 1}]); - controller.getWarehouses(); - $httpBackend.flush(); - - expect(controller.zoneWarehouses.length).toEqual(1); - }); - }); -}); diff --git a/modules/zone/front/upcoming-deliveries/index.html b/modules/zone/front/upcoming-deliveries/index.html deleted file mode 100644 index afcd0bbc6..000000000 --- a/modules/zone/front/upcoming-deliveries/index.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - -
- -
{{$ctrl.getWeekDay(detail.shipped)}} - {{detail.shipped | date: 'dd/MM/yyyy'}}
-
- - - - Province - Closing - Id - - - - - {{::zone.name}} - {{::zone.hour}} - {{::zone.zoneFk}} - - - -
-
-
diff --git a/modules/zone/front/upcoming-deliveries/index.js b/modules/zone/front/upcoming-deliveries/index.js deleted file mode 100644 index 371321711..000000000 --- a/modules/zone/front/upcoming-deliveries/index.js +++ /dev/null @@ -1,23 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $, vnWeekDays) { - super($element, $); - this.days = vnWeekDays.days; - } - - getWeekDay(jsonDate) { - const weekDay = new Date(jsonDate).getDay(); - - return this.days[weekDay].locale; - } -} - -Controller.$inject = ['$element', '$scope', 'vnWeekDays']; - -ngModule.vnComponent('vnUpcomingDeliveries', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/zone/front/upcoming-deliveries/index.spec.js b/modules/zone/front/upcoming-deliveries/index.spec.js deleted file mode 100644 index 95eb999f9..000000000 --- a/modules/zone/front/upcoming-deliveries/index.spec.js +++ /dev/null @@ -1,22 +0,0 @@ -import './index'; - -describe('component vnUpcomingDeliveries', () => { - let $scope; - let controller; - - beforeEach(ngModule('zone')); - - beforeEach(inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - const $element = angular.element(``); - controller = $componentController('vnUpcomingDeliveries', {$element, $scope}); - })); - - describe('getWeekDay()', () => { - it('should retrieve a weekday for a json passed', () => { - let jsonDate = '1970-01-01T22:00:00.000Z'; - - expect(controller.getWeekDay(jsonDate)).toEqual('Thursday'); - }); - }); -}); diff --git a/modules/zone/front/upcoming-deliveries/locale/es.yml b/modules/zone/front/upcoming-deliveries/locale/es.yml deleted file mode 100644 index 9f08e3a72..000000000 --- a/modules/zone/front/upcoming-deliveries/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Family: Familia -Percentage: Porcentaje -Dwindle: Mermas \ No newline at end of file diff --git a/modules/zone/front/upcoming-deliveries/style.scss b/modules/zone/front/upcoming-deliveries/style.scss deleted file mode 100644 index b52231a09..000000000 --- a/modules/zone/front/upcoming-deliveries/style.scss +++ /dev/null @@ -1,26 +0,0 @@ -@import "variables"; - -vn-upcoming-deliveries { - .header { - margin-bottom: 16px; - text-transform: uppercase; - font-size: 1.25rem; - line-height: 1; - padding: 7px; - padding-bottom: 7px; - padding-bottom: 4px; - font-weight: lighter; - background-color: $color-main-light; - border-bottom: 1px solid $color-primary; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - background-color: $color-bg; - } - - vn-table vn-th.waste-family, - vn-table vn-td.waste-family { - max-width: 64px; - width: 64px - } -} \ No newline at end of file diff --git a/modules/zone/front/warehouses/index.html b/modules/zone/front/warehouses/index.html deleted file mode 100644 index acd85f182..000000000 --- a/modules/zone/front/warehouses/index.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - {{::row.warehouse.name}} - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/zone/front/warehouses/index.js b/modules/zone/front/warehouses/index.js deleted file mode 100644 index 85b398658..000000000 --- a/modules/zone/front/warehouses/index.js +++ /dev/null @@ -1,56 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - $onInit() { - this.refresh(); - } - - get path() { - return `Zones/${this.$params.id}/warehouses`; - } - - refresh() { - let filter = {include: 'warehouse'}; - this.$http.get(this.path, {params: {filter}}) - .then(res => this.$.data = res.data); - } - - onCreate() { - this.selected = {}; - this.$.dialog.show(); - } - - onSave() { - this.$http.post(this.path, this.selected) - .then(() => { - this.selected = null; - this.isNew = null; - this.$.dialog.hide(); - this.refresh(); - }); - - return false; - } - - onDelete(row) { - this.$.confirm.show(); - this.deleteRow = row; - } - - delete() { - let row = this.deleteRow; - if (!row) return; - return this.$http.delete(`${this.path}/${row.id}`) - .then(() => { - let index = this.$.data.indexOf(row); - if (index !== -1) this.$.data.splice(index, 1); - this.deleteRow = null; - }); - } -} - -ngModule.vnComponent('vnZoneWarehouses', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/zone/front/warehouses/index.spec.js b/modules/zone/front/warehouses/index.spec.js deleted file mode 100644 index 0e71d541c..000000000 --- a/modules/zone/front/warehouses/index.spec.js +++ /dev/null @@ -1,60 +0,0 @@ -import './index.js'; - -describe('Zone warehouses', () => { - let $httpBackend; - let $httpParamSerializer; - let controller; - let $element; - - beforeEach(ngModule('zone')); - - beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => { - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - $element = angular.element(' { - it('should make an HTTP GET query and then set the data', () => { - const params = {filter: {include: 'warehouse'}}; - const serializedParams = $httpParamSerializer(params); - const path = `Zones/1/warehouses?${serializedParams}`; - $httpBackend.expect('GET', path).respond([{id: 1, name: 'Warehouse one'}]); - controller.refresh(); - $httpBackend.flush(); - - expect(controller.$.data).toBeDefined(); - }); - }); - - describe('onSave()', () => { - it('should make an HTTP POST query and then call the refresh() method', () => { - jest.spyOn(controller, 'refresh').mockReturnThis(); - - $httpBackend.expect('POST', `Zones/1/warehouses`).respond(200); - controller.onSave(); - $httpBackend.flush(); - - expect(controller.selected).toBeNull(); - expect(controller.isNew).toBeNull(); - expect(controller.$.dialog.hide).toHaveBeenCalledWith(); - expect(controller.refresh).toHaveBeenCalledWith(); - }); - }); - - describe('delete()', () => { - it('should make an HTTP DELETE query and then set deleteRow property to null value', () => { - controller.deleteRow = {id: 1}; - controller.$.data = [{id: 1}]; - $httpBackend.expect('DELETE', `Zones/1/warehouses/1`).respond(200); - controller.delete(); - $httpBackend.flush(); - - expect(controller.deleteRow).toBeNull(); - }); - }); -}); diff --git a/myt.config.yml b/myt.config.yml index 56239ca3c..25f94f1bd 100755 --- a/myt.config.yml +++ b/myt.config.yml @@ -2,6 +2,7 @@ code: vn-database versionSchema: util replace: true sumViews: false +defaultDefiner: vn@localhost mockDate: '2001-01-01 12:00:00' subdir: db schemas: @@ -42,7 +43,7 @@ fixtures: - ACL - fieldAcl - module - - defaultViewConfig + - defaultViewMultiConfig vn: - alertLevel - bookingPlanner @@ -66,9 +67,9 @@ fixtures: - siiTrascendencyInvoiceIn - siiTypeInvoiceIn - siiTypeInvoiceOut - - silexACL - state - ticketUpdateAction + - ticketCanAdvanceConfig - volumeConfig - workCenter - workerTimeControlError @@ -363,7 +364,7 @@ localFixtures: - travelConfig - travelRecalc - travelThermograph - - userConfig + - userMultiConfig - vehicle - wagonConfig - wagonType @@ -376,7 +377,7 @@ localFixtures: - workerBosses - workerBusinessType - workerConfig - - workerDocument + - workerDms - workerLog - workerMana - workerManaExcluded @@ -394,4 +395,4 @@ localFixtures: - zoneExclusionGeo - zoneGeo - zoneIncluded - - zoneWarehouse \ No newline at end of file + - zoneWarehouse diff --git a/package.json b/package.json index c2f630974..767ec231e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.24.0", + "version": "24.44.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", @@ -43,6 +43,7 @@ "mysql": "2.18.1", "node-ssh": "^11.0.0", "object.pick": "^1.3.0", + "pdf-merger-js": "^5.1.2", "puppeteer": "21.11.0", "read-chunk": "^3.2.0", "require-yaml": "0.0.1", @@ -59,7 +60,7 @@ "@babel/register": "^7.7.7", "@commitlint/cli": "^19.2.1", "@commitlint/config-conventional": "^19.1.0", - "@verdnatura/myt": "^1.6.9", + "@verdnatura/myt": "^1.6.12", "angular-mocks": "^1.7.9", "babel-jest": "^26.0.1", "babel-loader": "^8.2.4", @@ -80,10 +81,10 @@ "gulp-merge-json": "^1.3.1", "gulp-nodemon": "^2.5.0", "gulp-print": "^2.0.1", - "gulp-wrap": "^0.15.0", - "gulp-yaml": "^1.0.1", "gulp-rename": "^2.0.0", "gulp-replace": "^1.1.4", + "gulp-wrap": "^0.15.0", + "gulp-yaml": "^1.0.1", "html-loader": "^0.4.5", "html-loader-jest": "^0.2.1", "html-webpack-plugin": "^5.5.1", @@ -117,7 +118,10 @@ "test:front": "jest --watch", "back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back", "lint": "eslint ./ --cache --ignore-pattern .gitignore", - "watch:db": "node ./db/dbWatcher.js" + "watch:db": "node ./db/dbWatcher.js", + "commitlint": "commitlint --edit", + "prepare": "npx husky install", + "addReferenceTag": "node .husky/addReferenceTag.js" }, "jest": { "projects": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 22d5b46f1..042b91fe0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -95,6 +95,9 @@ dependencies: object.pick: specifier: ^1.3.0 version: 1.3.0 + pdf-merger-js: + specifier: ^5.1.2 + version: 5.1.2 puppeteer: specifier: 21.11.0 version: 21.11.0(typescript@5.4.4) @@ -140,8 +143,8 @@ devDependencies: specifier: ^19.1.0 version: 19.1.0 '@verdnatura/myt': - specifier: ^1.6.9 - version: 1.6.9 + specifier: ^1.6.12 + version: 1.6.12 angular-mocks: specifier: ^1.7.9 version: 1.8.3 @@ -2090,6 +2093,18 @@ packages: rimraf: 3.0.2 dev: true + /@pdf-lib/standard-fonts@1.0.0: + resolution: {integrity: sha512-hU30BK9IUN/su0Mn9VdlVKsWBS6GyhVfqjwl1FjZN4TxP6cCw0jP2w7V3Hf5uX7M0AZJ16vey9yE0ny7Sa59ZA==} + dependencies: + pako: 1.0.11 + dev: false + + /@pdf-lib/upng@1.0.1: + resolution: {integrity: sha512-dQK2FUMQtowVP00mtIksrlZhdFXQZPC+taih1q4CvPZ5vqdxR/LKBaFg0oAfzd1GlHZXXSPdQfzQnt+ViGvEIQ==} + dependencies: + pako: 1.0.11 + dev: false + /@pkgjs/parseargs@0.11.0: resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} @@ -2831,8 +2846,8 @@ packages: dev: false optional: true - /@verdnatura/myt@1.6.9: - resolution: {integrity: sha512-29IauYra9igfdPWwV4+pVV/tBXvIg0fkVHEpSz8Zz3G3lRtzm286FN2Kv6hZkxmD/F1n52O37jN9WLiLHDTW1Q==} + /@verdnatura/myt@1.6.12: + resolution: {integrity: sha512-t/SiDuQW9KJkcjhwQ9AkrcoTwghxQ7IyQ56e+88eYdoMi24l6bQGF0wHzMaIPRfQAoR8hqgfMOief4OAqW4Iqw==} hasBin: true dependencies: '@sqltools/formatter': 1.2.5 @@ -3291,6 +3306,7 @@ packages: /are-we-there-yet@1.1.7: resolution: {integrity: sha512-nxwy40TuMiUGqMyRHgCSWZ9FM4VAoRP4xUYSTv5ImRog+h9yISPbVH7H8fASCIzYn9wlEv4zvFL7uKDMCFQm3g==} + deprecated: This package is no longer supported. dependencies: delegates: 1.0.0 readable-stream: 2.3.8 @@ -4486,6 +4502,11 @@ packages: engines: {node: '>=14'} dev: true + /commander@11.1.0: + resolution: {integrity: sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==} + engines: {node: '>=16'} + dev: false + /commander@2.17.1: resolution: {integrity: sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==} dev: true @@ -6527,7 +6548,7 @@ packages: resolution: {integrity: sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==} engines: {node: '>= 4.0'} os: [darwin] - deprecated: The v1 package contains DANGEROUS / INSECURE binaries. Upgrade to safe fsevents v2 + deprecated: Upgrade to fsevents v2 to mitigate potential security issues requiresBuild: true dependencies: bindings: 1.5.0 @@ -6573,6 +6594,7 @@ packages: /gauge@2.7.4: resolution: {integrity: sha512-14x4kjc6lkD3ltw589k0NrPD6cCNTD6CWoVUNpB85+DrtONoZn+Rug6xZU5RvSC4+TZPxA5AnBibQYAvZn41Hg==} + deprecated: This package is no longer supported. dependencies: aproba: 1.2.0 console-control-strings: 1.1.0 @@ -10463,7 +10485,7 @@ packages: engines: {node: '>=10'} requiresBuild: true dependencies: - semver: 7.5.4 + semver: 7.6.0 dev: false optional: true @@ -10794,6 +10816,7 @@ packages: /npmlog@4.1.2: resolution: {integrity: sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==} + deprecated: This package is no longer supported. dependencies: are-we-there-yet: 1.1.7 console-control-strings: 1.1.0 @@ -11035,6 +11058,7 @@ packages: /osenv@0.1.5: resolution: {integrity: sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==} + deprecated: This package is no longer supported. dependencies: os-homedir: 1.0.2 os-tmpdir: 1.0.2 @@ -11323,6 +11347,24 @@ packages: pinkie-promise: 2.0.1 dev: true + /pdf-lib@1.17.1: + resolution: {integrity: sha512-V/mpyJAoTsN4cnP31vc0wfNA1+p20evqqnap0KLoRUN0Yk/p3wN52DOEsL4oBFcLdb76hlpKPtzJIgo67j/XLw==} + dependencies: + '@pdf-lib/standard-fonts': 1.0.0 + '@pdf-lib/upng': 1.0.1 + pako: 1.0.11 + tslib: 1.14.1 + dev: false + + /pdf-merger-js@5.1.2: + resolution: {integrity: sha512-RCBjLQILZ8UA4keO/Ip2/gjUuxigMMoK7mO5eJg6zjlnyymboFnRTgzKwOs/FiU9ornS2m72Qr95oARX1C24fw==} + engines: {node: '>=14'} + hasBin: true + dependencies: + commander: 11.1.0 + pdf-lib: 1.17.1 + dev: false + /pend@1.2.0: resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==} dev: false @@ -12459,6 +12501,7 @@ packages: hasBin: true dependencies: lru-cache: 6.0.0 + dev: true /semver@7.6.0: resolution: {integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==} @@ -12466,7 +12509,6 @@ packages: hasBin: true dependencies: lru-cache: 6.0.0 - dev: true /send@0.18.0(supports-color@6.1.0): resolution: {integrity: sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==} @@ -13836,6 +13878,10 @@ packages: resolution: {integrity: sha512-nsZd8ZeNUzukXPlJmTBwUAuABDe/9qtVDelJeT/qW0ow3ZS3BsQJtNkan1802aM9Uf68/Y8ljw86Hu0h5IUW3w==} dev: false + /tslib@1.14.1: + resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} + dev: false + /tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} diff --git a/print/core/components/email-footer/email-footer.html b/print/core/components/email-footer/email-footer.html index 9c5df59a9..5cacdd129 100644 --- a/print/core/components/email-footer/email-footer.html +++ b/print/core/components/email-footer/email-footer.html @@ -1,19 +1,16 @@ \ No newline at end of file diff --git a/print/core/email.js b/print/core/email.js index 5de13099a..a673685bb 100644 --- a/print/core/email.js +++ b/print/core/email.js @@ -2,6 +2,7 @@ const path = require('path'); const smtp = require('./smtp'); const Component = require('./component'); const Report = require('./report'); +const UserError = require('vn-loopback/util/user-error'); if (!process.env.OPENSSL_CONF) process.env.OPENSSL_CONF = '/etc/ssl/'; @@ -9,7 +10,6 @@ if (!process.env.OPENSSL_CONF) class Email extends Component { constructor(name, args) { super(name); - this.args = args; } @@ -33,7 +33,7 @@ class Email extends Component { const attachments = []; const getAttachments = async(componentPath, files) => { for (const file of files) { - const fileCopy = Object.assign({}, file); + const fileCopy = {...file}; const fileName = fileCopy.filename; if (options.overrideAttachments && !fileName.includes('.png')) continue; @@ -88,7 +88,11 @@ class Email extends Component { force: options.force }; - return await smtp.send(mailOptions); + try { + return await smtp.send(mailOptions); + } catch (error) { + throw new UserError('Cannot send mail'); + } } } diff --git a/print/templates/email/buyer-week-waste/sql/wasteWeekly.sql b/print/templates/email/buyer-week-waste/sql/wasteWeekly.sql index 943c085d0..e5dbdfcb6 100644 --- a/print/templates/email/buyer-week-waste/sql/wasteWeekly.sql +++ b/print/templates/email/buyer-week-waste/sql/wasteWeekly.sql @@ -1,11 +1,19 @@ -SELECT *, 100 * dwindle / total AS percentage +SELECT *, 100 * dwindle / total `percentage` FROM ( - SELECT buyer, - sum(saleTotal) as total, - sum(saleWaste) as dwindle + SELECT u.name buyer, + SUM(w.saleTotal) total, + SUM( + w.saleExternalWaste + + w.saleFaultWaste + + w.saleContainerWaste + + w.saleBreakWaste + + w.saleOtherWaste + ) dwindle FROM bs.waste w - JOIN vn.time t ON w.year = t.year AND w.week = t.week - WHERE t.dated = DATE_ADD(CURDATE(), INTERVAL -1 WEEK) - GROUP BY buyer + JOIN account.user u ON u.id = w.buyerFk + JOIN vn.itemType it ON it.id = w.itemTypeFk + WHERE w.year = YEAR(util.VN_CURDATE() - INTERVAL 1 WEEK) + AND w.week = WEEK(util.VN_CURDATE() - INTERVAL 1 WEEK, 4) + GROUP BY buyerFk ) sub - ORDER BY percentage DESC; \ No newline at end of file + ORDER BY `percentage` DESC; diff --git a/print/templates/email/invoice-ticket-closure/invoice-ticket-closure.html b/print/templates/email/invoice-ticket-closure/invoice-ticket-closure.html index 2effa8917..f72b2177f 100644 --- a/print/templates/email/invoice-ticket-closure/invoice-ticket-closure.html +++ b/print/templates/email/invoice-ticket-closure/invoice-ticket-closure.html @@ -7,6 +7,7 @@

{{ $t('ticketId') }}: {{ticket.ticketId}}

{{ $t('reason') }}: {{ticket.reason}}

+

{{ $t('clientId')}}{{ticket.clientId}}


diff --git a/print/templates/email/invoice-ticket-closure/locale/en.yml b/print/templates/email/invoice-ticket-closure/locale/en.yml index fef73d23f..34f31c8e3 100644 --- a/print/templates/email/invoice-ticket-closure/locale/en.yml +++ b/print/templates/email/invoice-ticket-closure/locale/en.yml @@ -1,4 +1,5 @@ subject: Nightly ticket closing process report title: Nightly ticket closing process report reason: Reason -ticketId: Ticket \ No newline at end of file +ticketId: Ticket +clientId: Client \ No newline at end of file diff --git a/print/templates/email/invoice-ticket-closure/locale/es.yml b/print/templates/email/invoice-ticket-closure/locale/es.yml index 7d146b83d..a87311114 100644 --- a/print/templates/email/invoice-ticket-closure/locale/es.yml +++ b/print/templates/email/invoice-ticket-closure/locale/es.yml @@ -1,4 +1,5 @@ subject: Informe proceso de cierre de tickets nocturno title: Informe proceso de cierre de tickets nocturno reason: Motivo -ticketId: Ticket \ No newline at end of file +ticketId: Ticket +clientId: Cliente \ No newline at end of file diff --git a/print/templates/email/mrw-deadline/assets/css/import.js b/print/templates/email/mrw-deadline/assets/css/import.js new file mode 100644 index 000000000..4b4bb7086 --- /dev/null +++ b/print/templates/email/mrw-deadline/assets/css/import.js @@ -0,0 +1,11 @@ +const Stylesheet = require(`vn-print/core/stylesheet`); + +const path = require('path'); +const vnPrintPath = path.resolve('print'); + +module.exports = new Stylesheet([ + `${vnPrintPath}/common/css/spacing.css`, + `${vnPrintPath}/common/css/misc.css`, + `${vnPrintPath}/common/css/layout.css`, + `${vnPrintPath}/common/css/email.css`]) + .mergeStyles(); diff --git a/print/templates/email/mrw-deadline/locale/en.yml b/print/templates/email/mrw-deadline/locale/en.yml new file mode 100644 index 000000000..e10ec9e58 --- /dev/null +++ b/print/templates/email/mrw-deadline/locale/en.yml @@ -0,0 +1,5 @@ +subject: Exceeding MRW Cut-off Time +title: Exceeding MRW Cut-off Time +greeting: Dear Team. +body: Please be informed that we have exceeded the cut-off time indicated by MRW. From this moment, all generated labels will have a delivery date for tomorrow.It is necessary to contact the MRW representatives to manage any urgencies or clarifications that may arise. +footer: Best regards. diff --git a/print/templates/email/mrw-deadline/locale/es.yml b/print/templates/email/mrw-deadline/locale/es.yml new file mode 100644 index 000000000..656639fc3 --- /dev/null +++ b/print/templates/email/mrw-deadline/locale/es.yml @@ -0,0 +1,5 @@ +subject: Superación de la Hora de Corte de MRW +title: Superación de la Hora de Corte de MRW +greeting: Estimado equipo. +body: Les informo que hemos superado la hora de corte indicada por MRW. A partir de este momento, todas las etiquetas generadas tendrán fecha de entrega para mañana.Es necesario que se pongan en contacto con los responsables de MRW para gestionar cualquier urgencia o aclaración que puedan necesitar. +footer: Saludos cordiales. diff --git a/print/templates/email/mrw-deadline/mrw-deadline.html b/print/templates/email/mrw-deadline/mrw-deadline.html new file mode 100644 index 000000000..adcf0228c --- /dev/null +++ b/print/templates/email/mrw-deadline/mrw-deadline.html @@ -0,0 +1,10 @@ + +
+
+

{{ $t('title') }}

+

{{$t('greeting')}}

+

{{$t('body')}}

+

{{$t('footer')}}

+
+
+
diff --git a/print/templates/email/mrw-deadline/mrw-deadline.js b/print/templates/email/mrw-deadline/mrw-deadline.js new file mode 100755 index 000000000..574d88a0d --- /dev/null +++ b/print/templates/email/mrw-deadline/mrw-deadline.js @@ -0,0 +1,9 @@ +const Component = require(`vn-print/core/component`); +const emailBody = new Component('email-body'); + +module.exports = { + name: 'mrw-deadline', + components: { + 'email-body': emailBody.build(), + } +}; diff --git a/print/templates/email/printer-setup/locale/fr.yml b/print/templates/email/printer-setup/locale/fr.yml new file mode 100644 index 000000000..0c9f7031a --- /dev/null +++ b/print/templates/email/printer-setup/locale/fr.yml @@ -0,0 +1,39 @@ +subject: Instalation et configuration de l'imprimante +title: "Merci pour votre confiance !" +description: + dear: Cher client + instructions: Veuillez suivre les instructions spécifiées dans cet e-mail pour procéder à l'installation de l'imprimante. + followGuide: Vous pouvez utiliser comme guide la vidéo du montage du ruban et de la bande. + https://www.youtube.com/watch?v=qhb0kgQF3o8. Vous + aurez également besoin de GoLabel, le programme pour imprimer les bandes. + downloadFrom: Vous pouvez le télécharger depuis ce lien. https://cdn.verdnatura.es/public/GoLabel.zip + downloadDriver: Vous pouvez télécharger le pilote de l'imprimante depuis ce lien. https://es.seagullscientific.com/support/downloads/drivers/godex/download/ +sections: + GoLabel: + title: Utilisation de GoLabel + description: Pour utiliser le programme d'impression des bandes, suivez ces étapes + steps: + - Ci-joint à cet e-mail, vous trouverez le fichier 'model.ezp' (le modèle de bandes de corona standard). Téléchargez-le et vous le trouverez probablement dans le dossier 'Téléchargements'. + - Ouvrez le programme GoLabel. + - Cliquez sur l'icône de la barre supérieure en forme de dossier avec une feuille. + - Sélectionnez le fichier nommé 'model.ezp' (qui se trouve probablement dans 'Téléchargements'), puis cliquez sur Ouvrir. + - Une fois le fichier ouvert, double-cliquez sur le texte. Dans la boîte qui s'ouvre, cliquez sur le texte d'exemple (dans ce cas "TUS HERMANOS") et il apparaîtra dans la même zone à gauche pour que vous puissiez l'éditer et écrire ce que vous souhaitez. + - Lorsque vous avez le texte souhaité, cliquez sur le bouton 'OK'. + - Allez dans 'Fichier' → 'Enregistrer sous' et enregistrez-le sur le bureau sous un autre nom. + - Ensuite, pour imprimer, vous devez d'abord configurer l'imprimante. + - Cliquez sur la huitième icône de la barre supérieure, qui sera ici une imprimante avec un engrenage orange. + - Une fois là, cliquez sur le menu déroulant du modèle d'imprimante et choisissez le modèle qui correspond au vôtre 'G***'. + - Cliquez sur 'Enregistrer' et notre imprimante sera configurée et prête. + - Et enfin, pour imprimer, cliquez sur la neuvième icône, qui correspond à une imprimante bleue. + help: + title: "Avez-vous besoin d'aide ?" + description: Si vous avez besoin d'aide, téléchargez notre programme de support afin que nous puissions nous connecter à distance à votre ordinateur et effectuer l'installation. Veuillez nous fournir un horaire de contact pour vous assister, et nous vous contacterons. + remoteSupport: Vous pouvez télécharger le programme depuis ce lien. http://soporte.verdnatura.es. +help: Pour toute question que vous pourriez avoir, n'hésitez pas à nous la poser. Nous sommes là pour vous aider ! +salesPersonName: Je suis votre commercial et mon nom est +salesPersonPhone: Téléphone et WhatsApp. +salesPersonEmail: Adresse e-mail. diff --git a/print/templates/email/sepa-core/locale/en.yml b/print/templates/email/sepa-core/locale/en.yml new file mode 100644 index 000000000..c6cc4dab4 --- /dev/null +++ b/print/templates/email/sepa-core/locale/en.yml @@ -0,0 +1,16 @@ +subject: Bank Direct Debit Request +title: SEPA CORE Direct Debit +description: + dear: Dear Customer + instructions:

Given the excellent relationship between our two companies + and to facilitate the payment processes of our invoices, we suggest the use + of the SEPA CORE direct debit system.

+

This service involves issuing our receipts to your company in an automated + and electronic manner, which represents a substantial reduction in costs for you + in terms of fees and bank charges.

+

If you accept our proposal, on the due date of each payment, it will be automatically + debited from your account through your bank.

+

This system is based on the electronic transmission of data; the handling of + physical documents has been eliminated.

+

We appreciate your cooperation,

+ conclusion: Thank you for your attention! diff --git a/print/templates/email/sepa-core/locale/es.yml b/print/templates/email/sepa-core/locale/es.yml index 10a1d32fe..a8dd9032e 100644 --- a/print/templates/email/sepa-core/locale/es.yml +++ b/print/templates/email/sepa-core/locale/es.yml @@ -9,9 +9,7 @@ description: forma automatizada y electrónicamente, lo que supone para usted una reducción sustancial de costos en términos de honorarios y gastos bancarios.

En caso de que acepte nuestra propuesta, a la fecha de vencimiento de cada efecto, - se debitará a su cuenta automáticamente a través de su entidad bancaria. - Por tanto, le pedimos que firme y envíe a su banco la autorización original adjunta, - debidamente cumplimentada, y nos devuelva una fotocopia de dicha autorización.

+ se debitará a su cuenta automáticamente a través de su entidad bancaria.

Este sistema se basa en la transmisión electrónica de datos; el manejo de documentos físicos ha sido eliminado.

Le agradecemos su cooperación,

diff --git a/print/templates/email/sepa-core/locale/fr.yml b/print/templates/email/sepa-core/locale/fr.yml index 98bd7593a..6d76ef24f 100644 --- a/print/templates/email/sepa-core/locale/fr.yml +++ b/print/templates/email/sepa-core/locale/fr.yml @@ -14,11 +14,7 @@ description: et commissions bancaires.

Dans le cas où vous accepteriez notre proposition, à l’échéance de chaque effet, votre compte sera débité - automatiquement par votre Banque. - Ainsi, nous vous demandons de signer et envoyer à votre - Banque l'original de l'autorisation pour débit en annexe, - dûment remplie, et de nous retourner une photocopie de la - dite autorisation.

+ automatiquement par votre Banque.

Ce système étant basé sur la transmission de données de manière électronique, le maniement de documents physiques á été éliminé

diff --git a/print/templates/reports/buy-label/assets/css/import.js b/print/templates/reports/buy-label/assets/css/import.js new file mode 100644 index 000000000..37a98dfdd --- /dev/null +++ b/print/templates/reports/buy-label/assets/css/import.js @@ -0,0 +1,12 @@ +const Stylesheet = require(`vn-print/core/stylesheet`); + +const path = require('path'); +const vnPrintPath = path.resolve('print'); + +module.exports = new Stylesheet([ + `${vnPrintPath}/common/css/spacing.css`, + `${vnPrintPath}/common/css/misc.css`, + `${vnPrintPath}/common/css/layout.css`, + `${vnPrintPath}/common/css/report.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/templates/reports/buy-label/assets/css/style.css b/print/templates/reports/buy-label/assets/css/style.css new file mode 100644 index 000000000..3b1f2f91e --- /dev/null +++ b/print/templates/reports/buy-label/assets/css/style.css @@ -0,0 +1,38 @@ +html { + font-family: "Roboto", "Helvetica", "Arial", sans-serif; + margin-top: -7px; + font-size: 28px; +} +table { + border: 1px solid; + width: 100%; + font-size: inherit; +} +td { + border: 1px solid; + padding: 5px; + width: 100%; +} +span { + font-size: 48px; + font-weight: bold; +} +.lbl { + color: gray; + font-weight: lighter; + font-size: 18px; + display: block; +} +.cell { + width: 157px; + height: 50px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.barcode { + text-align: center; +} +.one-third { + width: 314px; +} \ No newline at end of file diff --git a/print/templates/reports/buy-label/buy-label.html b/print/templates/reports/buy-label/buy-label.html new file mode 100644 index 000000000..5777d34de --- /dev/null +++ b/print/templates/reports/buy-label/buy-label.html @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ {{$t('size')}} + {{buy.size}} +
+
+
+ {{$t('category')}} + {{buy.category}} +
+
+
+ {{$t('color')}} + {{buy.color}} +
+
+
+ {{$t('origin')}} + {{buy.code}} +
+
+
+ {{$t('packing')}} + {{buy.packing}} +
+
+
+ {{$t('grouping')}} + {{buy.grouping}} +
+
+
+ {{$t('saleUnit')}} + {{buy.stems}} +
+
+
+ {{buy.itemFk}} +
+ + +
+ {{$t('control')}} + {{`${weekNum} / ${dayNum}`}} +
+
+ + +
+ {{$t('boxNum')}} + {{`${buy.labelNum} / ${buy.maxLabelNum}`}} +
+
+ diff --git a/print/templates/reports/buy-label/buy-label.js b/print/templates/reports/buy-label/buy-label.js new file mode 100755 index 000000000..289483051 --- /dev/null +++ b/print/templates/reports/buy-label/buy-label.js @@ -0,0 +1,39 @@ +const vnReport = require('../../../core/mixins/vn-report.js'); +const {DOMImplementation, XMLSerializer} = require('xmldom'); +const {models} = require('vn-loopback/server/server'); +const jsBarcode = require('jsbarcode'); +const moment = require('moment'); + +module.exports = { + name: 'buy-label', + mixins: [vnReport], + async serverPrefetch() { + const buy = await models.Buy.findById(this.id, null); + this.buys = await this.rawSqlFromDef('buy', [buy.entryFk, buy.entryFk, buy.entryFk, this.id]); + const date = new Date(); + this.weekNum = moment(date).isoWeek(); + this.dayNum = moment(date).day(); + }, + methods: { + getBarcode(id) { + const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null); + const svgNode = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + + jsBarcode(svgNode, id, { + xmlDocument: document, + format: 'code128', + displayValue: false, + width: 3.8, + height: 115, + }); + return new XMLSerializer().serializeToString(svgNode); + } + }, + props: { + id: { + type: Number, + required: true, + description: 'The entry id' + } + } +}; diff --git a/print/templates/reports/buy-label/locale/en.yml b/print/templates/reports/buy-label/locale/en.yml new file mode 100644 index 000000000..333282759 --- /dev/null +++ b/print/templates/reports/buy-label/locale/en.yml @@ -0,0 +1,13 @@ +reportName: Entry buys +variety: Bariety +size: Size +category: Category +color: Color +origin: Origin +packing: Packing +grouping: Grouping +unitSale: Un. sale +producer: Producer +control: Control +boxNum: Box no. +reference: Reference \ No newline at end of file diff --git a/print/templates/reports/buy-label/locale/es.yml b/print/templates/reports/buy-label/locale/es.yml new file mode 100644 index 000000000..af1d9aa1c --- /dev/null +++ b/print/templates/reports/buy-label/locale/es.yml @@ -0,0 +1,13 @@ +reportName: Etiqueta de compras +variety: Variedad +size: Medida +category: Categoría +color: Color +origin: Origen +packing: Packing +grouping: Grouping +saleUnit: Sale un. +producer: Productor +control: Control +boxNum: Caja nº +reference: Referencia \ No newline at end of file diff --git a/print/templates/reports/buy-label/options.json b/print/templates/reports/buy-label/options.json new file mode 100644 index 000000000..4ed0461b3 --- /dev/null +++ b/print/templates/reports/buy-label/options.json @@ -0,0 +1,11 @@ +{ + "width": "10cm", + "height": "10cm", + "margin": { + "top": "0.17cm", + "right": "0.2cm", + "bottom": "0cm", + "left": "0cm" + }, + "printBackground": true +} \ No newline at end of file diff --git a/print/templates/reports/buy-label/sql/buy.sql b/print/templates/reports/buy-label/sql/buy.sql new file mode 100644 index 000000000..26efeb06e --- /dev/null +++ b/print/templates/reports/buy-label/sql/buy.sql @@ -0,0 +1,38 @@ +WITH RECURSIVE numbers AS ( + SELECT 1 n + UNION ALL + SELECT n + 1 + FROM numbers + WHERE n < ( + SELECT MAX(stickers) + FROM buy + WHERE entryFk = ? + ) +), +labels AS ( + SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) labelNum, + i.name, + i.`size`, + i.category, + ink.id color, + o.code, + b.packing, + b.`grouping`, + i.stems, + b.id, + b.itemFk, + p.name producer, + IFNULL(i2.comment, i.comment) comment + FROM buy b + JOIN item i ON i.id = b.itemFk + LEFT JOIN producer p ON p.id = i.producerFk + LEFT JOIN ink ON ink.id = i.inkFk + LEFT JOIN origin o ON o.id = i.originFk + LEFT JOIN item i2 ON i2.id = b.itemOriginalFk + JOIN numbers num + WHERE b.entryFk = ? + AND num.n <= b.stickers +) +SELECT *, (SELECT SUM(stickers) FROM buy WHERE entryFk = ?) maxLabelNum + FROM labels + WHERE id = ? \ No newline at end of file diff --git a/print/templates/reports/cmr/sql/data.sql b/print/templates/reports/cmr/sql/data.sql index 42231709a..31620a80d 100644 --- a/print/templates/reports/cmr/sql/data.sql +++ b/print/templates/reports/cmr/sql/data.sql @@ -39,8 +39,7 @@ SELECT c.id cmrFk, LEFT JOIN supplier s ON s.id = c.supplierFk LEFT JOIN country cou ON cou.id = s.countryFk LEFT JOIN company co ON co.id = c.companyFk - LEFT JOIN supplierAccount sa ON sa.id = co.supplierAccountFk - LEFT JOIN supplier s2 ON s2.id = sa.supplierFk + LEFT JOIN supplier s2 ON s2.id = c.companyFk LEFT JOIN country cou2 ON cou2.id = s2.countryFk LEFT JOIN `address` a ON a.id = c.addressToFk LEFT JOIN province p ON p.id = a.provinceFk diff --git a/print/templates/reports/collection-label/collection-label.html b/print/templates/reports/collection-label/collection-label.html index 752a31185..1f57fc3d9 100644 --- a/print/templates/reports/collection-label/collection-label.html +++ b/print/templates/reports/collection-label/collection-label.html @@ -10,16 +10,12 @@ {{dashIfEmpty(labelData.shipped)}} - + {{dashIfEmpty(labelData.workerCode)}} - -
- {{dashIfEmpty(labelData.workerCode)}} - - {{labelData.labelCount || 0}} + {{labelCount || labelData.labelCount || 0}} {{labelData.code == 'V' ? (labelData.size || 0) + 'cm' : (labelData.volume || 0) + 'm³'}} diff --git a/print/templates/reports/collection-label/collection-label.js b/print/templates/reports/collection-label/collection-label.js index f2f697ae6..4aeaca854 100644 --- a/print/templates/reports/collection-label/collection-label.js +++ b/print/templates/reports/collection-label/collection-label.js @@ -1,7 +1,5 @@ -const {DOMImplementation, XMLSerializer} = require('xmldom'); const vnReport = require('../../../core/mixins/vn-report.js'); const {toDataURL} = require('qrcode'); -const jsBarcode = require('jsbarcode'); module.exports = { name: 'collection-label', @@ -30,11 +28,8 @@ module.exports = { const labels = await this.rawSqlFromDef('labelsData', [ticketIds]); - const [{scannableCodeType}] = await this.rawSqlFromDef('barcodeType'); - if (scannableCodeType === 'qr') { - for (const labelData of labels) - labelData.qrData = await this.getQr(labelData?.ticketFk, labelData?.workerFk); - } + for (const labelData of labels) + labelData.qrData = await this.getQr(labelData?.ticketFk, labelData?.workerFk); this.labelsData = labels; this.checkMainEntity(this.labelsData); @@ -50,20 +45,6 @@ module.exports = { }); return toDataURL(QRdata, {margin: 0}); }, - getBarcode(id) { - const xmlSerializer = new XMLSerializer(); - const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null); - const svgNode = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); - - jsBarcode(svgNode, id, { - xmlDocument: document, - format: 'code128', - displayValue: false, - width: 3.8, - height: 115, - }); - return xmlSerializer.serializeToString(svgNode); - }, getVertical(labelData) { let value; if (labelData.collectionFk) { diff --git a/print/templates/reports/collection-label/sql/barcodeType.sql b/print/templates/reports/collection-label/sql/barcodeType.sql deleted file mode 100644 index 0700c95a2..000000000 --- a/print/templates/reports/collection-label/sql/barcodeType.sql +++ /dev/null @@ -1,3 +0,0 @@ -SELECT scannableCodeType - FROM productionConfig - LIMIT 1 \ No newline at end of file diff --git a/print/templates/reports/collection-label/sql/labelsData.sql b/print/templates/reports/collection-label/sql/labelsData.sql index 2ffa6d8db..c96817b9c 100644 --- a/print/templates/reports/collection-label/sql/labelsData.sql +++ b/print/templates/reports/collection-label/sql/labelsData.sql @@ -35,7 +35,7 @@ SELECT c.itemPackingTypeFk code, LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id LEFT JOIN vn.`zone` zo ON t.zoneFk = zo.id LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id JOIN vn.productionConfig pc WHERE t.id IN (?) diff --git a/print/templates/reports/delivery-note/delivery-note.html b/print/templates/reports/delivery-note/delivery-note.html index 92dd1b126..c1701e084 100644 --- a/print/templates/reports/delivery-note/delivery-note.html +++ b/print/templates/reports/delivery-note/delivery-note.html @@ -81,6 +81,7 @@ {{sale.tag5}} {{sale.value5}} {{sale.tag6}} {{sale.value6}} {{sale.tag7}} {{sale.value7}} + {{$t('producer')}} {{ sale.subName }} @@ -249,4 +250,4 @@ v-bind:center-text="client.socialName" v-bind="$props"> - \ No newline at end of file + diff --git a/print/templates/reports/delivery-note/locale/en.yml b/print/templates/reports/delivery-note/locale/en.yml index 5902da8b3..84b31e494 100644 --- a/print/templates/reports/delivery-note/locale/en.yml +++ b/print/templates/reports/delivery-note/locale/en.yml @@ -20,6 +20,7 @@ vatType: VAT Type digitalSignature: Digital signature plantPassport: Plant passport packages: Packages +producer: Producer services: title: Services theader: @@ -44,7 +45,7 @@ taxes: taxBase: Tax base tax: Tax fee: Fee - tfoot: + tfoot: subtotal: Subtotal total: Total -observations: Observations \ No newline at end of file +observations: Observations diff --git a/print/templates/reports/delivery-note/locale/es.yml b/print/templates/reports/delivery-note/locale/es.yml index d87198f45..891e59d77 100644 --- a/print/templates/reports/delivery-note/locale/es.yml +++ b/print/templates/reports/delivery-note/locale/es.yml @@ -15,6 +15,7 @@ discount: Dto. vat: IVA amount: Importe total: Total +producer: Productor subtotal: Subtotal vatType: Tipo de IVA digitalSignature: Firma digital @@ -45,7 +46,7 @@ taxes: taxBase: Base imp. tax: Tasa fee: Cuota - tfoot: + tfoot: subtotal: Subtotal total: Total -observations: Observaciones \ No newline at end of file +observations: Observaciones diff --git a/print/templates/reports/delivery-note/locale/fr.yml b/print/templates/reports/delivery-note/locale/fr.yml index 603623a47..87cd2bcde 100644 --- a/print/templates/reports/delivery-note/locale/fr.yml +++ b/print/templates/reports/delivery-note/locale/fr.yml @@ -14,7 +14,8 @@ price: PRIX/u discount: Remise vat: TVA amount: Montant -total: Total +producer: producteur +total: Total subtotal: Total partiel vatType: Type de TVA digitalSignature: Signature numérique @@ -45,7 +46,7 @@ taxes: taxBase: Base imposable tax: Taxe fee: Quote - tfoot: + tfoot: subtotal: Total partiel total: Total -observations: Observations \ No newline at end of file +observations: Observations diff --git a/print/templates/reports/delivery-note/locale/pt.yml b/print/templates/reports/delivery-note/locale/pt.yml index fb49d230b..be39eb3f0 100644 --- a/print/templates/reports/delivery-note/locale/pt.yml +++ b/print/templates/reports/delivery-note/locale/pt.yml @@ -14,6 +14,7 @@ price: PVP/u discount: Dto. vat: IVA amount: Importe +producer: Produtor total: Total subtotal: Sub-total vatType: Tipo de IVA @@ -45,7 +46,7 @@ taxes: taxBase: Tributável tax: Taxa fee: Compartilhado - tfoot: + tfoot: subtotal: Subtotal total: Total -observations: Observações \ No newline at end of file +observations: Observações diff --git a/print/templates/reports/delivery-note/sql/sales.sql b/print/templates/reports/delivery-note/sql/sales.sql index c449030cf..4517473bd 100644 --- a/print/templates/reports/delivery-note/sql/sales.sql +++ b/print/templates/reports/delivery-note/sql/sales.sql @@ -1,43 +1,43 @@ -SELECT - s.id, - s.itemFk, - s.concept, - s.quantity, - s.price, - s.price - SUM(IF(ctr.id = 6, sc.value, 0)) netPrice, - s.discount, - i.size, - i.stems, - i.category, - it.id itemTypeId, - o.code AS origin, - i.inkFk, - s.ticketFk, - tcl.code vatType, - ib.ediBotanic botanical, - i.tag5, - i.value5, - i.tag6, - i.value6, - i.tag7, - i.value7 -FROM vn.sale s - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - LEFT JOIN component cr ON cr.id = sc.componentFk - LEFT JOIN componentType ctr ON ctr.id = cr.typeFk - LEFT JOIN item i ON i.id = s.itemFk - LEFT JOIN ticket t ON t.id = s.ticketFk - LEFT JOIN origin o ON o.id = i.originFk - LEFT JOIN country c ON c.id = o.countryFk - LEFT JOIN supplier sp ON sp.id = t.companyFk - LEFT JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id - AND itc.countryFk = sp.countryFk - LEFT JOIN taxClass tcl ON tcl.id = itc.taxClassFk - LEFT JOIN itemBotanicalWithGenus ib ON ib.itemFk = i.id - AND ic.code = 'plant' - AND ib.ediBotanic IS NOT NULL -WHERE s.ticketFk = ? -GROUP BY s.id -ORDER BY (it.isPackaging), s.concept, s.itemFk \ No newline at end of file +SELECT s.id, + s.itemFk, + s.concept, + s.quantity, + s.price, + s.price - SUM(IF(ctr.code = 'freight', sc.value, 0)) netPrice, + s.discount, + i.size, + i.stems, + i.category, + it.id itemTypeId, + o.code origin, + i.inkFk, + s.ticketFk, + tcl.code vatType, + ib.ediBotanic botanical, + i.tag5, + i.value5, + i.tag6, + i.value6, + i.tag7, + i.value7, + i.subName + FROM vn.sale s + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + LEFT JOIN component cr ON cr.id = sc.componentFk + LEFT JOIN componentType ctr ON ctr.id = cr.typeFk + LEFT JOIN item i ON i.id = s.itemFk + LEFT JOIN ticket t ON t.id = s.ticketFk + LEFT JOIN origin o ON o.id = i.originFk + LEFT JOIN country c ON c.id = o.countryFk + LEFT JOIN supplier sp ON sp.id = t.companyFk + LEFT JOIN itemType it ON it.id = i.typeFk + LEFT JOIN itemCategory ic ON ic.id = it.categoryFk + LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id + AND itc.countryFk = sp.countryFk + LEFT JOIN taxClass tcl ON tcl.id = itc.taxClassFk + LEFT JOIN itemBotanicalWithGenus ib ON ib.itemFk = i.id + AND ic.code = 'plant' + AND ib.ediBotanic IS NOT NULL + WHERE s.ticketFk = ? + GROUP BY s.id + ORDER BY (it.isPackaging), s.concept, s.itemFk diff --git a/print/templates/reports/entry-order/assets/css/style.css b/print/templates/reports/entry-order/assets/css/style.css index cabdadf9f..767b1185a 100644 --- a/print/templates/reports/entry-order/assets/css/style.css +++ b/print/templates/reports/entry-order/assets/css/style.css @@ -1,14 +1,20 @@ - - h3 { font-weight: 100; color: #555 } - .report-info { font-size: 20px } - .description strong { text-transform: uppercase; +} +.nowrap { + white-space: nowrap; +} +.padding { + padding: 16px; +} +.tags { + font-size: 10px; + margin: 0; } \ No newline at end of file diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html index ddf0e9b5d..e5d3bfb6d 100644 --- a/print/templates/reports/entry-order/entry-order.html +++ b/print/templates/reports/entry-order/entry-order.html @@ -4,23 +4,23 @@
-
+

{{$t('title')}}

+
-

{{$t('title')}}

- + - + - - + +
{{$t('entryId')}}{{$t('entryId')}} {{entry.id}}
{{$t('date')}}{{$t('date')}} {{formatDate(entry.landed,'%d-%m-%Y')}}
{{$t('ref')}}{{entry.invoiceNumber}}{{$t('ref')}}{{entry.invoiceNumber | dashIfEmpty}}
@@ -38,42 +38,56 @@
- +
+ - + + + + + - + + - + + + + + - - - - - - + + + + + + + + + + + +
{{$t('boxes')}} {{$t('packing')}}{{$t('concept')}}{{$t('concept')}}{{$t('reference')}}{{$t('tags')}} {{$t('quantity')}} {{$t('price')}} {{$t('amount')}}
{{buy.box}}{{buy.stickers}}x {{buy.packing}}{{buy.itemName}}{{buy.name}}{{buy.comment}} + {{buy.tag5}} → {{buy.value5}} + {{buy.tag6}} → {{buy.value6}} + {{buy.tag7}} → {{buy.value7}} + {{buy.quantity | number($i18n.locale)}}x {{buy.buyingValue | currency('EUR', $i18n.locale)}}= {{buy.buyingValue * buy.quantity | currency('EUR', $i18n.locale)}}
- {{buy.tag5}} {{buy.value5}} - {{buy.tag6}} {{buy.value6}} - {{buy.tag7}} {{buy.value7}} -
- {{$t('total')}} - {{getTotal() | currency('EUR', $i18n.locale)}}
{{getTotalBy('stickers')}}{{getTotalBy('quantity') | number($i18n.locale)}}{{getTotalBy('amount') | currency('EUR', $i18n.locale)}}
diff --git a/print/templates/reports/entry-order/entry-order.js b/print/templates/reports/entry-order/entry-order.js index d31ad1a36..56356e068 100755 --- a/print/templates/reports/entry-order/entry-order.js +++ b/print/templates/reports/entry-order/entry-order.js @@ -13,13 +13,17 @@ module.exports = { return {totalBalance: 0.00}; }, methods: { - getTotal() { - let total = 0.00; - this.buys.forEach(buy => { - total += buy.quantity * buy.buyingValue; - }); - - return total; + getTotalBy(property) { + return this.buys.reduce((total, buy) => { + switch (property) { + case 'amount': + return total + buy.quantity * buy.buyingValue; + case 'quantity': + return total + buy.quantity; + case 'stickers': + return total + buy.stickers; + } + }, 0); } }, props: { diff --git a/print/templates/reports/entry-order/locale/es.yml b/print/templates/reports/entry-order/locale/es.yml index 5c633aeaa..5a6716ba1 100644 --- a/print/templates/reports/entry-order/locale/es.yml +++ b/print/templates/reports/entry-order/locale/es.yml @@ -2,7 +2,7 @@ reportName: pedido-de-entrada title: Pedido supplierName: Proveedor supplierStreet: Dirección -entryId: Referencia interna +entryId: Nº Entrada date: Fecha ref: Nº Factura boxes: Cajas @@ -14,4 +14,6 @@ concept: Descripción total: Total entry: Entrada {0} supplierData: Datos del proveedor -notes: Notas \ No newline at end of file +notes: Notas +reference: Referencia +tags: Tags \ No newline at end of file diff --git a/print/templates/reports/entry-order/sql/buys.sql b/print/templates/reports/entry-order/sql/buys.sql index 5bf9f2dfe..92c055483 100644 --- a/print/templates/reports/entry-order/sql/buys.sql +++ b/print/templates/reports/entry-order/sql/buys.sql @@ -1,16 +1,17 @@ -SELECT - b.itemFk, - b.quantity, - b.buyingValue, - b.stickers box, - b.packing, - i.name itemName, - i.tag5, - i.value5, - i.tag6, - i.value6, - i.tag7, - i.value7 -FROM buy b - JOIN item i ON i.id = b.itemFk -WHERE b.entryFk = ? \ No newline at end of file +SELECT b.itemFk, + b.quantity, + b.buyingValue, + b.stickers, + b.packing, + i.name, + IFNULL(i2.comment, i.comment) comment, + i.tag5, + i.value5, + i.tag6, + i.value6, + i.tag7, + i.value7 + FROM buy b + JOIN item i ON i.id = b.itemFk + LEFT JOIN item i2 ON i2.id = b.itemOriginalFk + WHERE b.entryFk = ? diff --git a/print/templates/reports/entry-order/sql/entry.sql b/print/templates/reports/entry-order/sql/entry.sql index c30eebca8..2ab599123 100644 --- a/print/templates/reports/entry-order/sql/entry.sql +++ b/print/templates/reports/entry-order/sql/entry.sql @@ -1,9 +1,8 @@ -SELECT - e.id, - e.invoiceNumber, - c.code companyCode, - t.landed -FROM entry e - JOIN travel t ON t.id = e.travelFk - JOIN company c ON c.id = e.companyFk -WHERE e.id = ? +SELECT e.id, + e.invoiceNumber, + c.code companyCode, + t.landed + FROM entry e + JOIN travel t ON t.id = e.travelFk + JOIN company c ON c.id = e.companyFk + WHERE e.id = ? diff --git a/print/templates/reports/entry-order/sql/supplier.sql b/print/templates/reports/entry-order/sql/supplier.sql index 81ed7e883..214f7913f 100644 --- a/print/templates/reports/entry-order/sql/supplier.sql +++ b/print/templates/reports/entry-order/sql/supplier.sql @@ -1,11 +1,10 @@ -SELECT - s.name, - s.street, - s.nif, - s.postCode, - s.city, - p.name province -FROM supplier s - JOIN entry e ON e.supplierFk = s.id - LEFT JOIN province p ON p.id = s.provinceFk -WHERE e.id = ? +SELECT s.name, + s.street, + s.nif, + s.postCode, + s.city, + p.name province + FROM supplier s + JOIN entry e ON e.supplierFk = s.id + LEFT JOIN province p ON p.id = s.provinceFk + WHERE e.id = ? diff --git a/print/templates/reports/expedition-pallet-label/sql/labelData.sql b/print/templates/reports/expedition-pallet-label/sql/labelData.sql index 385614305..49a4031ae 100644 --- a/print/templates/reports/expedition-pallet-label/sql/labelData.sql +++ b/print/templates/reports/expedition-pallet-label/sql/labelData.sql @@ -5,7 +5,7 @@ SELECT ep.id palletFk, COUNT(es.id) labels, t.warehouseFk warehouseFk, dayname(r.created) `dayName`, - rs.id <=> rm.expeditionTruckFk isMatch + rs.id <=> rm.roadmapStopFk isMatch FROM vn.roadmapStop rs JOIN vn.expeditionPallet ep ON ep.truckFk = rs.id JOIN vn.expeditionScan es ON es.palletFk = ep.id @@ -13,7 +13,7 @@ SELECT ep.id palletFk, JOIN vn.ticket t ON t.id = e.ticketFk JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id - LEFT JOIN vn.roadmapStop rs2 ON rs2.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs2 ON rs2.id = rm.roadmapStopFk WHERE ep.id = ? GROUP BY ep.id, t.routeFk ORDER BY t.routeFk diff --git a/print/templates/reports/invoice-incoterms/invoice-incoterms.js b/print/templates/reports/invoice-incoterms/invoice-incoterms.js index cfe29169b..ebeaf4d7c 100755 --- a/print/templates/reports/invoice-incoterms/invoice-incoterms.js +++ b/print/templates/reports/invoice-incoterms/invoice-incoterms.js @@ -9,7 +9,7 @@ module.exports = { this.checkMainEntity(this.invoice); this.client = await this.findOneFromDef('client', [this.reference]); this.incoterms = - await this.findOneFromDef('incoterms', [this.reference, this.reference, this.reference, this.reference]); + await this.findOneFromDef('incoterms', [this.reference]); if (!this.incoterms) throw new UserError(`The address of the customer must have information about Incoterms and Customs Agent`); }, diff --git a/print/templates/reports/invoice-incoterms/sql/incoterms.sql b/print/templates/reports/invoice-incoterms/sql/incoterms.sql index 81c0ec189..016a8342e 100644 --- a/print/templates/reports/invoice-incoterms/sql/incoterms.sql +++ b/print/templates/reports/invoice-incoterms/sql/incoterms.sql @@ -1,52 +1,31 @@ -SELECT pack.packages, - a.incotermsFk, - ic.name incotermsName, - t.weight, - ca.fiscalName customsAgentName, - ca.street customsAgentStreet, - ca.nif customsAgentNif, - ca.phone customsAgentPhone, - ca.email customsAgentEmail, - CAST(vol.volume AS DECIMAL (10,2)) volume, - intr.intrastat - FROM vn.invoiceOut io - JOIN vn.supplier su ON su.id = io.companyFk - JOIN vn.client c ON c.id = io.clientFk - LEFT JOIN vn.province p ON p.id = c.provinceFk - JOIN vn.ticket t ON t.refFk = io.ref - JOIN vn.address a ON a.id = t.addressFk - JOIN vn.incoterms ic ON ic.code = a.incotermsFk - LEFT JOIN vn.customsAgent ca ON ca.id = a.customsAgentFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN ( - SELECT SUM(volume) volume, COUNT(*) packages - FROM vn.invoiceOut io - JOIN vn.ticket t ON t.refFk = io.ref - JOIN vn.saleVolume sv ON sv.ticketFk = t.id - WHERE t.refFk = ? - ) vol - JOIN vn.itemTaxCountry itc ON itc.countryFk = su.countryFk - AND itc.itemFk = s.itemFk - JOIN vn.taxClass tc ON tc.id = itc.taxClassFk - JOIN vn.invoiceOutSerial ios ON ios.code = io.serial - AND ios.taxAreaFk = 'WORLD' - JOIN vn.country cty ON cty.id = c.countryFk - JOIN vn.payMethod pm ON pm.id = c .payMethodFk - JOIN vn.company co ON co.id=io.companyFk - JOIN vn.supplierAccount sa ON sa.id=co.supplierAccountFk - JOIN ( - SELECT GROUP_CONCAT(DISTINCT ir.description ORDER BY ir.description SEPARATOR '. ' ) intrastat - FROM vn.ticket t - JOIN vn.invoiceOut io ON io.ref = t.refFk - JOIN vn.sale s ON t.id = s.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.intrastat ir ON ir.id = i.intrastatFk - WHERE t.refFk = ? - ) intr - JOIN ( - SELECT SUM(packages) packages - FROM ticket - WHERE refFk = ? - ) pack - WHERE t.refFk = ? - LIMIT 1 +WITH tickets AS( +SELECT id, packages, addressFk, weight + FROM ticket + WHERE refFk= ? +), volume AS( +SELECT SUM(volume) volume + FROM tickets t + JOIN vn.saleVolume sv ON sv.ticketFk = t.id +), intrastat AS( +SELECT GROUP_CONCAT(DISTINCT ir.description ORDER BY ir.description SEPARATOR '. ' ) intrastat + FROM tickets t + JOIN vn.sale s ON t.id = s.ticketFk + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.intrastat ir ON ir.id = i.intrastatFk +)SELECT SUM(t.packages) packages, + a.incotermsFk, + ic.name incotermsName, + MAX(t.weight) weight, + ca.fiscalName customsAgentName, + ca.street customsAgentStreet, + ca.nif customsAgentNif, + ca.phone customsAgentPhone, + ca.email customsAgentEmail, + CAST(v.volume AS DECIMAL (10,2)) volume, + i.intrastat + FROM tickets t + JOIN vn.address a ON a.id = t.addressFk + JOIN vn.incoterms ic ON ic.code = a.incotermsFk + LEFT JOIN vn.customsAgent ca ON ca.id = a.customsAgentFk + JOIN volume v + JOIN intrastat i diff --git a/print/templates/reports/invoice/invoice.html b/print/templates/reports/invoice/invoice.html index af1aaa423..c4e0b818a 100644 --- a/print/templates/reports/invoice/invoice.html +++ b/print/templates/reports/invoice/invoice.html @@ -104,7 +104,7 @@ {{sale.itemFk}} {{sale.quantity}} - {{sale.concept}} + {{sale.concept}} {{sale.subName}} {{sale.price | currency('EUR', $i18n.locale)}} {{(sale.discount / 100) | percentage}} {{sale.vatType}} diff --git a/print/templates/reports/invoice/locale/en.yml b/print/templates/reports/invoice/locale/en.yml index 336592f0c..336384457 100644 --- a/print/templates/reports/invoice/locale/en.yml +++ b/print/templates/reports/invoice/locale/en.yml @@ -34,4 +34,4 @@ plantPassport: Plant passport observations: Observations wireTransfer: "Pay method: Transferencia" accountNumber: "Account number: {0}" -services: Services \ No newline at end of file +services: Services diff --git a/print/templates/reports/invoice/locale/es.yml b/print/templates/reports/invoice/locale/es.yml index 32f6fc708..879977e39 100644 --- a/print/templates/reports/invoice/locale/es.yml +++ b/print/templates/reports/invoice/locale/es.yml @@ -34,4 +34,5 @@ plantPassport: Pasaporte fitosanitario observations: Observaciones wireTransfer: "Forma de pago: Transferencia" accountNumber: "Número de cuenta: {0}" -services: Servicios \ No newline at end of file +services: Servicios + diff --git a/print/templates/reports/invoice/sql/sales.sql b/print/templates/reports/invoice/sql/sales.sql index 8e5ad1102..2d29cc520 100644 --- a/print/templates/reports/invoice/sql/sales.sql +++ b/print/templates/reports/invoice/sql/sales.sql @@ -8,7 +8,8 @@ SELECT s.itemFk, s.concept, tc.code vatType, - it.isPackaging + it.isPackaging, + i.subName FROM vn.invoiceOut io JOIN vn.ticket t ON t.refFk = io.ref JOIN vn.supplier su ON su.id = io.companyFk @@ -38,6 +39,7 @@ SELECT NULL, ts.description, tc.code, + NULL, NULL FROM vn.invoiceOut io JOIN vn.ticket t ON t.refFk = io.ref diff --git a/print/templates/reports/previa-label/previa-label.html b/print/templates/reports/previa-label/previa-label.html index 1dc9b14d0..68042e978 100644 --- a/print/templates/reports/previa-label/previa-label.html +++ b/print/templates/reports/previa-label/previa-label.html @@ -19,7 +19,7 @@
{{previa.itemPackingTypeFk}}
{{previa.shippingHour}}:{{previa.shippingMinute}}
-
{{previa.items}}
+
{{previa.previousLines}}
diff --git a/print/templates/reports/sepa-core/locale/en.yml b/print/templates/reports/sepa-core/locale/en.yml new file mode 100644 index 000000000..6d7e23501 --- /dev/null +++ b/print/templates/reports/sepa-core/locale/en.yml @@ -0,0 +1,46 @@ +reportName: direct-debit-order +title: SEPA CORE Direct Debit Order +description: By signing this direct debit order, the debtor authorizes (A) the creditor + to send instructions to the debtor's bank to debit their account and (B) the bank to debit + their account according to the creditor's instructions. As part of their rights, + the debtor is entitled to a refund by their bank under the terms and conditions + of the contract signed with the bank. The refund request must be made within + eight weeks of the debit. You can obtain additional information about your rights + from your financial institution. +documentCopy: You must take a signed copy of this document to your Bank for registration to avoid returns. +mandatoryFields: ALL FIELDS MUST BE COMPLETED. +sendOrder: ONCE THIS DIRECT DEBIT ORDER IS SIGNED, IT MUST BE SENT TO THE CREDITOR + FOR SAFEGUARDING AND IT IS RECOMMENDED TO PROVIDE A COPY TO YOUR BANK. +supplier: + toCompleteBySupplier: To be completed by the creditor + orderReference: Direct debit order reference + identifier: Creditor identifier + name: Creditor's name + street: Address + location: Postal Code - City - Province + country: Country +client: + toCompleteByClient: To be completed by the debtor + name: Debtor's name(s) + fiscalId: NIF + street: Debtor's address + location: Postal Code - City - Province + country: Debtor's country + swift: Swift BIC + accountNumber: IBAN + accountHolder: "(Account holder(s))" + accountNumberFormat: In {0}, the IBAN consists of {1} characters always starting with {2} + paymentType: Payment type + recurrent: Recurrent + unique: Unique + signLocation: Date - City + sign: Debtor's signature and stamp +order: Direct Debit Order {0} +Francia: France +España: Spain +Portugal: Portugal +instructions: + title: Instructions + accountFields: Fill in the fields related to the bank account + signDocument: Sign and stamp the document. For it to be valid, the stamp must show the CIF/NIF. If not, the request must be accompanied by an account ownership certificate. + thanks: Thank you for your cooperation! \ No newline at end of file diff --git a/print/templates/reports/sepa-core/sepa-core.html b/print/templates/reports/sepa-core/sepa-core.html index 363ebdfe5..e5d14d06c 100644 --- a/print/templates/reports/sepa-core/sepa-core.html +++ b/print/templates/reports/sepa-core/sepa-core.html @@ -27,8 +27,7 @@ {{$t('supplier.identifier')}} -
{{supplier.iban}}
-
{{supplier.nif}}
+
{{supplier.accountDetailValue.join(', ')}}
diff --git a/print/templates/reports/sepa-core/sepa-core.js b/print/templates/reports/sepa-core/sepa-core.js index 96c512a9d..8c4e4911c 100755 --- a/print/templates/reports/sepa-core/sepa-core.js +++ b/print/templates/reports/sepa-core/sepa-core.js @@ -1,13 +1,16 @@ const vnReport = require('../../../core/mixins/vn-report.js'); -const db = require('../../../core/database'); module.exports = { name: 'sepa-core', mixins: [vnReport], async serverPrefetch() { - this.client = await this.findOneFromDef('client', [this.companyId, this.companyId, this.id]); + this.client = await this.findOneFromDef('client', [this.id]); this.checkMainEntity(this.client); - this.supplier = await this.findOneFromDef('supplier', [this.companyId, this.companyId, this.id]); + const suppliers = await this.rawSqlFromDef('supplier', [this.companyId, this.id]); + this.supplier = { + ...suppliers[0], + accountDetailValue: suppliers.map(val => val?.accountDetailValue) + }; }, props: { id: { @@ -19,16 +22,5 @@ module.exports = { type: Number, required: true } - }, - methods: { - getSupplierCif() { - return db.findOne(` - SELECT sa.iban, s.nif - FROM supplierAccount sa - JOIN company co ON co.supplierAccountFk = sa.id - JOIN supplier s ON sa.supplierFk = s.id - WHERE co.id = ?`) [this.companyId]; - } } - }; diff --git a/print/templates/reports/sepa-core/sql/client.sql b/print/templates/reports/sepa-core/sql/client.sql index b3ba180b3..6e0ec89eb 100644 --- a/print/templates/reports/sepa-core/sql/client.sql +++ b/print/templates/reports/sepa-core/sql/client.sql @@ -1,19 +1,14 @@ -SELECT - c.id, - m.code mandateCode, +SELECT c.id, c.socialName, c.street, c.postcode, c.city, c.fi, - p.name AS province, + p.name province, ct.name country, - ct.code AS countryCode, - ct.ibanLength AS ibanLength -FROM client c - JOIN country ct ON ct.id = c.countryFk - LEFT JOIN mandate m ON m.clientFk = c.id - AND m.companyFk = ? AND m.finished IS NULL - LEFT JOIN province p ON p.id = c.provinceFk -WHERE (m.companyFk = ? OR m.companyFk IS NULL) AND c.id = ? -ORDER BY m.created DESC LIMIT 1 \ No newline at end of file + ct.code countryCode, + ct.ibanLength ibanLength + FROM client c + JOIN country ct ON ct.id = c.countryFk + JOIN province p ON p.id = c.provinceFk + WHERE c.id = ? \ No newline at end of file diff --git a/print/templates/reports/sepa-core/sql/supplier.sql b/print/templates/reports/sepa-core/sql/supplier.sql index 156fc71c0..e7bede26d 100644 --- a/print/templates/reports/sepa-core/sql/supplier.sql +++ b/print/templates/reports/sepa-core/sql/supplier.sql @@ -1,27 +1,24 @@ -SELECT - m.code mandateCode, - s.name, - s.street, - sc.name country, - s.postCode, - s.city, - sp.name province, - s.nif, - sa.iban, - sa.supplierFk, - be.name bankName -FROM - client c - LEFT JOIN mandate m ON m.clientFk = c.id AND m.companyFk = ? AND m.finished IS NULL - LEFT JOIN supplier s ON s.id = m.companyFk - LEFT JOIN country sc ON sc.id = s.countryFk - LEFT JOIN province sp ON sp.id = s.provinceFk - LEFT JOIN province p ON p.id = c.provinceFk - LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id - LEFT JOIN bankEntity be ON sa.bankEntityFk = be.id -WHERE - (m.companyFk = ? OR m.companyFk IS NULL) - AND (c.id = ? OR (c.id IS NULL AND c.countryFk = sa.countryFk)) -ORDER BY - m.created DESC -LIMIT 1; +SELECT m.code mandateCode, + s.name, + s.street, + sc.name country, + s.postCode, + s.city, + sp.name province, + ad.value accountDetailValue + FROM client c + JOIN mandate m ON m.clientFk = c.id + JOIN mandateType mt ON mt.id = m.mandateTypeFk + JOIN supplier s ON s.id = m.companyFk + LEFT JOIN country sc ON sc.id = s.countryFk + LEFT JOIN province sp ON sp.id = s.provinceFk + JOIN supplierAccount sa ON sa.supplierFk = s.id + JOIN accountDetail ad ON ad.supplierAccountFk = sa.id + JOIN accountDetailType adt ON adt.id = ad.accountDetailTypeFk + WHERE m.companyFk = ? + AND m.finished IS NULL + AND c.id = ? + AND mt.code = 'CORE' + AND adt.description = 'Referencia Remesas' + GROUP BY m.id, ad.value + ORDER BY m.created DESC