From 6845f1456ecd075625ae15db4c800d06353401a8 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 25 Jul 2024 15:03:33 +0200 Subject: [PATCH 001/217] fix: refs #7781 prevent pallet merge --- .../vn/procedures/expeditionPallet_build.sql | 71 +++++++++++-------- 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/db/routines/vn/procedures/expeditionPallet_build.sql b/db/routines/vn/procedures/expeditionPallet_build.sql index e917c5eb2..3e51df50c 100644 --- a/db/routines/vn/procedures/expeditionPallet_build.sql +++ b/db/routines/vn/procedures/expeditionPallet_build.sql @@ -18,9 +18,11 @@ BEGIN */ DECLARE vCounter INT; DECLARE vExpeditionFk INT; + DECLARE vExpeditionWithPallet INT; DECLARE vTruckFk INT; DECLARE vPrinterFk INT; DECLARE vExpeditionStateTypeFk INT; + DECLARE vExpeditionWithOutPallet INT; CREATE OR REPLACE TEMPORARY TABLE tExpedition ( expeditionFk INT, @@ -44,48 +46,55 @@ BEGIN 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(palletFk) INTO vExpeditionWithPallet FROM tExpedition; + SELECT GROUP_CONCAT(expeditionFk SEPARATOR ', ') INTO vExpeditionWithOutPallet + FROM tExpedition + WHERE palletFk; - IF vPalletFk IS NULL THEN - 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 expeditionPallet SET truckFk = vTruckFk; - - SET vPalletFk = LAST_INSERT_ID(); + IF NOT vExpeditionWithPallet 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 id INTO vExpeditionStateTypeFk FROM expeditionStateType WHERE code = 'PALLETIZED'; - + INSERT INTO expeditionState(expeditionFk, typeFk) - SELECT expeditionFk, vExpeditionStateTypeFk FROM tExpedition; + SELECT expeditionFk, vExpeditionStateTypeFk + FROM tExpedition + WHERE palletFk IS NULL; + + IF vExpeditionWithPallet THEN + UPDATE arcRead + SET error = vExpeditionWithOutPallet + WHERE id = vArcId; + ELSE + UPDATE arcRead SET error = NULL WHERE id = vArcId; + END IF; SELECT printerFk INTO vPrinterFk FROM arcRead WHERE id = vArcId; From ba494a77e6f56b9a049503a5828c8e65439c3ee0 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 26 Jul 2024 12:39:00 +0200 Subject: [PATCH 002/217] fix: refs #7781 conditional --- db/routines/vn/procedures/expeditionPallet_build.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/expeditionPallet_build.sql b/db/routines/vn/procedures/expeditionPallet_build.sql index 3e51df50c..0e4621ca3 100644 --- a/db/routines/vn/procedures/expeditionPallet_build.sql +++ b/db/routines/vn/procedures/expeditionPallet_build.sql @@ -88,7 +88,7 @@ BEGIN FROM tExpedition WHERE palletFk IS NULL; - IF vExpeditionWithPallet THEN + IF vExpeditionWithOutPallet THEN UPDATE arcRead SET error = vExpeditionWithOutPallet WHERE id = vArcId; From 9f2057fdd085b59684b823d65e8276fc03601362 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 8 Aug 2024 12:46:10 +0200 Subject: [PATCH 003/217] fix: refs #7781 pallet merge --- .../vn/procedures/expeditionPallet_build.sql | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/db/routines/vn/procedures/expeditionPallet_build.sql b/db/routines/vn/procedures/expeditionPallet_build.sql index 0e4621ca3..8a86f70fe 100644 --- a/db/routines/vn/procedures/expeditionPallet_build.sql +++ b/db/routines/vn/procedures/expeditionPallet_build.sql @@ -6,23 +6,25 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionPallet_bu OUT vPalletFk INT ) BEGIN -/** Construye un pallet de expediciones. +/** + * 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 arcRead - * @param vWorkerFk INT Identificador de worker - * @param out vPalletFk Identificador de 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 vExpeditionWithPallet INT; DECLARE vTruckFk INT; DECLARE vPrinterFk INT; DECLARE vExpeditionStateTypeFk INT; - DECLARE vExpeditionWithOutPallet INT; + DECLARE vFreeExpeditionCount INT; + DECLARE vExpeditionWithPallet INT; CREATE OR REPLACE TEMPORARY TABLE tExpedition ( expeditionFk INT, @@ -46,15 +48,19 @@ BEGIN WHERE e.id = vExpeditionFk; END WHILE; - SELECT COUNT(palletFk) INTO vExpeditionWithPallet FROM tExpedition; - SELECT GROUP_CONCAT(expeditionFk SEPARATOR ', ') INTO vExpeditionWithOutPallet + SELECT COUNT(expeditionFk) INTO vFreeExpeditionCount + FROM tExpedition + WHERE palletFk IS NULL; + + SELECT GROUP_CONCAT(expeditionFk SEPARATOR ', ') INTO vExpeditionWithPallet FROM tExpedition WHERE palletFk; - IF NOT vExpeditionWithPallet THEN + IF NOT vFreeExpeditionCount THEN CALL util.throw ('NO_FREE_EXPEDITIONS'); END IF; + SELECT roadmapStopFk INTO vTruckFk FROM ( SELECT rm.roadmapStopFk, count(*) n @@ -88,9 +94,9 @@ BEGIN FROM tExpedition WHERE palletFk IS NULL; - IF vExpeditionWithOutPallet THEN + IF vExpeditionWithPallet THEN UPDATE arcRead - SET error = vExpeditionWithOutPallet + SET error = vExpeditionWithPallet WHERE id = vArcId; ELSE UPDATE arcRead SET error = NULL WHERE id = vArcId; From 6b1001ec6a6bf68eb9b7954ba9376aa71e03fd4d Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 19 Aug 2024 16:29:36 +0200 Subject: [PATCH 004/217] feat: refs #7353 drop section --- modules/monitor/front/index.js | 5 - .../monitor/front/index/clients/index.html | 110 ------- modules/monitor/front/index/clients/index.js | 96 ------- modules/monitor/front/index/index.html | 5 - modules/monitor/front/index/index.js | 34 --- modules/monitor/front/index/index.spec.js | 38 --- modules/monitor/front/index/locale/es.yml | 16 -- modules/monitor/front/index/orders/index.html | 141 --------- modules/monitor/front/index/orders/index.js | 74 ----- .../monitor/front/index/orders/index.spec.js | 50 ---- modules/monitor/front/index/orders/style.scss | 19 -- .../front/index/search-panel/index.html | 120 -------- .../monitor/front/index/search-panel/index.js | 59 ---- .../front/index/search-panel/index.spec.js | 71 ----- modules/monitor/front/index/style.scss | 85 ------ .../monitor/front/index/tickets/index.html | 270 ------------------ modules/monitor/front/index/tickets/index.js | 178 ------------ .../monitor/front/index/tickets/index.spec.js | 133 --------- .../monitor/front/index/tickets/style.scss | 47 --- modules/monitor/front/locale/es.yml | 1 - modules/monitor/front/main/index.html | 4 - modules/monitor/front/main/index.js | 11 +- modules/monitor/front/routes.json | 10 +- 23 files changed, 13 insertions(+), 1564 deletions(-) delete mode 100644 modules/monitor/front/index/clients/index.html delete mode 100644 modules/monitor/front/index/clients/index.js delete mode 100644 modules/monitor/front/index/index.html delete mode 100644 modules/monitor/front/index/index.js delete mode 100644 modules/monitor/front/index/index.spec.js delete mode 100644 modules/monitor/front/index/locale/es.yml delete mode 100644 modules/monitor/front/index/orders/index.html delete mode 100644 modules/monitor/front/index/orders/index.js delete mode 100644 modules/monitor/front/index/orders/index.spec.js delete mode 100644 modules/monitor/front/index/orders/style.scss delete mode 100644 modules/monitor/front/index/search-panel/index.html delete mode 100644 modules/monitor/front/index/search-panel/index.js delete mode 100644 modules/monitor/front/index/search-panel/index.spec.js delete mode 100644 modules/monitor/front/index/style.scss delete mode 100644 modules/monitor/front/index/tickets/index.html delete mode 100644 modules/monitor/front/index/tickets/index.js delete mode 100644 modules/monitor/front/index/tickets/index.spec.js delete mode 100644 modules/monitor/front/index/tickets/style.scss delete mode 100644 modules/monitor/front/locale/es.yml 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 deleted file mode 100644 index 7d7e72f6b..000000000 --- a/modules/monitor/front/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Sales monitor: Monitor de ventas \ 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", From 5a22f009f2cd3f9647fef02153f2133a2b849834 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 26 Aug 2024 14:06:10 +0200 Subject: [PATCH 005/217] refactor: refs #7817 itemShelving_addList change --- .../vn/procedures/itemShelving_addList.sql | 35 +++++++++++-------- .../11198-blackPhormium/00-firstScript.sql | 7 ++++ 2 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 db/versions/11198-blackPhormium/00-firstScript.sql diff --git a/db/routines/vn/procedures/itemShelving_addList.sql b/db/routines/vn/procedures/itemShelving_addList.sql index 130007de5..f74aa710f 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=`root`@`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); + 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/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; From 3d69d1ad626be4ae654b621669ea23a760ab4a2a Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 28 Aug 2024 14:37:45 +0200 Subject: [PATCH 006/217] fix: refs #6896 remove files --- e2e/paths/07-order/01_summary.spec.js | 46 --- e2e/paths/07-order/02_basic_data.spec.js | 69 ---- e2e/paths/07-order/03_lines.spec.js | 48 --- e2e/paths/07-order/04_catalog.spec.js | 97 ----- e2e/paths/07-order/05_index.spec.js | 34 -- modules/order/front/basic-data/index.html | 88 ---- modules/order/front/basic-data/index.js | 57 --- modules/order/front/basic-data/index.spec.js | 67 --- modules/order/front/basic-data/locale/es.yml | 1 - modules/order/front/basic-data/style.scss | 9 - modules/order/front/card/index.html | 5 - modules/order/front/card/index.js | 58 --- modules/order/front/card/index.spec.js | 31 -- .../front/catalog-search-panel/index.html | 54 --- .../order/front/catalog-search-panel/index.js | 38 -- modules/order/front/catalog-view/index.html | 81 ---- modules/order/front/catalog-view/index.js | 12 - .../order/front/catalog-view/locale/es.yml | 1 - modules/order/front/catalog-view/style.scss | 50 --- modules/order/front/catalog/index.html | 166 -------- modules/order/front/catalog/index.js | 377 ----------------- modules/order/front/catalog/index.spec.js | 386 ------------------ modules/order/front/catalog/locale/es.yml | 3 - modules/order/front/catalog/style.scss | 54 --- modules/order/front/create/card.html | 38 -- modules/order/front/create/card.js | 114 ------ modules/order/front/create/card.spec.js | 104 ----- modules/order/front/create/index.html | 16 - modules/order/front/create/index.js | 14 - modules/order/front/create/index.spec.js | 34 -- modules/order/front/create/locale/es.yml | 6 - modules/order/front/descriptor/index.html | 78 ---- modules/order/front/descriptor/index.js | 32 -- modules/order/front/descriptor/index.spec.js | 29 -- modules/order/front/descriptor/locale/es.yml | 12 - modules/order/front/index.js | 14 - modules/order/front/index/index.html | 90 ---- modules/order/front/index/index.js | 26 -- modules/order/front/index/index.spec.js | 67 --- modules/order/front/line/index.html | 96 ----- modules/order/front/line/index.js | 70 ---- modules/order/front/line/index.spec.js | 66 --- modules/order/front/line/locale/es.yml | 3 - modules/order/front/line/style.scss | 18 - modules/order/front/main/index.js | 8 +- modules/order/front/prices-popover/index.html | 52 --- modules/order/front/prices-popover/index.js | 115 ------ .../order/front/prices-popover/index.spec.js | 171 -------- .../order/front/prices-popover/locale/es.yml | 3 - modules/order/front/prices-popover/style.scss | 18 - modules/order/front/routes.json | 50 +-- modules/order/front/search-panel/index.html | 86 ---- modules/order/front/search-panel/index.js | 7 - .../order/front/search-panel/locale/es.yml | 11 - modules/order/front/summary/index.html | 131 ------ modules/order/front/summary/index.js | 41 -- modules/order/front/summary/index.spec.js | 47 --- modules/order/front/summary/style.scss | 20 - modules/order/front/volume/index.html | 66 --- modules/order/front/volume/index.js | 37 -- modules/order/front/volume/index.spec.js | 42 -- modules/order/front/volume/style.scss | 12 - 62 files changed, 10 insertions(+), 3666 deletions(-) delete mode 100644 e2e/paths/07-order/01_summary.spec.js delete mode 100644 e2e/paths/07-order/02_basic_data.spec.js delete mode 100644 e2e/paths/07-order/03_lines.spec.js delete mode 100644 e2e/paths/07-order/04_catalog.spec.js delete mode 100644 e2e/paths/07-order/05_index.spec.js delete mode 100644 modules/order/front/basic-data/index.html delete mode 100644 modules/order/front/basic-data/index.js delete mode 100644 modules/order/front/basic-data/index.spec.js delete mode 100644 modules/order/front/basic-data/locale/es.yml delete mode 100644 modules/order/front/basic-data/style.scss delete mode 100644 modules/order/front/card/index.html delete mode 100644 modules/order/front/card/index.js delete mode 100644 modules/order/front/card/index.spec.js delete mode 100644 modules/order/front/catalog-search-panel/index.html delete mode 100644 modules/order/front/catalog-search-panel/index.js delete mode 100644 modules/order/front/catalog-view/index.html delete mode 100644 modules/order/front/catalog-view/index.js delete mode 100644 modules/order/front/catalog-view/locale/es.yml delete mode 100644 modules/order/front/catalog-view/style.scss delete mode 100644 modules/order/front/catalog/index.html delete mode 100644 modules/order/front/catalog/index.js delete mode 100644 modules/order/front/catalog/index.spec.js delete mode 100644 modules/order/front/catalog/locale/es.yml delete mode 100644 modules/order/front/catalog/style.scss delete mode 100644 modules/order/front/create/card.html delete mode 100644 modules/order/front/create/card.js delete mode 100644 modules/order/front/create/card.spec.js delete mode 100644 modules/order/front/create/index.html delete mode 100644 modules/order/front/create/index.js delete mode 100644 modules/order/front/create/index.spec.js delete mode 100644 modules/order/front/create/locale/es.yml delete mode 100644 modules/order/front/descriptor/index.html delete mode 100644 modules/order/front/descriptor/index.js delete mode 100644 modules/order/front/descriptor/index.spec.js delete mode 100644 modules/order/front/descriptor/locale/es.yml delete mode 100644 modules/order/front/index/index.html delete mode 100644 modules/order/front/index/index.js delete mode 100644 modules/order/front/index/index.spec.js delete mode 100644 modules/order/front/line/index.html delete mode 100644 modules/order/front/line/index.js delete mode 100644 modules/order/front/line/index.spec.js delete mode 100644 modules/order/front/line/locale/es.yml delete mode 100644 modules/order/front/line/style.scss delete mode 100644 modules/order/front/prices-popover/index.html delete mode 100644 modules/order/front/prices-popover/index.js delete mode 100644 modules/order/front/prices-popover/index.spec.js delete mode 100644 modules/order/front/prices-popover/locale/es.yml delete mode 100644 modules/order/front/prices-popover/style.scss delete mode 100644 modules/order/front/search-panel/index.html delete mode 100644 modules/order/front/search-panel/index.js delete mode 100644 modules/order/front/search-panel/locale/es.yml delete mode 100644 modules/order/front/summary/index.html delete mode 100644 modules/order/front/summary/index.js delete mode 100644 modules/order/front/summary/index.spec.js delete mode 100644 modules/order/front/summary/style.scss delete mode 100644 modules/order/front/volume/index.html delete mode 100644 modules/order/front/volume/index.js delete mode 100644 modules/order/front/volume/index.spec.js delete mode 100644 modules/order/front/volume/style.scss 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/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 187dbbc83..000000000 --- a/modules/order/front/catalog-view/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Order created: Orden creada \ 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; - } - } -} From 225060ff7493a02e1dc3b5a53edb74f857f5b571 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 2 Sep 2024 09:24:08 +0200 Subject: [PATCH 007/217] fix: refs #7781 varible asign value --- .../vn/procedures/expeditionPallet_build.sql | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/expeditionPallet_build.sql b/db/routines/vn/procedures/expeditionPallet_build.sql index 8a86f70fe..2dbe19d14 100644 --- a/db/routines/vn/procedures/expeditionPallet_build.sql +++ b/db/routines/vn/procedures/expeditionPallet_build.sql @@ -52,7 +52,7 @@ BEGIN FROM tExpedition WHERE palletFk IS NULL; - SELECT GROUP_CONCAT(expeditionFk SEPARATOR ', ') INTO vExpeditionWithPallet + SELECT COUNT(expeditionFk) INTO vExpeditionWithPallet FROM tExpedition WHERE palletFk; @@ -60,7 +60,6 @@ BEGIN CALL util.throw ('NO_FREE_EXPEDITIONS'); END IF; - SELECT roadmapStopFk INTO vTruckFk FROM ( SELECT rm.roadmapStopFk, count(*) n @@ -91,12 +90,16 @@ BEGIN INSERT INTO expeditionState(expeditionFk, typeFk) SELECT expeditionFk, vExpeditionStateTypeFk - FROM tExpedition - WHERE palletFk IS NULL; + FROM tExpedition + WHERE palletFk IS NULL; IF vExpeditionWithPallet THEN UPDATE arcRead - SET error = vExpeditionWithPallet + SET error = ( + SELECT GROUP_CONCAT(expeditionFk SEPARATOR ', ') + FROM tExpedition + WHERE palletFk + ) WHERE id = vArcId; ELSE UPDATE arcRead SET error = NULL WHERE id = vArcId; From 09031822a67e0ff3109b320f9b6633cdc94c2e70 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 12 Sep 2024 08:24:33 +0200 Subject: [PATCH 008/217] feat: refs #7781 only print when no expedition form other pallets --- .../vn/procedures/expeditionPallet_build.sql | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/db/routines/vn/procedures/expeditionPallet_build.sql b/db/routines/vn/procedures/expeditionPallet_build.sql index 2dbe19d14..766064a5b 100644 --- a/db/routines/vn/procedures/expeditionPallet_build.sql +++ b/db/routines/vn/procedures/expeditionPallet_build.sql @@ -103,20 +103,20 @@ BEGIN WHERE id = vArcId; ELSE 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(), + JSON_OBJECT('palletFk', vPalletFk, 'userFk', account.myUser_getId()), + 'high' + ); + + UPDATE expeditionPallet SET isPrint = TRUE WHERE id = vPalletFk; END IF; - SELECT printerFk INTO vPrinterFk FROM arcRead WHERE id = vArcId; - - CALL report_print( - 'LabelPalletExpedition', - vPrinterFk, - account.myUser_getId(), - JSON_OBJECT('palletFk', vPalletFk, 'userFk', account.myUser_getId()), - 'high' - ); - - UPDATE expeditionPallet SET isPrint = TRUE WHERE id = vPalletFk; - DROP TEMPORARY TABLE tExpedition; END$$ DELIMITER ; From cfbc3692e972dc137085f3d131ed3ec258a4e129 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 13 Sep 2024 11:59:28 +0200 Subject: [PATCH 009/217] feat: refs #7874 clientObservationType --- .../00-addClientObservationType.sql | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 db/versions/11230-brownEucalyptus/00-addClientObservationType.sql diff --git a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql new file mode 100644 index 000000000..195c11d2f --- /dev/null +++ b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql @@ -0,0 +1,18 @@ +-- Place your SQL code here +CREATE TABLE IF NOT EXISTS vn.clientObservationType( + id tinyint(3) unsigned NOT NULL AUTO_INCREMENT, + code varchar(45) NOT NULL, + description varchar(50) NOT NULL, + PRIMARY KEY (id) +); + +ALTER TABLE vn.clientObservation ADD COLUMN typeFk tinyint(3) unsigned NOT NULL; +ALTER TABLE vn.clientObservation ADD CONSTRAINT clientObservationTypeFk FOREIGN KEY (typeFk) REFERENCES vn.clientObservationType(id); + +INSERT INTO salix.ACL + SET model = 'ClientObservationType', + property = '*', + accessType = 'READ', + permission = 'ALLOW', + principalType = 'ROLE', + principalId = 'employee'; \ No newline at end of file From 738a390ef791a75a51e4bc923fc2a7b5f21abf1d Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Sep 2024 10:08:23 +0200 Subject: [PATCH 010/217] refactor: refs #7886 Deleted proc buy_getVolumeByAgency --- .../vn/procedures/buy_getVolumeByAgency.sql | 20 ------------------- 1 file changed, 20 deletions(-) delete mode 100644 db/routines/vn/procedures/buy_getVolumeByAgency.sql diff --git a/db/routines/vn/procedures/buy_getVolumeByAgency.sql b/db/routines/vn/procedures/buy_getVolumeByAgency.sql deleted file mode 100644 index 7393d12d8..000000000 --- a/db/routines/vn/procedures/buy_getVolumeByAgency.sql +++ /dev/null @@ -1,20 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`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 ; From 4d0bb816326f0c6abe59b566c53424b3189f530b Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 16 Sep 2024 16:33:22 +0200 Subject: [PATCH 011/217] fix: refs #7323 worker/filter --- modules/worker/back/methods/worker/filter.js | 33 ++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/modules/worker/back/methods/worker/filter.js b/modules/worker/back/methods/worker/filter.js index 2f328d28f..cd386bc2a 100644 --- a/modules/worker/back/methods/worker/filter.js +++ b/modules/worker/back/methods/worker/filter.js @@ -67,6 +67,18 @@ module.exports = Self => { type: 'String', description: 'The worker user name', http: {source: 'query'} + }, + { + arg: 'SSN', + type: 'String', + description: 'The worker SSN', + http: {source: 'query'} + }, + { + arg: 'email', + type: 'String', + description: 'The user email', + http: {source: 'query'} } ], returns: { @@ -99,6 +111,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 +121,10 @@ module.exports = Self => { return {'d.id': value}; case 'userName': return {'u.name': {like: `%${value}%`}}; + case 'email': + return {'eu.email': {like: `%${value}%`}}; + case 'SSN': + return {'w.SSN': value}; } }); @@ -116,15 +134,24 @@ 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, + w.SSN, + 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)); From acdaa962116bdb8479410861635e5749230b5d8c Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 17 Sep 2024 12:30:11 +0200 Subject: [PATCH 012/217] refactor: refs #7817 Requested changes --- db/routines/vn/procedures/itemShelving_addList.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelving_addList.sql b/db/routines/vn/procedures/itemShelving_addList.sql index 18d45f857..ade92b9fd 100644 --- a/db/routines/vn/procedures/itemShelving_addList.sql +++ b/db/routines/vn/procedures/itemShelving_addList.sql @@ -38,7 +38,7 @@ BEGIN AND itemFk = vItemFk; END IF; - IF NOT (vIsChecking AND vIsChecked) THEN + IF NOT vIsChecking OR NOT vIsChecked THEN CALL itemShelving_add(vShelvingFk, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk); END IF; From 75b7e603c981591c2f512bc030f3042328055c0f Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 17 Sep 2024 16:08:51 +0200 Subject: [PATCH 013/217] fix: refs #7323 drop acl --- db/versions/11242-whiteAnthurium/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/versions/11242-whiteAnthurium/00-firstScript.sql 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 From 1ec8d8d5a00016b67a406db79d026c99295f3598 Mon Sep 17 00:00:00 2001 From: ivanm Date: Sun, 22 Sep 2024 07:24:21 +0200 Subject: [PATCH 014/217] feat: refs #7994 update sale.originalQuantity --- db/versions/11251-navyChrysanthemum/00-firstScript.sql | 3 +++ db/versions/11251-navyChrysanthemum/01-firstScript.sql | 1 + 2 files changed, 4 insertions(+) create mode 100644 db/versions/11251-navyChrysanthemum/00-firstScript.sql create mode 100644 db/versions/11251-navyChrysanthemum/01-firstScript.sql diff --git a/db/versions/11251-navyChrysanthemum/00-firstScript.sql b/db/versions/11251-navyChrysanthemum/00-firstScript.sql new file mode 100644 index 000000000..50409c205 --- /dev/null +++ b/db/versions/11251-navyChrysanthemum/00-firstScript.sql @@ -0,0 +1,3 @@ +UPDATE 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 From 753f6d786661e5dbd642c261d229d58bc7047bb2 Mon Sep 17 00:00:00 2001 From: ivanm Date: Sun, 22 Sep 2024 07:27:43 +0200 Subject: [PATCH 015/217] feat: refs #7994 add schema --- db/versions/11251-navyChrysanthemum/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11251-navyChrysanthemum/00-firstScript.sql b/db/versions/11251-navyChrysanthemum/00-firstScript.sql index 50409c205..801405e59 100644 --- a/db/versions/11251-navyChrysanthemum/00-firstScript.sql +++ b/db/versions/11251-navyChrysanthemum/00-firstScript.sql @@ -1,3 +1,3 @@ -UPDATE sale +UPDATE vn.sale SET originalQuantity = quantity WHERE originalQuantity IS NULL From 6ff76fd74b4bc636d42060b851ed073aa74a14c0 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 23 Sep 2024 14:40:38 +0200 Subject: [PATCH 016/217] feat: refs #7207 show queue in worker summary --- back/model-config.json | 6 ++++ back/models/queue-member.json | 38 ++++++++++++++++++++++++++ back/models/queue.json | 30 ++++++++++++++++++++ db/dump/fixtures.before.sql | 19 +++++++++++++ modules/account/back/models/sip.json | 9 ++++-- modules/worker/back/models/worker.json | 22 ++++++++++++++- 6 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 back/models/queue-member.json create mode 100644 back/models/queue.json diff --git a/back/model-config.json b/back/model-config.json index 20bfb06bd..dca9cb761 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -175,6 +175,12 @@ "PrintConfig": { "dataSource": "vn" }, + "QueueMember": { + "dataSource": "vn" + }, + "Queue": { + "dataSource": "vn" + }, "ViaexpressConfig": { "dataSource": "vn" }, 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/queue.json b/back/models/queue.json new file mode 100644 index 000000000..e7ad533ea --- /dev/null +++ b/back/models/queue.json @@ -0,0 +1,30 @@ +{ + "name": "Queue", + "base": "VnModel", + "options": { + "mysql": { + "table": "pbx.queue" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "description": { + "type": "string" + }, + "name": { + "type": "string" + } + }, + "acls": [ + { + "property": "*", + "accessType": "READ", + "principalType": "ROLE", + "principalId": "employee", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 514a94506..c01a7d584 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3972,3 +3972,22 @@ INSERT INTO vn.accountDetailType (id, description, code) 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 IGNORE INTO pbx.queue + SET description = 'X-men', + name = '1000', + config = 1; + +INSERT IGNORE INTO pbx.queueMember + SET queue = '1000', + extension = '1010'; + 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/worker/back/models/worker.json b/modules/worker/back/models/worker.json index b896e775b..ae10b5198 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -253,7 +253,27 @@ "relation": "client" }, { - "relation": "sip" + "relation": "sip", + "scope": { + "include": { + "relation": "queueMember", + "scope": { + "fields": [ + "queue", + "extension" + ], + "include": { + "relation": "queueRelation", + "scope": { + "fields": [ + "description", + "name" + ] + } + } + } + } + } } ] }, From c6a3004d1202d4065963126eb654ae95b0e8eba5 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 24 Sep 2024 10:15:01 +0200 Subject: [PATCH 017/217] feat: refs #7207 allocate new queue on dept change --- db/dump/fixtures.before.sql | 15 +++++++++------ db/routines/vn/triggers/business_afterUpdate.sql | 13 +++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index c01a7d584..8d1943667 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3982,12 +3982,15 @@ INSERT INTO pbx.queueMultiConfig maxLen = 0, ringInUse = 0; -INSERT IGNORE INTO pbx.queue - SET description = 'X-men', - name = '1000', - config = 1; +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'; + 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/vn/triggers/business_afterUpdate.sql b/db/routines/vn/triggers/business_afterUpdate.sql index 888308b9a..255fdd9f5 100644 --- a/db/routines/vn/triggers/business_afterUpdate.sql +++ b/db/routines/vn/triggers/business_afterUpdate.sql @@ -3,10 +3,23 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`business_afterUpdate` AFTER UPDATE ON `business` FOR EACH ROW BEGIN + DECLARE vnIsActive INT; + DECLARE vnExtension VARCHAR(10); + DECLARE vnQueue VARCHAR(10); + CALL worker_updateBusiness(NEW.workerFk); IF NOT (OLD.workerFk <=> NEW.workerFk) THEN CALL worker_updateBusiness(OLD.workerFk); END IF; + + SELECT COUNT(*) INTO vnIsActive FROM vn.worker WHERE businessFk = NEW.id; + + IF(vnIsActive) THEN + SELECT extension INTO vnExtension FROM pbx.sip WHERE user_id = NEW.workerFk COLLATE utf8mb3_general_ci; + SELECT pbxQueue INTO vnQueue FROM vn.department WHERE id = NEW.departmentFk COLLATE utf8mb3_general_ci; + + UPDATE pbx.queueMember SET queue = vnQueue WHERE extension = vnExtension; + END IF; END$$ DELIMITER ; From 02e837ebb68cc0d2c5d673f0c0b69dd16bc88d53 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 24 Sep 2024 15:43:33 +0200 Subject: [PATCH 018/217] feat: refs #7207 add queue on department change --- .../vn/procedures/queueMember_updateQueue.sql | 32 +++++++++++++++++++ .../vn/procedures/worker_updateBusiness.sql | 2 ++ .../vn/triggers/business_afterUpdate.sql | 17 ++++------ 3 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 db/routines/vn/procedures/queueMember_updateQueue.sql diff --git a/db/routines/vn/procedures/queueMember_updateQueue.sql b/db/routines/vn/procedures/queueMember_updateQueue.sql new file mode 100644 index 000000000..b470e909c --- /dev/null +++ b/db/routines/vn/procedures/queueMember_updateQueue.sql @@ -0,0 +1,32 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`queueMember_updateQueue`( + vBusinessFk INT +) +BEGIN +/** +* Replace the queue of a worker with the queue of the new department. +* +* @param vBusinessFk business id +*/ + DECLARE vNewQueue VARCHAR(10); + DECLARE vExtension VARCHAR(10); + DECLARE vPrevQueue VARCHAR(10); + + SELECT d.pbxQueue, s.extension, qm.queue INTO vNewQueue, vExtension, vPrevQueue + FROM business b + JOIN department d ON d.id = b.departmentFk + JOIN pbx.sip s ON s.user_id = b.workerFk + LEFT JOIN pbx.queueMember qm ON qm.extension = s.extension + WHERE b.id = vBusinessFk; + + IF vNewQueue IS NULL THEN + DELETE FROM pbx.queueMember WHERE extension = vExtension COLLATE utf8_general_ci; + ELSE + IF vPrevQueue IS NULL THEN + INSERT INTO pbx.queueMember (queue, extension) VALUES (vNewQueue, vExtension); + ELSE + UPDATE pbx.queueMember SET queue = vNewQueue WHERE extension = vExtension COLLATE utf8_general_ci; + END IF; + END IF; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/worker_updateBusiness.sql b/db/routines/vn/procedures/worker_updateBusiness.sql index a160c417a..43edb0416 100644 --- a/db/routines/vn/procedures/worker_updateBusiness.sql +++ b/db/routines/vn/procedures/worker_updateBusiness.sql @@ -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/triggers/business_afterUpdate.sql b/db/routines/vn/triggers/business_afterUpdate.sql index 255fdd9f5..11aeb88b6 100644 --- a/db/routines/vn/triggers/business_afterUpdate.sql +++ b/db/routines/vn/triggers/business_afterUpdate.sql @@ -3,9 +3,8 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`business_afterUpdate` AFTER UPDATE ON `business` FOR EACH ROW BEGIN - DECLARE vnIsActive INT; - DECLARE vnExtension VARCHAR(10); - DECLARE vnQueue VARCHAR(10); + DECLARE vIsActive BOOL; + DECLARE vExtension VARCHAR(10); CALL worker_updateBusiness(NEW.workerFk); @@ -13,13 +12,11 @@ BEGIN CALL worker_updateBusiness(OLD.workerFk); END IF; - SELECT COUNT(*) INTO vnIsActive FROM vn.worker WHERE businessFk = NEW.id; - - IF(vnIsActive) THEN - SELECT extension INTO vnExtension FROM pbx.sip WHERE user_id = NEW.workerFk COLLATE utf8mb3_general_ci; - SELECT pbxQueue INTO vnQueue FROM vn.department WHERE id = NEW.departmentFk COLLATE utf8mb3_general_ci; - - UPDATE pbx.queueMember SET queue = vnQueue WHERE extension = vnExtension; + 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 ; From 16b059a14ad8254424a05934873d7c1e72c964d2 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 24 Sep 2024 15:49:45 +0200 Subject: [PATCH 019/217] refactor: refs #7207 tab --- db/routines/vn/procedures/queueMember_updateQueue.sql | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/queueMember_updateQueue.sql b/db/routines/vn/procedures/queueMember_updateQueue.sql index b470e909c..d6f2a5d1e 100644 --- a/db/routines/vn/procedures/queueMember_updateQueue.sql +++ b/db/routines/vn/procedures/queueMember_updateQueue.sql @@ -20,12 +20,16 @@ BEGIN WHERE b.id = vBusinessFk; IF vNewQueue IS NULL THEN - DELETE FROM pbx.queueMember WHERE extension = vExtension COLLATE utf8_general_ci; + DELETE FROM pbx.queueMember + WHERE extension = vExtension COLLATE utf8_general_ci; ELSE IF vPrevQueue IS NULL THEN - INSERT INTO pbx.queueMember (queue, extension) VALUES (vNewQueue, vExtension); + INSERT INTO pbx.queueMember (queue, extension) + VALUES (vNewQueue, vExtension); ELSE - UPDATE pbx.queueMember SET queue = vNewQueue WHERE extension = vExtension COLLATE utf8_general_ci; + UPDATE pbx.queueMember + SET queue = vNewQueue + WHERE extension = vExtension COLLATE utf8_general_ci; END IF; END IF; END$$ From 1c42303a75e51e5e9539f37cb938e6572e2b2a43 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 25 Sep 2024 09:18:10 +0200 Subject: [PATCH 020/217] chore: refs #7207 drop useless relation --- back/model-config.json | 3 --- back/models/queue.json | 30 -------------------------- modules/worker/back/models/worker.json | 11 +--------- 3 files changed, 1 insertion(+), 43 deletions(-) delete mode 100644 back/models/queue.json diff --git a/back/model-config.json b/back/model-config.json index dca9cb761..b6d304675 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -178,9 +178,6 @@ "QueueMember": { "dataSource": "vn" }, - "Queue": { - "dataSource": "vn" - }, "ViaexpressConfig": { "dataSource": "vn" }, diff --git a/back/models/queue.json b/back/models/queue.json deleted file mode 100644 index e7ad533ea..000000000 --- a/back/models/queue.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "Queue", - "base": "VnModel", - "options": { - "mysql": { - "table": "pbx.queue" - } - }, - "properties": { - "id": { - "type": "number", - "id": true - }, - "description": { - "type": "string" - }, - "name": { - "type": "string" - } - }, - "acls": [ - { - "property": "*", - "accessType": "READ", - "principalType": "ROLE", - "principalId": "employee", - "permission": "ALLOW" - } - ] -} \ No newline at end of file diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index ae10b5198..c334c0d05 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -261,16 +261,7 @@ "fields": [ "queue", "extension" - ], - "include": { - "relation": "queueRelation", - "scope": { - "fields": [ - "description", - "name" - ] - } - } + ] } } } From 3e270befa5646a8521830de52cffca2b97603f16 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 25 Sep 2024 12:19:12 +0200 Subject: [PATCH 021/217] chore: refs #7874 refactor table --- .../00-addClientObservationType.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql index 195c11d2f..05376710a 100644 --- a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql +++ b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql @@ -1,14 +1,14 @@ --- Place your SQL code here +-- vn.clientObservationType CREATE TABLE IF NOT EXISTS vn.clientObservationType( id tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - code varchar(45) NOT NULL, + clientFk int(11) NOT NULL, + observationTypeFk tinyint(3) unsigned NOT NULL, description varchar(50) NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (id), + CONSTRAINT `clientFgn` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `clientObservationFgn` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ); -ALTER TABLE vn.clientObservation ADD COLUMN typeFk tinyint(3) unsigned NOT NULL; -ALTER TABLE vn.clientObservation ADD CONSTRAINT clientObservationTypeFk FOREIGN KEY (typeFk) REFERENCES vn.clientObservationType(id); - INSERT INTO salix.ACL SET model = 'ClientObservationType', property = '*', From 7c23acde64977267f770e773254daf55c8d34bcb Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 26 Sep 2024 09:08:42 +0200 Subject: [PATCH 022/217] feat: refs #7874 add observationTypeFk col --- .../00-addClientObservationType.sql | 21 +++--------------- .../back/models/client-observation.json | 22 +++++++++++++------ 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql index 05376710a..699d0bea4 100644 --- a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql +++ b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql @@ -1,18 +1,3 @@ --- vn.clientObservationType -CREATE TABLE IF NOT EXISTS vn.clientObservationType( - id tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - clientFk int(11) NOT NULL, - observationTypeFk tinyint(3) unsigned NOT NULL, - description varchar(50) NOT NULL, - PRIMARY KEY (id), - CONSTRAINT `clientFgn` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `clientObservationFgn` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -); - -INSERT INTO salix.ACL - SET model = 'ClientObservationType', - property = '*', - accessType = 'READ', - permission = 'ALLOW', - principalType = 'ROLE', - principalId = 'employee'; \ No newline at end of file +ALTER TABLE vn.clientObservation + ADD COLUMN observationTypeFk TINYINT(3) UNSIGNED, + ADD CONSTRAINT clientObservationTypeFk FOREIGN KEY (observationTypeFk) REFERENCES vn.observationType(id); \ No newline at end of file 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 From 5e5603410569c81cf6c3f3857eaefdccbad26601 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 26 Sep 2024 09:48:07 +0200 Subject: [PATCH 023/217] fix: refs #7323 rollback --- modules/worker/back/methods/worker/filter.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/modules/worker/back/methods/worker/filter.js b/modules/worker/back/methods/worker/filter.js index cd386bc2a..52c60572a 100644 --- a/modules/worker/back/methods/worker/filter.js +++ b/modules/worker/back/methods/worker/filter.js @@ -68,12 +68,6 @@ module.exports = Self => { description: 'The worker user name', http: {source: 'query'} }, - { - arg: 'SSN', - type: 'String', - description: 'The worker SSN', - http: {source: 'query'} - }, { arg: 'email', type: 'String', @@ -123,8 +117,6 @@ module.exports = Self => { return {'u.name': {like: `%${value}%`}}; case 'email': return {'eu.email': {like: `%${value}%`}}; - case 'SSN': - return {'w.SSN': value}; } }); @@ -137,7 +129,6 @@ module.exports = Self => { `SELECT w.id, w.lastName, w.firstName, - w.SSN, u.email, u.nickname, p.extension, From 4ebda1a06ffe0bdaf67bf4b1e5ea99a6383775e2 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 26 Sep 2024 14:06:45 +0200 Subject: [PATCH 024/217] feat: refs #7010 added filter fields to show packing type field in ticket list --- modules/ticket/back/methods/ticket/filter.js | 96 +++++++++++--------- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 06781c3c8..b72f224bf 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -228,52 +228,55 @@ module.exports = Self => { stmt = new ParameterizedSQL(` CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) - ENGINE = MEMORY + ENGINE = InnoDB SELECT t.id, - t.shipped, - CAST(DATE(t.shipped) AS CHAR) shippedDate, - HOUR(t.shipped) shippedHour, - t.nickname, - t.refFk, - t.routeFk, - t.warehouseFk, - t.clientFk, - t.totalWithoutVat, - t.totalWithVat, - io.id invoiceOutId, - a.provinceFk, - p.name province, - w.name warehouse, - am.name agencyMode, - am.id agencyModeFk, - st.name state, - st.classColor, - wk.lastName salesPerson, - ts.stateFk stateFk, - ts.alertLevel alertLevel, - ts.code alertLevelCode, - u.name userName, - c.salesPersonFk, - 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 - LEFT JOIN address a ON a.id = t.addressFk - LEFT JOIN province p ON p.id = a.provinceFk - LEFT JOIN warehouse w ON w.id = t.warehouseFk - LEFT JOIN agencyMode am ON am.id = t.agencyModeFk - LEFT JOIN ticketState ts ON ts.ticketFk = t.id - LEFT JOIN state st ON st.id = ts.stateFk - 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 + t.shipped, + CAST(DATE(t.shipped) AS CHAR) shippedDate, + HOUR(t.shipped) shippedHour, + t.nickname, + t.refFk, + t.routeFk, + t.warehouseFk, + t.clientFk, + t.totalWithoutVat, + t.totalWithVat, + io.id invoiceOutId, + a.provinceFk, + p.name province, + w.name warehouse, + am.name agencyMode, + am.id agencyModeFk, + st.name state, + st.classColor, + wk.lastName salesPerson, + ts.stateFk stateFk, + ts.alertLevel alertLevel, + ts.code alertLevelCode, + u.name userName, + c.salesPersonFk, + 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, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk SEPARATOR ', ') packing + FROM ticket t + LEFT JOIN invoiceOut io ON t.refFk = io.ref + LEFT JOIN zone z ON z.id = t.zoneFk + LEFT JOIN address a ON a.id = t.addressFk + LEFT JOIN province p ON p.id = a.provinceFk + LEFT JOIN warehouse w ON w.id = t.warehouseFk + LEFT JOIN agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN ticketState ts ON ts.ticketFk = t.id + LEFT JOIN state st ON st.id = ts.stateFk + 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 sale s ON t.id = s.ticketFk + LEFT JOIN item i ON i.id = s.itemFk `); if (args.orderFk) { @@ -292,6 +295,9 @@ module.exports = Self => { } stmt.merge(conn.makeWhere(filter.where)); + stmt.merge({ + sql: `GROUP BY t.id` + }); stmts.push(stmt); stmt = new ParameterizedSQL(` From 20e894257d6366470ce0e303d88d3ef36358d4d2 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 26 Sep 2024 16:07:14 +0200 Subject: [PATCH 025/217] fix: refs #7874 rollback --- .../11230-brownEucalyptus/00-addClientObservationType.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql index 699d0bea4..cb0849888 100644 --- a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql +++ b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql @@ -1,3 +1,3 @@ ALTER TABLE vn.clientObservation - ADD COLUMN observationTypeFk TINYINT(3) UNSIGNED, + ADD COLUMN observationTypeFk TINYINT(3) UNSIGNED NOT NULL, ADD CONSTRAINT clientObservationTypeFk FOREIGN KEY (observationTypeFk) REFERENCES vn.observationType(id); \ No newline at end of file From f3bf0b7432723721c2b933e07ad0e07114002bcf Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 26 Sep 2024 17:20:50 +0200 Subject: [PATCH 026/217] feat: refs #7874 validate required field --- loopback/locale/es.json | 5 +++-- modules/client/back/models/client-observation.js | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index ba4b90cb5..01b7ee1ee 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -379,5 +379,6 @@ "The entry does not have stickers": "La entrada no tiene etiquetas", "Too many records": "Demasiados registros", "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" -} + "No valid travel thermograph found": "No se encontró un termógrafo válido", + "type cannot be blank": "Se debe rellenar el tipo" +} \ No newline at end of file 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(); From b547858820d4e42de35105611a64557f3ee678e3 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 27 Sep 2024 08:28:12 +0200 Subject: [PATCH 027/217] perf: refs #7010 showing field correctly --- modules/ticket/back/methods/ticket/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index b72f224bf..37150e6e9 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -261,7 +261,7 @@ module.exports = Self => { z.id zoneFk, CAST(z.hour AS CHAR) hour, a.nickname addressNickname, - GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk SEPARATOR ', ') packing + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk SEPARATOR ',') packing FROM ticket t LEFT JOIN invoiceOut io ON t.refFk = io.ref LEFT JOIN zone z ON z.id = t.zoneFk From e7d07e496e9cf31316ad9f8c3d7873804aa8c15b Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 30 Sep 2024 10:16:45 +0200 Subject: [PATCH 028/217] fix: refs #7404 add rounding to volume detail --- .../entry/back/methods/stock-bought/getStockBoughtDetail.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js index 3e040d0d3..d5f712edf 100644 --- a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js +++ b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js @@ -45,8 +45,8 @@ module.exports = Self => { i.id itemFk, i.name itemName, ti.quantity, - (ac.conversionCoefficient * (ti.quantity / b.packing) * buy_getVolume(b.id)) - / (vc.trolleyM3 * 1000000) volume, + 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 From b55db4bdc00f0ab0e6e20604e268c7d3a0e4e73f Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 30 Sep 2024 14:09:57 +0200 Subject: [PATCH 029/217] feat: refs #7010 added subquery to avoid using group by in sql --- modules/ticket/back/methods/ticket/filter.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 37150e6e9..d7e77603b 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -229,7 +229,7 @@ module.exports = Self => { CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) ENGINE = InnoDB - SELECT t.id, + SELECT DISTINCT t.id, t.shipped, CAST(DATE(t.shipped) AS CHAR) shippedDate, HOUR(t.shipped) shippedHour, @@ -261,7 +261,11 @@ module.exports = Self => { z.id zoneFk, CAST(z.hour AS CHAR) hour, a.nickname addressNickname, - GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk SEPARATOR ',') packing + (SELECT GROUP_CONCAT(DISTINCT i2.itemPackingTypeFk ORDER BY i2.itemPackingTypeFk SEPARATOR ',') + FROM sale s2 + JOIN item i2 ON i2.id = s2.itemFk + WHERE s2.ticketFk = t.id + ) AS packing FROM ticket t LEFT JOIN invoiceOut io ON t.refFk = io.ref LEFT JOIN zone z ON z.id = t.zoneFk @@ -275,8 +279,6 @@ module.exports = Self => { 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 sale s ON t.id = s.ticketFk - LEFT JOIN item i ON i.id = s.itemFk `); if (args.orderFk) { @@ -295,9 +297,7 @@ module.exports = Self => { } stmt.merge(conn.makeWhere(filter.where)); - stmt.merge({ - sql: `GROUP BY t.id` - }); + stmts.push(stmt); stmt = new ParameterizedSQL(` From 982c1dd67bdc71df6c4350a43cdbb4b3ba0e619d Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 1 Oct 2024 07:42:06 +0200 Subject: [PATCH 030/217] feat: refs #8064 itemTagState --- .../11273-goldenDendro/00-firstScript.sql | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 db/versions/11273-goldenDendro/00-firstScript.sql 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'; From 4243cdbf50ba9cc504d9f55f351b01b837d49797 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 1 Oct 2024 09:18:16 +0200 Subject: [PATCH 031/217] fix: refs #7817 Tests back --- .../back/methods/item/specs/lastEntriesFilter.spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js index 2fd30c2ca..00488e534 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 two entry for the given item', async() => { + it('should return one 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(2); + expect(result.length).toEqual(1); await tx.rollback(); } catch (e) { @@ -22,7 +22,7 @@ describe('item lastEntriesFilter()', () => { } }); - it('should return six entries for the given item', async() => { + it('should return five 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(6); + expect(result.length).toEqual(5); await tx.rollback(); } catch (e) { From 304992e7cf341c563ef37ec3c8c25428fd3c093b Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 1 Oct 2024 13:40:33 +0200 Subject: [PATCH 032/217] feat: refs #8069 starting branch --- db/routines/hedera/procedures/orderRow_updateOverstocking.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 db/routines/hedera/procedures/orderRow_updateOverstocking.sql diff --git a/db/routines/hedera/procedures/orderRow_updateOverstocking.sql b/db/routines/hedera/procedures/orderRow_updateOverstocking.sql new file mode 100644 index 000000000..e69de29bb From fd262e32c118354d0994eefbb5e1195d766c2c2e Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 1 Oct 2024 14:25:10 +0200 Subject: [PATCH 033/217] feat: refs #8069 new trigger hedera.orderRow_afterInsert --- db/routines/hedera/triggers/orderRow_afterInsert.sql | 10 ++++++++++ db/versions/11277-wheatChico/00-firstScript.sql | 3 +++ 2 files changed, 13 insertions(+) create mode 100644 db/routines/hedera/triggers/orderRow_afterInsert.sql create mode 100644 db/versions/11277-wheatChico/00-firstScript.sql diff --git a/db/routines/hedera/triggers/orderRow_afterInsert.sql b/db/routines/hedera/triggers/orderRow_afterInsert.sql new file mode 100644 index 000000000..af1a1479f --- /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 = NOW() + WHERE id = NEW.orderFk; +END$$ +DELIMITER ; \ No newline at end of file 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'; From 03ea7580d8d3474a2b4d8aa40cffabdf45ebcc27 Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 1 Oct 2024 15:02:24 +0200 Subject: [PATCH 034/217] feat: refs #8069 new proc --- .../orderRow_updateOverstocking.sql | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/db/routines/hedera/procedures/orderRow_updateOverstocking.sql b/db/routines/hedera/procedures/orderRow_updateOverstocking.sql index e69de29bb..21cdb07ac 100644 --- a/db/routines/hedera/procedures/orderRow_updateOverstocking.sql +++ b/db/routines/hedera/procedures/orderRow_updateOverstocking.sql @@ -0,0 +1,26 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`orderRow_updateOverstocking`( + vWarehouseFk INT +) +BEGIN +/** +* Set amount = 0 to avoid overbooking sales +* +* @param vWarehouseFk vn.warehouse.id +*/ + DECLARE vCalcFk INT; + + CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, 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) < NOW() + AND a.available <= 0 + AND r.shipment BETWEEN CURDATE() AND util.dayEnd(CURDATE()) + AND NOT o.confirmed + AND r.warehouseFk = vWarehouseFk; +END$$ +DELIMITER ; \ No newline at end of file From 9d84c39fce036e03592ad87e2d5bf42477e4238a Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 2 Oct 2024 08:52:20 +0200 Subject: [PATCH 035/217] feat: refs #8069 orderRow_updateOverstocking --- .../orderRow_updateOverstocking.sql | 57 ++++++++++++++----- .../procedures/order_confirmWithUser.sql | 2 + 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/db/routines/hedera/procedures/orderRow_updateOverstocking.sql b/db/routines/hedera/procedures/orderRow_updateOverstocking.sql index 21cdb07ac..4bd1bb981 100644 --- a/db/routines/hedera/procedures/orderRow_updateOverstocking.sql +++ b/db/routines/hedera/procedures/orderRow_updateOverstocking.sql @@ -1,26 +1,53 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`orderRow_updateOverstocking`( - vWarehouseFk INT -) +CREATE OR REPLACE DEFINER=`vn`@`localhost` +PROCEDURE `hedera`.`orderRow_updateOverstocking`(vOrderFk INT) BEGIN /** * Set amount = 0 to avoid overbooking sales * -* @param vWarehouseFk vn.warehouse.id +* @param vOrderFk hedera.order.id */ DECLARE vCalcFk INT; + DECLARE vDated DATE; + DECLARE vDone BOOL; + DECLARE vWarehouseFk INT; - CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, CURDATE()); + DECLARE cWarehouses CURSOR FOR + SELECT DISTINCT warehouseFk, shipment + FROM orderRow r + WHERE r.orderFk = vOrderFk; - 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) < NOW() - AND a.available <= 0 - AND r.shipment BETWEEN CURDATE() AND util.dayEnd(CURDATE()) - AND NOT o.confirmed - AND r.warehouseFk = vWarehouseFk; + 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, vDated; + + IF vDone THEN + LEAVE checking; + END IF; + + CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated); + + 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) < NOW() + AND a.available <= 0 + AND r.shipment BETWEEN CURDATE() AND util.dayEnd(CURDATE()) + AND NOT o.confirmed + AND r.warehouseFk = vWarehouseFk; + END LOOP; + CLOSE cWarehouses; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 2b033b704..17adc74dd 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -101,6 +101,8 @@ BEGIN CALL order_checkEditable(vSelf); + CALL orderRow_updateOverstocking(vSelf); + -- Check order is not empty SELECT COUNT(*) > 0 INTO vHasRows FROM orderRow From 724ddd5fe8e47e9245b8ba551e40af0688691b33 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 2 Oct 2024 09:26:23 +0200 Subject: [PATCH 036/217] refactor: refs #7980 Deleted table buyMark --- db/routines/vn/procedures/clean.sql | 6 ------ db/routines/vn2008/views/Compres_mark.sql | 8 -------- db/versions/11281-purpleCyca/00-firstScript.sql | 1 + 3 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 db/routines/vn2008/views/Compres_mark.sql create mode 100644 db/versions/11281-purpleCyca/00-firstScript.sql diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index 4a1f526fc..ad6d66e12 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -50,12 +50,6 @@ 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; 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/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; From bbcf71619ce2f80be8dcfb8c1dff604d9b88651a Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 2 Oct 2024 09:56:36 +0200 Subject: [PATCH 037/217] fix: refs #6861 duplicatedTicketsInReserve --- .../vn/procedures/collection_getTickets.sql | 7 +-- .../itemShelvingSale_addBySale copy.sql | 48 +++++++++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 db/routines/vn/procedures/itemShelvingSale_addBySale copy.sql diff --git a/db/routines/vn/procedures/collection_getTickets.sql b/db/routines/vn/procedures/collection_getTickets.sql index 0f675041a..1391c27d4 100644 --- a/db/routines/vn/procedures/collection_getTickets.sql +++ b/db/routines/vn/procedures/collection_getTickets.sql @@ -46,7 +46,7 @@ BEGIN LEFT JOIN observation ob ON ob.ticketFk = t.id WHERE t.id = vParamFk AND t.shipped >= vYesterday - UNION ALL + UNION SELECT t.id ticketFk, IF(NOT(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`, am.name agencyName, @@ -67,7 +67,7 @@ BEGIN 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 + UNION SELECT sg.ticketFk, NULL `level`, am.name agencyName, @@ -84,6 +84,7 @@ BEGIN 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; + AND t.shipped >= vYesterday + GROUP BY ticketFk; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySale copy.sql b/db/routines/vn/procedures/itemShelvingSale_addBySale copy.sql new file mode 100644 index 000000000..7da1a82fa --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_addBySale copy.sql @@ -0,0 +1,48 @@ +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; + + SELECT iss.saleFk INTO vSaleFk + FROM itemShelvingSale iss + JOIN sale s ON s.id = iss.saleFk + WHERE iss.id = vSelf AND s.isAdded ; + + 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('The sale can not be deleted with sales picked'); + END IF; + + START TRANSACTION; + + 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 From 62bd2ae03bfb7ebd54bdf725a6455ccdfb0e0fff Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 2 Oct 2024 11:27:09 +0200 Subject: [PATCH 038/217] refactor: refs #6824 Throw for no delete itemShelving with itemShelvingSale --- .../vn/triggers/itemShelving_beforeDelete.sql | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/db/routines/vn/triggers/itemShelving_beforeDelete.sql b/db/routines/vn/triggers/itemShelving_beforeDelete.sql index 89737a841..8313e3ed9 100644 --- a/db/routines/vn/triggers/itemShelving_beforeDelete.sql +++ b/db/routines/vn/triggers/itemShelving_beforeDelete.sql @@ -2,14 +2,26 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelving_beforeDelete` BEFORE DELETE ON `itemShelving` FOR EACH ROW -INSERT INTO vn.itemShelvingLog(itemShelvingFk, - workerFk, - accion, - shelvingFk, - itemFk) - VALUES( OLD.id, - account.myUser_getId(), - 'ELIMINADO', - OLD.shelvingFk, - OLD.itemFk)$$ +BEGIN + DECLARE vItemShelvingSaleExists BOOL; + + SELECT COUNT(*) INTO vItemShelvingSaleExists + FROM itemShelvingSale + WHERE itemShelvingFk = OLD.id; + + IF vItemShelvingSaleExists AND @canDeleteItemShelvingSale IS NULL THEN + CALL util.throw('Cannot delete item shelving with item shelving sale'); + END IF; + + INSERT INTO vn.itemShelvingLog(itemShelvingFk, + workerFk, + accion, + shelvingFk, + itemFk) + VALUES( OLD.id, + account.myUser_getId(), + 'ELIMINADO', + OLD.shelvingFk, + OLD.itemFk); +END$$ DELIMITER ; From 2655e20ef64759f9f6a2574f8f3aa72979ab745a Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 2 Oct 2024 11:32:20 +0200 Subject: [PATCH 039/217] refactor: refs #6824 Throw for no delete itemShelving with itemShelvingSale --- db/routines/vn/procedures/clean.sql | 2 ++ db/routines/vn/triggers/itemShelving_beforeDelete.sql | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index 4a1f526fc..1e0697997 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -23,7 +23,9 @@ BEGIN DELETE FROM messageInbox WHERE sendDate < v2Months; DELETE FROM messageInbox WHERE sendDate < v2Months; DELETE FROM workerTimeControl WHERE timed < v4Years; + SET @canDeleteItemShelvingSale = TRUE; DELETE FROM itemShelving WHERE created < util.VN_CURDATE() AND visible = 0; + SET @canDeleteItemShelvingSale = NULL; DELETE FROM ticketDown WHERE created < util.yesterday(); DELETE IGNORE FROM expedition WHERE created < v26Months; DELETE cs diff --git a/db/routines/vn/triggers/itemShelving_beforeDelete.sql b/db/routines/vn/triggers/itemShelving_beforeDelete.sql index 8313e3ed9..dbe21dabd 100644 --- a/db/routines/vn/triggers/itemShelving_beforeDelete.sql +++ b/db/routines/vn/triggers/itemShelving_beforeDelete.sql @@ -9,7 +9,9 @@ BEGIN FROM itemShelvingSale WHERE itemShelvingFk = OLD.id; - IF vItemShelvingSaleExists AND @canDeleteItemShelvingSale IS NULL THEN + IF vItemShelvingSaleExists AND (NOT @canDeleteItemShelvingSale + OR @canDeleteItemShelvingSale IS NULL) THEN + CALL util.throw('Cannot delete item shelving with item shelving sale'); END IF; From fc1ea280fafa739cff7926f7ddd9b1cc93c12091 Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 2 Oct 2024 14:03:57 +0200 Subject: [PATCH 040/217] fix: refs #8069 new conception --- .../orderRow_updateOverstocking.sql | 25 +++++++++---------- .../procedures/order_confirmWithUser.sql | 13 ++++++++++ 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/db/routines/hedera/procedures/orderRow_updateOverstocking.sql b/db/routines/hedera/procedures/orderRow_updateOverstocking.sql index 4bd1bb981..ff8362c65 100644 --- a/db/routines/hedera/procedures/orderRow_updateOverstocking.sql +++ b/db/routines/hedera/procedures/orderRow_updateOverstocking.sql @@ -8,14 +8,14 @@ BEGIN * @param vOrderFk hedera.order.id */ DECLARE vCalcFk INT; - DECLARE vDated DATE; DECLARE vDone BOOL; DECLARE vWarehouseFk INT; DECLARE cWarehouses CURSOR FOR - SELECT DISTINCT warehouseFk, shipment - FROM orderRow r - WHERE r.orderFk = vOrderFk; + SELECT DISTINCT warehouseFk + FROM orderRow + WHERE orderFk = vOrderFk + AND shipped = util.VN_CURDATE(); DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -29,24 +29,23 @@ BEGIN checking: LOOP SET vDone = FALSE; - FETCH cWarehouses INTO vWarehouseFk, vDated; + FETCH cWarehouses INTO vWarehouseFk; IF vDone THEN LEAVE checking; END IF; - CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated); + 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 + 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) < NOW() + WHERE ADDTIME(o.rowUpdated, oc.reserveTime) < util.VN_NOW() AND a.available <= 0 - AND r.shipment BETWEEN CURDATE() AND util.dayEnd(CURDATE()) - AND NOT o.confirmed - AND r.warehouseFk = vWarehouseFk; + AND r.warehouseFk = vWarehouseFk + AND r.orderFk = vOrderFk; END LOOP; CLOSE cWarehouses; END$$ diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 17adc74dd..b3aab522e 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -12,6 +12,7 @@ BEGIN * @param vUser The user identifier */ DECLARE vHasRows BOOL; + DECLARE vHas0Amount BOOL; DECLARE vDone BOOL; DECLARE vWarehouseFk INT; DECLARE vShipment DATE; @@ -113,6 +114,18 @@ BEGIN CALL util.throw('ORDER_EMPTY'); END IF; + -- 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('Remove lines with quantity = 0 before confirming'); + END IF; + -- Crea los tickets del pedido OPEN vDates; lDates: LOOP From 43df98598c60737f6db173c2261022fc82f611da Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 2 Oct 2024 15:27:09 +0200 Subject: [PATCH 041/217] feat: refs #7346 manual invoice with address --- .../procedures/invoiceOut_newFromAddress.sql | 56 +++++ .../methods/invoiceOut/createManualInvoice.js | 208 ++++++++++-------- .../specs/createManualInvoice.spec.js | 87 +++----- 3 files changed, 203 insertions(+), 148 deletions(-) create mode 100644 db/routines/vn/procedures/invoiceOut_newFromAddress.sql diff --git a/db/routines/vn/procedures/invoiceOut_newFromAddress.sql b/db/routines/vn/procedures/invoiceOut_newFromAddress.sql new file mode 100644 index 000000000..d0ab90a3e --- /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/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js index c46da0ba5..32445a8df 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 consignatary 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,120 @@ 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, null, myOptions); + const company = await models.Company.findById(ticket.companyFk, null, 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, null, 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 +177,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 +188,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/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 ); } From ee52c8b45fdc2b70f7f0a08c1bc08a16732934a3 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 2 Oct 2024 15:34:53 +0200 Subject: [PATCH 042/217] fix: refs #7346 findByid con fields --- .../vn/procedures/invoiceOut_newFromAddress.sql | 4 ++-- .../back/methods/invoiceOut/createManualInvoice.js | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/invoiceOut_newFromAddress.sql b/db/routines/vn/procedures/invoiceOut_newFromAddress.sql index d0ab90a3e..495ace608 100644 --- a/db/routines/vn/procedures/invoiceOut_newFromAddress.sql +++ b/db/routines/vn/procedures/invoiceOut_newFromAddress.sql @@ -39,8 +39,8 @@ BEGIN AND t.refFk IS NULL AND t.companyFk = vCompanyFk AND t.shipped BETWEEN - util.firstDayOfYear(vMaxShipped - INTERVAL 1 YEAR) AND - util.dayend(vMaxShipped); + util.firstDayOfYear(vMaxShipped - INTERVAL 1 YEAR) + AND util.dayend(vMaxShipped); CALL invoiceOut_new(vSerial, util.VN_CURDATE(), vTaxArea, vInvoiceId); diff --git a/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js index 32445a8df..a06128848 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js @@ -13,7 +13,7 @@ module.exports = Self => { { arg: 'addressFk', type: 'any', - description: 'The consignatary address id' + description: 'The address id' }, { arg: 'ticketFk', @@ -72,8 +72,12 @@ module.exports = Self => { let query; try { if (ticketFk) { - const ticket = await models.Ticket.findById(ticketFk, null, myOptions); - const company = await models.Company.findById(ticket.companyFk, null, myOptions); + 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; @@ -93,7 +97,9 @@ module.exports = Self => { throw new UserError(`Max shipped required`); if (addressFk) { - const address = await models.Address.findById(addressFk, null, myOptions); + const address = await models.Address.findById(addressFk, { + fields: ['clientFk'] + }, myOptions); if (clientFk && clientFk !== address.clientFk) throw new UserError('The provided clientFk does not match'); From e870d16cb9ab4ea0315786c0cff8b7478ecfb052 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 3 Oct 2024 07:54:16 +0200 Subject: [PATCH 043/217] build: refs #8062 dump db --- db/dump/.dump/data.sql | 174 ++- db/dump/.dump/privileges.sql | 7 +- db/dump/.dump/structure.sql | 2298 ++++++++++------------------------ db/dump/.dump/triggers.sql | 95 +- 4 files changed, 817 insertions(+), 1757 deletions(-) diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index 5800d6ecd..4c210f87e 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -4,7 +4,7 @@ USE `util`; /*!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','11196','91ee956fbd1557848e4ab522bc5d39b2ec10e9b2','2024-09-18 07:28:14','11245'); +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); @@ -862,6 +862,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','11083','00-firstScript.sql','jen 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); @@ -875,12 +876,37 @@ INSERT INTO `versionLog` VALUES ('vn-database','11103','00-firstScript.sql','jen 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); @@ -942,6 +968,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','11172','14-firstScript.sql','jen 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); @@ -967,12 +994,45 @@ INSERT INTO `versionLog` VALUES ('vn-database','11205','00-firstScript.sql','jen 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 */; @@ -1345,6 +1405,8 @@ 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); @@ -1445,7 +1507,7 @@ INSERT INTO `ACL` VALUES (112,'Defaulter','*','READ','ALLOW','ROLE','employee',N 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','*','*','ALLOW','ROLE','employee',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); @@ -1541,8 +1603,6 @@ 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 (238,'Town','*','WRITE','ALLOW','ROLE','deliveryAssistant',NULL); -INSERT INTO `ACL` VALUES (239,'Province','*','WRITE','ALLOW','ROLE','deliveryAssistant',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); @@ -1556,7 +1616,7 @@ 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','*','*','ALLOW','ROLE','administrative',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); @@ -1931,7 +1991,7 @@ INSERT INTO `ACL` VALUES (699,'TicketSms','find','READ','ALLOW','ROLE','salesPer 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','delivery',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); @@ -2134,9 +2194,25 @@ INSERT INTO `ACL` VALUES (915,'ACL','*','WRITE','ALLOW','ROLE','developerBoss',1 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','$subordinate',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 (921,'Worker','findById','READ','ALLOW','ROLE','employee',NULL); +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'); @@ -2437,6 +2513,7 @@ 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 (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,'cost','coste',1,0); INSERT INTO `componentType` VALUES (2,NULL,'com ventas',1,1); @@ -2511,7 +2588,7 @@ INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',110,111 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,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); @@ -2568,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'); @@ -2605,44 +2682,44 @@ 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 `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,1,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,2,'ON_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'); -INSERT INTO `state` VALUES (6,'En Revisión',7,2,'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,2,'CHECKED',NULL,8,0,1,0,3,0,0,1,0,'warning'); -INSERT INTO `state` VALUES (9,'Encajando',9,3,'PACKING',NULL,9,0,1,0,0,0,0,1,0,NULL); -INSERT INTO `state` VALUES (10,'Encajado',10,3,'PACKED',NULL,10,0,1,0,0,0,0,0,0,NULL); -INSERT INTO `state` VALUES (11,'Facturado',0,4,'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,4,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0,NULL); -INSERT INTO `state` VALUES (14,'Preparado',6,2,'PREPARED',NULL,14,0,1,0,2,0,0,1,0,'warning'); -INSERT INTO `state` VALUES (15,'Pte Recogida',12,4,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0,NULL); -INSERT INTO `state` VALUES (16,'Entregado',13,4,'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,2,'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,2,'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,2,'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,2,'BOARD',5,30,0,0,0,2,0,0,3,0,'success'); -INSERT INTO `state` VALUES (31,'Polizon Impreso',4,2,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,2,0,'success'); -INSERT INTO `state` VALUES (32,'Polizon OK',3,2,'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,3,'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,2,'COOLER_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'); -INSERT INTO `state` VALUES (41,'Prep Parcial',6,2,'PARTIAL_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'); -INSERT INTO `state` VALUES (42,'Entregado en parte',13,3,'PARTIAL_DELIVERED',NULL,16,0,1,0,0,0,0,0,0,NULL); -INSERT INTO `state` VALUES (43,'Preparación por caja',6,2,'BOX_PICKING',7,42,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'); @@ -2659,6 +2736,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'); diff --git a/db/dump/.dump/privileges.sql b/db/dump/.dump/privileges.sql index 8ee823cfa..b144ac731 100644 --- a/db/dump/.dump/privileges.sql +++ b/db/dump/.dump/privileges.sql @@ -1347,7 +1347,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','component','guiller 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','production','itemShelvingSale','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update',''); 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'); @@ -1471,6 +1471,9 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','tillSerial',' 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 */; @@ -2191,6 +2194,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_recalcPricesByEn 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'); @@ -2206,6 +2210,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana-write','item_ValuateInv 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'); /*!40000 ALTER TABLE `procs_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 f9ad18c8f..af822a27c 100644 --- a/db/dump/.dump/structure.sql +++ b/db/dump/.dump/structure.sql @@ -76,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, @@ -92,7 +92,7 @@ CREATE TABLE `accountLog` ( `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 */; -- @@ -186,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` -- @@ -236,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` -- @@ -371,6 +337,7 @@ CREATE TABLE `roleLog` ( 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 */; @@ -515,6 +482,7 @@ CREATE TABLE `userLog` ( 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 */; @@ -2401,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` -- @@ -2643,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` -- @@ -2724,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 */; @@ -2780,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' -- @@ -3876,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'; @@ -3920,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` -- @@ -4292,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', @@ -4347,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` -- @@ -4392,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` -- @@ -4490,8 +4257,11 @@ CREATE TABLE `waste` ( `itemFk` int(11) NOT NULL DEFAULT 0, `saleTotal` decimal(10,2) DEFAULT NULL COMMENT 'Coste', `saleWasteQuantity` decimal(10,2) DEFAULT NULL, - `saleInternalWaste` 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`), @@ -6509,10 +6279,24 @@ 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 vDateFrom DATE DEFAULT util.VN_CURDATE() - INTERVAL WEEKDAY(util.VN_CURDATE()) DAY; - DECLARE vDateTo DATE DEFAULT vDateFrom + INTERVAL 6 DAY; +/** + * 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); @@ -6524,16 +6308,32 @@ BEGIN s.itemFk, SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity), SUM(IF(aw.`type`, s.quantity, 0)), - SUM( - IF( - aw.`type` = 'internal', + SUM(IF( + aw.`type` = 'external', (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, 0 ) - ), - SUM( - IF( - aw.`type` = 'external', + ), + 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 ) @@ -6550,7 +6350,26 @@ BEGIN JOIN vn.buy b ON b.id = lb.buy_id WHERE t.shipped BETWEEN vDateFrom AND vDateTo AND w.isManaged - GROUP BY i.id; + 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 */ ; @@ -9347,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' @@ -10085,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 */ ; @@ -19047,6 +18310,7 @@ CREATE TABLE `ACLLog` ( 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 */; @@ -19455,6 +18719,7 @@ CREATE TABLE `bufferLog` ( 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 */; @@ -24087,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, @@ -24151,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` -- @@ -24297,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 */ ;; @@ -25754,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 */ ; @@ -26555,7 +25923,7 @@ DROP TABLE IF EXISTS `addressWaste`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `addressWaste` ( `addressFk` int(11) NOT NULL, - `type` enum('internal','external') 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; @@ -26572,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`) @@ -26646,6 +26011,7 @@ CREATE TABLE `agencyLog` ( 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; @@ -27029,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, @@ -27388,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` -- @@ -27661,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, @@ -27686,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`), @@ -27925,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', @@ -27973,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`), @@ -28156,6 +27493,7 @@ CREATE TABLE `claimLog` ( 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 */; @@ -28264,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` -- @@ -28346,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, @@ -28362,7 +27683,6 @@ 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 '@deprecated 2024-06-12 refs #7545 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, @@ -28378,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`), @@ -28600,6 +27919,7 @@ CREATE TABLE `clientLog` ( 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 */; @@ -28798,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, @@ -28852,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, @@ -28869,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; @@ -29017,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`), @@ -29036,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', @@ -29046,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 */; @@ -29102,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 ', @@ -29534,22 +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`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `corridor` -- @@ -29579,7 +28878,6 @@ CREATE TABLE `country` ( `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, @@ -29589,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` (`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; @@ -29699,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 */; @@ -29841,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`), @@ -29851,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, @@ -30130,6 +29422,7 @@ CREATE TABLE `deviceProductionLog` ( 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 */; @@ -30268,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', @@ -30356,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, @@ -30367,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, @@ -30619,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, @@ -30719,6 +30008,7 @@ CREATE TABLE `entryLog` ( 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 */; @@ -31014,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, @@ -31588,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='@deprecated 2024-05-21'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `franceExpressConfig` -- @@ -32317,6 +31583,7 @@ CREATE TABLE `invoiceInLog` ( 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 */; @@ -32649,14 +31916,12 @@ 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` decimal(10,2) DEFAULT NULL, `nonRecycledPlastic` decimal(10,2) DEFAULT NULL, - `minQuantity__` int(10) unsigned DEFAULT NULL COMMENT '@deprecated 2024-07-11 refs #7704 Cantidad mínima para una línea de venta', `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, @@ -33015,6 +32280,7 @@ CREATE TABLE `itemLog` ( 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 */; @@ -33235,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`, @@ -33599,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 COMMENT '@deprecated 2024-07-01 refs #7418', - `target__` double NOT NULL DEFAULT 0.15 COMMENT '@deprecated 2024-07-01 refs #7418', - `topMargin__` double NOT NULL DEFAULT 0.3 COMMENT '@deprecated 2024-07-01 refs #7418', - `profit__` double NOT NULL DEFAULT 0.02 COMMENT '@deprecated 2024-07-01 refs #7418', - `density__` double NOT NULL DEFAULT 167 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', `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', @@ -33626,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 */; @@ -33839,9 +33092,7 @@ 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 COMMENT '@deprecated 2024-05-28 refs #7400 Modificar contador asientos contables', - `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 */; @@ -34791,6 +34042,7 @@ CREATE TABLE `packaging` ( `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`), @@ -34984,6 +34236,7 @@ CREATE TABLE `packingSiteDeviceLog` ( 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 */; @@ -35065,7 +34318,7 @@ 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 `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 */; @@ -35094,6 +34347,7 @@ CREATE TABLE `parkingLog` ( 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; @@ -35267,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 */; @@ -35288,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, - `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', `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; @@ -35655,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` -- @@ -35913,6 +35191,7 @@ CREATE TABLE `productionConfigLog` ( 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 */; @@ -36359,6 +35638,7 @@ CREATE TABLE `rateLog` ( 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 */; @@ -36877,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` -- @@ -36916,6 +36181,7 @@ CREATE TABLE `routeLog` ( 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 */; @@ -36965,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` -- @@ -37247,6 +36495,7 @@ CREATE TABLE `saleGroupLog` ( 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 */; @@ -37369,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', @@ -37378,11 +36626,9 @@ 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 */; @@ -37939,6 +37185,7 @@ CREATE TABLE `shelvingLog` ( 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 */; @@ -38348,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, @@ -38385,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` -- @@ -38439,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 COMMENT 'refs #7345 @deprecated 2024-05-10 - Utilizar withholdingSageFk', `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, @@ -38506,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, @@ -38720,6 +37983,7 @@ CREATE TABLE `supplierLog` ( 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 */; @@ -39050,6 +38314,21 @@ CREATE TABLE `ticket` ( ) 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` -- @@ -39462,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, @@ -39481,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`), @@ -39541,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 DELETE CASCADE 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` -- @@ -39631,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` -- @@ -39994,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, @@ -40009,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`), @@ -40132,6 +39376,7 @@ CREATE TABLE `travelLog` ( 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 */; @@ -40226,6 +39471,7 @@ CREATE TABLE `userLog` ( 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 */; @@ -40549,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, @@ -40574,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 */; @@ -40621,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 */; -- @@ -40645,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 @@ -40680,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, @@ -40695,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` -- @@ -40795,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, @@ -40815,7 +40046,6 @@ CREATE TABLE `worker` ( UNIQUE KEY `worker_business` (`businessFk`), 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`), @@ -41037,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 */; @@ -41219,6 +40449,7 @@ CREATE TABLE `workerLog` ( 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 */; @@ -41721,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`), @@ -41997,6 +41229,7 @@ CREATE TABLE `zoneLog` ( 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 */; @@ -42394,7 +41627,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 `travel_setDelivered` ON SCHEDULE EVERY 1 DAY STARTS '2024-07-12 00:10:00' ON COMPLETION PRESERVE ENABLE DO BEGIN +/*!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(); @@ -43658,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=`vn`@`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 */ ; @@ -45084,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=`vn`@`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 */ ; @@ -45308,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=`vn`@`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 */ ; @@ -46512,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=`vn`@`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 */ ; @@ -48720,7 +47754,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_getUltimate`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_getUltimate`( vItemFk INT, vWarehouseFk SMALLINT, vDated DATE @@ -48780,7 +47814,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_getUltimateFromInterval`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `buy_getUltimateFromInterval`( vItemFk INT, vWarehouseFk SMALLINT, vStarted DATE, @@ -49533,7 +48567,10 @@ BEGIN 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; @@ -49633,7 +48670,7 @@ CREATE DEFINER=`vn`@`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 @@ -49651,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)) @@ -49734,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, @@ -49929,7 +49002,8 @@ BEGIN tmp.ticketComponentBase, tmp.ticketComponentRate, tmp.ticketComponentCopy, - tSpecialPrice; + tPriceDelta, + tSpecialPrice; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -50535,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=`vn`@`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 */ ; @@ -51788,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, @@ -51813,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 @@ -51826,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)) @@ -52403,7 +51453,7 @@ BEGIN 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 + 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`, @@ -52591,7 +51641,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_mergeSales`(vCollectionFk INT) +CREATE DEFINER=`vn`@`localhost` PROCEDURE `collection_mergeSales`(vCollectionFk INT) BEGIN DECLARE vDone BOOL; DECLARE vTicketFk INT; @@ -53739,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 @@ -59689,98 +58739,6 @@ ELSE INSERT INTO vn.itemBarcode(itemFk,code) VALUES (vItemFk,vCode); 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 `itemFuentesBalance` */; -/*!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 `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 ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -59797,7 +58755,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemMinimumQuantity_check`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemMinimumQuantity_check`( vSelf INT, vItemFk INT, vStarted DATE, @@ -60226,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 = 'IGNORE_SPACE,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 = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`vn`@`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 */ ; @@ -60341,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=`vn`@`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 */ ; @@ -60429,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 @@ -60807,7 +59661,8 @@ BEGIN getUser()); UPDATE itemShelving - SET visible = visible - vQuantity + SET visible = visible - vQuantity, + available = available - vQuantity WHERE id = vItemShelvingFk; UPDATE vn.saleTracking @@ -61034,7 +59889,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSale_addBySaleGroup`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingSale_addBySaleGroup`( vSaleGroupFk INT(11) ) BEGIN @@ -62265,12 +61120,12 @@ CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelving_selfConsumption`( ) 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; @@ -62339,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; @@ -62392,7 +61248,8 @@ BEGIN IF vNewItemShelvingFk THEN UPDATE itemShelving ish JOIN itemShelving ish2 ON ish2.id = vItemShelvingFk - SET ish.visible = ish.visible + ish2.visible + SET ish.visible = ish.visible + ish2.visible, + ish.available = ish.available + ish2.available WHERE ish.id = vNewItemShelvingFk; DELETE FROM itemShelving @@ -63730,7 +62587,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; @@ -64517,25 +63375,24 @@ 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 vAvailableCalcFk INT; - DECLARE vVisibleCalcFk INT; - DECLARE vTypeFk INT; DECLARE vPriority INT DEFAULT 1; CALL cache.available_refresh(vAvailableCalcFk, FALSE, vWarehouseFk, vDated); - CALL cache.visible_refresh(vVisibleCalcFk, FALSE, vWarehouseFk); WITH itemTags AS ( SELECT i.id, @@ -64555,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, @@ -64578,13 +63452,13 @@ BEGIN WHEN b.groupingMode = 'packing' THEN b.packing ELSE 1 END minQuantity, - v.visible located, + 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 = vAvailableCalcFk - LEFT JOIN cache.visible v ON v.item_id = i.id - AND v.calc_id = vVisibleCalcFk + 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 @@ -64594,20 +63468,21 @@ BEGIN LEFT JOIN vn.tag t ON t.id = it.tagFk LEFT JOIN vn.buy b ON b.id = lb.buy_id 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 ; @@ -67052,60 +65927,66 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`vn`@`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 ; @@ -67427,15 +66308,15 @@ proc: BEGIN UPDATE tmp.productionBuffer pb JOIN sale s ON s.ticketFk = pb.ticketFk 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 cache.last_buy lb ON lb.warehouse_id = vWarehouseFk AND lb.item_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 pb.isOwn; + AND s.quantity >= b.packing + AND pb.isOwn; DROP TEMPORARY TABLE tmp.productionTicket, @@ -67753,7 +66634,6 @@ BEGIN i.itemPackingTypeFk, isa.`size`, isa.Estado, - isa.sectorProdPriority, isa.available, isa.sectorFk, isa.matricula, @@ -71167,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 @@ -71341,6 +70222,81 @@ 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 `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 */ ; @@ -72063,7 +71019,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `supplier_statementWithEntries`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `supplier_statementWithEntries`( vSupplierFk INT, vCurrencyFk INT, vCompanyFk INT, @@ -72081,14 +71037,14 @@ BEGIN * @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 +* @return tmp.supplierStatement */ DECLARE vBalanceStartingDate DATETIME; SET @euroBalance:= 0; SET @currencyBalance:= 0; - SELECT balanceStartingDate + SELECT balanceStartingDate INTO vBalanceStartingDate FROM invoiceInConfig; @@ -72128,14 +71084,14 @@ BEGIN c.code, 'invoiceIn' statementType FROM invoiceIn ii - JOIN invoiceInDueDay iid ON iid.invoiceInFk = ii.id + 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 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 + GROUP BY iid.id, ii.id UNION ALL SELECT p.bankFk, p.companyFk, @@ -72171,7 +71127,7 @@ BEGIN AND vCurrencyFk IN (p.currencyFk, 0) AND vCompanyFk IN (p.companyFk, 0) AND (vIsConciliated = p.isConciliated OR NOT vIsConciliated) - UNION ALL + UNION ALL SELECT NULL, companyFk, NULL, @@ -72198,7 +71154,7 @@ BEGIN AND vCurrencyFk IN (se.currencyFk,0) AND vCompanyFk IN (se.companyFk,0) AND (vIsConciliated = se.isConciliated OR NOT vIsConciliated) - UNION ALL + UNION ALL SELECT NULL bankFk, e.companyFk, 'E' serial, @@ -72214,7 +71170,7 @@ BEGIN FALSE isBooked, c.code, 'order' - FROM entry e + FROM entry e JOIN travel tr ON tr.id = e.travelFk JOIN currency c ON c.id = e.currencyFk WHERE e.supplierFk = vSupplierFk @@ -73667,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, @@ -73699,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, @@ -73756,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; @@ -73813,6 +72775,7 @@ BEGIN t.clientFk, t.warehouseFk, ts.alertLevel, + sub2.alertLevel futureAlertLevel, t.shipped, t.totalWithVat, sub2.shipped futureShipped, @@ -73839,6 +72802,7 @@ BEGIN t.addressFk, t.id, t.shipped, + ts.alertLevel, st.name state, st.code, st.classColor, @@ -75713,7 +74677,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_mergeSales`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_mergeSales`( vSelf INT ) BEGIN @@ -76368,7 +75332,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setProblemRiskByClient`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_setProblemRiskByClient`( vClientFk INT ) BEGIN @@ -76710,7 +75674,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setVolume`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_setVolume`( vSelf INT ) BEGIN @@ -76747,7 +75711,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setVolumeItemCost`( +CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_setVolumeItemCost`( vItemFk INT ) BEGIN @@ -81322,7 +80286,9 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`vn`@`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 @@ -81335,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 ;; @@ -83331,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`, @@ -83596,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; -- @@ -85619,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` */; @@ -87940,7 +86906,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!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`,`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 */; +/*!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 */; @@ -88840,7 +87806,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!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 `MIDNIGHT`(`util`.`VN_CURDATE`()) */; +/*!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 */; @@ -89134,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 */; @@ -89296,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 */; @@ -91240,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 */; @@ -91506,4 +90472,4 @@ USE `vn2008`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-09-18 9:32:42 +-- Dump completed on 2024-10-03 5:53:26 diff --git a/db/dump/.dump/triggers.sql b/db/dump/.dump/triggers.sql index b0879a9c5..0e3bd2424 100644 --- a/db/dump/.dump/triggers.sql +++ b/db/dump/.dump/triggers.sql @@ -4306,35 +4306,13 @@ DELIMITER ; /*!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`.`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=`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 ; @@ -5018,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 */;; @@ -5552,7 +5533,7 @@ DELIMITER ; /*!50003 SET @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_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`host_beforeInsert` BEFORE INSERT ON `host` FOR EACH ROW BEGIN @@ -6518,6 +6499,36 @@ BEGIN SET NEW.userFk = account.myUser_getId(); SET NEW.available = NEW.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_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_afterInsert` + AFTER INSERT ON `itemShelving` + FOR EACH ROW +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 */ ; @@ -7925,7 +7936,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`roadmap_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`roadmap_beforeInsert` BEFORE INSERT ON `roadmap` FOR EACH ROW BEGIN @@ -7949,7 +7960,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`roadmap_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`roadmap_beforeUpdate` BEFORE UPDATE ON `roadmap` FOR EACH ROW BEGIN @@ -8604,7 +8615,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleGroupDetail_beforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleGroupDetail_beforeInsert` BEFORE INSERT ON `saleGroupDetail` FOR EACH ROW BEGIN @@ -8624,7 +8635,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleGroupDetail_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleGroupDetail_beforeUpdate` BEFORE UPDATE ON `saleGroupDetail` FOR EACH ROW BEGIN @@ -8644,7 +8655,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleGroupDetail_afterDelete` +/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`saleGroupDetail_afterDelete` AFTER DELETE ON `saleGroupDetail` FOR EACH ROW BEGIN @@ -8925,7 +8936,7 @@ DELIMITER ;; 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 ; @@ -8949,12 +8960,12 @@ 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 */;; @@ -8978,7 +8989,7 @@ DELIMITER ;; 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 ; @@ -10852,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=`vn`@`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(); @@ -10872,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=`vn`@`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(); @@ -10892,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=`vn`@`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 */;; @@ -11458,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-09-18 9:32:59 +-- Dump completed on 2024-10-03 5:53:44 From b34727a436cb2c054310b996129111c047ed17ea Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 3 Oct 2024 08:39:30 +0200 Subject: [PATCH 044/217] fix: refs #8069 wrong field name --- db/routines/hedera/procedures/orderRow_updateOverstocking.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/hedera/procedures/orderRow_updateOverstocking.sql b/db/routines/hedera/procedures/orderRow_updateOverstocking.sql index ff8362c65..b383cd135 100644 --- a/db/routines/hedera/procedures/orderRow_updateOverstocking.sql +++ b/db/routines/hedera/procedures/orderRow_updateOverstocking.sql @@ -15,7 +15,7 @@ BEGIN SELECT DISTINCT warehouseFk FROM orderRow WHERE orderFk = vOrderFk - AND shipped = util.VN_CURDATE(); + AND shipment = util.VN_CURDATE(); DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; From 34c4715f6e559cb21ff92920ea8057244280d6f5 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 3 Oct 2024 09:49:16 +0200 Subject: [PATCH 045/217] build: refs #8062 dump db and import ticketCanAdvanceConfig --- db/dump/.dump/data.sql | 2 ++ db/dump/.dump/privileges.sql | 7 ++++--- db/dump/.dump/structure.sql | 2 +- db/dump/.dump/triggers.sql | 2 +- myt.config.yml | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index 4c210f87e..ca254055b 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -2724,6 +2724,8 @@ INSERT INTO `state` VALUES (43,'Preparación por caja',6,2,'BOX_PICKING',42,0,0, 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); diff --git a/db/dump/.dump/privileges.sql b/db/dump/.dump/privileges.sql index b144ac731..66e553763 100644 --- a/db/dump/.dump/privileges.sql +++ b/db/dump/.dump/privileges.sql @@ -1347,7 +1347,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','component','guiller 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',''); +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'); @@ -2075,7 +2075,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_addby 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-proxy1.servers.dc.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'); @@ -2126,7 +2126,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_filterb 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@db-proxy1.servers.dc.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'); @@ -2211,6 +2211,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','guest','ticketCalculatePurge',' 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 */; diff --git a/db/dump/.dump/structure.sql b/db/dump/.dump/structure.sql index af822a27c..0bd03ac32 100644 --- a/db/dump/.dump/structure.sql +++ b/db/dump/.dump/structure.sql @@ -90472,4 +90472,4 @@ USE `vn2008`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-10-03 5:53:26 +-- Dump completed on 2024-10-03 7:42:53 diff --git a/db/dump/.dump/triggers.sql b/db/dump/.dump/triggers.sql index 0e3bd2424..74190df36 100644 --- a/db/dump/.dump/triggers.sql +++ b/db/dump/.dump/triggers.sql @@ -11469,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-10-03 5:53:44 +-- Dump completed on 2024-10-03 7:43:14 diff --git a/myt.config.yml b/myt.config.yml index 663b1aec2..25f94f1bd 100755 --- a/myt.config.yml +++ b/myt.config.yml @@ -69,6 +69,7 @@ fixtures: - siiTypeInvoiceOut - state - ticketUpdateAction + - ticketCanAdvanceConfig - volumeConfig - workCenter - workerTimeControlError From 120aa3e16941199683e65164822358a297038ee4 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 3 Oct 2024 07:48:41 +0200 Subject: [PATCH 046/217] fix: recover entry descriptor and deleted code --- front/core/services/app.js | 11 + .../entry/front/descriptor-popover/index.html | 3 + .../entry/front/descriptor-popover/index.js | 9 + modules/entry/front/descriptor/index.html | 65 ++++++ modules/entry/front/descriptor/index.js | 99 +++++++++ modules/entry/front/index.js | 3 + modules/entry/front/routes.json | 90 ++++++++ modules/entry/front/summary/index.html | 195 ++++++++++++++++++ modules/entry/front/summary/index.js | 33 +++ modules/entry/front/summary/style.scss | 30 +++ modules/item/front/routes.json | 2 +- modules/travel/front/routes.json | 2 +- 12 files changed, 540 insertions(+), 2 deletions(-) create mode 100644 modules/entry/front/descriptor-popover/index.html create mode 100644 modules/entry/front/descriptor-popover/index.js create mode 100644 modules/entry/front/descriptor/index.html create mode 100644 modules/entry/front/descriptor/index.js create mode 100644 modules/entry/front/summary/index.html create mode 100644 modules/entry/front/summary/index.js create mode 100644 modules/entry/front/summary/style.scss diff --git a/front/core/services/app.js b/front/core/services/app.js index cec7bea7f..210b307d6 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -66,6 +66,17 @@ export default class App { ]} }; + 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}`); + } + + if (this.logger.$params.id) + newRoute = newRoute.concat(`${this.logger.$params.id}`); + return this.logger.$http.get('Urls/findOne', {filter}) .then(res => { if (res && res.data) diff --git a/modules/entry/front/descriptor-popover/index.html b/modules/entry/front/descriptor-popover/index.html new file mode 100644 index 000000000..23f641632 --- /dev/null +++ b/modules/entry/front/descriptor-popover/index.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/entry/front/descriptor-popover/index.js b/modules/entry/front/descriptor-popover/index.js new file mode 100644 index 000000000..d79aed03e --- /dev/null +++ b/modules/entry/front/descriptor-popover/index.js @@ -0,0 +1,9 @@ +import ngModule from '../module'; +import DescriptorPopover from 'salix/components/descriptor-popover'; + +class Controller extends DescriptorPopover {} + +ngModule.vnComponent('vnEntryDescriptorPopover', { + slotTemplate: require('./index.html'), + controller: Controller +}); diff --git a/modules/entry/front/descriptor/index.html b/modules/entry/front/descriptor/index.html new file mode 100644 index 000000000..3354d4155 --- /dev/null +++ b/modules/entry/front/descriptor/index.html @@ -0,0 +1,65 @@ + + + + Show entry report + + + +
+ + + + + + +
+
+ + + + +
+ +
+
+ + + \ No newline at end of file diff --git a/modules/entry/front/descriptor/index.js b/modules/entry/front/descriptor/index.js new file mode 100644 index 000000000..3452a6d34 --- /dev/null +++ b/modules/entry/front/descriptor/index.js @@ -0,0 +1,99 @@ +import ngModule from '../module'; +import Descriptor from 'salix/components/descriptor'; + +class Controller extends Descriptor { + get entry() { + return this.entity; + } + + set entry(value) { + this.entity = value; + } + + get travelFilter() { + let travelFilter; + const entryTravel = this.entry && this.entry.travel; + + if (entryTravel && entryTravel.agencyModeFk) { + travelFilter = this.entry && JSON.stringify({ + agencyModeFk: entryTravel.agencyModeFk + }); + } + return travelFilter; + } + + get entryFilter() { + let entryTravel = this.entry && this.entry.travel; + + if (!entryTravel || !entryTravel.landed) return null; + + const date = new Date(entryTravel.landed); + 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.entry.supplierFk, + from, + to + }); + } + + loadData() { + const filter = { + include: [ + { + 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'] + } + } + ] + }; + + return this.getData(`Entries/${this.id}`, {filter}) + .then(res => this.entity = res.data); + } + + showEntryReport() { + this.vnReport.show(`Entries/${this.id}/entry-order-pdf`); + } +} + +ngModule.vnComponent('vnEntryDescriptor', { + template: require('./index.html'), + controller: Controller, + bindings: { + entry: '<' + } +}); diff --git a/modules/entry/front/index.js b/modules/entry/front/index.js index a7209a0bd..0f2208862 100644 --- a/modules/entry/front/index.js +++ b/modules/entry/front/index.js @@ -1,3 +1,6 @@ export * from './module'; import './main'; +import './descriptor'; +import './descriptor-popover'; +import './summary'; diff --git a/modules/entry/front/routes.json b/modules/entry/front/routes.json index 53c599cf1..a2e70e37d 100644 --- a/modules/entry/front/routes.json +++ b/modules/entry/front/routes.json @@ -8,6 +8,12 @@ "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"}, + {"state": "entry.card.log", "icon": "history"} ] }, "keybindings": [ @@ -27,6 +33,90 @@ "component": "vn-entry-index", "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", + "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"] } ] } diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html new file mode 100644 index 000000000..22ea87bdf --- /dev/null +++ b/modules/entry/front/summary/index.html @@ -0,0 +1,195 @@ + + + +
+ + + + #{{$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}}

+
+
+ + +
+ + +
+
+
+ + + + diff --git a/modules/entry/front/summary/index.js b/modules/entry/front/summary/index.js new file mode 100644 index 000000000..6e18bc959 --- /dev/null +++ b/modules/entry/front/summary/index.js @@ -0,0 +1,33 @@ +import ngModule from '../module'; +import './style.scss'; +import Summary from 'salix/components/summary'; + +class Controller extends Summary { + get entry() { + if (!this._entry) + return this.$params; + + return this._entry; + } + + set entry(value) { + this._entry = value; + + if (value && value.id) + this.getEntryData(); + } + + getEntryData() { + return this.$http.get(`Entries/${this.entry.id}/getEntry`).then(response => { + this.entryData = response.data; + }); + } +} + +ngModule.vnComponent('vnEntrySummary', { + template: require('./index.html'), + controller: Controller, + bindings: { + entry: '<' + } +}); diff --git a/modules/entry/front/summary/style.scss b/modules/entry/front/summary/style.scss new file mode 100644 index 000000000..1d5b22e30 --- /dev/null +++ b/modules/entry/front/summary/style.scss @@ -0,0 +1,30 @@ +@import "variables"; + + +vn-entry-summary .summary { + max-width: $width-lg; + + .dark-row { + background-color: lighten($color-marginal, 10%); + } + + tbody tr:nth-child(1) { + border-top: $border-thin; + } + + tbody tr:nth-child(1), + tbody tr:nth-child(2) { + border-left: $border-thin; + border-right: $border-thin + } + + tbody tr:nth-child(3) { + height: inherit + } + + tr { + margin-bottom: 10px; + } +} + +$color-font-link-medium: lighten($color-font-link, 20%) \ No newline at end of file diff --git a/modules/item/front/routes.json b/modules/item/front/routes.json index 4b7cd1490..05b887a96 100644 --- a/modules/item/front/routes.json +++ b/modules/item/front/routes.json @@ -3,7 +3,7 @@ "name": "Items", "icon": "icon-item", "validations" : true, - "dependencies": ["worker", "client", "ticket"], + "dependencies": ["worker", "client", "ticket", "entry"], "menus": { "main": [ {"state": "item.index", "icon": "icon-item"}, diff --git a/modules/travel/front/routes.json b/modules/travel/front/routes.json index 5a63620d4..ccdc657d9 100644 --- a/modules/travel/front/routes.json +++ b/modules/travel/front/routes.json @@ -3,7 +3,7 @@ "name": "Travels", "icon": "local_airport", "validations": true, - "dependencies": ["worker"], + "dependencies": ["worker", "entry"], "menus": { "main": [ {"state": "travel.index", "icon": "local_airport"}, From 555ada26d18c47dfe2bd2e9f37a0604c9a0416eb Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 3 Oct 2024 10:26:18 +0200 Subject: [PATCH 047/217] fix: conflicts --- front/core/services/app.js | 1 - 1 file changed, 1 deletion(-) diff --git a/front/core/services/app.js b/front/core/services/app.js index 91dd69377..3fe257a49 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -66,7 +66,6 @@ export default class App { ]} }; - if (this.logger.$params.q) { let tableValue = this.logger.$params.q; const q = JSON.parse(tableValue); From fd877119a97c89660b012ceedc866ff23ef4240e Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 3 Oct 2024 10:34:01 +0200 Subject: [PATCH 048/217] chore: refs #7874 drop useless locale --- loopback/locale/es.json | 1 - 1 file changed, 1 deletion(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 9308fd4ec..6c4833a77 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -381,6 +381,5 @@ "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 From 2071518f579e43aa07089ed83b3a2daba24986fa Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 3 Oct 2024 10:35:04 +0200 Subject: [PATCH 049/217] fix: refs #7874 rollback --- loopback/locale/es.json | 1 + 1 file changed, 1 insertion(+) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 6c4833a77..9308fd4ec 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -381,5 +381,6 @@ "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 From 82f8e84288b3a30370c5551c8ce4f7d887d79c12 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 3 Oct 2024 11:42:21 +0200 Subject: [PATCH 050/217] fix: refs #6861 collectionGetTickets --- db/routines/vn/procedures/collection_getTickets.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/collection_getTickets.sql b/db/routines/vn/procedures/collection_getTickets.sql index 4566792fa..0f675041a 100644 --- a/db/routines/vn/procedures/collection_getTickets.sql +++ b/db/routines/vn/procedures/collection_getTickets.sql @@ -23,7 +23,7 @@ BEGIN 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 + AND tc.collectionFk = vParamFk ) SELECT t.id ticketFk, IF(!(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`, From 32415d36169b9fc3487fa921c0de5d06bfee9653 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 3 Oct 2024 11:56:36 +0200 Subject: [PATCH 051/217] fix: refs #6861 collectionGetTickets --- db/routines/vn/procedures/collection_getTickets.sql | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/collection_getTickets.sql b/db/routines/vn/procedures/collection_getTickets.sql index 0f675041a..6b7a794a9 100644 --- a/db/routines/vn/procedures/collection_getTickets.sql +++ b/db/routines/vn/procedures/collection_getTickets.sql @@ -21,9 +21,8 @@ BEGIN 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 + 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`, From 3f325d865f9e02717b9b2a5049660cf5ee139abc Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 3 Oct 2024 12:08:23 +0200 Subject: [PATCH 052/217] fix: refs #7404 test for lasEntriesFilter --- .../back/methods/item/specs/lastEntriesFilter.spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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) { From 76308f7e3723c238e93d43141c060d29602c1e2d Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 3 Oct 2024 12:13:38 +0200 Subject: [PATCH 053/217] fix(salix): filter isWorker in DefaulterView --- modules/client/front/defaulter/index.html | 2 +- modules/client/front/defaulter/index.js | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/client/front/defaulter/index.html b/modules/client/front/defaulter/index.html index 33bb751f1..440f34d3d 100644 --- a/modules/client/front/defaulter/index.html +++ b/modules/client/front/defaulter/index.html @@ -54,7 +54,7 @@ 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': From f1bc959a49460aeb24cbb8b42790db63ef5b4a05 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 3 Oct 2024 12:40:52 +0200 Subject: [PATCH 054/217] fix: refs #7956 item_getSimilar block db --- db/routines/vn/procedures/item_getSimilar.sql | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index 56afd92e9..243aacc2f 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -18,9 +18,11 @@ BEGIN * @param vDaysInForward Días de alcance para las ventas */ DECLARE vAvailableCalcFk INT; + DECLARE vVisibleCalcFk INT; DECLARE vPriority INT DEFAULT 1; CALL cache.available_refresh(vAvailableCalcFk, FALSE, vWarehouseFk, vDated); + CALL cache.visible_refresh(vVisibleCalcFk, FALSE, vWarehouseFk); WITH itemTags AS ( SELECT i.id, @@ -41,12 +43,6 @@ BEGIN 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 @@ -58,7 +54,7 @@ BEGIN GROUP BY s.itemFk ) SELECT i.id itemFk, - LEAST(CAST(sd.quantity AS INT), sk.stock) advanceable, + LEAST(CAST(sd.quantity AS INT), v.visible) advanceable, i.longName, i.subName, i.tag5, @@ -80,13 +76,14 @@ BEGIN WHEN b.groupingMode = 'packing' THEN b.packing ELSE 1 END minQuantity, - sk.stock located, + v.visible 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 = vAvailableCalcFk - LEFT JOIN stock sk ON sk.itemFk = i.id + 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 @@ -96,7 +93,7 @@ BEGIN LEFT JOIN vn.tag t ON t.id = it.tagFk LEFT JOIN vn.buy b ON b.id = lb.buy_id JOIN itemTags its - WHERE (a.available > 0 OR sd.quantity < sk.stock) + WHERE (a.available > 0 OR sd.quantity < v.visible) AND (i.typeFk = its.typeFk OR NOT vShowType) AND i.id <> vSelf ORDER BY (a.available > 0) DESC, From 90311b047d24b5a6869688201c6f1cd33ebdd5c7 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 3 Oct 2024 14:35:45 +0200 Subject: [PATCH 055/217] fix: hotfix redirect --- front/core/services/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/core/services/app.js b/front/core/services/app.js index 3fe257a49..fa129c3fc 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -74,7 +74,7 @@ export default class App { newRoute = newRoute.concat(`?table=${tableValue}`); } - if (this.logger.$params.id) + if (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}) From 46e2ffd6c22d2eb554f8580a2ecf1fb3b5d849d0 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 3 Oct 2024 14:39:58 +0200 Subject: [PATCH 056/217] fix: refs #7404 add fixtures --- db/dump/fixtures.before.sql | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 58a4dc9f1..d4bc13730 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -185,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); @@ -3941,6 +3942,11 @@ 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 From 5416d382555164e2c58cc9d80da7f39a3dbee2e2 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 3 Oct 2024 15:25:56 +0200 Subject: [PATCH 057/217] feat: refs #7874 redirect to lilium --- modules/client/front/note/index/index.html | 31 ---------------------- modules/client/front/note/index/index.js | 7 ++--- 2 files changed, 4 insertions(+), 34 deletions(-) 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`); } } From 3638e9abb6f125fb04c7478083ad5d0a2daaa4a7 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 3 Oct 2024 16:50:31 +0200 Subject: [PATCH 058/217] refactor: refs #7207 simplify code --- .../vn/procedures/queueMember_updateQueue.sql | 36 ++++++++----------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/db/routines/vn/procedures/queueMember_updateQueue.sql b/db/routines/vn/procedures/queueMember_updateQueue.sql index d6f2a5d1e..b330eed66 100644 --- a/db/routines/vn/procedures/queueMember_updateQueue.sql +++ b/db/routines/vn/procedures/queueMember_updateQueue.sql @@ -1,36 +1,30 @@ DELIMITER $$ + CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`queueMember_updateQueue`( vBusinessFk INT ) BEGIN -/** -* Replace the queue of a worker with the queue of the new department. -* -* @param vBusinessFk business id -*/ + /** + * 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 vPrevQueue VARCHAR(10); - SELECT d.pbxQueue, s.extension, qm.queue INTO vNewQueue, vExtension, vPrevQueue + SELECT d.pbxQueue, s.extension, qm.queue + INTO vNewQueue, vExtension, vPrevQueue FROM business b JOIN department d ON d.id = b.departmentFk - JOIN pbx.sip s ON s.user_id = b.workerFk + JOIN pbx.sip s ON s.user_id = b.workerFk LEFT JOIN pbx.queueMember qm ON qm.extension = s.extension - WHERE b.id = vBusinessFk; + WHERE b.id = vBusinessFk; - IF vNewQueue IS NULL THEN - DELETE FROM pbx.queueMember - WHERE extension = vExtension COLLATE utf8_general_ci; - ELSE - IF vPrevQueue IS NULL THEN - INSERT INTO pbx.queueMember (queue, extension) - VALUES (vNewQueue, vExtension); - ELSE - UPDATE pbx.queueMember - SET queue = vNewQueue - WHERE extension = vExtension COLLATE utf8_general_ci; - END IF; - END IF; + 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 From 197517dfccba371cbe7de7f948c5bb8bfb917b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 3 Oct 2024 17:02:40 +0200 Subject: [PATCH 059/217] fix: refs #7956 item_getSimilar block db --- db/routines/vn/procedures/item_getSimilar.sql | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index 243aacc2f..883d88914 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -18,11 +18,9 @@ BEGIN * @param vDaysInForward Días de alcance para las ventas */ DECLARE vAvailableCalcFk INT; - DECLARE vVisibleCalcFk INT; DECLARE vPriority INT DEFAULT 1; CALL cache.available_refresh(vAvailableCalcFk, FALSE, vWarehouseFk, vDated); - CALL cache.visible_refresh(vVisibleCalcFk, FALSE, vWarehouseFk); WITH itemTags AS ( SELECT i.id, @@ -43,6 +41,16 @@ BEGIN LEFT JOIN vn.tag t ON t.id = it.tagFk WHERE i.id = vSelf ), + stock AS ( + SELECT ish.itemFk, + SUM(ish.visible) stock + 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 + WHERE s.warehouseFk = vWarehouseFk + GROUP BY ish.itemFk + ), sold AS ( SELECT SUM(s.quantity) quantity, s.itemFk FROM vn.sale s @@ -54,7 +62,7 @@ BEGIN GROUP BY s.itemFk ) SELECT i.id itemFk, - LEAST(CAST(sd.quantity AS INT), v.visible) advanceable, + LEAST(CAST(sd.quantity AS INT), sk.stock) advanceable, i.longName, i.subName, i.tag5, @@ -76,14 +84,13 @@ BEGIN WHEN b.groupingMode = 'packing' THEN b.packing ELSE 1 END minQuantity, - v.visible located, + 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 = vAvailableCalcFk - LEFT JOIN cache.visible v ON v.item_id = i.id - AND v.calc_id = vVisibleCalcFk + 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 @@ -93,7 +100,7 @@ BEGIN LEFT JOIN vn.tag t ON t.id = it.tagFk LEFT JOIN vn.buy b ON b.id = lb.buy_id JOIN itemTags its - WHERE (a.available > 0 OR sd.quantity < v.visible) + WHERE (a.available > 0 OR sd.quantity < sk.stock) AND (i.typeFk = its.typeFk OR NOT vShowType) AND i.id <> vSelf ORDER BY (a.available > 0) DESC, From c6839254036ff6068903548e618e0c0940536f8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 3 Oct 2024 15:19:57 +0000 Subject: [PATCH 060/217] Actualizar db/routines/vn/procedures/item_getSimilar.sql --- db/routines/vn/procedures/item_getSimilar.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index 883d88914..eeb71a693 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -44,10 +44,10 @@ BEGIN stock AS ( SELECT ish.itemFk, SUM(ish.visible) stock - 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 + 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.warehouseFk = vWarehouseFk GROUP BY ish.itemFk ), From 0374cbd4c9ca794063b5a2f21d9f57dd136e29f7 Mon Sep 17 00:00:00 2001 From: ivanm Date: Thu, 3 Oct 2024 18:20:21 +0200 Subject: [PATCH 061/217] fix: hotfix email rutas --- .../route/back/methods/route/driverRouteEmail.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/modules/route/back/methods/route/driverRouteEmail.js b/modules/route/back/methods/route/driverRouteEmail.js index 62147db87..bbac2b0e8 100644 --- a/modules/route/back/methods/route/driverRouteEmail.js +++ b/modules/route/back/methods/route/driverRouteEmail.js @@ -39,8 +39,6 @@ module.exports = Self => { const {reportMail} = agencyMode(); let user; let account; - let userEmail; - ctx.args.recipients = reportMail ? reportMail.split(',').map(email => email.trim()) : []; if (workerFk) { user = await models.VnUser.findById(workerFk, { @@ -50,17 +48,10 @@ module.exports = Self => { account = await models.Account.findById(workerFk); } - if (user?.active && account) - userEmail = user.emailUser().email; - - if (userEmail) - ctx.args.recipients.push(userEmail); - - ctx.args.recipients = [...new Set(ctx.args.recipients)]; - - if (!ctx.args.recipients.length) - throw new UserError('An email is necessary'); + if (user?.active && account) ctx.args.recipient = user.emailUser().email; + else ctx.args.recipient = reportMail; + if (!ctx.args.recipient) throw new UserError('An email is necessary'); return Self.sendTemplate(ctx, 'driver-route'); }; }; From 486c7f4fa3322c2c23895c45b95c757a0f7c292d Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 3 Oct 2024 20:07:24 +0000 Subject: [PATCH 062/217] fix(salix): Redirect to Lilium from create claim --- front/core/services/app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/front/core/services/app.js b/front/core/services/app.js index fa129c3fc..199bd8b58 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -66,17 +66,17 @@ export default class App { ]} }; + const hasId = !isNaN(parseFloat(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}`); - } - - if (this.logger.$params.id && newRoute.indexOf(this.logger.$params.id) < 0) + } 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) From b85989105bf67243ede70b8c58d656388aad0d29 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 3 Oct 2024 22:29:01 +0200 Subject: [PATCH 063/217] fix(salix): redirect from travel to addEntry --- front/core/services/app.js | 2 +- modules/travel/front/descriptor-menu/index.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/front/core/services/app.js b/front/core/services/app.js index 199bd8b58..d9d16816d 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -76,7 +76,7 @@ export default class App { 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) diff --git a/modules/travel/front/descriptor-menu/index.js b/modules/travel/front/descriptor-menu/index.js index f68502ec3..854148ca0 100644 --- a/modules/travel/front/descriptor-menu/index.js +++ b/modules/travel/front/descriptor-menu/index.js @@ -75,7 +75,8 @@ class Controller extends Section { async redirectToCreateEntry() { this.$state.go('home'); - window.location.href = await this.vnApp.getUrl(`entry/create?travelFk=${this.travelId}`); + const createForm = JSON.stringify({travelFk: this.travelId}); + window.location.href = await this.vnApp.getUrl(`entry/list?createForm=${createForm}`); } onCloneWithEntriesAccept() { From 4f9c9dbacea739ea04665e44811ee80e11aa40a9 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 3 Oct 2024 22:32:54 +0200 Subject: [PATCH 064/217] perf(salix): remove space --- front/core/services/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/core/services/app.js b/front/core/services/app.js index 199bd8b58..d9d16816d 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -76,7 +76,7 @@ export default class App { 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) From 83f0f113323a3edfd05cd01cdb5144791ff90b92 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 3 Oct 2024 22:33:56 +0200 Subject: [PATCH 065/217] fix(salix): redirect from travel to addEntry --- modules/travel/front/descriptor-menu/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/travel/front/descriptor-menu/index.js b/modules/travel/front/descriptor-menu/index.js index 854148ca0..f68502ec3 100644 --- a/modules/travel/front/descriptor-menu/index.js +++ b/modules/travel/front/descriptor-menu/index.js @@ -75,8 +75,7 @@ class Controller extends Section { async redirectToCreateEntry() { this.$state.go('home'); - const createForm = JSON.stringify({travelFk: this.travelId}); - window.location.href = await this.vnApp.getUrl(`entry/list?createForm=${createForm}`); + window.location.href = await this.vnApp.getUrl(`entry/create?travelFk=${this.travelId}`); } onCloneWithEntriesAccept() { From 229d5369a12da90374ba0a5df068a993836c624e Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 4 Oct 2024 07:20:10 +0200 Subject: [PATCH 066/217] fix: refs #7404 spec for new entry fixture --- modules/entry/back/methods/entry/specs/filter.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/entry/back/methods/entry/specs/filter.spec.js b/modules/entry/back/methods/entry/specs/filter.spec.js index 105838858..4bf5127b0 100644 --- a/modules/entry/back/methods/entry/specs/filter.spec.js +++ b/modules/entry/back/methods/entry/specs/filter.spec.js @@ -39,7 +39,7 @@ describe('Entry filter()', () => { const result = await models.Entry.filter(ctx, options); - expect(result.length).toEqual(11); + expect(result.length).toEqual(12); await tx.rollback(); } catch (e) { @@ -152,7 +152,7 @@ describe('Entry filter()', () => { const result = await models.Entry.filter(ctx, options); - expect(result.length).toEqual(10); + expect(result.length).toEqual(11); await tx.rollback(); } catch (e) { From 72bab95be186b12bf2edb226a9ab6711ce68bdfc Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 4 Oct 2024 07:52:13 +0200 Subject: [PATCH 067/217] fix: refs #7781 leave early before any updates on the proc --- .../vn/procedures/expeditionPallet_build.sql | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/db/routines/vn/procedures/expeditionPallet_build.sql b/db/routines/vn/procedures/expeditionPallet_build.sql index 766064a5b..cffa42633 100644 --- a/db/routines/vn/procedures/expeditionPallet_build.sql +++ b/db/routines/vn/procedures/expeditionPallet_build.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionPallet_bu vWorkerFk INT, OUT vPalletFk INT ) -BEGIN +proc: BEGIN /** * Builds an expedition pallet. * @@ -56,6 +56,17 @@ BEGIN FROM tExpedition WHERE palletFk; + IF vExpeditionWithPallet THEN + UPDATE arcRead + SET error = ( + SELECT GROUP_CONCAT(expeditionFk SEPARATOR ', ') + FROM tExpedition + WHERE palletFk + ) + WHERE id = vArcId; + LEAVE proc; + END IF; + IF NOT vFreeExpeditionCount THEN CALL util.throw ('NO_FREE_EXPEDITIONS'); END IF; @@ -93,29 +104,19 @@ BEGIN FROM tExpedition WHERE palletFk IS NULL; - IF vExpeditionWithPallet THEN - UPDATE arcRead - SET error = ( - SELECT GROUP_CONCAT(expeditionFk SEPARATOR ', ') - FROM tExpedition - WHERE palletFk - ) - WHERE id = vArcId; - ELSE - UPDATE arcRead SET error = NULL WHERE id = vArcId; + UPDATE arcRead SET error = NULL WHERE id = vArcId; - SELECT printerFk INTO vPrinterFk FROM arcRead WHERE id = vArcId; + SELECT printerFk INTO vPrinterFk FROM arcRead WHERE id = vArcId; - CALL report_print( - 'LabelPalletExpedition', - vPrinterFk, - account.myUser_getId(), - JSON_OBJECT('palletFk', vPalletFk, 'userFk', account.myUser_getId()), - 'high' - ); + CALL report_print( + 'LabelPalletExpedition', + vPrinterFk, + account.myUser_getId(), + JSON_OBJECT('palletFk', vPalletFk, 'userFk', account.myUser_getId()), + 'high' + ); - UPDATE expeditionPallet SET isPrint = TRUE WHERE id = vPalletFk; - END IF; + UPDATE expeditionPallet SET isPrint = TRUE WHERE id = vPalletFk; DROP TEMPORARY TABLE tExpedition; END$$ From 7aa8200fcaf6f2588a2ab8597cfff0b5864bcd53 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 4 Oct 2024 09:02:59 +0200 Subject: [PATCH 068/217] fix: refs #7956 item_getSimilar --- db/routines/vn/procedures/item_getSimilar.sql | 74 +++++++------------ 1 file changed, 28 insertions(+), 46 deletions(-) diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index eeb71a693..537f53848 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -8,19 +8,22 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_getSimilar`( ) BEGIN /** -* 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 -*/ + * 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(vAvailableCalcFk, FALSE, vWarehouseFk, vDated); + CALL cache.visible_refresh(vVisibleCalcFk, FALSE, vWarehouseFk); WITH itemTags AS ( SELECT i.id, @@ -40,29 +43,9 @@ BEGIN AND it.priority = vPriority LEFT JOIN vn.tag t ON t.id = it.tagFk WHERE i.id = vSelf - ), - stock AS ( - SELECT ish.itemFk, - SUM(ish.visible) stock - 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.warehouseFk = vWarehouseFk - GROUP BY ish.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, + NULL advanceable, -- https://redmine.verdnatura.es/issues/7956#note-4 i.longName, i.subName, i.tag5, @@ -84,13 +67,13 @@ BEGIN WHEN b.groupingMode = 'packing' THEN b.packing ELSE 1 END minQuantity, - sk.stock located, + v.visible 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 = vAvailableCalcFk - LEFT JOIN stock sk ON sk.itemFk = i.id + 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 @@ -100,21 +83,20 @@ BEGIN LEFT JOIN vn.tag t ON t.id = it.tagFk LEFT JOIN vn.buy b ON b.id = lb.buy_id JOIN itemTags its - WHERE (a.available > 0 OR sd.quantity < sk.stock) + WHERE a.available > 0 AND (i.typeFk = its.typeFk OR NOT vShowType) AND i.id <> vSelf - 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 + 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 LIMIT 100; END$$ DELIMITER ; From 9843d001b5d30b5cb3a12390a1897e140dfa9732 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 4 Oct 2024 07:09:59 +0000 Subject: [PATCH 069/217] fix(salix): change parse method --- front/core/services/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/core/services/app.js b/front/core/services/app.js index d9d16816d..dba6e70bf 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -66,7 +66,7 @@ export default class App { ]} }; - const hasId = !isNaN(parseFloat(route.split('/')[1])); + const hasId = !isNaN(parseInt(route.split('/')[1])); if (this.logger.$params.q) { let tableValue = this.logger.$params.q; From f8f205a4f89829c0ea9272eb21177b16e424dc5f Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 4 Oct 2024 10:29:50 +0200 Subject: [PATCH 070/217] feat: update myt version --- package.json | 2 +- pnpm-lock.yaml | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 8f9670903..32c1f21d8 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@babel/register": "^7.7.7", "@commitlint/cli": "^19.2.1", "@commitlint/config-conventional": "^19.1.0", - "@verdnatura/myt": "^1.6.11", + "@verdnatura/myt": "^1.6.12", "angular-mocks": "^1.7.9", "babel-jest": "^26.0.1", "babel-loader": "^8.2.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e2480cf4a..042b91fe0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -143,8 +143,8 @@ devDependencies: specifier: ^19.1.0 version: 19.1.0 '@verdnatura/myt': - specifier: ^1.6.11 - version: 1.6.11 + specifier: ^1.6.12 + version: 1.6.12 angular-mocks: specifier: ^1.7.9 version: 1.8.3 @@ -2846,8 +2846,8 @@ packages: dev: false optional: true - /@verdnatura/myt@1.6.11: - resolution: {integrity: sha512-uqdbSJSznBBzAoRkvBt600nUMEPL1PJ2v73eWMZbaoGUMiZiNAehYjs4gIrObP1cxC85JOx97XoLpG0BzPsaig==} + /@verdnatura/myt@1.6.12: + resolution: {integrity: sha512-t/SiDuQW9KJkcjhwQ9AkrcoTwghxQ7IyQ56e+88eYdoMi24l6bQGF0wHzMaIPRfQAoR8hqgfMOief4OAqW4Iqw==} hasBin: true dependencies: '@sqltools/formatter': 1.2.5 @@ -6548,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 @@ -10485,7 +10485,7 @@ packages: engines: {node: '>=10'} requiresBuild: true dependencies: - semver: 7.5.4 + semver: 7.6.0 dev: false optional: true @@ -12501,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==} @@ -12508,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==} From 324875ec1f779f049b996b821418470378a627b0 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 4 Oct 2024 10:42:33 +0200 Subject: [PATCH 071/217] fix: refs #6861 deleteAdded --- .../vn/procedures/collection_getTickets.sql | 5 ++--- ...copy.sql => itemShelvingSale_deleteAdded.sql} | 16 ++++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) rename db/routines/vn/procedures/{itemShelvingSale_addBySale copy.sql => itemShelvingSale_deleteAdded.sql} (85%) diff --git a/db/routines/vn/procedures/collection_getTickets.sql b/db/routines/vn/procedures/collection_getTickets.sql index 1391c27d4..fed7a3eb6 100644 --- a/db/routines/vn/procedures/collection_getTickets.sql +++ b/db/routines/vn/procedures/collection_getTickets.sql @@ -21,9 +21,8 @@ BEGIN 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 + 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`, diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySale copy.sql b/db/routines/vn/procedures/itemShelvingSale_deleteAdded.sql similarity index 85% rename from db/routines/vn/procedures/itemShelvingSale_addBySale copy.sql rename to db/routines/vn/procedures/itemShelvingSale_deleteAdded.sql index 7da1a82fa..0de523127 100644 --- a/db/routines/vn/procedures/itemShelvingSale_addBySale copy.sql +++ b/db/routines/vn/procedures/itemShelvingSale_deleteAdded.sql @@ -12,15 +12,17 @@ proc: BEGIN DECLARE vHasSalesPicked BOOL; DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; + 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 ; + WHERE iss.id = vSelf AND s.isAdded; IF vSaleFk IS NULL THEN CALL util.throw('The sale can not be deleted'); @@ -31,11 +33,9 @@ proc: BEGIN WHERE saleFk = vSaleFk AND isPicked; IF vHasSalesPicked THEN - CALL util.throw('The sale can not be deleted with sales picked'); + CALL util.throw('A sale with picked sales cannot be deleted'); END IF; - START TRANSACTION; - UPDATE itemShelvingSale iss JOIN itemShelving ish ON ish.id = iss.itemShelvingFk SET ish.available = ish.available + iss.quantity From 5d7d9f8d9e4e9c4e5a6562c49b6a48adc45e038e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 4 Oct 2024 13:07:54 +0200 Subject: [PATCH 072/217] fix: refs #6861 deleteAdded --- db/routines/vn/procedures/itemShelvingSale_deleteAdded.sql | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/itemShelvingSale_deleteAdded.sql b/db/routines/vn/procedures/itemShelvingSale_deleteAdded.sql index 0de523127..9b15e82d1 100644 --- a/db/routines/vn/procedures/itemShelvingSale_deleteAdded.sql +++ b/db/routines/vn/procedures/itemShelvingSale_deleteAdded.sql @@ -22,9 +22,10 @@ proc: BEGIN SELECT iss.saleFk INTO vSaleFk FROM itemShelvingSale iss JOIN sale s ON s.id = iss.saleFk - WHERE iss.id = vSelf AND s.isAdded; + WHERE iss.id = vSelf AND s.isAdded + FOR UPDATE; - IF vSaleFk IS NULL THEN + IF vSaleFk IS NULL THEN CALL util.throw('The sale can not be deleted'); END IF; @@ -32,7 +33,7 @@ proc: BEGIN FROM itemShelvingSale WHERE saleFk = vSaleFk AND isPicked; - IF vHasSalesPicked THEN + IF vHasSalesPicked THEN CALL util.throw('A sale with picked sales cannot be deleted'); END IF; From 52e8bac168830e72f9df7e5be41cbaf9893df6ea Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 4 Oct 2024 13:34:04 +0200 Subject: [PATCH 073/217] fix: refs #7524 backSuppliersPackaging --- .../back/methods/supplier/getWithPackaging.js | 40 +++++++++++++++++++ .../supplier/specs/getWithPackaging.spec.js | 32 +++++++++++++++ modules/supplier/back/models/supplier.js | 1 + 3 files changed, 73 insertions(+) create mode 100644 modules/supplier/back/methods/supplier/getWithPackaging.js create mode 100644 modules/supplier/back/methods/supplier/specs/getWithPackaging.spec.js diff --git a/modules/supplier/back/methods/supplier/getWithPackaging.js b/modules/supplier/back/methods/supplier/getWithPackaging.js new file mode 100644 index 000000000..658b0696c --- /dev/null +++ b/modules/supplier/back/methods/supplier/getWithPackaging.js @@ -0,0 +1,40 @@ +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 = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const entries = await models.Entry.find({ + where: {typeFk: 'packaging'}, + 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/getWithPackaging.spec.js b/modules/supplier/back/methods/supplier/specs/getWithPackaging.spec.js new file mode 100644 index 000000000..f73d20f84 --- /dev/null +++ b/modules/supplier/back/methods/supplier/specs/getWithPackaging.spec.js @@ -0,0 +1,32 @@ +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, + }); + + 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/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' From 6766cebd2a68e2b91432d56e913e438fff43941f Mon Sep 17 00:00:00 2001 From: Pako Date: Fri, 4 Oct 2024 13:56:54 +0200 Subject: [PATCH 074/217] fix: refs #8069 call moved upper than transaction start --- .../procedures/order_confirmWithUser.sql | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index b3aab522e..026f589e9 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -98,22 +98,8 @@ BEGIN SELECT employeeFk INTO vUserFk FROM orderConfig; END IF; - START TRANSACTION; - - CALL order_checkEditable(vSelf); - CALL orderRow_updateOverstocking(vSelf); - -- Check order is not empty - SELECT COUNT(*) > 0 INTO vHasRows - FROM orderRow - WHERE orderFk = vSelf - AND amount > 0; - - IF NOT vHasRows THEN - CALL util.throw('ORDER_EMPTY'); - END IF; - -- Check if any product has a quantity of 0 SELECT EXISTS ( SELECT id @@ -125,6 +111,20 @@ BEGIN IF vHas0Amount THEN CALL util.throw('Remove lines with quantity = 0 before confirming'); END IF; + + START TRANSACTION; + + CALL order_checkEditable(vSelf); + + -- Check order is not empty + SELECT COUNT(*) > 0 INTO vHasRows + FROM orderRow + WHERE orderFk = vSelf + AND amount > 0; + + IF NOT vHasRows THEN + CALL util.throw('ORDER_EMPTY'); + END IF; -- Crea los tickets del pedido OPEN vDates; From 9f97de021a79d96a2dfeb017496d4b38bc6e3182 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 4 Oct 2024 16:04:31 +0200 Subject: [PATCH 075/217] chore: refs #7874 fix e2e --- e2e/paths/02-client/08_add_notes.spec.js | 42 ------------------------ e2e/paths/02-client/21_defaulter.spec.js | 15 ++------- 2 files changed, 3 insertions(+), 54 deletions(-) delete mode 100644 e2e/paths/02-client/08_add_notes.spec.js 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'); - }); }); From e0d0b6696393fa7132321dfdc4518ca82d9187cf Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 4 Oct 2024 16:48:38 +0200 Subject: [PATCH 076/217] feat: refs #7207 add transaction --- .../vn/procedures/queueMember_updateQueue.sql | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/queueMember_updateQueue.sql b/db/routines/vn/procedures/queueMember_updateQueue.sql index b330eed66..c3207e663 100644 --- a/db/routines/vn/procedures/queueMember_updateQueue.sql +++ b/db/routines/vn/procedures/queueMember_updateQueue.sql @@ -11,14 +11,18 @@ BEGIN */ DECLARE vNewQueue VARCHAR(10); DECLARE vExtension VARCHAR(10); - DECLARE vPrevQueue VARCHAR(10); + DECLARE exit handler FOR SQLEXCEPTION + BEGIN + ROLLBACK; + END; - SELECT d.pbxQueue, s.extension, qm.queue - INTO vNewQueue, vExtension, vPrevQueue + START TRANSACTION; + + 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 - LEFT JOIN pbx.queueMember qm ON qm.extension = s.extension WHERE b.id = vBusinessFk; DELETE FROM pbx.queueMember @@ -26,5 +30,7 @@ BEGIN INSERT IGNORE INTO pbx.queueMember (queue, extension) VALUES (vNewQueue, vExtension); + + COMMIT; END$$ DELIMITER ; \ No newline at end of file From 4a17d9ec0e0f29364bc6006920b700d76d9b3ef4 Mon Sep 17 00:00:00 2001 From: guillermo Date: Sun, 6 Oct 2024 09:07:48 +0200 Subject: [PATCH 077/217] fix: refs #7760 collection_assing --- db/routines/vn/procedures/collection_assign.sql | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index ba83f1fbb..c2d4a34ef 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -118,9 +118,19 @@ BEGIN IF vCollectionFk IS NULL THEN CALL collection_new(vUserFk, vCollectionFk); - UPDATE `collection` - SET workerFk = vUserFk - WHERE id = 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; END$$ DELIMITER ; \ No newline at end of file From ba9d0743b525e484b9f62f7eba13d473c69c5f12 Mon Sep 17 00:00:00 2001 From: guillermo Date: Sun, 6 Oct 2024 10:20:34 +0200 Subject: [PATCH 078/217] refactor: refs #6824 Throw for no delete itemShelving with itemShelvingSale --- db/routines/vn/procedures/clean.sql | 9 +++++++-- db/routines/vn/triggers/itemShelving_beforeDelete.sql | 4 +--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index 1e0697997..249290c10 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -23,9 +23,14 @@ BEGIN DELETE FROM messageInbox WHERE sendDate < v2Months; DELETE FROM messageInbox WHERE sendDate < v2Months; DELETE FROM workerTimeControl WHERE timed < v4Years; - SET @canDeleteItemShelvingSale = TRUE; + 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; - SET @canDeleteItemShelvingSale = NULL; DELETE FROM ticketDown WHERE created < util.yesterday(); DELETE IGNORE FROM expedition WHERE created < v26Months; DELETE cs diff --git a/db/routines/vn/triggers/itemShelving_beforeDelete.sql b/db/routines/vn/triggers/itemShelving_beforeDelete.sql index dbe21dabd..dbfb63849 100644 --- a/db/routines/vn/triggers/itemShelving_beforeDelete.sql +++ b/db/routines/vn/triggers/itemShelving_beforeDelete.sql @@ -9,9 +9,7 @@ BEGIN FROM itemShelvingSale WHERE itemShelvingFk = OLD.id; - IF vItemShelvingSaleExists AND (NOT @canDeleteItemShelvingSale - OR @canDeleteItemShelvingSale IS NULL) THEN - + IF vItemShelvingSaleExists THEN CALL util.throw('Cannot delete item shelving with item shelving sale'); END IF; From 7fc2e34af917d82781590e06dc65ac0d81bcbfa3 Mon Sep 17 00:00:00 2001 From: guillermo Date: Sun, 6 Oct 2024 10:54:51 +0200 Subject: [PATCH 079/217] refactor: refs #6824 Fix tests --- .../item/back/methods/item-shelving/deleteItemShelvings.js | 5 +++++ .../methods/item-shelving/specs/deleteItemShelvings.spec.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) 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/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) { From 6b7f161d9a7bcb713722704127bf3d2abb9a6ace Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 7 Oct 2024 06:39:41 +0200 Subject: [PATCH 080/217] fix: refs #7844 sale_problems llena --- db/routines/vn/procedures/sale_getProblems.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 2bba8fbc3..b50b4784d 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -40,7 +40,7 @@ BEGIN isTooLittle BOOL DEFAULT FALSE, isVip BOOL DEFAULT FALSE, PRIMARY KEY (ticketFk, saleFk) - ) ENGINE = MEMORY; + ); -- No memory INSERT INTO tmp.sale_problems(ticketFk, saleFk, From 7b4d15cb23592446f9a1f2ffda92b822b64286d8 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 7 Oct 2024 07:30:36 +0200 Subject: [PATCH 081/217] refactor: refs #6824 Requested changes --- .../vn/triggers/itemShelving_beforeDelete.sql | 32 ++++++------------- .../11283-redAspidistra/00-firstScript.sql | 3 ++ 2 files changed, 13 insertions(+), 22 deletions(-) create mode 100644 db/versions/11283-redAspidistra/00-firstScript.sql diff --git a/db/routines/vn/triggers/itemShelving_beforeDelete.sql b/db/routines/vn/triggers/itemShelving_beforeDelete.sql index dbfb63849..89737a841 100644 --- a/db/routines/vn/triggers/itemShelving_beforeDelete.sql +++ b/db/routines/vn/triggers/itemShelving_beforeDelete.sql @@ -2,26 +2,14 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelving_beforeDelete` BEFORE DELETE ON `itemShelving` FOR EACH ROW -BEGIN - DECLARE vItemShelvingSaleExists BOOL; - - SELECT COUNT(*) INTO vItemShelvingSaleExists - FROM itemShelvingSale - WHERE itemShelvingFk = OLD.id; - - IF vItemShelvingSaleExists THEN - CALL util.throw('Cannot delete item shelving with item shelving sale'); - END IF; - - INSERT INTO vn.itemShelvingLog(itemShelvingFk, - workerFk, - accion, - shelvingFk, - itemFk) - VALUES( OLD.id, - account.myUser_getId(), - 'ELIMINADO', - OLD.shelvingFk, - OLD.itemFk); -END$$ +INSERT INTO vn.itemShelvingLog(itemShelvingFk, + workerFk, + accion, + shelvingFk, + itemFk) + VALUES( OLD.id, + account.myUser_getId(), + 'ELIMINADO', + OLD.shelvingFk, + OLD.itemFk)$$ DELIMITER ; 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; From 4da63900a2d69064f69d400b0c740c8f86ed948f Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 7 Oct 2024 07:36:50 +0200 Subject: [PATCH 082/217] fix: refs #7760 collection_assing added global handler sqlexception --- db/routines/vn/procedures/collection_assign.sql | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index c2d4a34ef..a4c861c96 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -3,7 +3,7 @@ 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. @@ -45,6 +45,12 @@ BEGIN 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 From e90d48c7774a2ad504bce6cc698c1cffe5178c45 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 7 Oct 2024 08:00:34 +0200 Subject: [PATCH 083/217] fix: refs #7524 backSuppliersPackaging --- modules/supplier/back/methods/supplier/getWithPackaging.js | 7 ++++++- .../back/methods/supplier/specs/getWithPackaging.spec.js | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/supplier/back/methods/supplier/getWithPackaging.js b/modules/supplier/back/methods/supplier/getWithPackaging.js index 658b0696c..07e563412 100644 --- a/modules/supplier/back/methods/supplier/getWithPackaging.js +++ b/modules/supplier/back/methods/supplier/getWithPackaging.js @@ -15,12 +15,17 @@ module.exports = Self => { 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'}, + where: { + typeFk: 'packaging', + created: {gte: oneYearAgo} + }, include: { relation: 'supplier', scope: { diff --git a/modules/supplier/back/methods/supplier/specs/getWithPackaging.spec.js b/modules/supplier/back/methods/supplier/specs/getWithPackaging.spec.js index f73d20f84..bd30d7437 100644 --- a/modules/supplier/back/methods/supplier/specs/getWithPackaging.spec.js +++ b/modules/supplier/back/methods/supplier/specs/getWithPackaging.spec.js @@ -18,6 +18,7 @@ describe('Supplier getWithPackaging()', () => { await entry.updateAttributes({ typeFk: typeFk, + created: new Date() }); const result = await models.Supplier.getWithPackaging(myOptions); From 542d0dcbd22b37714bff5f6eadfd29e83eabe07e Mon Sep 17 00:00:00 2001 From: Pako Date: Mon, 7 Oct 2024 08:41:07 +0200 Subject: [PATCH 084/217] feat(itemShelving): refs #8075 new field isMoving indicates the record must be transferred to another sector Refs: #8075 --- db/versions/11284-turquoiseLaurel/00-firstScript.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/versions/11284-turquoiseLaurel/00-firstScript.sql 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'; From de769efc0fe5a37bf2ec18e4b31d6dd7f05a3251 Mon Sep 17 00:00:00 2001 From: Pako Date: Mon, 7 Oct 2024 09:05:03 +0200 Subject: [PATCH 085/217] feat: refs #8075 autoupdating --- db/routines/vn/triggers/itemShelving_beforeUpdate.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/routines/vn/triggers/itemShelving_beforeUpdate.sql b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql index fabdf8efb..e22713a58 100644 --- a/db/routines/vn/triggers/itemShelving_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql @@ -9,5 +9,8 @@ BEGIN SET NEW.userFk = account.myUser_getId(); END IF; + IF NEW.shelvingFk <> OLD.shelvingFk THEN + SET NEW.isMoving = FALSE; + END IF; END$$ DELIMITER ; From e105fba227f1828b3d957623434580f75cc3c4f5 Mon Sep 17 00:00:00 2001 From: Pako Date: Mon, 7 Oct 2024 13:46:56 +0200 Subject: [PATCH 086/217] feat: refs #8075 itemShelving new field movingState --- db/routines/vn/triggers/itemShelving_beforeUpdate.sql | 2 +- db/versions/11285-orangeErica/00-firstScript.sql | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 db/versions/11285-orangeErica/00-firstScript.sql diff --git a/db/routines/vn/triggers/itemShelving_beforeUpdate.sql b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql index e22713a58..53f85de01 100644 --- a/db/routines/vn/triggers/itemShelving_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql @@ -10,7 +10,7 @@ BEGIN END IF; IF NEW.shelvingFk <> OLD.shelvingFk THEN - SET NEW.isMoving = FALSE; + SET NEW.movingState = NULL; END IF; END$$ DELIMITER ; 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; From 22719820fde2af9852ccef33994d8be752e1ae10 Mon Sep 17 00:00:00 2001 From: Pako Date: Mon, 7 Oct 2024 14:21:18 +0200 Subject: [PATCH 087/217] feat: refs #8069 overStocking protocol --- .../orderRow_updateOverstocking.sql | 52 +++++++++++++++++++ .../procedures/order_confirmWithUser.sql | 15 ++++++ .../hedera/triggers/orderRow_afterInsert.sql | 10 ++++ .../11287-azureRaphis/00-firstScript.sql | 3 ++ 4 files changed, 80 insertions(+) create mode 100644 db/routines/hedera/procedures/orderRow_updateOverstocking.sql create mode 100644 db/routines/hedera/triggers/orderRow_afterInsert.sql create mode 100644 db/versions/11287-azureRaphis/00-firstScript.sql diff --git a/db/routines/hedera/procedures/orderRow_updateOverstocking.sql b/db/routines/hedera/procedures/orderRow_updateOverstocking.sql new file mode 100644 index 000000000..e919ff922 --- /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 ; \ No newline at end of file diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 2b033b704..a0c5c5667 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -13,6 +13,7 @@ BEGIN */ DECLARE vHasRows BOOL; DECLARE vDone BOOL; + DECLARE vHas0Amount BOOL; DECLARE vWarehouseFk INT; DECLARE vShipment DATE; DECLARE vShipmentDayEnd DATETIME; @@ -97,6 +98,20 @@ BEGIN 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('Remove lines with quantity = 0 before confirming'); + END IF; + START TRANSACTION; CALL order_checkEditable(vSelf); diff --git a/db/routines/hedera/triggers/orderRow_afterInsert.sql b/db/routines/hedera/triggers/orderRow_afterInsert.sql new file mode 100644 index 000000000..525e5d4d2 --- /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 = NOW() + WHERE id = NEW.orderFk; +END$$ +DELIMITER ; \ No newline at end of file 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 From 33a4061058c234ed29e55abca6c8758ec24ba29f Mon Sep 17 00:00:00 2001 From: Pako Date: Mon, 7 Oct 2024 14:24:55 +0200 Subject: [PATCH 088/217] feat: refs #8069 8069-overStocking --- .../orderRow_updateOverstocking.sql | 52 +++++++++++++++++++ .../hedera/triggers/orderRow_afterInsert.sql | 10 ++++ .../11288-purpleFern/00-firstScript.sql | 3 ++ 3 files changed, 65 insertions(+) create mode 100644 db/routines/hedera/procedures/orderRow_updateOverstocking.sql create mode 100644 db/routines/hedera/triggers/orderRow_afterInsert.sql create mode 100644 db/versions/11288-purpleFern/00-firstScript.sql diff --git a/db/routines/hedera/procedures/orderRow_updateOverstocking.sql b/db/routines/hedera/procedures/orderRow_updateOverstocking.sql new file mode 100644 index 000000000..e919ff922 --- /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 ; \ No newline at end of file diff --git a/db/routines/hedera/triggers/orderRow_afterInsert.sql b/db/routines/hedera/triggers/orderRow_afterInsert.sql new file mode 100644 index 000000000..525e5d4d2 --- /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 = NOW() + WHERE id = NEW.orderFk; +END$$ +DELIMITER ; \ 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 From 20836d734c6fdcdd8714e9d2f6b8fc6c4675f2b3 Mon Sep 17 00:00:00 2001 From: Pako Date: Mon, 7 Oct 2024 14:25:46 +0200 Subject: [PATCH 089/217] fix: refs #8069 order_confirmWithUser --- .../hedera/procedures/order_confirmWithUser.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 2b033b704..a0c5c5667 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -13,6 +13,7 @@ BEGIN */ DECLARE vHasRows BOOL; DECLARE vDone BOOL; + DECLARE vHas0Amount BOOL; DECLARE vWarehouseFk INT; DECLARE vShipment DATE; DECLARE vShipmentDayEnd DATETIME; @@ -97,6 +98,20 @@ BEGIN 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('Remove lines with quantity = 0 before confirming'); + END IF; + START TRANSACTION; CALL order_checkEditable(vSelf); From 952f8f3dfcb6976b98d33ba3ab5da5286f8de632 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 7 Oct 2024 15:14:03 +0200 Subject: [PATCH 090/217] feat(Docuware): refs #8066 use oath --- back/methods/docuware/core.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/back/methods/docuware/core.js b/back/methods/docuware/core.js index 74d922236..760909aa3 100644 --- a/back/methods/docuware/core.js +++ b/back/methods/docuware/core.js @@ -8,12 +8,22 @@ module.exports = Self => { * @return {object} - The headers */ Self.getOptions = async() => { - const docuwareConfig = await Self.app.models.DocuwareConfig.findOne(); + const {url, username, password} = await Self.app.models.DocuwareConfig.findOne(); + const {IdentityServiceUrl} = await axios.get(`${url}/Home/IdentityServiceInfo`); + const {token_endpoint} = await axios.get(`${IdentityServiceUrl}/.well-known/openid-configuration`); + const {access_token} = await axios.post(token_endpoint, { + grant_type: 'password', + scope: 'docuware.platform', + client_id: 'docuware.platform.net.client', + username, // falta añadirlos + password // falta añadirlos + }); + const headers = { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', - 'Cookie': docuwareConfig.cookie + 'access_token': access_token } }; From d164cccee511a6cb9246ecf2a647b51b6d55f182 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 7 Oct 2024 16:14:16 +0200 Subject: [PATCH 091/217] fix: refs #6861 assignCollection --- back/methods/collection/assignCollection.js | 11 +- .../vn/procedures/collection_getAssigned.sql | 171 +++++++++++------- 2 files changed, 114 insertions(+), 68 deletions(-) diff --git a/back/methods/collection/assignCollection.js b/back/methods/collection/assignCollection.js index 2ff37ab59..2a7ec9ad5 100644 --- a/back/methods/collection/assignCollection.js +++ b/back/methods/collection/assignCollection.js @@ -19,8 +19,15 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const [info, info2, [{'@vCollectionFk': collectionFk}]] = await Self.rawSql( - 'CALL vn.collection_getAssigned(?, @vCollectionFk);SELECT @vCollectionFk', [userId], myOptions); + + 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); diff --git a/db/routines/vn/procedures/collection_getAssigned.sql b/db/routines/vn/procedures/collection_getAssigned.sql index 518e2dd7b..7151129bf 100644 --- a/db/routines/vn/procedures/collection_getAssigned.sql +++ b/db/routines/vn/procedures/collection_getAssigned.sql @@ -5,100 +5,139 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_getAssigne ) 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 - * + * 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 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, - pc.collection_assign_lockname - INTO vHasTooMuchCollections, - vLockName - FROM tmp.collection c - JOIN productionConfig pc; + 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('There are pending collections'); - 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)); + 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' - 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 - SET userFk = 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 - 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; - CALL itemShelvingSale_addByCollection(vCollectionFk); - - DO RELEASE_LOCK(vLockName); END$$ DELIMITER ; \ No newline at end of file From 330c1f3de69f1e41caa19f1cf02aee7c02060e3e Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 7 Oct 2024 17:50:36 +0200 Subject: [PATCH 092/217] chore: refs #7207 drop transaction --- db/routines/vn/procedures/queueMember_updateQueue.sql | 7 ------- 1 file changed, 7 deletions(-) diff --git a/db/routines/vn/procedures/queueMember_updateQueue.sql b/db/routines/vn/procedures/queueMember_updateQueue.sql index c3207e663..5af44da4f 100644 --- a/db/routines/vn/procedures/queueMember_updateQueue.sql +++ b/db/routines/vn/procedures/queueMember_updateQueue.sql @@ -12,11 +12,6 @@ BEGIN DECLARE vNewQueue VARCHAR(10); DECLARE vExtension VARCHAR(10); DECLARE exit handler FOR SQLEXCEPTION - BEGIN - ROLLBACK; - END; - - START TRANSACTION; SELECT d.pbxQueue, s.extension INTO vNewQueue, vExtension @@ -30,7 +25,5 @@ BEGIN INSERT IGNORE INTO pbx.queueMember (queue, extension) VALUES (vNewQueue, vExtension); - - COMMIT; END$$ DELIMITER ; \ No newline at end of file From 023842ac33a75a016f29930d85d77e290656c3c8 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 8 Oct 2024 08:33:04 +0200 Subject: [PATCH 093/217] feat: refs #7994 comment changes --- db/versions/11251-navyChrysanthemum/00-firstScript.sql | 2 ++ db/versions/11251-navyChrysanthemum/01-firstScript.sql | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/db/versions/11251-navyChrysanthemum/00-firstScript.sql b/db/versions/11251-navyChrysanthemum/00-firstScript.sql index 801405e59..6ec0a66bb 100644 --- a/db/versions/11251-navyChrysanthemum/00-firstScript.sql +++ b/db/versions/11251-navyChrysanthemum/00-firstScript.sql @@ -1,3 +1,5 @@ +/* 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 index e3e08e0aa..c942e0400 100644 --- a/db/versions/11251-navyChrysanthemum/01-firstScript.sql +++ b/db/versions/11251-navyChrysanthemum/01-firstScript.sql @@ -1 +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 +-- 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 From b4dc5276ddf9f16678cbdc4664b890d563d6e263 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 8 Oct 2024 08:36:17 +0200 Subject: [PATCH 094/217] fix: refs #7986 create fk --- db/versions/11290-blackOrchid/00-firstScript.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 db/versions/11290-blackOrchid/00-firstScript.sql diff --git a/db/versions/11290-blackOrchid/00-firstScript.sql b/db/versions/11290-blackOrchid/00-firstScript.sql new file mode 100644 index 000000000..e573e9e32 --- /dev/null +++ b/db/versions/11290-blackOrchid/00-firstScript.sql @@ -0,0 +1,6 @@ + +ALTER TABLE `vn`.`worker` +ADD COLUMN `motoFk` INT(11) UNSIGNED DEFAULT NULL; + +ALTER TABLE `vn`.`worker` +ADD CONSTRAINT `worker_machineFk` FOREIGN KEY (`motoFk`) REFERENCES `machine` (`id`) ON UPDATE CASCADE ON DELETE SET NULL; From 9695fea48f30207dffe9897993af2446acb23b9a Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 8 Oct 2024 12:05:19 +0200 Subject: [PATCH 095/217] feat(Docuware): refs #8066 add username and password --- back/methods/docuware/core.js | 25 ++++++++++--------- back/models/docuware-config.json | 17 ++++++------- .../11291-purpleChico/00-firstScript.sql | 2 ++ 3 files changed, 22 insertions(+), 22 deletions(-) create mode 100644 db/versions/11291-purpleChico/00-firstScript.sql diff --git a/back/methods/docuware/core.js b/back/methods/docuware/core.js index 760909aa3..9545cd878 100644 --- a/back/methods/docuware/core.js +++ b/back/methods/docuware/core.js @@ -9,15 +9,16 @@ module.exports = Self => { */ Self.getOptions = async() => { const {url, username, password} = await Self.app.models.DocuwareConfig.findOne(); - const {IdentityServiceUrl} = await axios.get(`${url}/Home/IdentityServiceInfo`); - const {token_endpoint} = await axios.get(`${IdentityServiceUrl}/.well-known/openid-configuration`); - const {access_token} = await axios.post(token_endpoint, { + const {data: {IdentityServiceUrl}} = await axios.get(`${url}/Home/IdentityServiceInfo`); + const {data: {token_endpoint}} = await axios.get(`${IdentityServiceUrl}/.well-known/openid-configuration`); + const data = await axios.post(token_endpoint, JSON.stringify({ grant_type: 'password', scope: 'docuware.platform', client_id: 'docuware.platform.net.client', - username, // falta añadirlos - password // falta añadirlos - }); + username, + password + })); + console.log('data: ', data); const headers = { headers: { @@ -42,8 +43,8 @@ module.exports = Self => { * @return {number} - The fileCabinet id */ Self.getDialog = async(code, action, fileCabinetId) => { - if (!process.env.NODE_ENV) - return Math.floor(Math.random() + 100); + // if (!process.env.NODE_ENV) + // return Math.floor(Math.random() + 100); const docuwareInfo = await Self.app.models.Docuware.findOne({ where: { @@ -69,8 +70,8 @@ module.exports = Self => { * @return {number} - The fileCabinet id */ Self.getFileCabinet = async code => { - if (!process.env.NODE_ENV) - return Math.floor(Math.random() + 100); + // if (!process.env.NODE_ENV) + // return Math.floor(Math.random() + 100); const options = await Self.getOptions(); const docuwareInfo = await Self.app.models.Docuware.findOne({ @@ -95,7 +96,7 @@ module.exports = Self => { * @return {object} - The data */ Self.get = async(code, filter, parse) => { - if (!process.env.NODE_ENV) return; + // if (!process.env.NODE_ENV) return; const options = await Self.getOptions(); const fileCabinetId = await Self.getFileCabinet(code); @@ -118,7 +119,7 @@ module.exports = Self => { * @return {object} - The data */ Self.getById = async(code, id, parse) => { - if (!process.env.NODE_ENV) return; + // if (!process.env.NODE_ENV) return; const docuwareInfo = await Self.app.models.Docuware.findOne({ fields: ['findById'], diff --git a/back/models/docuware-config.json b/back/models/docuware-config.json index 9d06c4874..244ae2790 100644 --- a/back/models/docuware-config.json +++ b/back/models/docuware-config.json @@ -18,15 +18,12 @@ }, "cookie": { "type": "string" + }, + "username": { + "type": "string" + }, + "password": { + "type": "string" } - }, - "acls": [ - { - "property": "*", - "accessType": "*", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - } - ] + } } diff --git a/db/versions/11291-purpleChico/00-firstScript.sql b/db/versions/11291-purpleChico/00-firstScript.sql new file mode 100644 index 000000000..db66c4c98 --- /dev/null +++ b/db/versions/11291-purpleChico/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.docuwareConfig ADD IF NOT EXISTS username varchar(100) NULL; +ALTER TABLE vn.docuwareConfig ADD IF NOT EXISTS password varchar(100) NULL; From 02adc6473a985038c2f28c8ae705e5bf0c475705 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 8 Oct 2024 12:22:47 +0200 Subject: [PATCH 096/217] fix: duplicate variable --- db/routines/hedera/procedures/order_confirmWithUser.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 690e7ff34..6e4087ad8 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -14,7 +14,6 @@ BEGIN DECLARE vHasRows BOOL; DECLARE vHas0Amount BOOL; DECLARE vDone BOOL; - DECLARE vHas0Amount BOOL; DECLARE vWarehouseFk INT; DECLARE vShipment DATE; DECLARE vShipmentDayEnd DATETIME; From d497ffc781c68e5be4a060ee442ab3ffeca6dd5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 8 Oct 2024 13:32:57 +0000 Subject: [PATCH 097/217] Actualizar modules/ticket/back/methods/ticket/closure.js --- modules/ticket/back/methods/ticket/closure.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/ticket/back/methods/ticket/closure.js b/modules/ticket/back/methods/ticket/closure.js index a75596bac..945406ab4 100644 --- a/modules/ticket/back/methods/ticket/closure.js +++ b/modules/ticket/back/methods/ticket/closure.js @@ -22,6 +22,8 @@ module.exports = async function(ctx, Self, tickets, options) { const failedtickets = []; for (const ticket of tickets) { try { + await Self.rawSql(`CALL util.debugAdd('invoicingTicket', ?)`, [ticket.id], {userId}); + await Self.app.models.InvoiceOut.getSerial(ticket.clientFk, ticket.companyFk, ticket.addressFk, 'quick'); await Self.rawSql( `CALL vn.ticket_closeByTicket(?)`, @@ -149,6 +151,11 @@ module.exports = async function(ctx, Self, tickets, options) { myOptions); } } catch (error) { + await Self.rawSql(` + INSERT INTO util.debug (variable, value) + VALUES ('invoicingTicketError', ?) + `, [ticket.id + ' - ' + error]); + if (error.responseCode == 450) { await invalidEmail(ticket); continue; From 39e808bca764d2283994b18758413a6882e44283 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 8 Oct 2024 16:06:38 +0200 Subject: [PATCH 098/217] fix: refs #7986 fix model --- db/versions/11290-blackOrchid/00-firstScript.sql | 9 +++------ modules/worker/back/models/operator.json | 14 +++++++++++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/db/versions/11290-blackOrchid/00-firstScript.sql b/db/versions/11290-blackOrchid/00-firstScript.sql index e573e9e32..e0c0e391c 100644 --- a/db/versions/11290-blackOrchid/00-firstScript.sql +++ b/db/versions/11290-blackOrchid/00-firstScript.sql @@ -1,6 +1,3 @@ - -ALTER TABLE `vn`.`worker` -ADD COLUMN `motoFk` INT(11) UNSIGNED DEFAULT NULL; - -ALTER TABLE `vn`.`worker` -ADD CONSTRAINT `worker_machineFk` FOREIGN KEY (`motoFk`) REFERENCES `machine` (`id`) ON UPDATE CASCADE ON DELETE SET NULL; +ALTER TABLE `vn`.`operator` +ADD COLUMN `machineFk` int(11) DEFAULT NULL, +ADD CONSTRAINT `operator_machine_FK` FOREIGN KEY (`machineFk`) REFERENCES `vn`.`machine` (`id`) ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/modules/worker/back/models/operator.json b/modules/worker/back/models/operator.json index d4832bccf..9933babc6 100644 --- a/modules/worker/back/models/operator.json +++ b/modules/worker/back/models/operator.json @@ -30,7 +30,10 @@ "isOnReservationMode": { "type": "boolean", "required": true - } + }, + "machineFk": { + "type": "number" + } }, "relations": { "sector": { @@ -53,6 +56,11 @@ "model": "ItemPackingType", "foreignKey": "itemPackingTypeFk", "primaryKey": "code" - } + }, + "machine": { + "type": "belongsTo", + "model": "Machine", + "foreignKey": "machineFk" + } } -} \ No newline at end of file +} From 3cf7591206eb6ee02c3c3ab846f9e2e49d377dde Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 8 Oct 2024 17:03:27 +0200 Subject: [PATCH 099/217] fix(closeAll): not use transaction --- modules/ticket/back/methods/ticket/closeAll.js | 2 +- modules/ticket/back/methods/ticket/closure.js | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index 143c0a3f0..8869f9464 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -54,7 +54,7 @@ module.exports = Self => { JOIN country co ON co.id = p.countryFk LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk WHERE (al.code = 'PACKED' OR (am.code = 'refund' AND al.code <> 'delivered')) - AND DATE(t.shipped) BETWEEN ? - INTERVAL 2 DAY AND util.dayEnd(?) + AND DATE(t.shipped) BETWEEN ? - INTERVAL 7 DAY AND util.dayEnd(?) AND t.refFk IS NULL GROUP BY t.id `, [toDate, toDate]); diff --git a/modules/ticket/back/methods/ticket/closure.js b/modules/ticket/back/methods/ticket/closure.js index a75596bac..892c1ddc6 100644 --- a/modules/ticket/back/methods/ticket/closure.js +++ b/modules/ticket/back/methods/ticket/closure.js @@ -12,16 +12,18 @@ module.exports = async function(ctx, Self, tickets, options) { Object.assign(myOptions, options); let tx; - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } + // if (!myOptions.transaction) { + // tx = await Self.beginTransaction({}); + // myOptions.transaction = tx; + // } if (tickets.length == 0) return; const failedtickets = []; for (const ticket of tickets) { try { + await Self.rawSql(`CALL util.debugAdd('invoicingTicket', ?)`, [ticket.id], {userId}); + await Self.app.models.InvoiceOut.getSerial(ticket.clientFk, ticket.companyFk, ticket.addressFk, 'quick'); await Self.rawSql( `CALL vn.ticket_closeByTicket(?)`, @@ -149,6 +151,10 @@ module.exports = async function(ctx, Self, tickets, options) { myOptions); } } catch (error) { + await Self.rawSql(` + INSERT INTO util.debug (variable, value) + VALUES ('invoicingTicketError', ?) + `, [ticket.id + ' - ' + error]); if (error.responseCode == 450) { await invalidEmail(ticket); continue; From 040304d04f5e587b77b1235733d3d914e3ee589b Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 8 Oct 2024 17:10:19 +0200 Subject: [PATCH 100/217] fix: merge --- modules/ticket/back/methods/ticket/closure.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/closure.js b/modules/ticket/back/methods/ticket/closure.js index 4797d47da..d20c83304 100644 --- a/modules/ticket/back/methods/ticket/closure.js +++ b/modules/ticket/back/methods/ticket/closure.js @@ -155,10 +155,7 @@ module.exports = async function(ctx, Self, tickets, options) { INSERT INTO util.debug (variable, value) VALUES ('invoicingTicketError', ?) `, [ticket.id + ' - ' + error]); -<<<<<<< HEAD -======= ->>>>>>> 087818e39d86256ae1e166112b0f648a7a0ff239 if (error.responseCode == 450) { await invalidEmail(ticket); continue; From 5eda0af20f84f609fe9d992ca45d788c605822fe Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 9 Oct 2024 07:24:34 +0200 Subject: [PATCH 101/217] feat: refs #8075 itemShelvingMoving --- db/routines/vn/triggers/itemShelving_beforeUpdate.sql | 3 +++ db/versions/11294-azureFern/00-firstScript.sql | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 db/versions/11294-azureFern/00-firstScript.sql diff --git a/db/routines/vn/triggers/itemShelving_beforeUpdate.sql b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql index fabdf8efb..53f85de01 100644 --- a/db/routines/vn/triggers/itemShelving_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql @@ -9,5 +9,8 @@ BEGIN 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/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 From 679773b33eb8961ec18f7e58e49cbd553cfdbbdb Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 9 Oct 2024 07:26:22 +0200 Subject: [PATCH 102/217] feat: refs #8075 itemShelvingMoving --- db/routines/vn/triggers/itemShelving_beforeUpdate.sql | 3 +++ db/versions/11295-brownLaurel/00-firstScript.sql | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 db/versions/11295-brownLaurel/00-firstScript.sql diff --git a/db/routines/vn/triggers/itemShelving_beforeUpdate.sql b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql index fabdf8efb..53f85de01 100644 --- a/db/routines/vn/triggers/itemShelving_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql @@ -9,5 +9,8 @@ BEGIN 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/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 From 4eab12dd0453218a0298427534f3d00650797f62 Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 9 Oct 2024 07:41:43 +0200 Subject: [PATCH 103/217] fix: refs #8069 throw message in spanish --- db/routines/hedera/procedures/order_confirmWithUser.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index a0c5c5667..b7ed500d7 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -109,8 +109,8 @@ BEGIN ) INTO vHas0Amount; IF vHas0Amount THEN - CALL util.throw('Remove lines with quantity = 0 before confirming'); - END IF; + CALL util.throw('Hay líneas vacías. Por favor, elimínelas'); + END IF; START TRANSACTION; From 208869bd306565cc31bb90a7b09e5c9f2596a9ea Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 10 Oct 2024 08:20:41 +0200 Subject: [PATCH 104/217] fix: refs #8069 removed obsolete variables --- db/routines/hedera/procedures/order_confirmWithUser.sql | 2 -- db/routines/hedera/triggers/orderRow_afterInsert.sql | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index b7ed500d7..44da9d071 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -22,7 +22,6 @@ BEGIN DECLARE vItemFk INT; DECLARE vConcept VARCHAR(30); DECLARE vAmount INT; - DECLARE vAvailable INT; DECLARE vPrice DECIMAL(10,2); DECLARE vSaleFk INT; DECLARE vRowFk INT; @@ -32,7 +31,6 @@ BEGIN DECLARE vClientFk INT; DECLARE vCompanyFk INT; DECLARE vAgencyModeFk INT; - DECLARE vCalcFk INT; DECLARE vIsTaxDataChecked BOOL; DECLARE vDates CURSOR FOR diff --git a/db/routines/hedera/triggers/orderRow_afterInsert.sql b/db/routines/hedera/triggers/orderRow_afterInsert.sql index 525e5d4d2..d0da043e7 100644 --- a/db/routines/hedera/triggers/orderRow_afterInsert.sql +++ b/db/routines/hedera/triggers/orderRow_afterInsert.sql @@ -4,7 +4,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterIns FOR EACH ROW BEGIN UPDATE `order` - SET rowUpdated = NOW() + SET rowUpdated = util.VN_NOW() WHERE id = NEW.orderFk; END$$ DELIMITER ; \ No newline at end of file From 295c31a5f078a41e1cdb5dc29af3f232977956e7 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 10 Oct 2024 11:01:25 +0200 Subject: [PATCH 105/217] feat: refs #7874 add finance obs type --- db/dump/fixtures.before.sql | 3 ++- .../11230-brownEucalyptus/00-addClientObservationType.sql | 2 +- db/versions/11230-brownEucalyptus/01-addNewObservation.vn.sql | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 db/versions/11230-brownEucalyptus/01-addNewObservation.vn.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index d475ef02f..7f7e50dd3 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -546,7 +546,8 @@ INSERT INTO `vn`.`observationType`(`id`,`description`, `code`) (6, 'Weight', 'weight'), (7, 'InvoiceOut', 'invoiceOut'), (8, 'DropOff', 'dropOff'), - (9, 'Sustitución', 'substitution'); + (9, 'Sustitución', 'substitution'), + (10, 'Finance', 'finance'); INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`description`) VALUES diff --git a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql index cb0849888..53a737bc5 100644 --- a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql +++ b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql @@ -1,3 +1,3 @@ ALTER TABLE vn.clientObservation ADD COLUMN observationTypeFk TINYINT(3) UNSIGNED NOT NULL, - ADD CONSTRAINT clientObservationTypeFk FOREIGN KEY (observationTypeFk) REFERENCES vn.observationType(id); \ No newline at end of file + ADD CONSTRAINT clientObservationTypeFk FOREIGN KEY (observationTypeFk) REFERENCES vn.observationType(id); \ No newline at end of file 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 From 770c604d6b9e758745a4087305d7fa45fbdb2b12 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 10 Oct 2024 16:30:04 +0200 Subject: [PATCH 106/217] chore: refs #7919 delete if ticketRefund --- db/routines/vn/triggers/ticket_afterUpdate.sql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/db/routines/vn/triggers/ticket_afterUpdate.sql b/db/routines/vn/triggers/ticket_afterUpdate.sql index f6c5e6523..e849c1faa 100644 --- a/db/routines/vn/triggers/ticket_afterUpdate.sql +++ b/db/routines/vn/triggers/ticket_afterUpdate.sql @@ -12,5 +12,10 @@ BEGIN CALL ticket_doCmr(NEW.id); END IF; END IF; + + IF NEW.isDeleted THEN + DELETE FROM ticketRefund + WHERE refundTicketFk = NEW.id; + END IF; END$$ DELIMITER ; From 78a9b788bf3d77ca736694d4f3fadc259cde69e7 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 14 Oct 2024 08:42:54 +0200 Subject: [PATCH 107/217] feat: refs #7006 itemTypeLog created --- .../vn/triggers/itemType_afterDelete.sql | 12 ++++++++++ .../vn/triggers/itemType_beforeInsert.sql | 8 +++++++ .../vn/triggers/itemType_beforeUpdate.sql | 1 + .../triggers/productionConfig_afterDelete.sql | 2 +- .../11297-graySalal/00-firstScript.sql | 24 +++++++++++++++++++ modules/item/back/models/item-type-log.json | 9 +++++++ 6 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 db/routines/vn/triggers/itemType_afterDelete.sql create mode 100644 db/routines/vn/triggers/itemType_beforeInsert.sql create mode 100644 db/versions/11297-graySalal/00-firstScript.sql create mode 100644 modules/item/back/models/item-type-log.json diff --git a/db/routines/vn/triggers/itemType_afterDelete.sql b/db/routines/vn/triggers/itemType_afterDelete.sql new file mode 100644 index 000000000..32a1ba31c --- /dev/null +++ b/db/routines/vn/triggers/itemType_afterDelete.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemType_afterDelete` + AFTER DELETE ON `itemType` + FOR EACH ROW +BEGIN + INSERT INTO itemTypeLog + SET `action` = 'delete', + `changedModel` = 'ItemType', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/itemType_beforeInsert.sql b/db/routines/vn/triggers/itemType_beforeInsert.sql new file mode 100644 index 000000000..d33d8fb56 --- /dev/null +++ b/db/routines/vn/triggers/itemType_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemType_beforeInsert` + BEFORE INSERT ON `itemType` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/itemType_beforeUpdate.sql b/db/routines/vn/triggers/itemType_beforeUpdate.sql index 613ae8bfa..6a03d40d0 100644 --- a/db/routines/vn/triggers/itemType_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemType_beforeUpdate.sql @@ -3,6 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemType_beforeUpdate` BEFORE UPDATE ON `itemType` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); IF NEW.itemPackingTypeFk = '' THEN SET NEW.itemPackingTypeFk = NULL; diff --git a/db/routines/vn/triggers/productionConfig_afterDelete.sql b/db/routines/vn/triggers/productionConfig_afterDelete.sql index 6b6800d4f..bd485d590 100644 --- a/db/routines/vn/triggers/productionConfig_afterDelete.sql +++ b/db/routines/vn/triggers/productionConfig_afterDelete.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`productionConfig_afterD AFTER DELETE ON `productionConfig` FOR EACH ROW BEGIN - INSERT INTO productionConfig + INSERT INTO productionConfigLog SET `action` = 'delete', `changedModel` = 'ProductionConfig', `changedModelId` = OLD.id, diff --git a/db/versions/11297-graySalal/00-firstScript.sql b/db/versions/11297-graySalal/00-firstScript.sql new file mode 100644 index 000000000..d6aeb1ec2 --- /dev/null +++ b/db/versions/11297-graySalal/00-firstScript.sql @@ -0,0 +1,24 @@ +ALTER TABLE vn.itemType + ADD editorFk int(10) unsigned DEFAULT NULL NULL, + ADD CONSTRAINT itemType_user_FK FOREIGN KEY (editorFk) REFERENCES account.`user`(id); + +CREATE TABLE `vn`.`itemTypeLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `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('ItemType') NOT NULL DEFAULT 'ItemType', + `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 `itemTypeLogUserFk_idx` (`userFk`), + KEY `itemTypeLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), + KEY `itemTypeLog_originFk` (`originFk`,`creationDate`), + KEY `itemTypeLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, + CONSTRAINT `itemTypeLogUserFk` 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; diff --git a/modules/item/back/models/item-type-log.json b/modules/item/back/models/item-type-log.json new file mode 100644 index 000000000..61e27e9ba --- /dev/null +++ b/modules/item/back/models/item-type-log.json @@ -0,0 +1,9 @@ +{ + "name": "ItemTypeLog", + "base": "Log", + "options": { + "mysql": { + "table": "ItemTypeLog" + } + } +} From 6c621726334adf2a4e93816c7dfceac28f9a6009 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 14 Oct 2024 09:31:35 +0200 Subject: [PATCH 108/217] feat: refs #7006 itemTypeLog created --- db/versions/11297-graySalal/00-firstScript.sql | 3 +++ modules/item/back/model-config.json | 3 +++ modules/item/back/models/item-type-log.json | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/db/versions/11297-graySalal/00-firstScript.sql b/db/versions/11297-graySalal/00-firstScript.sql index d6aeb1ec2..372af804c 100644 --- a/db/versions/11297-graySalal/00-firstScript.sql +++ b/db/versions/11297-graySalal/00-firstScript.sql @@ -22,3 +22,6 @@ CREATE TABLE `vn`.`itemTypeLog` ( KEY `itemTypeLog_creationDate_IDX` (`creationDate` DESC) USING BTREE, CONSTRAINT `itemTypeLogUserFk` 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; + +INSERT IGNORE INTO salix.ACL (model,property,principalId) + VALUES ('ItemTypeLog','*','employee'); diff --git a/modules/item/back/model-config.json b/modules/item/back/model-config.json index 5dbe4d62a..dcd973524 100644 --- a/modules/item/back/model-config.json +++ b/modules/item/back/model-config.json @@ -47,6 +47,9 @@ "ItemType": { "dataSource": "vn" }, + "ItemTypeLog": { + "dataSource": "vn" + }, "ItemTypeTag": { "dataSource": "vn" }, diff --git a/modules/item/back/models/item-type-log.json b/modules/item/back/models/item-type-log.json index 61e27e9ba..82a218aa6 100644 --- a/modules/item/back/models/item-type-log.json +++ b/modules/item/back/models/item-type-log.json @@ -3,7 +3,7 @@ "base": "Log", "options": { "mysql": { - "table": "ItemTypeLog" + "table": "itemTypeLog" } } } From 4ee6a46bd567cfbc7660d78daae1b88af76fce6a Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 14 Oct 2024 11:29:49 +0200 Subject: [PATCH 109/217] feat: added new filter param --- .../back/methods/ticket-request/filter.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/ticket/back/methods/ticket-request/filter.js b/modules/ticket/back/methods/ticket-request/filter.js index 5364cef9a..ad000036b 100644 --- a/modules/ticket/back/methods/ticket-request/filter.js +++ b/modules/ticket/back/methods/ticket-request/filter.js @@ -59,6 +59,11 @@ module.exports = Self => { arg: 'state', type: 'string', description: `Search request by request state` + }, + { + arg: 'myTeam', + type: 'boolean', + description: `Team partners` } ], returns: { @@ -75,6 +80,24 @@ module.exports = Self => { const conn = Self.dataSource.connector; const userId = ctx.req.accessToken.userId; const myOptions = {}; + const models = Self.app.models; + const args = ctx.args; + + // Apply filter by team + const teamMembersId = []; + if (args.myTeam != null) { + const worker = await models.Worker.findById(userId, { + include: { + relation: 'collegues' + } + }, myOptions); + const collegues = worker.collegues() || []; + for (let collegue of collegues) + teamMembersId.push(collegue.collegueFk); + + if (teamMembersId.length == 0) + teamMembersId.push(userId); + } if (typeof options == 'object') Object.assign(myOptions, options); @@ -113,6 +136,11 @@ module.exports = Self => { return {'w.id': value}; case 'salesPersonFk': return {'c.salesPersonFk': value}; + case 'myTeam': + if (value) + return {'c.salesPersonFk': {inq: teamMembersId}}; + else + return {'c.salesPersonFk': {nin: teamMembersId}}; } }); From 06b7d568376923fe50388cd42ce0672031ab5c9c Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 14 Oct 2024 13:01:30 +0200 Subject: [PATCH 110/217] fix: refs #6861 assignCollection&isOnReservationMode --- db/versions/11289-azureAralia/00-firstScript.sql | 2 ++ modules/shelving/back/models/sector.json | 5 ++++- modules/worker/back/methods/device/handle-user.js | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 db/versions/11289-azureAralia/00-firstScript.sql 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/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/worker/back/methods/device/handle-user.js b/modules/worker/back/methods/device/handle-user.js index 55302c1cb..abafffd55 100644 --- a/modules/worker/back/methods/device/handle-user.js +++ b/modules/worker/back/methods/device/handle-user.js @@ -87,7 +87,7 @@ module.exports = Self => { { relation: 'sector', scope: { - fields: ['warehouseFk', 'description'], + fields: ['warehouseFk', 'description', 'isOnReservationMode'], } }, { relation: 'printer', From 07849ebeb8234172072b027317ad8517dc34cfe4 Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 14 Oct 2024 13:25:09 +0200 Subject: [PATCH 111/217] fix: myTeam param --- modules/ticket/back/methods/ticket-request/filter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket-request/filter.js b/modules/ticket/back/methods/ticket-request/filter.js index ad000036b..2e1d2fbae 100644 --- a/modules/ticket/back/methods/ticket-request/filter.js +++ b/modules/ticket/back/methods/ticket-request/filter.js @@ -138,9 +138,9 @@ module.exports = Self => { return {'c.salesPersonFk': value}; case 'myTeam': if (value) - return {'c.salesPersonFk': {inq: teamMembersId}}; + return {'tr.requesterFk': {inq: teamMembersId}}; else - return {'c.salesPersonFk': {nin: teamMembersId}}; + return {'tr.requesterFk': {nin: teamMembersId}}; } }); From f3b5a70b673de493a110257cd0fae9c4081160da Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 14 Oct 2024 14:41:25 +0200 Subject: [PATCH 112/217] feat: refs #7323 show right error --- modules/worker/back/methods/worker/new.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/worker/back/methods/worker/new.js b/modules/worker/back/methods/worker/new.js index bb43fba99..7da8a8da2 100644 --- a/modules/worker/back/methods/worker/new.js +++ b/modules/worker/back/methods/worker/new.js @@ -217,6 +217,7 @@ module.exports = Self => { const code = e.code; const message = e.sqlMessage; + 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`); From ccf9dbde8e1f8e8612ec3276a49cc7c9d62541c2 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 14 Oct 2024 17:11:12 +0200 Subject: [PATCH 113/217] feat: refs #7919 test --- .../methods/ticket/specs/setDeleted.spec.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js index 782c31c02..4e858af8e 100644 --- a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js +++ b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js @@ -113,5 +113,25 @@ describe('ticket setDeleted()', () => { expect(error.message).not.toContain('Tickets with associated refunds'); }); + + it('should delete a refund ticket from ticketRefund table', async() => { + const tx = await models.Ticket.beginTransaction({}); + try { + const options = {transaction: tx}; + + const ticketId = 24; + const refundTicket = await models.TicketRefund.findOne({where: {refundTicketFk: ticketId}}, options); + + expect(refundTicket).toBeTruthy(); + + await models.Ticket.setDeleted(ctx, ticketId, options); + const isRemoved = await models.TicketRefund.findOne({where: {refundTicketFk: ticketId}}, options); + + expect(isRemoved).toBeNull(); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + } + }); }); }); From a35208d903f3c3329451da3141a159b66a2a13c3 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 14 Oct 2024 17:14:01 +0200 Subject: [PATCH 114/217] feat: refs #7919 test --- modules/ticket/back/methods/ticket/specs/setDeleted.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js index 4e858af8e..088487f3a 100644 --- a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js +++ b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js @@ -114,7 +114,7 @@ describe('ticket setDeleted()', () => { expect(error.message).not.toContain('Tickets with associated refunds'); }); - it('should delete a refund ticket from ticketRefund table', async() => { + it('should delete the refund - original ticket relation', async() => { const tx = await models.Ticket.beginTransaction({}); try { const options = {transaction: tx}; From 6d4c71d465bf40cd8bf592bfd9e4ffde24293210 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 14 Oct 2024 17:14:40 +0200 Subject: [PATCH 115/217] feat: refs #7919 test --- modules/ticket/back/methods/ticket/specs/setDeleted.spec.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js index 088487f3a..b70c94cee 100644 --- a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js +++ b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js @@ -125,9 +125,11 @@ describe('ticket setDeleted()', () => { expect(refundTicket).toBeTruthy(); await models.Ticket.setDeleted(ctx, ticketId, options); - const isRemoved = await models.TicketRefund.findOne({where: {refundTicketFk: ticketId}}, options); + const removedRefundTicket = await models.TicketRefund.findOne({ + where: {refundTicketFk: ticketId}}, + options); - expect(isRemoved).toBeNull(); + expect(removedRefundTicket).toBeNull(); await tx.rollback(); } catch (e) { await tx.rollback(); From 3c881d5e483b904dfcb0be489e313345099c755a Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 15 Oct 2024 08:00:19 +0200 Subject: [PATCH 116/217] refactor(docuware): refs #8066 use Authorization --- back/methods/docuware/core.js | 42 ++++++++++++------- back/methods/docuware/upload.js | 2 +- back/models/docuware-config.json | 5 ++- .../11291-purpleChico/00-firstScript.sql | 2 + 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/back/methods/docuware/core.js b/back/methods/docuware/core.js index 9545cd878..6d3bb58ed 100644 --- a/back/methods/docuware/core.js +++ b/back/methods/docuware/core.js @@ -4,32 +4,45 @@ module.exports = Self => { /** * Returns basic headers * - * @param {string} cookie - The docuware cookie * @return {object} - The headers */ Self.getOptions = async() => { - const {url, username, password} = await Self.app.models.DocuwareConfig.findOne(); - const {data: {IdentityServiceUrl}} = await axios.get(`${url}/Home/IdentityServiceInfo`); - const {data: {token_endpoint}} = await axios.get(`${IdentityServiceUrl}/.well-known/openid-configuration`); - const data = await axios.post(token_endpoint, JSON.stringify({ - grant_type: 'password', - scope: 'docuware.platform', - client_id: 'docuware.platform.net.client', - username, - password - })); - console.log('data: ', data); + const docuwareConfig = await Self.app.models.DocuwareConfig.findOne(); + const now = new Date().getTime(); + let {url, username, password, token, expired} = docuwareConfig; + + if (!expired || expired < now + 60) { + const {data: {IdentityServiceUrl}} = await axios.get(`${url}/Home/IdentityServiceInfo`); + const {data: {token_endpoint}} = await axios.get(`${IdentityServiceUrl}/.well-known/openid-configuration`); + const {data} = await axios.post(token_endpoint, { + grant_type: 'password', + scope: 'docuware.platform', + client_id: 'docuware.platform.net.client', + username, + password + }, {headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/x-www-form-urlencoded' + }}); + + const newToken = data.access_token; + token = data.token_type + ' ' + newToken; + await docuwareConfig.updateAttributes({ + token, + expired: now + data.expires_in + }); + } const headers = { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', - 'access_token': access_token + 'Authorization': token } }; return { - url: docuwareConfig.url, + url, headers }; }; @@ -80,6 +93,7 @@ module.exports = Self => { } }); + console.log('options.headers: ', options.headers); const fileCabinetResponse = await axios.get(`${options.url}/FileCabinets`, options.headers); const fileCabinets = fileCabinetResponse.data.FileCabinet; const fileCabinetId = fileCabinets.find(fileCabinet => fileCabinet.Name === docuwareInfo.fileCabinetName).Id; diff --git a/back/methods/docuware/upload.js b/back/methods/docuware/upload.js index 0102911e0..5b35b7598 100644 --- a/back/methods/docuware/upload.js +++ b/back/methods/docuware/upload.js @@ -143,7 +143,7 @@ module.exports = Self => { headers: { 'Content-Type': 'multipart/form-data', 'X-File-ModifiedDate': Date.vnNew(), - 'Cookie': docuwareOptions.headers.headers.Cookie, + 'Authorization': docuwareOptions.headers.headers.Authorization, ...data.getHeaders() }, }; diff --git a/back/models/docuware-config.json b/back/models/docuware-config.json index 244ae2790..b15cb4c03 100644 --- a/back/models/docuware-config.json +++ b/back/models/docuware-config.json @@ -16,7 +16,7 @@ "url": { "type": "string" }, - "cookie": { + "token": { "type": "string" }, "username": { @@ -24,6 +24,9 @@ }, "password": { "type": "string" + }, + "expired":{ + "type": "number" } } } diff --git a/db/versions/11291-purpleChico/00-firstScript.sql b/db/versions/11291-purpleChico/00-firstScript.sql index db66c4c98..e60b90376 100644 --- a/db/versions/11291-purpleChico/00-firstScript.sql +++ b/db/versions/11291-purpleChico/00-firstScript.sql @@ -1,2 +1,4 @@ ALTER TABLE vn.docuwareConfig ADD IF NOT EXISTS username varchar(100) NULL; ALTER TABLE vn.docuwareConfig ADD IF NOT EXISTS password varchar(100) NULL; +ALTER TABLE vn.docuwareConfig ADD IF NOT EXISTS token text NULL; +ALTER TABLE vn.docuwareConfig ADD IF NOT EXISTS expired int(11) NULL; From f2d1aa5f1659e70e188d08e77d568119fb1ce6ac Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 15 Oct 2024 08:17:03 +0200 Subject: [PATCH 117/217] feat: refs #8098 closureDaysAgo --- db/versions/11298-wheatIvy/00-closure.sql | 3 +++ .../ticket/back/methods/ticket/closeAll.js | 21 ++++++++++--------- modules/ticket/back/methods/ticket/closure.js | 5 +---- .../back/methods/ticket/specs/closure.spec.js | 4 ++-- 4 files changed, 17 insertions(+), 16 deletions(-) create mode 100644 db/versions/11298-wheatIvy/00-closure.sql 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/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index 8869f9464..4ae83b647 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -45,17 +45,18 @@ module.exports = Self => { eu.email salesPersonEmail, t.addressFk FROM ticket t - JOIN agencyMode am ON am.id = t.agencyModeFk - JOIN warehouse wh ON wh.id = t.warehouseFk AND wh.hasComission - 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 + JOIN agencyMode am ON am.id = t.agencyModeFk + JOIN warehouse wh ON wh.id = t.warehouseFk AND wh.hasComission + 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 + JOIN ticketConfig tc ON TRUE WHERE (al.code = 'PACKED' OR (am.code = 'refund' AND al.code <> 'delivered')) - AND DATE(t.shipped) BETWEEN ? - INTERVAL 7 DAY AND util.dayEnd(?) - AND t.refFk IS NULL + AND DATE(t.shipped) BETWEEN ? - INTERVAL tc.closureDaysAgo DAY AND util.dayEnd(?) + AND t.refFk IS NULL GROUP BY t.id `, [toDate, toDate]); const ticketIds = tickets.map(ticket => ticket.id); diff --git a/modules/ticket/back/methods/ticket/closure.js b/modules/ticket/back/methods/ticket/closure.js index d20c83304..56bd6eccd 100644 --- a/modules/ticket/back/methods/ticket/closure.js +++ b/modules/ticket/back/methods/ticket/closure.js @@ -12,10 +12,7 @@ module.exports = async function(ctx, Self, tickets, options) { Object.assign(myOptions, options); let tx; - // if (!myOptions.transaction) { - // tx = await Self.beginTransaction({}); - // myOptions.transaction = tx; - // } + // IMPORTANT: Due to its high cost in production, wrapping this process in a transaction may cause timeouts. if (tickets.length == 0) return; diff --git a/modules/ticket/back/methods/ticket/specs/closure.spec.js b/modules/ticket/back/methods/ticket/specs/closure.spec.js index 303c38233..cafe178cb 100644 --- a/modules/ticket/back/methods/ticket/specs/closure.spec.js +++ b/modules/ticket/back/methods/ticket/specs/closure.spec.js @@ -50,9 +50,9 @@ describe('Ticket closure functionality', () => { expect(ticketStateBefore.code).not.toBe(ticketStateAfter.code); - const ticketAfter = await models.TicketState.findById(ticketId, null, options); + const ticketAfter = await models.Ticket.findById(ticketId, null, options); - expect(ticketAfter.refFk).toBeUndefined(); + expect(ticketAfter.refFk).toBeNull(); }); it('should send Incoterms authorization email on first order', async() => { From 63f062a06925fb12dc25612003e1eab8851f5515 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 15 Oct 2024 08:19:35 +0200 Subject: [PATCH 118/217] fix(renewToken): refs #8093 test & fix(sql) addClientObservationType --- back/methods/vn-user/specs/renew-token.spec.js | 4 ++-- .../11230-brownEucalyptus/00-addClientObservationType.sql | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/back/methods/vn-user/specs/renew-token.spec.js b/back/methods/vn-user/specs/renew-token.spec.js index 8f1bb54c1..8941916ec 100644 --- a/back/methods/vn-user/specs/renew-token.spec.js +++ b/back/methods/vn-user/specs/renew-token.spec.js @@ -72,9 +72,9 @@ describe('Renew Token', () => { } expect(error).toBeDefined(); - const query = 'SELECT * FROM util.debug'; - const debugLog = await models.Application.rawSql(query, null); + const query = 'SELECT * FROM util.debug WHERE variable = "renewToken"'; + const debugLog = await models.Application.rawSql(query); expect(debugLog.length).toEqual(1); }); diff --git a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql index 53a737bc5..1542ff28a 100644 --- a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql +++ b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql @@ -1,3 +1,3 @@ -ALTER TABLE vn.clientObservation - ADD COLUMN observationTypeFk TINYINT(3) UNSIGNED NOT NULL, - ADD CONSTRAINT clientObservationTypeFk FOREIGN KEY (observationTypeFk) REFERENCES vn.observationType(id); \ No newline at end of file +ALTER TABLE vn.clientObservation + ADD COLUMN IF NOT EXISTS observationTypeFk TINYINT(3) UNSIGNED NOT NULL, + ADD CONSTRAINT clientObservationTypeFk FOREIGN KEY (observationTypeFk) REFERENCES vn.observationType(id); From 4526873bbe7e94debe793b9f1143e899e5e8c365 Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 15 Oct 2024 08:24:13 +0200 Subject: [PATCH 119/217] feat: refs #8098 without Date --- modules/ticket/back/methods/ticket/closeAll.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index 4ae83b647..4e2f4ef3c 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -55,7 +55,7 @@ module.exports = Self => { 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 tc.closureDaysAgo 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]); @@ -109,6 +109,7 @@ 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 @@ -117,7 +118,7 @@ module.exports = Self => { 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 @@ -142,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 From 976e50b566ff70d7542f33888d9397ee2fa73cdd Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 15 Oct 2024 08:25:53 +0200 Subject: [PATCH 120/217] feat: refs #8098 identation --- .../ticket/back/methods/ticket/closeAll.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index 4e2f4ef3c..4fd72d454 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -45,18 +45,18 @@ module.exports = Self => { eu.email salesPersonEmail, t.addressFk FROM ticket t - JOIN agencyMode am ON am.id = t.agencyModeFk - JOIN warehouse wh ON wh.id = t.warehouseFk AND wh.hasComission - 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 - JOIN ticketConfig tc ON TRUE + JOIN agencyMode am ON am.id = t.agencyModeFk + JOIN warehouse wh ON wh.id = t.warehouseFk AND wh.hasComission + 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 + JOIN ticketConfig tc ON TRUE WHERE (al.code = 'PACKED' OR (am.code = 'refund' AND al.code <> 'delivered')) - AND t.shipped BETWEEN ? - INTERVAL tc.closureDaysAgo DAY AND util.dayEnd(?) - AND t.refFk IS NULL + AND t.shipped BETWEEN ? - INTERVAL tc.closureDaysAgo DAY AND util.dayEnd(?) + AND t.refFk IS NULL GROUP BY t.id `, [toDate, toDate]); const ticketIds = tickets.map(ticket => ticket.id); From c5f987d04c9f4054aa2d9d0fdff9d5243435f331 Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 15 Oct 2024 08:44:08 +0200 Subject: [PATCH 121/217] fix: refs #8098 renew token test fixed --- back/methods/vn-user/specs/renew-token.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/vn-user/specs/renew-token.spec.js b/back/methods/vn-user/specs/renew-token.spec.js index 8f1bb54c1..929c2f38d 100644 --- a/back/methods/vn-user/specs/renew-token.spec.js +++ b/back/methods/vn-user/specs/renew-token.spec.js @@ -72,7 +72,7 @@ describe('Renew Token', () => { } expect(error).toBeDefined(); - const query = 'SELECT * FROM util.debug'; + const query = 'SELECT * FROM util.debug WHERE variable = "renewToken"'; const debugLog = await models.Application.rawSql(query, null); From 52e573501ad4d5fa120291b24f1ba9cf53dfaea0 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 15 Oct 2024 08:46:43 +0200 Subject: [PATCH 122/217] feat: refs #8108 create tables itemTag --- .../11300-limeMedeola/00-firstScript.sql | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 db/versions/11300-limeMedeola/00-firstScript.sql diff --git a/db/versions/11300-limeMedeola/00-firstScript.sql b/db/versions/11300-limeMedeola/00-firstScript.sql new file mode 100644 index 000000000..21920b692 --- /dev/null +++ b/db/versions/11300-limeMedeola/00-firstScript.sql @@ -0,0 +1,85 @@ +CREATE TABLE IF NOT EXISTS `vn`.`itemFarmingTag` ( + `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`.`itemFarmingTag` (`name`) VALUES ('Enraizado'); + +UPDATE vn.tag + SET isFree=0, + sourceTable='itemFarmingTag' + WHERE name= 'cultivo'; + + + +CREATE TABLE IF NOT EXISTS `vn`.`itemWrappingTag` ( + `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`.`itemWrappingTag` (`name`) VALUES ('Bolsa'); +INSERT IGNORE INTO `vn`.`itemWrappingTag` (`name`) VALUES ('Caja cartón'); +INSERT IGNORE INTO `vn`.`itemWrappingTag` (`name`) VALUES ('Caja decorativa'); +INSERT IGNORE INTO `vn`.`itemWrappingTag` (`name`) VALUES ('Celofán'); +INSERT IGNORE INTO `vn`.`itemWrappingTag` (`name`) VALUES ('Papel kraft'); +INSERT IGNORE INTO `vn`.`itemWrappingTag` (`name`) VALUES ('Plástico'); +INSERT IGNORE INTO `vn`.`itemWrappingTag` (`name`) VALUES ('Variable'); + +UPDATE vn.tag + SET isFree=0, + sourceTable='itemWrappingTag' + WHERE name= 'Envoltorio'; + + + +CREATE TABLE IF NOT EXISTS `vn`.`itemLanguageTag` ( + `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`.`itemLanguageTag` (`name`) VALUES ('Castellano'); +INSERT IGNORE INTO `vn`.`itemLanguageTag` (`name`) VALUES ('Catalán'); +INSERT IGNORE INTO `vn`.`itemLanguageTag` (`name`) VALUES ('Euskera'); +INSERT IGNORE INTO `vn`.`itemLanguageTag` (`name`) VALUES ('Francés'); +INSERT IGNORE INTO `vn`.`itemLanguageTag` (`name`) VALUES ('Gallego'); +INSERT IGNORE INTO `vn`.`itemLanguageTag` (`name`) VALUES ('Inglés'); +INSERT IGNORE INTO `vn`.`itemLanguageTag` (`name`) VALUES ('Portugués'); + +UPDATE vn.tag + SET isFree=0, + sourceTable='itemLanguageTag' + WHERE name= 'Idioma'; + + + +CREATE TABLE IF NOT EXISTS `vn`.`itemStemTag` ( + `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`.`itemStemTag` (`name`) VALUES ('Natural'); +INSERT IGNORE INTO `vn`.`itemStemTag` (`name`) VALUES ('Seminatural'); +INSERT IGNORE INTO `vn`.`itemStemTag` (`name`) VALUES ('Sintético'); + +UPDATE vn.tag + SET isFree=0, + sourceTable='itemStemTag' + WHERE name= 'Tronco'; + + +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemFarmingTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemWrappingTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemLanguageTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemStemTag TO logisticAssist; \ No newline at end of file From a2b9a59eb532267e1084348b30b9badd9c4b1a98 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 15 Oct 2024 08:58:57 +0200 Subject: [PATCH 123/217] fix(sql): addClientObservationType --- .../11230-brownEucalyptus/00-addClientObservationType.sql | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql index 1542ff28a..b4486f9d4 100644 --- a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql +++ b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql @@ -1,3 +1,2 @@ -ALTER TABLE vn.clientObservation - ADD COLUMN IF NOT EXISTS observationTypeFk TINYINT(3) UNSIGNED NOT NULL, - ADD CONSTRAINT clientObservationTypeFk FOREIGN KEY (observationTypeFk) REFERENCES vn.observationType(id); +ALTER TABLE vn.clientObservation ADD COLUMN IF NOT EXISTS observationTypeFk TINYINT(3) UNSIGNED NOT NULL; +ALTER TABLE vn.clientObservation ADD CONSTRAINT clientObservationTypeFk FOREIGN KEY IF NOT EXISTS (observationTypeFk) REFERENCES vn.observationType(id); From e334152acc901fb1357a59d9da85c317b9b29548 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 15 Oct 2024 09:03:15 +0200 Subject: [PATCH 124/217] refactor: deleted comment --- .../ticket/back/methods/ticket-request/filter.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/ticket/back/methods/ticket-request/filter.js b/modules/ticket/back/methods/ticket-request/filter.js index 2e1d2fbae..53f90b98f 100644 --- a/modules/ticket/back/methods/ticket-request/filter.js +++ b/modules/ticket/back/methods/ticket-request/filter.js @@ -83,7 +83,12 @@ module.exports = Self => { const models = Self.app.models; const args = ctx.args; - // Apply filter by team + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (ctx.args.mine) + ctx.args.attenderFk = userId; + const teamMembersId = []; if (args.myTeam != null) { const worker = await models.Worker.findById(userId, { @@ -99,12 +104,6 @@ module.exports = Self => { teamMembersId.push(userId); } - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (ctx.args.mine) - ctx.args.attenderFk = userId; - let where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': From 8ff06d63c58e39628f8e9dae3e72d4356b491ea2 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 15 Oct 2024 09:16:07 +0200 Subject: [PATCH 125/217] fix(sql): addClientObservationType --- .../11230-brownEucalyptus/00-addClientObservationType.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql index b4486f9d4..935758b8d 100644 --- a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql +++ b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql @@ -1,2 +1,2 @@ -ALTER TABLE vn.clientObservation ADD COLUMN IF NOT EXISTS observationTypeFk TINYINT(3) UNSIGNED NOT NULL; +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); From cf78a12f3a50cac8dc3f4df4fee31cf12146e69b Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 15 Oct 2024 09:18:20 +0200 Subject: [PATCH 126/217] fix(sql): addClientObservationType --- .../11230-brownEucalyptus/00-addClientObservationType.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql index 935758b8d..f69e20611 100644 --- a/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql +++ b/db/versions/11230-brownEucalyptus/00-addClientObservationType.sql @@ -1,2 +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); From 85f8b6fd20d8001d8d8a9b40e97514448569f469 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 15 Oct 2024 09:29:38 +0200 Subject: [PATCH 127/217] build: init version 24.44 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 32c1f21d8..767ec231e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.42.0", + "version": "24.44.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From c73fd51a9ca6ff5a5cf1d7490a2ba83b1f566d85 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 15 Oct 2024 09:45:14 +0200 Subject: [PATCH 128/217] fix: refs #7986 add acl --- db/versions/11290-blackOrchid/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/versions/11290-blackOrchid/00-firstScript.sql b/db/versions/11290-blackOrchid/00-firstScript.sql index e0c0e391c..fe568ed6e 100644 --- a/db/versions/11290-blackOrchid/00-firstScript.sql +++ b/db/versions/11290-blackOrchid/00-firstScript.sql @@ -1,3 +1,6 @@ ALTER TABLE `vn`.`operator` ADD COLUMN `machineFk` int(11) DEFAULT NULL, ADD CONSTRAINT `operator_machine_FK` FOREIGN KEY (`machineFk`) REFERENCES `vn`.`machine` (`id`) ON DELETE SET NULL ON UPDATE CASCADE; + +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Machine','*','*','ALLOW','ROLE','productionBoss'); From b1b36a33a0eb7fb2215305ef56bb3e12c650ca8b Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 15 Oct 2024 09:47:39 +0200 Subject: [PATCH 129/217] chore(docuware_core): refs #8066 add returns --- back/methods/docuware/core.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/back/methods/docuware/core.js b/back/methods/docuware/core.js index 6d3bb58ed..391a8b4ab 100644 --- a/back/methods/docuware/core.js +++ b/back/methods/docuware/core.js @@ -56,8 +56,8 @@ module.exports = Self => { * @return {number} - The fileCabinet id */ Self.getDialog = async(code, action, fileCabinetId) => { - // if (!process.env.NODE_ENV) - // return Math.floor(Math.random() + 100); + if (!process.env.NODE_ENV) + return Math.floor(Math.random() + 100); const docuwareInfo = await Self.app.models.Docuware.findOne({ where: { @@ -83,8 +83,8 @@ module.exports = Self => { * @return {number} - The fileCabinet id */ Self.getFileCabinet = async code => { - // if (!process.env.NODE_ENV) - // return Math.floor(Math.random() + 100); + if (!process.env.NODE_ENV) + return Math.floor(Math.random() + 100); const options = await Self.getOptions(); const docuwareInfo = await Self.app.models.Docuware.findOne({ @@ -93,7 +93,6 @@ module.exports = Self => { } }); - console.log('options.headers: ', options.headers); const fileCabinetResponse = await axios.get(`${options.url}/FileCabinets`, options.headers); const fileCabinets = fileCabinetResponse.data.FileCabinet; const fileCabinetId = fileCabinets.find(fileCabinet => fileCabinet.Name === docuwareInfo.fileCabinetName).Id; @@ -110,7 +109,7 @@ module.exports = Self => { * @return {object} - The data */ Self.get = async(code, filter, parse) => { - // if (!process.env.NODE_ENV) return; + if (!process.env.NODE_ENV) return; const options = await Self.getOptions(); const fileCabinetId = await Self.getFileCabinet(code); @@ -133,7 +132,7 @@ module.exports = Self => { * @return {object} - The data */ Self.getById = async(code, id, parse) => { - // if (!process.env.NODE_ENV) return; + if (!process.env.NODE_ENV) return; const docuwareInfo = await Self.app.models.Docuware.findOne({ fields: ['findById'], From da55fffef02385c03945fb5ca30b0f42a8961161 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 15 Oct 2024 11:18:04 +0200 Subject: [PATCH 130/217] feat: refs #8108 addMoreTablesTag --- db/routines/vn/procedures/entry_transfer.sql | 121 ++++++++++++++++++ .../11300-limeMedeola/00-firstScript.sql | 72 ++++++++++- 2 files changed, 189 insertions(+), 4 deletions(-) create mode 100644 db/routines/vn/procedures/entry_transfer.sql diff --git a/db/routines/vn/procedures/entry_transfer.sql b/db/routines/vn/procedures/entry_transfer.sql new file mode 100644 index 000000000..6d7da2b37 --- /dev/null +++ b/db/routines/vn/procedures/entry_transfer.sql @@ -0,0 +1,121 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_transfer`(vOriginalEntry INT, OUT vNewEntry INT) +BEGIN +/** +* Adelanta a mañana la mercancia de una entrada a partir de lo que hay ubicado en el almacén +* +* @param vOriginalEntry entrada que se quiera adelantar +*/ + + DECLARE vNewEntryFk INT; + DECLARE vTravelFk INT; + DECLARE vWarehouseFk INT; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + -- Clonar la entrada + CALL entry_clone(vOriginalEntry,vNewEntryFk); + + START TRANSACTION; + + -- Hay que crear un nuevo travel, con salida hoy y llegada mañana y asignar la entrada nueva al nuevo travel. + INSERT INTO travel( + shipped, + landed, + warehouseInFk, + warehouseOutFk, + `ref`, + isReceived, + agencyModeFk) + SELECT util.VN_CURDATE(), + util.VN_CURDATE() + INTERVAL 1 DAY, + t.warehouseInFk, + t.warehouseInFk, + t.`ref`, + t.isReceived, + t.agencyModeFk + FROM travel t + JOIN entry e ON e.travelFk = t.id + WHERE e.id = vOriginalEntry; + + SET vTravelFk = LAST_INSERT_ID(); + + UPDATE entry + SET travelFk = vTravelFk + WHERE id = vNewEntryFk; + + -- Poner a 0 las cantidades + UPDATE buy b + SET b.quantity = 0, b.stickers = 0 + WHERE b.entryFk = vNewEntryFk; + + -- Eliminar duplicados + DELETE b.* + FROM buy b + LEFT JOIN (SELECT b.id, b.itemFk + FROM buy b + WHERE b.entryFk = vNewEntryFk + GROUP BY b.itemFk) tBuy ON tBuy.id = b.id + WHERE b.entryFk = vNewEntryFk + AND tBuy.id IS NULL; + + SELECT t.warehouseInFk INTO vWarehouseFk + FROM travel t + JOIN entry e ON e.travelFk = t.id + WHERE e.id = vOriginalEntry; + + -- Actualizar la nueva entrada con lo que no está ubicado HOY, descontando lo vendido HOY de esas ubicaciones + CREATE OR REPLACE TEMPORARY TABLE tBuy + ENGINE = MEMORY + SELECT tBuy.itemFk, IFNULL(iss.visible,0) visible, tBuy.totalQuantity, IFNULL(sales.sold,0) sold + FROM (SELECT b.itemFk, SUM(b.quantity) totalQuantity + FROM buy b + WHERE b.entryFk = vOriginalEntry + GROUP BY b.itemFk + ) tBuy + LEFT JOIN ( + SELECT ish.itemFk, SUM(visible) visible + 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 + WHERE s.warehouseFk = vWarehouseFk + AND sh.parked = util.VN_CURDATE() + GROUP BY ish.itemFk) iss ON tBuy.itemFk = iss.itemFk + LEFT JOIN ( + SELECT s.itemFk, SUM(s.quantity) sold + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN itemShelvingSale iss ON iss.saleFk = s.id + JOIN itemShelving is2 ON is2.id = iss.itemShelvingFk + JOIN shelving s2 ON s2.code = is2.shelvingFk + WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) + AND s2.parked = util.VN_CURDATE() + GROUP BY s.itemFk) sales ON sales.itemFk = tBuy.itemFk + WHERE visible = tBuy.totalQuantity + OR iss.itemFk IS NULL; + + UPDATE buy b + JOIN (SELECT * FROM tBuy) sub ON sub.itemFk = b.itemFk + SET b.quantity = sub.totalQuantity - sub.visible - sub.sold + WHERE b.entryFk = vNewEntryFk; + + -- Limpia la nueva entrada + DELETE b.* + FROM buy b + WHERE b.entryFk = vNewEntryFk + AND b.quantity = 0; + + COMMIT; + + SET vNewEntry = vNewEntryFk; + + CALL cache.visible_refresh(@c,TRUE,7); + CALL cache.available_refresh(@c, TRUE, 7, util.VN_CURDATE()); + +END$$ +DELIMITER ; diff --git a/db/versions/11300-limeMedeola/00-firstScript.sql b/db/versions/11300-limeMedeola/00-firstScript.sql index 21920b692..313a65e81 100644 --- a/db/versions/11300-limeMedeola/00-firstScript.sql +++ b/db/versions/11300-limeMedeola/00-firstScript.sql @@ -79,7 +79,71 @@ UPDATE vn.tag WHERE name= 'Tronco'; -GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemFarmingTag TO logisticAssist; -GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemWrappingTag TO logisticAssist; -GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemLanguageTag TO logisticAssist; -GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemStemTag TO logisticAssist; \ No newline at end of file +CREATE TABLE IF NOT EXISTS `vn`.`itemBreederTag` ( + `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`.`itemBreederTag` (`name`) VALUES ('David Austin'); + +UPDATE vn.tag + SET isFree=0, + sourceTable='itemBreederTag' + WHERE name= 'Obtentor'; + + + +CREATE TABLE IF NOT EXISTS `vn`.`itemBaseTag` ( + `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`.`itemBaseTag` (`name`) VALUES ('Biodegradable'); +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Caballete'); +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Cerámica'); +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Cristal'); +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Plástico por inyección'); +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Madera'); +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Plástico'); +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Rígido'); +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Ruedas'); +INSERT IGNORE INTO `vn`.`itemBaseTag` (`name`) VALUES ('Sin soporte rígido'); + +UPDATE vn.tag + SET isFree=0, + sourceTable='itemBaseTag' + WHERE name= 'Soporte'; + + + +CREATE TABLE IF NOT EXISTS `vn`.`itemVatRateTag` ( + `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`.`itemVatRateTag` (`name`) VALUES ('General'); +INSERT IGNORE INTO `vn`.`itemVatRateTag` (`name`) VALUES ('Reducido'); + + +UPDATE vn.tag + SET isFree=0, + sourceTable='itemVatRateTag' + WHERE name= 'Tipo de IVA'; + + +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemFarmingTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemWrappingTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemLanguageTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemStemTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemWrappingTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemBaseTag TO logisticAssist; +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemBreederTag TO logisticAssist; \ No newline at end of file From 8da005f08ab1c0775c1cfee83bbdbadff3ca0cfa Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 15 Oct 2024 11:19:08 +0200 Subject: [PATCH 131/217] feat: refs #8108 refs #9108 --- db/routines/vn/procedures/entry_transfer.sql | 121 ------------------- 1 file changed, 121 deletions(-) delete mode 100644 db/routines/vn/procedures/entry_transfer.sql diff --git a/db/routines/vn/procedures/entry_transfer.sql b/db/routines/vn/procedures/entry_transfer.sql deleted file mode 100644 index 6d7da2b37..000000000 --- a/db/routines/vn/procedures/entry_transfer.sql +++ /dev/null @@ -1,121 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_transfer`(vOriginalEntry INT, OUT vNewEntry INT) -BEGIN -/** -* Adelanta a mañana la mercancia de una entrada a partir de lo que hay ubicado en el almacén -* -* @param vOriginalEntry entrada que se quiera adelantar -*/ - - DECLARE vNewEntryFk INT; - DECLARE vTravelFk INT; - DECLARE vWarehouseFk INT; - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - -- Clonar la entrada - CALL entry_clone(vOriginalEntry,vNewEntryFk); - - START TRANSACTION; - - -- Hay que crear un nuevo travel, con salida hoy y llegada mañana y asignar la entrada nueva al nuevo travel. - INSERT INTO travel( - shipped, - landed, - warehouseInFk, - warehouseOutFk, - `ref`, - isReceived, - agencyModeFk) - SELECT util.VN_CURDATE(), - util.VN_CURDATE() + INTERVAL 1 DAY, - t.warehouseInFk, - t.warehouseInFk, - t.`ref`, - t.isReceived, - t.agencyModeFk - FROM travel t - JOIN entry e ON e.travelFk = t.id - WHERE e.id = vOriginalEntry; - - SET vTravelFk = LAST_INSERT_ID(); - - UPDATE entry - SET travelFk = vTravelFk - WHERE id = vNewEntryFk; - - -- Poner a 0 las cantidades - UPDATE buy b - SET b.quantity = 0, b.stickers = 0 - WHERE b.entryFk = vNewEntryFk; - - -- Eliminar duplicados - DELETE b.* - FROM buy b - LEFT JOIN (SELECT b.id, b.itemFk - FROM buy b - WHERE b.entryFk = vNewEntryFk - GROUP BY b.itemFk) tBuy ON tBuy.id = b.id - WHERE b.entryFk = vNewEntryFk - AND tBuy.id IS NULL; - - SELECT t.warehouseInFk INTO vWarehouseFk - FROM travel t - JOIN entry e ON e.travelFk = t.id - WHERE e.id = vOriginalEntry; - - -- Actualizar la nueva entrada con lo que no está ubicado HOY, descontando lo vendido HOY de esas ubicaciones - CREATE OR REPLACE TEMPORARY TABLE tBuy - ENGINE = MEMORY - SELECT tBuy.itemFk, IFNULL(iss.visible,0) visible, tBuy.totalQuantity, IFNULL(sales.sold,0) sold - FROM (SELECT b.itemFk, SUM(b.quantity) totalQuantity - FROM buy b - WHERE b.entryFk = vOriginalEntry - GROUP BY b.itemFk - ) tBuy - LEFT JOIN ( - SELECT ish.itemFk, SUM(visible) visible - 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 - WHERE s.warehouseFk = vWarehouseFk - AND sh.parked = util.VN_CURDATE() - GROUP BY ish.itemFk) iss ON tBuy.itemFk = iss.itemFk - LEFT JOIN ( - SELECT s.itemFk, SUM(s.quantity) sold - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN itemShelvingSale iss ON iss.saleFk = s.id - JOIN itemShelving is2 ON is2.id = iss.itemShelvingFk - JOIN shelving s2 ON s2.code = is2.shelvingFk - WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) - AND s2.parked = util.VN_CURDATE() - GROUP BY s.itemFk) sales ON sales.itemFk = tBuy.itemFk - WHERE visible = tBuy.totalQuantity - OR iss.itemFk IS NULL; - - UPDATE buy b - JOIN (SELECT * FROM tBuy) sub ON sub.itemFk = b.itemFk - SET b.quantity = sub.totalQuantity - sub.visible - sub.sold - WHERE b.entryFk = vNewEntryFk; - - -- Limpia la nueva entrada - DELETE b.* - FROM buy b - WHERE b.entryFk = vNewEntryFk - AND b.quantity = 0; - - COMMIT; - - SET vNewEntry = vNewEntryFk; - - CALL cache.visible_refresh(@c,TRUE,7); - CALL cache.available_refresh(@c, TRUE, 7, util.VN_CURDATE()); - -END$$ -DELIMITER ; From 536c2fa5b5228cc0858f47229021d6bea3290d52 Mon Sep 17 00:00:00 2001 From: ivanm Date: Tue, 15 Oct 2024 13:54:02 +0200 Subject: [PATCH 132/217] feat: refs #7994 update sale.originalQuantity --- db/versions/11251-navyChrysanthemum/00-firstScript.sql | 2 -- db/versions/11251-navyChrysanthemum/01-firstScript.sql | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/db/versions/11251-navyChrysanthemum/00-firstScript.sql b/db/versions/11251-navyChrysanthemum/00-firstScript.sql index 6ec0a66bb..801405e59 100644 --- a/db/versions/11251-navyChrysanthemum/00-firstScript.sql +++ b/db/versions/11251-navyChrysanthemum/00-firstScript.sql @@ -1,5 +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 index c942e0400..e3e08e0aa 100644 --- a/db/versions/11251-navyChrysanthemum/01-firstScript.sql +++ b/db/versions/11251-navyChrysanthemum/01-firstScript.sql @@ -1 +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 +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 From 099fe8f9502164570079c8a718249b03b9761a95 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 15 Oct 2024 14:42:35 +0200 Subject: [PATCH 133/217] fix: refs #7986 fix model --- modules/worker/back/models/operator.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/worker/back/models/operator.json b/modules/worker/back/models/operator.json index 9933babc6..b75bf6732 100644 --- a/modules/worker/back/models/operator.json +++ b/modules/worker/back/models/operator.json @@ -24,6 +24,9 @@ "warehouseFk": { "type": "number" }, + "sectorFk": { + "type": "number" + }, "labelerFk": { "type": "number" }, @@ -33,6 +36,15 @@ }, "machineFk": { "type": "number" + }, + "linesLimit": { + "type": "number" + }, + "volumeLimit": { + "type": "number" + }, + "sizeLimit": { + "type": "number" } }, "relations": { From 4a88ba5078132adee8e7f24657ee29da0445f873 Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 15 Oct 2024 15:43:12 +0200 Subject: [PATCH 134/217] feat: refs #7744 closeAll Test --- db/dump/fixtures.before.sql | 24 ++++-- loopback/locale/es.json | 1 + loopback/locale/fr.json | 1 + loopback/locale/pt.json | 1 + modules/invoiceOut/back/models/invoice-out.js | 2 + modules/ticket/back/methods/sale/usesMana.js | 2 +- .../ticket/back/methods/ticket/closeAll.js | 44 +++++----- modules/ticket/back/methods/ticket/closure.js | 10 ++- .../methods/ticket/specs/closeAll.spec.js | 80 +++++++++++++++++++ 9 files changed, 136 insertions(+), 29 deletions(-) create mode 100644 modules/ticket/back/methods/ticket/specs/closeAll.spec.js diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 7f7e50dd3..6007b73e0 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -632,14 +632,21 @@ INSERT INTO vn.invoiceOutConfig SET id = 1, parallelism = 8; -INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaFk`, `isCEE`, `type`) +INSERT INTO `vn`.`invoiceOutSerial` + (`code`,`description`, `isTaxed`, `taxAreaFk`, `isCEE`, `type`) VALUES - ('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, 'multiple'), - ('R', 'Rectificativa', 1, 'NATIONAL', 0, NULL), - ('E', 'Exportación rápida', 0, 'WORLD', 0, 'quick'); + ('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, 'multiple'), + ('R', 'Rectificativa', 1, 'NATIONAL', 0, NULL), + ('E', 'Exportación rápida', 0, 'WORLD', 0, 'quick'), + ('H', 'Intracomunitaria rápida', 0, 'CEE', 1, 'quick'), + ('P', 'Factura simplificada', 1, 'NATIONAL', 0, NULL), + ('PE', 'COOPERATIE FLORAHOLLAND UA', 0, 'CEE', 1, NULL), + ('S', 'Simplificada', 1, 'NATIONAL', 0, NULL), + ('X', 'Exportación global', 0, 'WORLD', 0, 'global'), + ('N', 'Múltiple Intracomunitaria', 0, 'CEE', 1, 'multiple'); INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`) VALUES @@ -2911,7 +2918,8 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`) (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'), - (9, 'mrw-deadline','The MRW deadline has passed'); + (9, 'mrw-deadline','The MRW deadline has passed'), + (10,'invoice-ticket-closure','Tickets not invoiced during the nightly closure ticket process'); TRUNCATE `util`.`notificationAcl`; INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 9308fd4ec..0349fa8fb 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -350,6 +350,7 @@ "Cmr file does not exist": "El archivo del cmr no existe", "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", + "No invoice series found for these parameters": "No se encontró una serie para estos parámetros", "The line could not be marked": "La linea no puede ser marcada", "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.", diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index a6648b186..23bd5cc04 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -350,6 +350,7 @@ "Cmr file does not exist": "Le fichier cmr n'existe pas", "You are not allowed to modify the alias": "Vous n'êtes pas autorisé à modifier l'alias", "The address of the customer must have information about Incoterms and Customs Agent": "L'adresse du client doit contenir des informations sur les Incoterms et l'agent des douanes", + "No invoice series found for these parameters": "Aucune série de facture trouvée pour ces paramètres", "The line could not be marked": "La ligne ne peut pas être marquée", "This password can only be changed by the user themselves": "Ce mot de passe ne peut être modifié que par l'utilisateur lui-même", "They're not your subordinate": "Ce n'est pas votre subordonné.", diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index a43f0e780..f85afd607 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -350,6 +350,7 @@ "Cmr file does not exist": "O arquivo CMR não existe", "You are not allowed to modify the alias": "Você não tem permissão para modificar o alias", "The address of the customer must have information about Incoterms and Customs Agent": "O endereço do cliente deve ter informações sobre Incoterms e Agente Aduaneiro", + "No invoice series found for these parameters": "Nenhuma série de fatura encontrada para esses parâmetros", "The line could not be marked": "A linha não pôde ser marcada", "This password can only be changed by the user themselves": "Esta senha só pode ser alterada pelo próprio usuário", "They're not your subordinate": "Eles não são seus subordinados.", diff --git a/modules/invoiceOut/back/models/invoice-out.js b/modules/invoiceOut/back/models/invoice-out.js index bab1fa375..f8fc8cdbf 100644 --- a/modules/invoiceOut/back/models/invoice-out.js +++ b/modules/invoiceOut/back/models/invoice-out.js @@ -79,6 +79,8 @@ module.exports = Self => { type ], myOptions); + if (!serial) + throw new UserError('No invoice series found for these parameters'); const invoiceOutSerial = await Self.app.models.InvoiceOutSerial.findById(serial); if (invoiceOutSerial?.taxAreaFk == 'WORLD') { diff --git a/modules/ticket/back/methods/sale/usesMana.js b/modules/ticket/back/methods/sale/usesMana.js index 31beb3a4c..b4768d80a 100644 --- a/modules/ticket/back/methods/sale/usesMana.js +++ b/modules/ticket/back/methods/sale/usesMana.js @@ -31,6 +31,6 @@ module.exports = Self => { const usesMana = departments.find(department => department.id == workerDepartment.departmentFk); - return usesMana ? true : false; + return !!usesMana; }; }; diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index 4fd72d454..1b3f84295 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -1,11 +1,17 @@ -const UserError = require('vn-loopback/util/user-error'); const closure = require('./closure'); module.exports = Self => { Self.remoteMethodCtx('closeAll', { description: 'Makes the closure process from all warehouses', accessType: 'WRITE', - accepts: [], + accepts: [ + { + arg: 'options', + type: 'object', + http: {source: 'body'}, + description: 'Optional parameters, including transaction.' + } + ], returns: { type: 'object', root: true @@ -16,21 +22,20 @@ module.exports = Self => { } }); - Self.closeAll = async ctx => { + Self.closeAll = async(ctx, 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. + const toDate = Date.vnNew(); toDate.setHours(0, 0, 0, 0); toDate.setDate(toDate.getDate() - 1); - const todayMinDate = Date.vnNew(); - todayMinDate.setHours(0, 0, 0, 0); - - const todayMaxDate = Date.vnNew(); - todayMaxDate.setHours(23, 59, 59, 59); - - // Prevent closure for current day - if (toDate >= todayMinDate && toDate <= todayMaxDate) - throw new UserError('You cannot close tickets for today'); - const tickets = await Self.rawSql(` SELECT t.id, t.clientFk, @@ -58,12 +63,12 @@ module.exports = Self => { AND t.shipped BETWEEN ? - INTERVAL tc.closureDaysAgo DAY AND util.dayEnd(?) AND t.refFk IS NULL GROUP BY t.id - `, [toDate, toDate]); + `, [toDate, toDate], myOptions); const ticketIds = tickets.map(ticket => ticket.id); await Self.rawSql(` INSERT INTO util.debug (variable, value) VALUES ('nightInvoicing', ?) - `, [ticketIds.join(',')]); + `, [ticketIds.join(',')], myOptions); await Self.rawSql(` WITH ticketNotInvoiceable AS( @@ -133,9 +138,9 @@ module.exports = Self => { ) SELECT IF(errors = '{"tickets": null}', 'No errors', util.notification_send('invoice-ticket-closure', errors, NULL)) - FROM ticketNotInvoiceable`, [toDate, toDate]); + FROM ticketNotInvoiceable`, [toDate, toDate], myOptions); - await closure(ctx, Self, tickets); + await closure(ctx, Self, tickets, myOptions); await Self.rawSql(` UPDATE ticket t @@ -150,7 +155,10 @@ module.exports = Self => { AND al.code NOT IN ('DELIVERED', 'PACKED') AND NOT t.packages AND tob.id IS NULL - AND t.routeFk`, [toDate, toDate], {userId: ctx.req.accessToken.userId}); + AND t.routeFk`, [toDate, toDate], 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 56bd6eccd..64f198834 100644 --- a/modules/ticket/back/methods/ticket/closure.js +++ b/modules/ticket/back/methods/ticket/closure.js @@ -19,9 +19,15 @@ module.exports = async function(ctx, Self, tickets, options) { const failedtickets = []; for (const ticket of tickets) { try { - await Self.rawSql(`CALL util.debugAdd('invoicingTicket', ?)`, [ticket.id], {userId}); + await Self.rawSql(`CALL util.debugAdd('invoicingTicket', ?)`, [ticket.id], {userId}, + myOptions); - await Self.app.models.InvoiceOut.getSerial(ticket.clientFk, ticket.companyFk, ticket.addressFk, 'quick'); + await Self.app.models.InvoiceOut.getSerial( + ticket.clientFk, + ticket.companyFk, + ticket.addressFk, + 'quick', + myOptions); await Self.rawSql( `CALL vn.ticket_closeByTicket(?)`, [ticket.id], diff --git a/modules/ticket/back/methods/ticket/specs/closeAll.spec.js b/modules/ticket/back/methods/ticket/specs/closeAll.spec.js new file mode 100644 index 000000000..4b067ce7e --- /dev/null +++ b/modules/ticket/back/methods/ticket/specs/closeAll.spec.js @@ -0,0 +1,80 @@ +const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); + +fdescribe('Ticket Closure - closeAll function', () => { + let ctx = { + req: { + getLocale: () => 'es', + accessToken: {userId: 1106}, + headers: {origin: 'http://localhost'}, + __: value => value, + }, + args: {} + }; + let options; + let tx; + let originalVnNew; + + beforeEach(async() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: ctx.req}); + tx = await models.Ticket.beginTransaction({}); + options = {transaction: tx}; + originalVnNew = Date.vnNew; + spyOn(Date, 'vnNew').and.callFake(() => { + const mockDate = originalVnNew(); + mockDate.setDate(mockDate.getDate() + 1); + return mockDate; + }); + }); + + afterEach(async() => { + if (tx) + await tx.rollback(); + }); + + xit('should successfully close all tickets when conditions are met', async() => { + const ticketsBefore = await models.Ticket.find({ + where: { + packages: {neq: 0} + } + }, options); + const packedTicketsIds = ticketsBefore.map(ticket => ticket.id); + + const packedTicketsBefore = await models.TicketLastState.find({ + where: { + ticketFk: {inq: packedTicketsIds}, + lastState: 'Encajado' + } + }, options); + + await models.Ticket.closeAll(ctx, options); + + const packedTicketsAfter = await models.TicketLastState.find({ + where: { + ticketFk: {inq: packedTicketsIds}, + lastState: 'Encajado' + } + }, options); + + expect(packedTicketsBefore.length).toBeGreaterThan(packedTicketsAfter.length); + }); + + fit('should set routeFk to NULL when conditions are met', async() => { + const ticketsBefore = await models.Ticket.find({ + where: { + routeFk: {neq: null} + } + }, options); + + await models.Ticket.closeAll(ctx, options); + + const ticketsAfter = await models.Ticket.find({ + where: { + id: {inq: ticketsBefore.map(ticket => ticket.id)}, + routeFk: {neq: null} + } + }, options); + + expect(ticketsBefore.length).toBeGreaterThan(ticketsAfter.length); + }); +}); From b592ccc1624542e0f9efc1c9dedca4d12566f3bd Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 15 Oct 2024 17:01:09 +0200 Subject: [PATCH 135/217] fix: refs #6861 getTickets --- back/methods/collection/getTickets.js | 6 ++++-- db/routines/vn/triggers/itemShelvingSale_afterInsert.sql | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/back/methods/collection/getTickets.js b/back/methods/collection/getTickets.js index 2a2b67524..48301a366 100644 --- a/back/methods/collection/getTickets.js +++ b/back/methods/collection/getTickets.js @@ -62,7 +62,8 @@ module.exports = Self => { p.code parkingCodePrevia, p.pickingOrder pickingOrderPrevia, iss.id itemShelvingSaleFk, - iss.isPicked + iss.isPicked, + iss.itemShelvingFk FROM ticketCollection tc LEFT JOIN collection c ON c.id = tc.collectionFk JOIN sale s ON s.ticketFk = tc.ticketFk @@ -102,7 +103,8 @@ module.exports = Self => { p.code, p.pickingOrder, iss.id itemShelvingSaleFk, - iss.isPicked + iss.isPicked, + iss.itemShelvingFk FROM sectorCollection sc JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id JOIN saleGroup sg ON sg.id = ss.saleGroupFk diff --git a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql index 3531b094c..5ad83d289 100644 --- a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql +++ b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql @@ -3,10 +3,10 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelvingSale_afterI AFTER INSERT ON `itemShelvingSale` FOR EACH ROW BEGIN - UPDATE sale s JOIN operator o ON o.workerFk = account.myUser_getId() - SET s.isPicked = IF(o.isOnReservationMode, s.isPicked, TRUE) + JOIN sector se ON s.id = o.sectorFk + SET s.isPicked = IF((se.isOnReservationMode IS NULL AND o.isOnReservationMode) OR se.isOnReservationMode, s.isPicked, TRUE) WHERE id = NEW.saleFk; END$$ DELIMITER ; \ No newline at end of file From 2adc424ccb3814a51a87e3b1cdfba0ca86b4da5e Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 15 Oct 2024 17:07:35 +0200 Subject: [PATCH 136/217] fix: refs #6861 getTickets --- db/routines/vn/triggers/itemShelvingSale_afterInsert.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql index 5ad83d289..1980691b5 100644 --- a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql +++ b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelvingSale_afterI BEGIN UPDATE sale s JOIN operator o ON o.workerFk = account.myUser_getId() - JOIN sector se ON s.id = o.sectorFk + JOIN sector se ON se.id = o.sectorFk SET s.isPicked = IF((se.isOnReservationMode IS NULL AND o.isOnReservationMode) OR se.isOnReservationMode, s.isPicked, TRUE) WHERE id = NEW.saleFk; END$$ From d57f4fc44a7711b891b65b19c7ec8a9b6104abbf Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 15 Oct 2024 17:24:14 +0200 Subject: [PATCH 137/217] chore: refs #7919 refactor, drop relation on back --- db/routines/vn/triggers/ticket_afterUpdate.sql | 5 ----- modules/ticket/back/methods/ticket/setDeleted.js | 5 ++++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/triggers/ticket_afterUpdate.sql b/db/routines/vn/triggers/ticket_afterUpdate.sql index e849c1faa..f6c5e6523 100644 --- a/db/routines/vn/triggers/ticket_afterUpdate.sql +++ b/db/routines/vn/triggers/ticket_afterUpdate.sql @@ -12,10 +12,5 @@ BEGIN CALL ticket_doCmr(NEW.id); END IF; END IF; - - IF NEW.isDeleted THEN - DELETE FROM ticketRefund - WHERE refundTicketFk = NEW.id; - END IF; END$$ DELIMITER ; diff --git a/modules/ticket/back/methods/ticket/setDeleted.js b/modules/ticket/back/methods/ticket/setDeleted.js index a684e1cbc..e868e9258 100644 --- a/modules/ticket/back/methods/ticket/setDeleted.js +++ b/modules/ticket/back/methods/ticket/setDeleted.js @@ -49,9 +49,12 @@ module.exports = Self => { where: {originalTicketFk: id} }, myOptions); + const isRefund = !!ticketRefunds?.length; + const allDeleted = ticketRefunds.every(refund => refund.refundTicket().isDeleted); - if (ticketRefunds?.length && !allDeleted) { + if (!isRefund) await models.TicketRefund.destroyAll({refundTicketFk: id}, myOptions); + if (isRefund && !allDeleted) { const notDeleted = []; for (const refund of ticketRefunds) if (!refund.refundTicket().isDeleted) notDeleted.push(refund.refundTicket().id); From 12abca0a2d2819e559e4d64a8ee147a89c278c00 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 15 Oct 2024 18:12:07 +0200 Subject: [PATCH 138/217] fix: refs #6861 getTickets --- db/routines/vn/triggers/itemShelvingSale_afterInsert.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql index 1980691b5..ad4a6f670 100644 --- a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql +++ b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql @@ -6,7 +6,7 @@ BEGIN UPDATE sale s JOIN operator o ON o.workerFk = account.myUser_getId() JOIN sector se ON se.id = o.sectorFk - SET s.isPicked = IF((se.isOnReservationMode IS NULL AND o.isOnReservationMode) OR se.isOnReservationMode, s.isPicked, TRUE) - WHERE id = NEW.saleFk; + SET s.isPicked = IF(IFNULL(se.isOnReservationMode, o.isOnReservationMode), s.isPicked, TRUE) + WHERE s.id = NEW.saleFk; END$$ DELIMITER ; \ No newline at end of file From 46e657675b1ce8ae70c1742c41d17746892978e9 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 16 Oct 2024 08:26:39 +0200 Subject: [PATCH 139/217] fix: refs #7906 remake method --- loopback/locale/en.json | 3 ++- loopback/locale/es.json | 5 +++-- modules/zone/back/methods/zone/deleteZone.js | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index ea84cb6eb..a7e21960b 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -240,5 +240,6 @@ "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" + "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line", + "There are tickets for this area, delete them first": "There are tickets for this area, delete them first" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 9308fd4ec..6d50f634e 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -382,5 +382,6 @@ "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 + "type cannot be blank": "Se debe rellenar el tipo", + "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero" +} diff --git a/modules/zone/back/methods/zone/deleteZone.js b/modules/zone/back/methods/zone/deleteZone.js index a75302703..34ab177ac 100644 --- a/modules/zone/back/methods/zone/deleteZone.js +++ b/modules/zone/back/methods/zone/deleteZone.js @@ -1,3 +1,4 @@ +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('deleteZone', { description: 'Delete a zone', @@ -57,7 +58,8 @@ module.exports = Self => { where: {id: userId} }, myOptions); - await models.Ticket.rawSql('UPDATE ticket SET zoneFk = NULL WHERE zoneFk = ?', [id], myOptions); + if (ticketList.length > 0) + throw new UserError('There are tickets for this area, delete them first'); for (ticket of ticketList) { if (ticket.ticketState().alertLevel == 0) { From c6e764b478b9481376f187c32c9c73b5b26cb23d Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 16 Oct 2024 08:32:10 +0200 Subject: [PATCH 140/217] feat: refs #7348 hasDailyInvoice from client --- back/models/autonomy.json | 6 +- back/models/country.json | 4 + back/models/province.json | 5 +- db/routines/vn/procedures/client_create.sql | 10 +- db/routines/vn/procedures/ticket_close.sql | 7 +- .../11302-limeTulip/00-firstScript.sql | 13 ++ .../back/methods/client/createWithUser.js | 20 ++- .../client/specs/createWithUser.spec.js | 143 +++++++++++------- .../ticket/back/methods/ticket/closeAll.js | 4 +- .../back/methods/ticket/closeByTicket.js | 4 +- 10 files changed, 145 insertions(+), 71 deletions(-) create mode 100644 db/versions/11302-limeTulip/00-firstScript.sql diff --git a/back/models/autonomy.json b/back/models/autonomy.json index 8c9d82936..214061cf5 100644 --- a/back/models/autonomy.json +++ b/back/models/autonomy.json @@ -16,6 +16,10 @@ "name": { "type": "string", "required": true + }, + "hasDailyInvoice": { + "type": "boolean", + "description": "Indicates if the autonomy has daily invoice enabled" } }, "relations": { @@ -40,4 +44,4 @@ "permission": "ALLOW" } ] -} \ No newline at end of file +} diff --git a/back/models/country.json b/back/models/country.json index 5b9d842a8..80d456702 100644 --- a/back/models/country.json +++ b/back/models/country.json @@ -28,6 +28,10 @@ }, "continentFk": { "type": "number" + }, + "hasDailyInvoice": { + "type": "boolean", + "description": "Indicates if the autonomy has daily invoice enabled" } }, "relations": { diff --git a/back/models/province.json b/back/models/province.json index 77e0b24a6..61a1574d7 100644 --- a/back/models/province.json +++ b/back/models/province.json @@ -16,6 +16,9 @@ "name": { "type": "string", "required": true + }, + "autonomyFk": { + "type": "number" } }, "relations": { @@ -55,4 +58,4 @@ "permission": "ALLOW" } ] -} \ No newline at end of file +} diff --git a/db/routines/vn/procedures/client_create.sql b/db/routines/vn/procedures/client_create.sql index 3df3df905..fad01c107 100644 --- a/db/routines/vn/procedures/client_create.sql +++ b/db/routines/vn/procedures/client_create.sql @@ -34,22 +34,19 @@ BEGIN DECLARE vIsTaxDataChecked TINYINT(1); DECLARE vHasCoreVnl BOOLEAN; DECLARE vMandateTypeFk INT; - DECLARE vHasDailyInvoice BOOLEAN; SELECT cc.defaultPayMethodFk, cc.defaultDueDay, cc.defaultCredit, cc.defaultIsTaxDataChecked, cc.defaultHasCoreVnl, - cc.defaultMandateTypeFk, - c.hasDailyInvoice + cc.defaultMandateTypeFk INTO vPayMethodFk, vDueDay, vDefaultCredit, vIsTaxDataChecked, vHasCoreVnl, - vMandateTypeFk, - vHasDailyInvoice + vMandateTypeFk FROM clientConfig cc LEFT JOIN province p ON p.id = vProvinceFk LEFT JOIN country c ON c.id = p.countryFk; @@ -70,8 +67,7 @@ BEGIN credit = vDefaultCredit, isTaxDataChecked = vIsTaxDataChecked, hasCoreVnl = vHasCoreVnl, - isEqualizated = FALSE, - hasDailyInvoice = vHasDailyInvoice + isEqualizated = FALSE ON duplicate KEY UPDATE payMethodFk = vPayMethodFk, dueDay = vDueDay, diff --git a/db/routines/vn/procedures/ticket_close.sql b/db/routines/vn/procedures/ticket_close.sql index 0da001ffa..e2dcef9a5 100644 --- a/db/routines/vn/procedures/ticket_close.sql +++ b/db/routines/vn/procedures/ticket_close.sql @@ -43,7 +43,7 @@ BEGIN c.isTaxDataChecked, t.companyFk, t.shipped, - IFNULL(a.hasDailyInvoice, co.hasDailyInvoice), + c.hasDailyInvoice, w.isManaged, c.hasToInvoice INTO vClientFk, @@ -55,9 +55,6 @@ BEGIN 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 - JOIN country co ON co.id = p.countryFk JOIN warehouse w ON w.id = t.warehouseFk WHERE t.id = vCurTicketFk; @@ -85,7 +82,7 @@ BEGIN IF(vHasDailyInvoice) AND vHasToInvoice THEN SELECT invoiceSerial(vClientFk, vCompanyFk, 'quick') INTO vSerial; - IF vSerial IS NULL THEN + IF vSerial IS NULL THEN CALL util.throw('Cannot booking without a serial'); END IF; diff --git a/db/versions/11302-limeTulip/00-firstScript.sql b/db/versions/11302-limeTulip/00-firstScript.sql new file mode 100644 index 000000000..7bda31b64 --- /dev/null +++ b/db/versions/11302-limeTulip/00-firstScript.sql @@ -0,0 +1,13 @@ + +UPDATE `vn`.`client` c + JOIN `vn`.`country` co ON co.id=c.countryFk +SET c.hasDailyInvoice = co.hasDailyInvoice +WHERE co.hasDailyInvoice IS NOT NULL + AND c.hasDailyInvoice = FALSE; + +UPDATE `vn`.`client` c + JOIN `vn`.`province` p ON p.id=c.provinceFk + JOIN `vn`.`autonomy` a ON a.id = p.autonomyFk +SET c.hasDailyInvoice = a.hasDailyInvoice +WHERE a.hasDailyInvoice IS NOT NULL + AND c.hasDailyInvoice = FALSE; diff --git a/modules/client/back/methods/client/createWithUser.js b/modules/client/back/methods/client/createWithUser.js index 06b885ab8..c8cd282e1 100644 --- a/modules/client/back/methods/client/createWithUser.js +++ b/modules/client/back/methods/client/createWithUser.js @@ -43,6 +43,23 @@ module.exports = function(Self) { }; try { + const province = await models.Province.findOne({ + where: {id: data.provinceFk}, + fields: ['autonomyFk'] + }); + + const autonomy = province ? await models.Autonomy.findOne({ + where: {id: province.autonomyFk}, + fields: ['hasDailyInvoice'] + }) : null; + + const country = await models.Country.findOne({ + where: {id: data.countryFk}, + fields: ['hasDailyInvoice'] + }); + + const hasDailyInvoice = (autonomy?.hasDailyInvoice ?? country?.hasDailyInvoice) || false; + const account = await models.VnUser.create(user, myOptions); const client = await Self.create({ id: account.id, @@ -57,7 +74,8 @@ module.exports = function(Self) { provinceFk: data.provinceFk, countryFk: data.countryFk, isEqualizated: data.isEqualizated, - businessTypeFk: data.businessTypeFk + businessTypeFk: data.businessTypeFk, + hasDailyInvoice: hasDailyInvoice }, myOptions); const address = await models.Address.create({ diff --git a/modules/client/back/methods/client/specs/createWithUser.spec.js b/modules/client/back/methods/client/specs/createWithUser.spec.js index 5b1ff5da9..f47c24087 100644 --- a/modules/client/back/methods/client/specs/createWithUser.spec.js +++ b/modules/client/back/methods/client/specs/createWithUser.spec.js @@ -1,67 +1,79 @@ const models = require('vn-loopback/server/server').models; + describe('Client Create', () => { - const newAccount = { - userName: 'deadpool', - email: 'deadpool@marvel.com', - fi: '16195279J', - name: 'Wade', - socialName: 'DEADPOOL MARVEL', - street: 'WALL STREET', - city: 'New York', - businessTypeFk: 'florist', - provinceFk: 1 - }; - const newAccountWithoutEmail = JSON.parse(JSON.stringify(newAccount)); - delete newAccountWithoutEmail.email; + let options; + let tx; beforeAll.mockLoopBackContext(); - it(`should not find deadpool as he's not created yet`, async() => { - const tx = await models.Client.beginTransaction({}); + beforeEach(async() => { + tx = await models.Client.beginTransaction({}); + options = {transaction: tx}; + }); + afterEach(async() => await tx.rollback()); + + it('should not find deadpool as he is not created yet', async() => { try { - const options = {transaction: tx}; + const account = await models.VnUser.findOne({where: {name: 'deadpool'}}, options); + const client = await models.Client.findOne({where: {name: 'Wade'}}, options); - const account = await models.VnUser.findOne({where: {name: newAccount.userName}}, options); - const client = await models.Client.findOne({where: {name: newAccount.name}}, options); - - expect(account).toEqual(null); - expect(client).toEqual(null); - - await tx.rollback(); + expect(account).toBeNull(); + expect(client).toBeNull(); } catch (e) { await tx.rollback(); throw e; } }); - it('should not create a new account', async() => { - const tx = await models.Client.beginTransaction({}); - + it('should throw an error when creating a new account without email', async() => { let error; + const newAccountWithoutEmail = { + userName: 'deadpool', + fi: '16195279J', + name: 'Wade', + socialName: 'DEADPOOL MARVEL', + street: 'WALL STREET', + city: 'New York', + businessTypeFk: 'florist', + provinceFk: 1 + }; + try { - const options = {transaction: tx}; await models.Client.createWithUser(newAccountWithoutEmail, options); - - await tx.rollback(); + fail('shapoifaspodifa spdofij'); } catch (e) { - error = e.message; - - await tx.rollback(); + error = e; } - expect(error).toEqual(`An email is necessary`); + expect(error.message).toEqual('An email is necessary'); }); - it('should create a new account', async() => { - const tx = await models.Client.beginTransaction({}); + it('should create a new account with dailyInvoice', async() => { + const newAccount = { + userName: 'deadpool', + email: 'deadpool@marvel.com', + fi: '16195279J', + name: 'Wade', + socialName: 'DEADPOOL MARVEL', + street: 'WALL STREET', + city: 'New York', + businessTypeFk: 'florist', + provinceFk: 1 + }; try { - const options = {transaction: tx}; + const province = await models.Province.findById(newAccount.provinceFk, { + fields: ['id', 'name', 'autonomyFk'], + include: { + relation: 'autonomy' + } + }, options); const client = await models.Client.createWithUser(newAccount, options); const account = await models.VnUser.findOne({where: {name: newAccount.userName}}, options); + expect(province.autonomy().hasDailyInvoice).toBeTruthy(); expect(account.name).toEqual(newAccount.userName); expect(client.id).toEqual(account.id); expect(client.name).toEqual(newAccount.name); @@ -69,8 +81,38 @@ describe('Client Create', () => { expect(client.fi).toEqual(newAccount.fi); expect(client.socialName).toEqual(newAccount.socialName); expect(client.businessTypeFk).toEqual(newAccount.businessTypeFk); - + expect(client.hasDailyInvoice).toBeTruthy(); + } catch (e) { await tx.rollback(); + throw e; + } + }); + + it('should create a new account without dailyInvoice', async() => { + const newAccount = { + userName: 'deadpool', + email: 'deadpool@marvel.com', + fi: '16195279J', + name: 'Wade', + socialName: 'DEADPOOL MARVEL', + street: 'WALL STREET', + city: 'New York', + businessTypeFk: 'florist', + provinceFk: 3 + }; + + try { + const province = await models.Province.findById(newAccount.provinceFk, { + fields: ['id', 'name', 'autonomyFk'], + include: { + relation: 'autonomy' + } + }, options); + + const client = await models.Client.createWithUser(newAccount, options); + + expect(province.autonomy.hasDailyInvoice).toBeFalsy(); + expect(client.hasDailyInvoice).toBeFalsy(); } catch (e) { await tx.rollback(); throw e; @@ -78,26 +120,25 @@ describe('Client Create', () => { }); it('should not be able to create a user if exists', async() => { - const tx = await models.Client.beginTransaction({}); - let error; - + const newAccount = { + userName: 'deadpool', + email: 'deadpool@marvel.com', + fi: '16195279J', + name: 'Wade', + socialName: 'DEADPOOL MARVEL', + street: 'WALL STREET', + city: 'New York', + businessTypeFk: 'florist', + provinceFk: 1 + }; try { - const options = {transaction: tx}; - await models.Client.createWithUser(newAccount, options); - const client = await models.Client.createWithUser(newAccount, options); - - expect(client).toBeNull(); - - await tx.rollback(); + await models.Client.createWithUser(newAccount, options); } catch (e) { - await tx.rollback(); error = e; } - const errorName = error.details.codes.name[0]; - - expect(errorName).toEqual('uniqueness'); + expect(error.message).toContain('already exists'); }); }); diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index 4fd72d454..b9060d2f2 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -41,7 +41,7 @@ module.exports = Self => { c.salesPersonFk, c.isToBeMailed, c.hasToInvoice, - co.hasDailyInvoice, + c.hasDailyInvoice, eu.email salesPersonEmail, t.addressFk FROM ticket t @@ -120,7 +120,7 @@ module.exports = Self => { WHERE (al.code = 'PACKED' OR (am.code = 'refund' AND al.code <> 'delivered')) AND t.shipped BETWEEN ? - INTERVAL tc.closureDaysAgo DAY AND util.dayEnd(?) AND t.refFk IS NULL - AND IFNULL(a.hasDailyInvoice, co.hasDailyInvoice) + AND c.hasDailyInvoice GROUP BY ticketFk HAVING hasErrorToInvoice OR hasErrorTaxDataChecked diff --git a/modules/ticket/back/methods/ticket/closeByTicket.js b/modules/ticket/back/methods/ticket/closeByTicket.js index 40fe048a5..8a21267b6 100644 --- a/modules/ticket/back/methods/ticket/closeByTicket.js +++ b/modules/ticket/back/methods/ticket/closeByTicket.js @@ -50,7 +50,7 @@ module.exports = Self => { c.salesPersonFk, c.isToBeMailed, c.hasToInvoice, - co.hasDailyInvoice, + c.hasDailyInvoice, eu.email salesPersonEmail, t.addressFk FROM expedition e @@ -58,8 +58,6 @@ module.exports = Self => { 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.id = ? From aac4dd0a6d1719ccc9937faa67871b5dd205bc78 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 16 Oct 2024 08:52:27 +0200 Subject: [PATCH 141/217] feat: refs #7348 minor bug --- modules/client/back/methods/client/specs/createWithUser.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/client/back/methods/client/specs/createWithUser.spec.js b/modules/client/back/methods/client/specs/createWithUser.spec.js index f47c24087..8cff96ac5 100644 --- a/modules/client/back/methods/client/specs/createWithUser.spec.js +++ b/modules/client/back/methods/client/specs/createWithUser.spec.js @@ -41,7 +41,6 @@ describe('Client Create', () => { try { await models.Client.createWithUser(newAccountWithoutEmail, options); - fail('shapoifaspodifa spdofij'); } catch (e) { error = e; } From c355fcfece4c201ae7ab183d4c1237530f26f755 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 16 Oct 2024 09:03:47 +0200 Subject: [PATCH 142/217] test(docuware_core): refs #8066 adapt --- back/methods/docuware/core.js | 4 +- back/methods/docuware/specs/core.spec.js | 164 ++++++++++++----------- 2 files changed, 86 insertions(+), 82 deletions(-) diff --git a/back/methods/docuware/core.js b/back/methods/docuware/core.js index 391a8b4ab..3de33b786 100644 --- a/back/methods/docuware/core.js +++ b/back/methods/docuware/core.js @@ -8,10 +8,10 @@ module.exports = Self => { */ Self.getOptions = async() => { const docuwareConfig = await Self.app.models.DocuwareConfig.findOne(); - const now = new Date().getTime(); + const now = Date.vnNow(); let {url, username, password, token, expired} = docuwareConfig; - if (!expired || expired < now + 60) { + if (process.env.NODE_ENV && (!expired || expired < now + 60)) { const {data: {IdentityServiceUrl}} = await axios.get(`${url}/Home/IdentityServiceInfo`); const {data: {token_endpoint}} = await axios.get(`${IdentityServiceUrl}/.well-known/openid-configuration`); const {data} = await axios.post(token_endpoint, { diff --git a/back/methods/docuware/specs/core.spec.js b/back/methods/docuware/specs/core.spec.js index cdf8a3b62..47580483d 100644 --- a/back/methods/docuware/specs/core.spec.js +++ b/back/methods/docuware/specs/core.spec.js @@ -2,87 +2,54 @@ const axios = require('axios'); const models = require('vn-loopback/server/server').models; describe('Docuware core', () => { - beforeAll(() => { + const fileCabinetCode = 'deliveryNote'; + beforeAll(async() => { process.env.NODE_ENV = 'testing'; - }); - afterAll(() => { - delete process.env.NODE_ENV; - }); - - describe('getOptions()', () => { - it('should return url and headers', async() => { - const result = await models.Docuware.getOptions(); - - expect(result.url).toBeDefined(); - expect(result.headers).toBeDefined(); + const docuwareInfo = await models.Docuware.findOne({ + where: { + code: fileCabinetCode + } }); - }); - describe('getDialog()', () => { - it('should return dialogId', async() => { - const dialogs = { - data: { - Dialog: [ - { - DisplayName: 'find', - Id: 'getDialogTest' - } - ] - } - }; - spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(dialogs))); - const result = await models.Docuware.getDialog('deliveryNote', 'find', 'randomFileCabinetId'); + spyOn(axios, 'get').and.callFake(url => { + if (url.includes('IdentityServiceInfo')) return {data: {IdentityServiceUrl: 'IdentityServiceUrl'}}; + if (url.includes('IdentityServiceUrl')) return {data: {token_endpoint: 'token_endpoint'}}; + if (url.includes('dialogs')) { + return { + data: { + Dialog: [ + { + DisplayName: 'find', + Id: 'getDialogTest' + } + ] + } + }; + } - expect(result).toEqual('getDialogTest'); - }); - }); - - describe('getFileCabinet()', () => { - it('should return fileCabinetId', async() => { - const code = 'deliveryNote'; - const docuwareInfo = await models.Docuware.findOne({ - where: { - code - } - }); - const dialogs = { - data: { + if (url.includes('FileCabinets')) { + return {data: { FileCabinet: [ { Name: docuwareInfo.fileCabinetName, Id: 'getFileCabinetTest' } ] - } - }; - spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(dialogs))); - const result = await models.Docuware.getFileCabinet(code); - - expect(result).toEqual('getFileCabinetTest'); - }); - }); - - describe('get()', () => { - it('should return data without parse', async() => { - spyOn(models.Docuware, 'getFileCabinet').and.returnValue((new Promise(resolve => resolve(Math.random())))); - spyOn(models.Docuware, 'getDialog').and.returnValue((new Promise(resolve => resolve(Math.random())))); - const data = { - data: { - id: 1 - } - }; - spyOn(axios, 'post').and.returnValue(new Promise(resolve => resolve(data))); - const result = await models.Docuware.get('deliveryNote'); - - expect(result.id).toEqual(1); + }}; + } }); - it('should return data with parse', async() => { - spyOn(models.Docuware, 'getFileCabinet').and.returnValue((new Promise(resolve => resolve(Math.random())))); - spyOn(models.Docuware, 'getDialog').and.returnValue((new Promise(resolve => resolve(Math.random())))); - const data = { - data: { + spyOn(axios, 'post').and.callFake(url => { + if (url.includes('token_endpoint')) { + return {data: { + access_token: 'access_token', + token_type: 'bearer', + expires_in: 10000 + }}; + } + if (url.includes('DialogExpression')) { + return {data: { Items: [{ Fields: [ { @@ -103,12 +70,52 @@ describe('Docuware core', () => { ] }] } - }; + }; + } + }); + }); + + afterAll(() => { + delete process.env.NODE_ENV; + }); + + describe('getOptions()', () => { + it('should return url and headers', async() => { + const result = await models.Docuware.getOptions(); + + expect(result.url).toBeDefined(); + expect(result.headers).toBeDefined(); + }); + }); + + describe('Dialog()', () => { + it('should return dialogId', async() => { + const result = await models.Docuware.getDialog('deliveryNote', 'find', 'randomFileCabinetId'); + + expect(result).toEqual('getDialogTest'); + }); + }); + + describe('getFileCabinet()', () => { + it('should return fileCabinetId', async() => { + const result = await models.Docuware.getFileCabinet(fileCabinetCode); + + expect(result).toEqual('getFileCabinetTest'); + }); + }); + + describe('get()', () => { + it('should return data without parse', async() => { + const [result] = await models.Docuware.get('deliveryNote'); + + expect(result.firstRequiredField).toEqual(1); + }); + + it('should return data with parse', async() => { const parse = { 'firstRequiredField': 'id', 'secondRequiredField': 'name', }; - spyOn(axios, 'post').and.returnValue(new Promise(resolve => resolve(data))); const [result] = await models.Docuware.get('deliveryNote', null, parse); expect(result.id).toEqual(1); @@ -119,17 +126,14 @@ describe('Docuware core', () => { describe('getById()', () => { it('should return data', async() => { - spyOn(models.Docuware, 'getFileCabinet').and.returnValue((new Promise(resolve => resolve(Math.random())))); - spyOn(models.Docuware, 'getDialog').and.returnValue((new Promise(resolve => resolve(Math.random())))); - const data = { - data: { - id: 1 - } - }; - spyOn(axios, 'post').and.returnValue(new Promise(resolve => resolve(data))); - const result = await models.Docuware.getById('deliveryNote', 1); + spyOn(models.Docuware, 'get'); + await models.Docuware.getById('deliveryNote', 1); - expect(result.id).toEqual(1); + expect(models.Docuware.get).toHaveBeenCalledWith( + 'deliveryNote', + {condition: [Object({DBName: 'N__ALBAR_N', Value: [1]})]}, + undefined + ); }); }); }); From 8ca097d4a9fc979fe14e4a25e4b3e0df503d1daf Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 16 Oct 2024 09:23:39 +0200 Subject: [PATCH 143/217] chore: refs #7919 change var name --- modules/ticket/back/methods/ticket/setDeleted.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/setDeleted.js b/modules/ticket/back/methods/ticket/setDeleted.js index e868e9258..fcab95ee2 100644 --- a/modules/ticket/back/methods/ticket/setDeleted.js +++ b/modules/ticket/back/methods/ticket/setDeleted.js @@ -49,12 +49,12 @@ module.exports = Self => { where: {originalTicketFk: id} }, myOptions); - const isRefund = !!ticketRefunds?.length; + const hasRefund = !!ticketRefunds?.length; const allDeleted = ticketRefunds.every(refund => refund.refundTicket().isDeleted); - if (!isRefund) await models.TicketRefund.destroyAll({refundTicketFk: id}, myOptions); - if (isRefund && !allDeleted) { + if (!hasRefund) await models.TicketRefund.destroyAll({refundTicketFk: id}, myOptions); + if (hasRefund && !allDeleted) { const notDeleted = []; for (const refund of ticketRefunds) if (!refund.refundTicket().isDeleted) notDeleted.push(refund.refundTicket().id); From c5aa7dc44e4bac9148b226420e9a687054c037fa Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 16 Oct 2024 09:30:37 +0200 Subject: [PATCH 144/217] fix: refs #7906 edit test --- .../zone/back/methods/zone/specs/deleteZone.spec.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js index 08dafd181..60e704161 100644 --- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js +++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js @@ -8,7 +8,7 @@ describe('zone deletezone()', () => { __: value => value }; const ctx = {req: activeCtx}; - const zoneId = 9; + const zoneId = 4; let ticketIDs; let originalTicketStates; @@ -35,18 +35,8 @@ describe('zone deletezone()', () => { await models.Zone.deleteZone(ctx, zoneId, options); const updatedZone = await models.Zone.findById(zoneId, null, options); - const anUpdatedTicket = await models.Ticket.findById(ticketIDs[0], null, options); - - const updatedTicketStates = await models.TicketState.find({ - where: { - ticketFk: {inq: ticketIDs}, - code: 'FIXING' - } - }, options); expect(updatedZone).toBeNull(); - expect(anUpdatedTicket.zoneFk).toBeNull(); - expect(updatedTicketStates.length).toBeGreaterThan(originalTicketStates.length); await tx.rollback(); } catch (e) { From 8f01e4d110ad040c33674bb5b51664d0e3dd93be Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 16 Oct 2024 09:32:15 +0200 Subject: [PATCH 145/217] fix: refs #7353 redirect to lilium --- modules/monitor/front/locale/es.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 modules/monitor/front/locale/es.yml diff --git a/modules/monitor/front/locale/es.yml b/modules/monitor/front/locale/es.yml new file mode 100644 index 000000000..01b26b70c --- /dev/null +++ b/modules/monitor/front/locale/es.yml @@ -0,0 +1,16 @@ +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 From a28217001642d8a44c25ebce4c64f7cc85a2e10d Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 16 Oct 2024 11:36:48 +0200 Subject: [PATCH 146/217] fix: refs #7906 fix method --- modules/zone/back/methods/zone/deleteZone.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/modules/zone/back/methods/zone/deleteZone.js b/modules/zone/back/methods/zone/deleteZone.js index 34ab177ac..5b0fe11f4 100644 --- a/modules/zone/back/methods/zone/deleteZone.js +++ b/modules/zone/back/methods/zone/deleteZone.js @@ -53,23 +53,10 @@ module.exports = Self => { const promises = []; const ticketList = await models.Ticket.find(filter, myOptions); - const fixingState = await models.State.findOne({where: {code: 'FIXING'}}, myOptions); - const worker = await models.Worker.findOne({ - where: {id: userId} - }, myOptions); if (ticketList.length > 0) throw new UserError('There are tickets for this area, delete them first'); - for (ticket of ticketList) { - if (ticket.ticketState().alertLevel == 0) { - promises.push(models.Ticket.state(ctx, { - ticketFk: ticket.id, - stateFk: fixingState.id, - userFk: worker.id - }, myOptions)); - } - } await Promise.all(promises); await models.Zone.destroyById(id, myOptions); From 3e443ad5ced8090ee005bfa79add11e60c30a654 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 16 Oct 2024 12:22:57 +0200 Subject: [PATCH 147/217] fix: refs #7230 producer fix --- print/templates/reports/delivery-note/delivery-note.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/print/templates/reports/delivery-note/delivery-note.html b/print/templates/reports/delivery-note/delivery-note.html index c1701e084..ccf2fbfb4 100644 --- a/print/templates/reports/delivery-note/delivery-note.html +++ b/print/templates/reports/delivery-note/delivery-note.html @@ -58,6 +58,7 @@ {{$t('reference')}} {{$t('quantity')}} {{$t('concept')}} + {{$t('producer')}} {{$t('price')}} {{$t('discount')}} {{$t('vat')}} @@ -69,7 +70,7 @@ {{sale.itemFk}} {{sale.quantity}} {{sale.concept}} - {{sale.price | currency('EUR', $i18n.locale)}} + {{sale.subName}} {{(sale.discount / 100) | percentage}} {{sale.vatType}} @@ -81,7 +82,6 @@ {{sale.tag5}} {{sale.value5}} {{sale.tag6}} {{sale.value6}} {{sale.tag7}} {{sale.value7}} - {{$t('producer')}} {{ sale.subName }} From 5de4a11e8b2a236bb4055253fa1c19dd9ae04e80 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 16 Oct 2024 13:53:20 +0200 Subject: [PATCH 148/217] fix: refs #7230 fix line --- print/templates/reports/delivery-note/delivery-note.html | 1 + 1 file changed, 1 insertion(+) diff --git a/print/templates/reports/delivery-note/delivery-note.html b/print/templates/reports/delivery-note/delivery-note.html index ccf2fbfb4..89bc07488 100644 --- a/print/templates/reports/delivery-note/delivery-note.html +++ b/print/templates/reports/delivery-note/delivery-note.html @@ -71,6 +71,7 @@ {{sale.quantity}} {{sale.concept}} {{sale.subName}} + {{sale.price | currency('EUR', $i18n.locale)}} {{(sale.discount / 100) | percentage}} {{sale.vatType}} From 3f3b93625583f6366a9cd6b4f9d6008b81016645 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 16 Oct 2024 13:56:42 +0200 Subject: [PATCH 149/217] fix: refs #7906 remove code --- modules/zone/back/methods/zone/deleteZone.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/zone/back/methods/zone/deleteZone.js b/modules/zone/back/methods/zone/deleteZone.js index 5b0fe11f4..ffe23c9b9 100644 --- a/modules/zone/back/methods/zone/deleteZone.js +++ b/modules/zone/back/methods/zone/deleteZone.js @@ -50,14 +50,12 @@ module.exports = Self => { } } }; - const promises = []; const ticketList = await models.Ticket.find(filter, myOptions); if (ticketList.length > 0) throw new UserError('There are tickets for this area, delete them first'); - await Promise.all(promises); await models.Zone.destroyById(id, myOptions); if (tx) await tx.commit(); From 681f82a3ae934f7834d1122ef2821241242f1771 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 16 Oct 2024 16:09:53 +0200 Subject: [PATCH 150/217] feat: refs #7744 test back ok --- .../back/methods/invoiceOut/delete.js | 8 ++--- modules/ticket/back/methods/ticket/closure.js | 3 +- .../methods/ticket/specs/closeAll.spec.js | 32 ++----------------- 3 files changed, 8 insertions(+), 35 deletions(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/delete.js b/modules/invoiceOut/back/methods/invoiceOut/delete.js index d6efd9961..1ab9a582b 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/delete.js +++ b/modules/invoiceOut/back/methods/invoiceOut/delete.js @@ -37,7 +37,7 @@ module.exports = Self => { const tickets = await models.Ticket.find({ where: {refFk: invoiceOut.ref} }, myOptions); - + const [bookEntry] = await models.Xdiario.find({ where: { SERIE: invoiceOut.ref[0], @@ -55,13 +55,13 @@ module.exports = Self => { if (bookEntry) { if (bookEntry.enlazadoSage) { const params = { - bookEntry: bookEntry.ASIEN, + bookEntry: bookEntry.ASIEN, invoiceOutRef: invoiceOut.ref - } + }; await Self.rawSql(`SELECT util.notification_send('book-entry-deleted', ?, NULL)`, [JSON.stringify(params)], myOptions); - }; + } await models.Xdiario.destroyAll({ ASIEN: bookEntry.ASIEN diff --git a/modules/ticket/back/methods/ticket/closure.js b/modules/ticket/back/methods/ticket/closure.js index 64f198834..e4cb49007 100644 --- a/modules/ticket/back/methods/ticket/closure.js +++ b/modules/ticket/back/methods/ticket/closure.js @@ -19,8 +19,7 @@ module.exports = async function(ctx, Self, tickets, options) { const failedtickets = []; for (const ticket of tickets) { try { - await Self.rawSql(`CALL util.debugAdd('invoicingTicket', ?)`, [ticket.id], {userId}, - myOptions); + await Self.rawSql(`CALL util.debugAdd('invoicingTicket', ?)`, [ticket.id], myOptions); await Self.app.models.InvoiceOut.getSerial( ticket.clientFk, diff --git a/modules/ticket/back/methods/ticket/specs/closeAll.spec.js b/modules/ticket/back/methods/ticket/specs/closeAll.spec.js index 4b067ce7e..f01541eec 100644 --- a/modules/ticket/back/methods/ticket/specs/closeAll.spec.js +++ b/modules/ticket/back/methods/ticket/specs/closeAll.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); -fdescribe('Ticket Closure - closeAll function', () => { +describe('Ticket Closure - closeAll function', () => { let ctx = { req: { getLocale: () => 'es', @@ -17,6 +17,7 @@ fdescribe('Ticket Closure - closeAll function', () => { beforeEach(async() => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: ctx.req}); + tx = await models.Ticket.beginTransaction({}); options = {transaction: tx}; originalVnNew = Date.vnNew; @@ -32,34 +33,7 @@ fdescribe('Ticket Closure - closeAll function', () => { await tx.rollback(); }); - xit('should successfully close all tickets when conditions are met', async() => { - const ticketsBefore = await models.Ticket.find({ - where: { - packages: {neq: 0} - } - }, options); - const packedTicketsIds = ticketsBefore.map(ticket => ticket.id); - - const packedTicketsBefore = await models.TicketLastState.find({ - where: { - ticketFk: {inq: packedTicketsIds}, - lastState: 'Encajado' - } - }, options); - - await models.Ticket.closeAll(ctx, options); - - const packedTicketsAfter = await models.TicketLastState.find({ - where: { - ticketFk: {inq: packedTicketsIds}, - lastState: 'Encajado' - } - }, options); - - expect(packedTicketsBefore.length).toBeGreaterThan(packedTicketsAfter.length); - }); - - fit('should set routeFk to NULL when conditions are met', async() => { + it('should set routeFk to NULL when conditions are met', async() => { const ticketsBefore = await models.Ticket.find({ where: { routeFk: {neq: null} From de0fe37ffe978118101fdd2c34615b103ec84da7 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 16 Oct 2024 16:16:51 +0200 Subject: [PATCH 151/217] feat: refs #8083 add prop --- modules/ticket/back/models/expedition.json | 117 +++++++++++---------- 1 file changed, 60 insertions(+), 57 deletions(-) diff --git a/modules/ticket/back/models/expedition.json b/modules/ticket/back/models/expedition.json index 2dcca1e87..f3f912ec3 100644 --- a/modules/ticket/back/models/expedition.json +++ b/modules/ticket/back/models/expedition.json @@ -1,63 +1,66 @@ { - "name": "Expedition", - "base": "VnModel", - "mixins": { - "Loggable": true + "name": "Expedition", + "base": "VnModel", + "mixins": { + "Loggable": true + }, + "options": { + "mysql": { + "table": "expedition" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "description": "Identifier" }, - "options": { - "mysql": { - "table": "expedition" - } + "freightItemFk": { + "type": "number" }, - "properties": { - "id": { - "id": true, - "type": "number", - "description": "Identifier" - }, - "freightItemFk": { - "type": "number" - }, - "created": { - "type": "date" - }, - "counter": { - "type": "number" - }, - "externalId": { - "type": "string" - } + "created": { + "type": "date" }, - "relations": { - "ticket": { - "type": "belongsTo", - "model": "Ticket", - "foreignKey": "ticketFk" - }, - "agencyMode": { - "type": "belongsTo", - "model": "AgencyMode", - "foreignKey": "agencyModeFk" - }, - "worker": { - "type": "belongsTo", - "model": "Worker", - "foreignKey": "workerFk" - }, - "packages": { - "type": "hasMany", - "model": "TicketPackaging", - "foreignKey": "ticketFk" - }, - "freightItem": { - "type": "belongsTo", - "model": "Item", - "foreignKey": "freightItemFk" - }, - "packaging": { - "type": "belongsTo", - "model": "Package", - "foreignKey": "packagingFk" - } + "counter": { + "type": "number" + }, + "externalId": { + "type": "string" + }, + "stateTypeFk": { + "type": "number" + } + }, + "relations": { + "ticket": { + "type": "belongsTo", + "model": "Ticket", + "foreignKey": "ticketFk" + }, + "agencyMode": { + "type": "belongsTo", + "model": "AgencyMode", + "foreignKey": "agencyModeFk" + }, + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "packages": { + "type": "hasMany", + "model": "TicketPackaging", + "foreignKey": "ticketFk" + }, + "freightItem": { + "type": "belongsTo", + "model": "Item", + "foreignKey": "freightItemFk" + }, + "packaging": { + "type": "belongsTo", + "model": "Package", + "foreignKey": "packagingFk" } } +} \ No newline at end of file From 999cb2dbb44361f20471532e39e52b94a4dee038 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 17 Oct 2024 10:08:27 +0200 Subject: [PATCH 152/217] feat: refs #8119 itemCampaignQuantity --- .../vn/events/itemCampaignQuantity_add.sql | 8 ++ .../procedures/itemCampaignQuantity_add.sql | 81 +++++++++++++++++++ .../11308-redCymbidium/00-firstScript.sql | 24 ++++++ 3 files changed, 113 insertions(+) create mode 100644 db/routines/vn/events/itemCampaignQuantity_add.sql create mode 100644 db/routines/vn/procedures/itemCampaignQuantity_add.sql create mode 100644 db/versions/11308-redCymbidium/00-firstScript.sql diff --git a/db/routines/vn/events/itemCampaignQuantity_add.sql b/db/routines/vn/events/itemCampaignQuantity_add.sql new file mode 100644 index 000000000..a90a678f3 --- /dev/null +++ b/db/routines/vn/events/itemCampaignQuantity_add.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`itemCampaignQuantity_add` + ON SCHEDULE EVERY 5 MINUTE + STARTS '2024-10-18 03:00:00.000' + ON COMPLETION PRESERVE + ENABLE +DO CALL itemCampaignQuantity_add(NULL, NULL, NULL)$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/itemCampaignQuantity_add.sql b/db/routines/vn/procedures/itemCampaignQuantity_add.sql new file mode 100644 index 000000000..af5d0e2de --- /dev/null +++ b/db/routines/vn/procedures/itemCampaignQuantity_add.sql @@ -0,0 +1,81 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemCampaignQuantity_add`( + vDateFrom DATE, + vDateTo DATE, + vCampaign VARCHAR(100) +) +proc: BEGIN +/** + * Añade registros a tabla itemCampaignQuantity. + * + * @param vDateFrom Fecha desde + * @param vDateTo Fecha hasta + * @param vCampaign Código de la campaña + */ + DECLARE vYesterday INT; + DECLARE vDefaultCampaign VARCHAR(100); + DECLARE vPreviousDaysToInsert INT; + DECLARE vDateSumFrom DATE; + DECLARE vDateSumTo DATE; + DECLARE vScopeDays DATE; + + SET vYesterday = util.yesterday(); + + IF vDateFrom IS NULL THEN + SET vDateFrom = vYesterday; + END IF; + + IF vDateTo IS NULL THEN + SET vDateTo = vYesterday; + END IF; + + IF vDateFrom > vDateTo THEN + CALL util.throw('Start date cannot be later than end date'); + END IF; + + SELECT defaultCampaign, previousDaysToInsert + INTO vDefaultCampaign, vPreviousDaysToInsert + FROM itemCampaignQuantityConfig; + + IF vCampaign IS NULL THEN + SET vCampaign = vDefaultCampaign; + END IF; + + IF vCampaign IS NULL OR vPreviousDaysToInsert IS NULL THEN + CALL util.throw('Missing values in the configuration table'); + END IF; + + SELECT dated, scopeDays INTO vDateSumTo, vScopeDays + FROM campaign + WHERE dated > util.VN_CURDATE() + AND code = vCampaign + ORDER BY dated + LIMIT 1; + + IF vDateSumTo IS NULL OR vScopeDays IS NULL THEN + CALL util.throw('Missing data in campaign table'); + END IF; + + IF NOT util.VN_CURDATE() BETWEEN vDateSumTo - INTERVAL vPreviousDaysToInsert DAY + AND vDateSumTo THEN + LEAVE proc; + END IF; + + SET vDateSumFrom = vDateSumTo - INTERVAL vScopeDays DAY; + + INSERT INTO itemCampaignQuantity(dated, itemFk, quantity, campaign) + SELECT DATE(s.created), + s.itemFk, + CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo + THEN SUM(s.quantity) + END quantity, + vCampaign + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN client c ON c.id = t.clientFk + WHERE s.created BETWEEN vDateFrom AND util.dayEnd(vDateTo) + AND c.businessTypeFk <> 'worker' + GROUP BY DATE(s.created), s.itemFk + HAVING quantity; +END$$ +DELIMITER ; diff --git a/db/versions/11308-redCymbidium/00-firstScript.sql b/db/versions/11308-redCymbidium/00-firstScript.sql new file mode 100644 index 000000000..ea3436b80 --- /dev/null +++ b/db/versions/11308-redCymbidium/00-firstScript.sql @@ -0,0 +1,24 @@ +CREATE TABLE IF NOT EXISTS vn.itemCampaignQuantity ( + dated date NOT NULL, + itemFk int(11) NOT NULL, + quantity decimal(10,2) NOT NULL, + campaign varchar(100) NOT NULL, + CONSTRAINT itemCampaignQuantity_pk PRIMARY KEY (dated,itemFk), + CONSTRAINT itemCampaignQuantity_item_FK FOREIGN KEY (itemFk) REFERENCES vn.item(id) ON DELETE RESTRICT ON UPDATE CASCADE +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci; + +CREATE TABLE IF NOT EXISTS vn.itemCampaignQuantityConfig ( + id int(10) unsigned NOT NULL PRIMARY, + defaultCampaign varchar(100) NOT NULL COMMENT 'Campaña por defecto si se le pasa NULL', + previousDaysToInsert int(10) unsigned NOT NULL COMMENT 'Días anteriores a la fecha de fin de campaña para insertar', + CONSTRAINT `itemCampaignQuantityConfig_check` CHECK (`id` = 1) +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8mb3 +COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO vn.itemCampaignQuantityConfig(id, defaultCampaign, previousDaysToInsert) + VALUES (1, 'allSaints', 90); From ec13c41be327c560c3982f70f2b3c2ac159e046e Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 17 Oct 2024 10:09:57 +0200 Subject: [PATCH 153/217] feat: refs #8119 itemCampaignQuantity --- db/routines/vn/events/itemCampaignQuantity_add.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/events/itemCampaignQuantity_add.sql b/db/routines/vn/events/itemCampaignQuantity_add.sql index a90a678f3..4deb2d556 100644 --- a/db/routines/vn/events/itemCampaignQuantity_add.sql +++ b/db/routines/vn/events/itemCampaignQuantity_add.sql @@ -1,6 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`itemCampaignQuantity_add` - ON SCHEDULE EVERY 5 MINUTE + ON SCHEDULE EVERY 1 DAY STARTS '2024-10-18 03:00:00.000' ON COMPLETION PRESERVE ENABLE From 3628abd5bfe87c47c359e01ca54331f1a0bb99f4 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 17 Oct 2024 10:15:45 +0200 Subject: [PATCH 154/217] feat: refs #8119 itemCampaignQuantity --- db/routines/vn/procedures/itemCampaignQuantity_add.sql | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/itemCampaignQuantity_add.sql b/db/routines/vn/procedures/itemCampaignQuantity_add.sql index af5d0e2de..56e68c3b0 100644 --- a/db/routines/vn/procedures/itemCampaignQuantity_add.sql +++ b/db/routines/vn/procedures/itemCampaignQuantity_add.sql @@ -12,13 +12,15 @@ proc: BEGIN * @param vDateTo Fecha hasta * @param vCampaign Código de la campaña */ - DECLARE vYesterday INT; + DECLARE vCurdate DATE; + DECLARE vYesterday DATE; DECLARE vDefaultCampaign VARCHAR(100); DECLARE vPreviousDaysToInsert INT; DECLARE vDateSumFrom DATE; DECLARE vDateSumTo DATE; DECLARE vScopeDays DATE; + SET vCurdate = util.VN_CURDATE(); SET vYesterday = util.yesterday(); IF vDateFrom IS NULL THEN @@ -47,7 +49,7 @@ proc: BEGIN SELECT dated, scopeDays INTO vDateSumTo, vScopeDays FROM campaign - WHERE dated > util.VN_CURDATE() + WHERE dated > vCurdate AND code = vCampaign ORDER BY dated LIMIT 1; @@ -56,7 +58,7 @@ proc: BEGIN CALL util.throw('Missing data in campaign table'); END IF; - IF NOT util.VN_CURDATE() BETWEEN vDateSumTo - INTERVAL vPreviousDaysToInsert DAY + IF NOT vCurdate BETWEEN vDateSumTo - INTERVAL vPreviousDaysToInsert DAY AND vDateSumTo THEN LEAVE proc; END IF; From 41d078aaf1db20eea232fcf1600be544212f4b47 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 17 Oct 2024 10:16:26 +0200 Subject: [PATCH 155/217] feat: refs #8119 itemCampaignQuantity --- db/routines/vn/procedures/itemCampaignQuantity_add.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemCampaignQuantity_add.sql b/db/routines/vn/procedures/itemCampaignQuantity_add.sql index 56e68c3b0..6cadd09be 100644 --- a/db/routines/vn/procedures/itemCampaignQuantity_add.sql +++ b/db/routines/vn/procedures/itemCampaignQuantity_add.sql @@ -18,7 +18,7 @@ proc: BEGIN DECLARE vPreviousDaysToInsert INT; DECLARE vDateSumFrom DATE; DECLARE vDateSumTo DATE; - DECLARE vScopeDays DATE; + DECLARE vScopeDays INT; SET vCurdate = util.VN_CURDATE(); SET vYesterday = util.yesterday(); From 8ca69d3574185ca860ff0cdce42e732412a2d836 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 17 Oct 2024 10:21:39 +0200 Subject: [PATCH 156/217] feat: refs #8119 Minor change --- db/routines/vn/procedures/itemCampaignQuantity_add.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/itemCampaignQuantity_add.sql b/db/routines/vn/procedures/itemCampaignQuantity_add.sql index 6cadd09be..6dffb3918 100644 --- a/db/routines/vn/procedures/itemCampaignQuantity_add.sql +++ b/db/routines/vn/procedures/itemCampaignQuantity_add.sql @@ -68,9 +68,9 @@ proc: BEGIN INSERT INTO itemCampaignQuantity(dated, itemFk, quantity, campaign) SELECT DATE(s.created), s.itemFk, - CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo - THEN SUM(s.quantity) - END quantity, + SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo + THEN s.quantity + END) quantity, vCampaign FROM sale s JOIN ticket t ON t.id = s.ticketFk From 2bd98b7fb663a339e314cf7e64cdaf2fe662e712 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 17 Oct 2024 10:29:35 +0200 Subject: [PATCH 157/217] feat: refs #8119 Minor change --- db/versions/11308-redCymbidium/00-firstScript.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/versions/11308-redCymbidium/00-firstScript.sql b/db/versions/11308-redCymbidium/00-firstScript.sql index ea3436b80..baa703a5a 100644 --- a/db/versions/11308-redCymbidium/00-firstScript.sql +++ b/db/versions/11308-redCymbidium/00-firstScript.sql @@ -1,4 +1,4 @@ -CREATE TABLE IF NOT EXISTS vn.itemCampaignQuantity ( +CREATE TABLE IF NOT EXISTS `vn`.`itemCampaignQuantity` ( dated date NOT NULL, itemFk int(11) NOT NULL, quantity decimal(10,2) NOT NULL, @@ -10,8 +10,8 @@ ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -CREATE TABLE IF NOT EXISTS vn.itemCampaignQuantityConfig ( - id int(10) unsigned NOT NULL PRIMARY, +CREATE TABLE IF NOT EXISTS `vn`.`itemCampaignQuantityConfig` ( + id int(10) unsigned NOT NULL PRIMARY KEY, defaultCampaign varchar(100) NOT NULL COMMENT 'Campaña por defecto si se le pasa NULL', previousDaysToInsert int(10) unsigned NOT NULL COMMENT 'Días anteriores a la fecha de fin de campaña para insertar', CONSTRAINT `itemCampaignQuantityConfig_check` CHECK (`id` = 1) @@ -20,5 +20,5 @@ ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -INSERT IGNORE INTO vn.itemCampaignQuantityConfig(id, defaultCampaign, previousDaysToInsert) +INSERT IGNORE INTO `vn`.`itemCampaignQuantityConfig` (id, defaultCampaign, previousDaysToInsert) VALUES (1, 'allSaints', 90); From f85267db9262c71ddb81017009c08aba9395cd6f Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 17 Oct 2024 11:06:11 +0200 Subject: [PATCH 158/217] feat: refs #8119 Fix test --- back/methods/vn-user/specs/renew-token.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/back/methods/vn-user/specs/renew-token.spec.js b/back/methods/vn-user/specs/renew-token.spec.js index 8f1bb54c1..8941916ec 100644 --- a/back/methods/vn-user/specs/renew-token.spec.js +++ b/back/methods/vn-user/specs/renew-token.spec.js @@ -72,9 +72,9 @@ describe('Renew Token', () => { } expect(error).toBeDefined(); - const query = 'SELECT * FROM util.debug'; - const debugLog = await models.Application.rawSql(query, null); + const query = 'SELECT * FROM util.debug WHERE variable = "renewToken"'; + const debugLog = await models.Application.rawSql(query); expect(debugLog.length).toEqual(1); }); From a188efb1e33d24e5a70f6301f6b739b3d93de12b Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 17 Oct 2024 11:45:13 +0200 Subject: [PATCH 159/217] refactor: refs #7930 Deleted HEALTHCHECK of back dockerfile --- back/Dockerfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/back/Dockerfile b/back/Dockerfile index 363192a0b..3e2a90c58 100644 --- a/back/Dockerfile +++ b/back/Dockerfile @@ -55,7 +55,4 @@ COPY \ README.md \ ./ -CMD ["pm2-runtime", "./back/process.yml"] - -HEALTHCHECK --interval=15s --timeout=10s \ - CMD curl -f http://localhost:3000/api/Applications/status || exit 1 +CMD ["pm2-runtime", "./back/process.yml"] \ No newline at end of file From faecbbb3735034876e7544891fc63702e089b0ad Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 17 Oct 2024 13:08:58 +0200 Subject: [PATCH 160/217] feat: refs #8108 saltos de linea --- db/versions/11300-limeMedeola/00-firstScript.sql | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/db/versions/11300-limeMedeola/00-firstScript.sql b/db/versions/11300-limeMedeola/00-firstScript.sql index 313a65e81..28b033b4a 100644 --- a/db/versions/11300-limeMedeola/00-firstScript.sql +++ b/db/versions/11300-limeMedeola/00-firstScript.sql @@ -13,8 +13,6 @@ UPDATE vn.tag sourceTable='itemFarmingTag' WHERE name= 'cultivo'; - - CREATE TABLE IF NOT EXISTS `vn`.`itemWrappingTag` ( `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, `name` varchar(50) DEFAULT NULL, @@ -36,8 +34,6 @@ UPDATE vn.tag sourceTable='itemWrappingTag' WHERE name= 'Envoltorio'; - - CREATE TABLE IF NOT EXISTS `vn`.`itemLanguageTag` ( `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, `name` varchar(50) DEFAULT NULL, @@ -59,8 +55,6 @@ UPDATE vn.tag sourceTable='itemLanguageTag' WHERE name= 'Idioma'; - - CREATE TABLE IF NOT EXISTS `vn`.`itemStemTag` ( `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, `name` varchar(50) DEFAULT NULL, @@ -94,8 +88,6 @@ UPDATE vn.tag sourceTable='itemBreederTag' WHERE name= 'Obtentor'; - - CREATE TABLE IF NOT EXISTS `vn`.`itemBaseTag` ( `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, `name` varchar(50) DEFAULT NULL, @@ -120,8 +112,6 @@ UPDATE vn.tag sourceTable='itemBaseTag' WHERE name= 'Soporte'; - - CREATE TABLE IF NOT EXISTS `vn`.`itemVatRateTag` ( `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, `name` varchar(50) DEFAULT NULL, @@ -133,13 +123,11 @@ CREATE TABLE IF NOT EXISTS `vn`.`itemVatRateTag` ( INSERT IGNORE INTO `vn`.`itemVatRateTag` (`name`) VALUES ('General'); INSERT IGNORE INTO `vn`.`itemVatRateTag` (`name`) VALUES ('Reducido'); - UPDATE vn.tag SET isFree=0, sourceTable='itemVatRateTag' WHERE name= 'Tipo de IVA'; - GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemFarmingTag TO logisticAssist; GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemWrappingTag TO logisticAssist; GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemLanguageTag TO logisticAssist; From cb539624056c6d88d182b27745daec7334c40eb9 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 17 Oct 2024 13:58:21 +0200 Subject: [PATCH 161/217] fix: refs #6861 saleTrackingAdd --- ...saleTracking_sectorCollectionAddPrevOK.sql | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql diff --git a/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql b/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql new file mode 100644 index 000000000..3ac31752a --- /dev/null +++ b/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql @@ -0,0 +1,26 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleTracking_sectorCollectionAddPrevOK`(vSectorCollectionFk INT) +BEGIN +/** + * Inserta los registros de sectorCollection con el estado PREVIA OK si la reserva está picked + * + * @param vSectorCollectionFk Identificador de vn.sectorCollection + */ + REPLACE saleTracking( + saleFk, + isChecked, + workerFk, + stateFk + ) + SELECT sgd.saleFk, + TRUE, + sc.userFk, + s.id + FROM vn.sectorCollection sc + JOIN sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id + JOIN saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk + JOIN state s ON s.code = 'OK PREVIOUS' + JOIN itemShelvingSale iss ON iss.saleFk = sgd.saleFk + WHERE sc.id = vSectorCollectionFk AND iss.isPicked; +END$$ +DELIMITER ; From 28e957fecd9ba5e5c71088d00cdcdf7d47032232 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 17 Oct 2024 14:46:19 +0200 Subject: [PATCH 162/217] refactor: refs #8106 refs #1406 Optimized ticket_getTax --- db/routines/vn/procedures/ticket_getTax.sql | 56 ++++++++++++------- .../back/methods/invoiceOut/negativeBases.js | 18 +++--- 2 files changed, 45 insertions(+), 29 deletions(-) diff --git a/db/routines/vn/procedures/ticket_getTax.sql b/db/routines/vn/procedures/ticket_getTax.sql index 947c45806..fc266f978 100644 --- a/db/routines/vn/procedures/ticket_getTax.sql +++ b/db/routines/vn/procedures/ticket_getTax.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_getTax`(IN vTaxArea VARCHAR(25)) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_getTax`( + vTaxArea VARCHAR(25) +) BEGIN /** * Calcula la base imponible, el IVA y el recargo de equivalencia para @@ -33,30 +35,44 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.ticketTax (PRIMARY KEY (ticketFk, code, rate)) ENGINE = MEMORY - SELECT * FROM ( - SELECT tmpTicket.ticketFk, + WITH sales AS ( + SELECT s.id, + s.ticketFk, + s.itemFk, + s.quantity * s.price * (100 - s.discount) / 100 total, + t.companyFk, + t.addressFk, + su.countryFk, + ata.areaFk, + itc.taxClassFk + FROM vn.sale s + JOIN tmp.ticket tmp ON tmp.ticketFk = s.ticketFk + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.supplier su ON su.id = t.companyFk + JOIN tmp.addressTaxArea ata ON ata.addressFk = t.addressFk + AND ata.companyFk = t.companyFk + JOIN vn.itemTaxCountry itc ON itc.itemFk = s.itemFk + AND itc.countryFk = su.countryFk + HAVING total + ), + ticketTax AS ( + SELECT s.ticketFk, bp.pgcFk, - SUM(s.quantity * s.price * (100 - s.discount) / 100 ) taxableBase, + SUM(s.total) taxableBase, pgc.rate, tc.code, bp.priority - FROM tmp.ticket tmpTicket - JOIN sale s ON s.ticketFk = tmpTicket.ticketFk - JOIN item i ON i.id = s.itemFk - JOIN ticket t ON t.id = tmpTicket.ticketFk - JOIN supplier su ON su.id = t.companyFk - JOIN tmp.addressTaxArea ata ON ata.addressFk = t.addressFk - AND ata.companyFk = t.companyFk - JOIN itemTaxCountry itc ON itc.itemFk = i.id - AND itc.countryFk = su.countryFk - JOIN bookingPlanner bp ON bp.countryFk = su.countryFk - AND bp.taxAreaFk = ata.areaFk - AND bp.taxClassFk = itc.taxClassFk - JOIN pgc ON pgc.code = bp.pgcFk - JOIN taxClass tc ON tc.id = bp.taxClassFk - GROUP BY tmpTicket.ticketFk, pgc.code, pgc.rate + FROM sales s + JOIN vn.bookingPlanner bp ON bp.countryFk = s.countryFk + AND bp.taxAreaFk = s.areaFk + AND bp.taxClassFk = s.taxClassFk + JOIN vn.pgc ON pgc.code = bp.pgcFk + JOIN vn.taxClass tc ON tc.id = bp.taxClassFk + GROUP BY s.ticketFk, pgc.code, pgc.rate HAVING taxableBase - ) t3 + ) + SELECT * + FROM ticketTax ORDER BY priority; CREATE OR REPLACE TEMPORARY TABLE tmp.ticketServiceTax diff --git a/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js b/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js index 76ef29604..9e491b35c 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js +++ b/modules/invoiceOut/back/methods/invoiceOut/negativeBases.js @@ -48,13 +48,13 @@ module.exports = Self => { let stmt; stmts.push(new ParameterizedSQL( `CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - (KEY (ticketFk)) + (INDEX (ticketFk)) ENGINE = MEMORY SELECT id ticketFk - FROM ticket t + FROM ticket WHERE shipped BETWEEN ? AND util.dayEnd(?) AND refFk IS NULL`, [args.from, args.to])); - stmts.push(`CALL vn.ticket_getTax(NULL)`); + stmts.push(`CALL ticket_getTax(NULL)`); stmts.push(new ParameterizedSQL( `CREATE OR REPLACE TEMPORARY TABLE tmp.filter ENGINE = MEMORY @@ -71,12 +71,12 @@ module.exports = Self => { c.isTaxDataChecked, w.id comercialId, u.name workerName - FROM vn.ticket t - JOIN vn.company co ON co.id = t.companyFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.client c ON c.id = t.clientFk - JOIN vn.country cou ON cou.id = c.countryFk - LEFT JOIN vn.worker w ON w.id = c.salesPersonFk + FROM ticket t + JOIN company co ON co.id = t.companyFk + JOIN sale s ON s.ticketFk = t.id + JOIN client c ON c.id = t.clientFk + JOIN country cou ON cou.id = c.countryFk + LEFT JOIN worker w ON w.id = c.salesPersonFk JOIN account.user u ON u.id = w.id LEFT JOIN ( SELECT ticketFk, taxableBase From 63c0ec308f3231fbc276c7e3ee365cdc2464d5c7 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 17 Oct 2024 17:01:44 +0200 Subject: [PATCH 163/217] fix: refs #6861 saleTrackingAdd --- ...saleTracking_sectorCollectionAddPrevOK.sql | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql b/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql index 3ac31752a..a5d34c2d6 100644 --- a/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql +++ b/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleTracking_sectorCollectionAddPrevOK`(vSectorCollectionFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleTracking_sectorCollectionAddPrevOK`( + vSectorCollectionFk INT + ) BEGIN /** * Inserta los registros de sectorCollection con el estado PREVIA OK si la reserva está picked @@ -12,15 +14,15 @@ BEGIN workerFk, stateFk ) - SELECT sgd.saleFk, - TRUE, - sc.userFk, - s.id - FROM vn.sectorCollection sc - JOIN sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id - JOIN saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk - JOIN state s ON s.code = 'OK PREVIOUS' - JOIN itemShelvingSale iss ON iss.saleFk = sgd.saleFk - WHERE sc.id = vSectorCollectionFk AND iss.isPicked; + SELECT sgd.saleFk, + TRUE, + sc.userFk, + s.id + FROM sectorCollection sc + JOIN sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id + JOIN saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk + JOIN state s ON s.code = 'OK PREVIOUS' + JOIN itemShelvingSale iss ON iss.saleFk = sgd.saleFk + WHERE sc.id = vSectorCollectionFk AND iss.isPicked; END$$ DELIMITER ; From 7dc35458e8973188cf4b968f335c438b378e85e5 Mon Sep 17 00:00:00 2001 From: ivanm Date: Thu, 17 Oct 2024 17:05:08 +0200 Subject: [PATCH 164/217] refactor: refs #7865 delete client.gestdocFk from TPV --- db/dump/fixtures.before.sql | 30 +++++++++---------- db/routines/vn2008/views/Clientes.sql | 1 - db/versions/11311-tealFern/00-firstScript.sql | 1 + 3 files changed, 16 insertions(+), 16 deletions(-) create mode 100644 db/versions/11311-tealFern/00-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 7f7e50dd3..a6852be7e 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -388,23 +388,23 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`) (4, 'GCN Channel'), (5, 'The Newspaper'); -INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`businessTypeFk`,`typeFk`) +INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`businessTypeFk`,`typeFk`) VALUES - (1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@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, 18, 0, 'florist','normal'), - (1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), - (1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), - (1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), - (1105, 'Max Eisenhardt', '251628698', 'MAGNETO', 'Rogue', 'UNKNOWN WHEREABOUTS', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 18, 0, 'florist','normal'), - (1106, 'DavidCharlesHaller', '53136686Q', 'LEGION', 'Charles Xavier', 'CITY OF NEW YORK, NEW YORK, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 19, 0, 'florist','normal'), - (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, 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'); + (1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), + (1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), + (1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), + (1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 18, 0, 'florist','normal'), + (1105, 'Max Eisenhardt', '251628698', 'MAGNETO', 'Rogue', 'UNKNOWN WHEREABOUTS', 'Gotham', 46460, 1111111111, 222222222, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 300, 8, 1, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, NULL, 0, 0, 18, 0, 'florist','normal'), + (1106, 'DavidCharlesHaller', '53136686Q', 'LEGION', 'Charles Xavier', 'CITY OF NEW YORK, NEW YORK, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, NULL, 0, 0, 19, 0, 'florist','normal'), + (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, 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, 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, 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, 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, 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, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 0, 1, 0, NULL, 1, 0, NULL, 0, 'others','loses'); -INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`) - SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), UPPER(CONCAT(name, 'Social')), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1 +INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`) + SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), UPPER(CONCAT(name, 'Social')), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, 10, 5, util.VN_CURDATE(), 1 FROM `account`.`role` `r` WHERE `r`.`hasLogin` = 1; diff --git a/db/routines/vn2008/views/Clientes.sql b/db/routines/vn2008/views/Clientes.sql index 153d875bc..9f8ef712e 100644 --- a/db/routines/vn2008/views/Clientes.sql +++ b/db/routines/vn2008/views/Clientes.sql @@ -22,7 +22,6 @@ AS SELECT `c`.`id` AS `id_cliente`, `c`.`credit` AS `credito`, `c`.`countryFk` AS `Id_Pais`, `c`.`isActive` AS `activo`, - `c`.`gestdocFk` AS `gestdoc_id`, `c`.`quality` AS `calidad`, `c`.`payMethodFk` AS `pay_met_id`, `c`.`created` AS `created`, diff --git a/db/versions/11311-tealFern/00-firstScript.sql b/db/versions/11311-tealFern/00-firstScript.sql new file mode 100644 index 000000000..909747f3c --- /dev/null +++ b/db/versions/11311-tealFern/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.client CHANGE gestdocFk gestdocFk__ int(11) DEFAULT NULL NULL COMMENT '@deprecated 2024-10-17'; \ No newline at end of file From 34630360866759b5bce57227b5581d203abf98ed Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 17 Oct 2024 17:20:21 +0200 Subject: [PATCH 165/217] fix: refs #6861 saleTrackingAdd --- .../saleTracking_sectorCollectionAddPrevOK.sql | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql b/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql index a5d34c2d6..003168ec8 100644 --- a/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql +++ b/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql @@ -1,23 +1,15 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleTracking_sectorCollectionAddPrevOK`( vSectorCollectionFk INT - ) +) BEGIN /** * Inserta los registros de sectorCollection con el estado PREVIA OK si la reserva está picked * * @param vSectorCollectionFk Identificador de vn.sectorCollection */ - REPLACE saleTracking( - saleFk, - isChecked, - workerFk, - stateFk - ) - SELECT sgd.saleFk, - TRUE, - sc.userFk, - s.id + REPLACE saleTracking(saleFk, isChecked, workerFk, stateFk) + SELECT sgd.saleFk, TRUE, sc.userFk, s.id FROM sectorCollection sc JOIN sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id JOIN saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk From 865da7bba2b6d071bcbfd8432ea8bfcf091e784c Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 18 Oct 2024 07:15:26 +0200 Subject: [PATCH 166/217] refactor: refs #8106 Requested changes --- db/routines/vn/procedures/ticket_getTax.sql | 35 +++++++++------------ 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/db/routines/vn/procedures/ticket_getTax.sql b/db/routines/vn/procedures/ticket_getTax.sql index fc266f978..cb9dc09d9 100644 --- a/db/routines/vn/procedures/ticket_getTax.sql +++ b/db/routines/vn/procedures/ticket_getTax.sql @@ -36,8 +36,7 @@ BEGIN (PRIMARY KEY (ticketFk, code, rate)) ENGINE = MEMORY WITH sales AS ( - SELECT s.id, - s.ticketFk, + SELECT s.ticketFk, s.itemFk, s.quantity * s.price * (100 - s.discount) / 100 total, t.companyFk, @@ -54,25 +53,21 @@ BEGIN JOIN vn.itemTaxCountry itc ON itc.itemFk = s.itemFk AND itc.countryFk = su.countryFk HAVING total - ), - ticketTax AS ( - SELECT s.ticketFk, - bp.pgcFk, - SUM(s.total) taxableBase, - pgc.rate, - tc.code, - bp.priority - FROM sales s - JOIN vn.bookingPlanner bp ON bp.countryFk = s.countryFk - AND bp.taxAreaFk = s.areaFk - AND bp.taxClassFk = s.taxClassFk - JOIN vn.pgc ON pgc.code = bp.pgcFk - JOIN vn.taxClass tc ON tc.id = bp.taxClassFk - GROUP BY s.ticketFk, pgc.code, pgc.rate - HAVING taxableBase ) - SELECT * - FROM ticketTax + SELECT s.ticketFk, + bp.pgcFk, + SUM(s.total) taxableBase, + pgc.rate, + tc.code, + bp.priority + FROM sales s + JOIN vn.bookingPlanner bp ON bp.countryFk = s.countryFk + AND bp.taxAreaFk = s.areaFk + AND bp.taxClassFk = s.taxClassFk + JOIN vn.pgc ON pgc.code = bp.pgcFk + JOIN vn.taxClass tc ON tc.id = bp.taxClassFk + GROUP BY s.ticketFk, pgc.code, pgc.rate + HAVING taxableBase ORDER BY priority; CREATE OR REPLACE TEMPORARY TABLE tmp.ticketServiceTax From 4bd28c62b9ffc43470ec2f883ee1d4d3b8328872 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 18 Oct 2024 07:35:36 +0200 Subject: [PATCH 167/217] feat: refs #8119 Requested changes --- db/versions/11308-redCymbidium/00-firstScript.sql | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/db/versions/11308-redCymbidium/00-firstScript.sql b/db/versions/11308-redCymbidium/00-firstScript.sql index baa703a5a..6e0afdd8b 100644 --- a/db/versions/11308-redCymbidium/00-firstScript.sql +++ b/db/versions/11308-redCymbidium/00-firstScript.sql @@ -1,14 +1,16 @@ CREATE TABLE IF NOT EXISTS `vn`.`itemCampaignQuantity` ( + `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, dated date NOT NULL, itemFk int(11) NOT NULL, quantity decimal(10,2) NOT NULL, campaign varchar(100) NOT NULL, - CONSTRAINT itemCampaignQuantity_pk PRIMARY KEY (dated,itemFk), + UNIQUE KEY `itemCampaignQuantity_UNIQUE` (`dated`,`itemFk`), CONSTRAINT itemCampaignQuantity_item_FK FOREIGN KEY (itemFk) REFERENCES vn.item(id) ON DELETE RESTRICT ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 -COLLATE=utf8mb3_unicode_ci; +COLLATE=utf8mb3_unicode_ci +COMMENT='Tallos confirmados por día en los días de más producción de una campaña'; CREATE TABLE IF NOT EXISTS `vn`.`itemCampaignQuantityConfig` ( id int(10) unsigned NOT NULL PRIMARY KEY, From 7e604f1a19f7a993aba6c47b3d522fac3e180a07 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 18 Oct 2024 07:44:28 +0200 Subject: [PATCH 168/217] feat: refs #8119 Requested changes --- db/routines/vn/procedures/itemCampaignQuantity_add.sql | 2 +- db/versions/11308-redCymbidium/00-firstScript.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/itemCampaignQuantity_add.sql b/db/routines/vn/procedures/itemCampaignQuantity_add.sql index 6dffb3918..ca041d2d2 100644 --- a/db/routines/vn/procedures/itemCampaignQuantity_add.sql +++ b/db/routines/vn/procedures/itemCampaignQuantity_add.sql @@ -65,7 +65,7 @@ proc: BEGIN SET vDateSumFrom = vDateSumTo - INTERVAL vScopeDays DAY; - INSERT INTO itemCampaignQuantity(dated, itemFk, quantity, campaign) + REPLACE itemCampaignQuantity(dated, itemFk, quantity, campaign) SELECT DATE(s.created), s.itemFk, SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo diff --git a/db/versions/11308-redCymbidium/00-firstScript.sql b/db/versions/11308-redCymbidium/00-firstScript.sql index 6e0afdd8b..d90cd1ae6 100644 --- a/db/versions/11308-redCymbidium/00-firstScript.sql +++ b/db/versions/11308-redCymbidium/00-firstScript.sql @@ -10,7 +10,7 @@ CREATE TABLE IF NOT EXISTS `vn`.`itemCampaignQuantity` ( ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci -COMMENT='Tallos confirmados por día en los días de más producción de una campaña'; +COMMENT='Tallos confirmados por día en los días de más producción de una campaña. La tabla está pensada para que sea una foto.'; CREATE TABLE IF NOT EXISTS `vn`.`itemCampaignQuantityConfig` ( id int(10) unsigned NOT NULL PRIMARY KEY, From 93494c3eb05ad06cab9102cc06ebdebac06dab85 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 18 Oct 2024 08:02:06 +0200 Subject: [PATCH 169/217] refactor: refs #7811 Deleted pm2 --- back/Dockerfile | 5 ++--- back/process.yml | 7 ------- 2 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 back/process.yml diff --git a/back/Dockerfile b/back/Dockerfile index 3e2a90c58..0f75f6949 100644 --- a/back/Dockerfile +++ b/back/Dockerfile @@ -32,8 +32,7 @@ RUN apt-get update \ RUN apt-get update \ && apt-get install -y --no-install-recommends \ samba-common-bin samba-dsdb-modules\ - && rm -rf /var/lib/apt/lists/* \ - && npm -g install pm2 + && rm -rf /var/lib/apt/lists/* # Salix @@ -55,4 +54,4 @@ COPY \ README.md \ ./ -CMD ["pm2-runtime", "./back/process.yml"] \ No newline at end of file +CMD ["node", "--tls-min-v1.0", "--openssl-legacy-provider", "./loopback/server/server.js"] \ No newline at end of file diff --git a/back/process.yml b/back/process.yml deleted file mode 100644 index 94072b57d..000000000 --- a/back/process.yml +++ /dev/null @@ -1,7 +0,0 @@ -apps: - - script: ./loopback/server/server.js - name: salix-back - instances: 1 - max_restarts: 0 - autorestart: false - node_args: --tls-min-v1.0 --openssl-legacy-provider From 02dc9520244f673d143eddcce2e176b88bc5695a Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 18 Oct 2024 08:28:08 +0200 Subject: [PATCH 170/217] fix: refs #7906 add test --- .../back/methods/zone/specs/deleteZone.spec.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js index 60e704161..14cb303ea 100644 --- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js +++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js @@ -9,8 +9,8 @@ describe('zone deletezone()', () => { }; const ctx = {req: activeCtx}; const zoneId = 4; + const zoneId2 = 3; let ticketIDs; - let originalTicketStates; beforeAll(async() => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ @@ -44,4 +44,19 @@ describe('zone deletezone()', () => { throw e; } }); + + it('should not delete the zone if it has tickets', async() => { + const tx = await models.Zone.beginTransaction({}); + + try { + const options = {transaction: tx}; + await models.Zone.deleteZone(ctx, zoneId2, options); + + expect(e.message).toEqual('There are tickets for this area, delete them first'); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + } + }); }); From 1273e895afa18d89fabc9a16590b1b63cd73544f Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 18 Oct 2024 09:27:43 +0200 Subject: [PATCH 171/217] fix: refs #7906 fix test back --- modules/zone/back/methods/zone/specs/deleteZone.spec.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js index 14cb303ea..aef7fd290 100644 --- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js +++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js @@ -48,15 +48,16 @@ describe('zone deletezone()', () => { it('should not delete the zone if it has tickets', async() => { const tx = await models.Zone.beginTransaction({}); + let error; try { const options = {transaction: tx}; await models.Zone.deleteZone(ctx, zoneId2, options); - - expect(e.message).toEqual('There are tickets for this area, delete them first'); - await tx.rollback(); } catch (e) { + error = e.message; await tx.rollback(); } + + expect(error).toEqual('There are tickets for this area, delete them first'); }); }); From 46993ad10324b839f25b90476dacbb7dbae15803 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 18 Oct 2024 09:29:01 +0200 Subject: [PATCH 172/217] refactor: refs #7010 deleted distinct --- modules/ticket/back/methods/ticket/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index d7e77603b..d3e53c702 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -229,7 +229,7 @@ module.exports = Self => { CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) ENGINE = InnoDB - SELECT DISTINCT t.id, + SELECT t.id, t.shipped, CAST(DATE(t.shipped) AS CHAR) shippedDate, HOUR(t.shipped) shippedHour, From 34deba406bbb8d6792a5334cb4c0367fe43b35a2 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 18 Oct 2024 12:59:52 +0200 Subject: [PATCH 173/217] feat: refs #7266 First commit --- .../reports/item-label/assets/css/style.css | 113 +++++------------- .../reports/item-label/item-label.html | 66 +++++----- 2 files changed, 68 insertions(+), 111 deletions(-) diff --git a/print/templates/reports/item-label/assets/css/style.css b/print/templates/reports/item-label/assets/css/style.css index 1101604b9..0dea5a9e4 100644 --- a/print/templates/reports/item-label/assets/css/style.css +++ b/print/templates/reports/item-label/assets/css/style.css @@ -1,88 +1,37 @@ -* { - box-sizing: border-box; +html { + font-family: "Roboto", "Helvetica", "Arial", sans-serif; + font-size: 12px; } -.label { - font-size: 1.2em; -} - -.barcode { - float: left; - width: 40%; -} - -.barcode h1 { - text-align: center; - font-size: 1.8em; - margin: 0 0 10px 0 -} - -.barcode .image { - text-align: center -} - -.barcode .image img { - width: 170px -} - -.data { - float: left; - width: 60%; -} - -.data .header { - background-color: #000; - text-overflow: ellipsis; - white-space: nowrap; - overflow: hidden; - margin-bottom: 25px; - text-align: right; - font-size: 1.2em; - padding: 0.2em; - color: #FFF -} - -.data .color, -.data .producer { - text-transform: uppercase; - text-align: right; - font-size: 1.5em; - text-overflow: ellipsis; - white-space: nowrap; - overflow: hidden; -} - -.data .producer { - text-justify: inter-character; -} - -.data .details { - border-top: 4px solid #000; - padding-top: 2px; -} - -.data .details .package { - padding-right: 5px; - float: left; +table { width: 50%; + font-size: 12px; + float: right; } - -.package .packing, -.package .dated, -.package .labelNumber { - text-align: right +td { + border: 3px solid white; } - -.package .packing { - font-size: 1.8em; - font-weight: 400 -} - -.data .details .size { - background-color: #000; +.center { text-align: center; - font-size: 3em; - padding: 0.2em 0; - float: left; - width: 50%; - color: #FFF +} +.cursive { + font-style: italic; +} +.bold { + font-weight: bold; +} +.black { + background-color: black; + color: white; +} +.md { + font-size: 18px; +} +.xl { + font-size: 36px; +} +.border-black { + border: 2px solid #000000; +} +.regular-with { + width: 60px; } \ No newline at end of file diff --git a/print/templates/reports/item-label/item-label.html b/print/templates/reports/item-label/item-label.html index 66509ab38..e2526fc6b 100644 --- a/print/templates/reports/item-label/item-label.html +++ b/print/templates/reports/item-label/item-label.html @@ -1,29 +1,37 @@ - - -
-
-

{{item.id}}

-
- -
-
-
-
{{item.name}}
-
{{tags.color}}
-
{{tags.producer}}
-
-
-
{{packing()}}
-
{{formatDate(new Date(), '%W/%d')}}
-
{{labelPage}}
-
-
{{item.size}}
-
-
-
- -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1
EUC Cinerea60
Color: LIV150
Origen: VCL
Productor: L'Arenal
Comprador: ATJF:42/11 / 50
Entrada: 358799
E622/2
+ + \ No newline at end of file From b8e782d3a569f935aeb7d55ce65ecde345a7d93b Mon Sep 17 00:00:00 2001 From: carlossa Date: Sun, 20 Oct 2024 15:59:24 +0200 Subject: [PATCH 174/217] fix: refs #6831 filter observation --- modules/client/back/methods/defaulter/filter.js | 3 ++- modules/client/back/methods/defaulter/observationEmail.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/client/back/methods/defaulter/filter.js b/modules/client/back/methods/defaulter/filter.js index 9f19dee0a..5359ce4a7 100644 --- a/modules/client/back/methods/defaulter/filter.js +++ b/modules/client/back/methods/defaulter/filter.js @@ -74,7 +74,8 @@ module.exports = Self => { pm.name payMethod, r.finished IS NULL hasRecovery, dp.id departmentFk, - dp.name departmentName + dp.name departmentName, + dp.notificationEmail departmentEmail FROM defaulter d JOIN client c ON c.id = d.clientFk JOIN country cn ON cn.id = c.countryFk diff --git a/modules/client/back/methods/defaulter/observationEmail.js b/modules/client/back/methods/defaulter/observationEmail.js index c06d1d3d0..797e88f74 100644 --- a/modules/client/back/methods/defaulter/observationEmail.js +++ b/modules/client/back/methods/defaulter/observationEmail.js @@ -47,7 +47,7 @@ module.exports = Self => { await models.Mail.create({ subject: $t('Comment added to client', {clientFk: defaulter.clientFk}), body: body, - receiver: `${defaulter.salesPersonName}@verdnatura.es`, + receiver: `${defaulter.departmentEmail}`, replyTo: `${user.name}@verdnatura.es` }, myOptions); } From b88dc1c70fc956920b292f6d16a8e270d85667f6 Mon Sep 17 00:00:00 2001 From: carlossa Date: Sun, 20 Oct 2024 16:23:24 +0200 Subject: [PATCH 175/217] fix: refs #6850 remove notifyPickUp --- modules/claim/back/methods/claim/updateClaim.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/modules/claim/back/methods/claim/updateClaim.js b/modules/claim/back/methods/claim/updateClaim.js index 326192385..927e27622 100644 --- a/modules/claim/back/methods/claim/updateClaim.js +++ b/modules/claim/back/methods/claim/updateClaim.js @@ -119,18 +119,4 @@ module.exports = Self => { }); await models.Chat.sendCheckingPresence(ctx, workerId, message); } - - async function notifyPickUp(ctx, workerId, claim) { - const models = Self.app.models; - const url = await models.Url.getUrl(); - const $t = ctx.req.__; // $translate - - const message = $t('Claim will be picked', { - claimId: claim.id, - clientName: claim.client().name, - claimUrl: `${url}claim/${claim.id}/summary`, - claimPickup: $t(claim.pickup) - }); - await models.Chat.sendCheckingPresence(ctx, workerId, message); - } }; From 19fbb836a60f6dd6478f24cf04a54e2c801b4cf7 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 21 Oct 2024 08:30:39 +0200 Subject: [PATCH 176/217] fix: refs #6850 fix model --- modules/claim/back/methods/claim/updateClaim.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/claim/back/methods/claim/updateClaim.js b/modules/claim/back/methods/claim/updateClaim.js index 927e27622..f2f3f9050 100644 --- a/modules/claim/back/methods/claim/updateClaim.js +++ b/modules/claim/back/methods/claim/updateClaim.js @@ -86,9 +86,6 @@ module.exports = Self => { const salesPerson = claim.client().salesPersonUser(); if (salesPerson) { - if (changedPickup && updatedClaim.pickup) - await notifyPickUp(ctx, salesPerson.id, claim); - if (args.claimStateFk) { const newState = await models.ClaimState.findById(args.claimStateFk, null, myOptions); await notifyStateChange(ctx, salesPerson.id, claim, newState.description); From bbc17d1ff886898b90cb2a75d33d8598665fcb27 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 21 Oct 2024 08:33:16 +0200 Subject: [PATCH 177/217] fix: refs #230926 item_getSimilar --- db/routines/vn/procedures/item_getSimilar.sql | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index 537f53848..336f3521e 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -24,6 +24,7 @@ BEGIN CALL cache.available_refresh(vAvailableCalcFk, FALSE, vWarehouseFk, vDated); CALL cache.visible_refresh(vVisibleCalcFk, FALSE, vWarehouseFk); + CALL buy_getUltimate(NULL, vWarehouseFk, vDated); WITH itemTags AS ( SELECT i.id, @@ -74,14 +75,13 @@ BEGIN 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 tmp.buyUltimate bu ON bu.itemFk = i.id 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 vn.buy b ON b.id = lb.buy_id + LEFT JOIN vn.buy b ON b.id = bu.buyFk JOIN itemTags its WHERE a.available > 0 AND (i.typeFk = its.typeFk OR NOT vShowType) @@ -98,5 +98,7 @@ BEGIN (i.tag8 = its.tag8) DESC, match8 DESC LIMIT 100; + + DROP TEMPORARY TABLE tmp.buyUltimate; END$$ DELIMITER ; From eea09a9d4ae250a351d90e0fe65030da882c6cd2 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 21 Oct 2024 09:24:53 +0200 Subject: [PATCH 178/217] fix: refs #6850 add code --- modules/claim/back/methods/claim/updateClaim.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/claim/back/methods/claim/updateClaim.js b/modules/claim/back/methods/claim/updateClaim.js index f2f3f9050..563b5b53d 100644 --- a/modules/claim/back/methods/claim/updateClaim.js +++ b/modules/claim/back/methods/claim/updateClaim.js @@ -85,13 +85,11 @@ module.exports = Self => { const updatedClaim = await claim.updateAttributes(args, myOptions); const salesPerson = claim.client().salesPersonUser(); - if (salesPerson) { - 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 (salesPerson && 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(); From 288dc1c598b7cc4ff2457c9bfc9bc683ffce5086 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 21 Oct 2024 10:05:58 +0200 Subject: [PATCH 179/217] feat: refs #7524 myteam filter wip --- .../back/methods/ticket/getTicketsAdvance.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/modules/ticket/back/methods/ticket/getTicketsAdvance.js b/modules/ticket/back/methods/ticket/getTicketsAdvance.js index 1bd5f83de..4585c5d61 100644 --- a/modules/ticket/back/methods/ticket/getTicketsAdvance.js +++ b/modules/ticket/back/methods/ticket/getTicketsAdvance.js @@ -50,6 +50,11 @@ module.exports = Self => { type: 'boolean', description: 'True when lines and stock of origin are equal' }, + { + arg: 'myTeam', + type: 'boolean', + description: `Whether to show only tickets for the current logged user team (currently user tickets)` + }, { arg: 'filter', type: 'object', @@ -69,11 +74,27 @@ module.exports = Self => { Self.getTicketsAdvance = async(ctx, options) => { const args = ctx.args; const conn = Self.dataSource.connector; + const userId = ctx.req.accessToken.userId; const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); + const teamMembersId = []; + if (args.myTeam != null) { + const worker = await models.Worker.findById(userId, { + include: { + relation: 'collegues' + } + }, myOptions); + const collegues = worker.collegues() || []; + for (let collegue of collegues) + teamMembersId.push(collegue.collegueFk); + + if (teamMembersId.length == 0) + teamMembersId.push(userId); + } + const where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'id': @@ -96,6 +117,11 @@ module.exports = Self => { }; case 'isFullMovable': return {'f.isFullMovable': value}; + case 'myTeam': + if (value) + return {'c.salesPersonFk': {inq: teamMembersId}}; + else + return {'c.salesPersonFk': {nin: teamMembersId}}; } }); From cb4e8355ba3f21d05c202ded792f3588d1f5bf65 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 21 Oct 2024 10:58:36 +0200 Subject: [PATCH 180/217] feat: refs #7524 myteam filter --- modules/ticket/back/methods/ticket/getTicketsAdvance.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/getTicketsAdvance.js b/modules/ticket/back/methods/ticket/getTicketsAdvance.js index 4585c5d61..1088d357c 100644 --- a/modules/ticket/back/methods/ticket/getTicketsAdvance.js +++ b/modules/ticket/back/methods/ticket/getTicketsAdvance.js @@ -82,7 +82,7 @@ module.exports = Self => { const teamMembersId = []; if (args.myTeam != null) { - const worker = await models.Worker.findById(userId, { + const worker = await Self.app.models.Worker.findById(userId, { include: { relation: 'collegues' } @@ -119,9 +119,9 @@ module.exports = Self => { return {'f.isFullMovable': value}; case 'myTeam': if (value) - return {'c.salesPersonFk': {inq: teamMembersId}}; + return {'workerFk': {inq: teamMembersId}}; else - return {'c.salesPersonFk': {nin: teamMembersId}}; + return {'workerFk': {nin: teamMembersId}}; } }); From e38c061debb71120f5aefc19f1e91a43531c7765 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 21 Oct 2024 11:36:44 +0200 Subject: [PATCH 181/217] fix: add date format on insert data --- .../bs/procedures/clientNewBorn_recalc.sql | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/db/routines/bs/procedures/clientNewBorn_recalc.sql b/db/routines/bs/procedures/clientNewBorn_recalc.sql index 1c89b5745..c56ffe49c 100644 --- a/db/routines/bs/procedures/clientNewBorn_recalc.sql +++ b/db/routines/bs/procedures/clientNewBorn_recalc.sql @@ -7,24 +7,23 @@ BLOCK1: BEGIN DECLARE vPreviousShipped DATE; DECLARE vDone boolean; DECLARE cur cursor for - - SELECT clientFk, firstShipped - FROM bs.clientNewBorn; DECLARE continue HANDLER FOR NOT FOUND SET vDone = TRUE; SET vDone := FALSE; DELETE FROM bs.clientNewBorn WHERE isModified = FALSE; - INSERT INTO clientNewBorn(clientFk, firstShipped, lastShipped) - SELECT c.id, MAX(t.shipped), MAX(t.shipped) - FROM vn.client c - JOIN vn.ticket t on t.clientFk = c.id - LEFT JOIN clientNewBorn cb on cb.clientFk = c.id - WHERE t.shipped BETWEEN TIMESTAMPADD(YEAR, -1, util.VN_CURDATE()) AND util.VN_CURDATE() AND cb.isModified is null - GROUP BY c.id; + INSERT INTO clientNewBorn(clientFk, firstShipped, lastShipped) + SELECT c.id, DATE(MAX(t.shipped)), DATE(MAX(t.shipped)) + FROM vn.client c + JOIN vn.ticket t ON t.clientFk = c.id + LEFT JOIN clientNewBorn cb ON cb.clientFk = c.id + WHERE t.shipped BETWEEN util.VN_CURDATE() - INTERVAL 1 YEAR + AND util.VN_CURDATE() + AND cb.isModified IS NULL + GROUP BY c.id; + OPEN cur; - LOOP1: LOOP SET vDone := FALSE; FETCH cur INTO vClientFk, vShipped; From e479873547e262c3a7054e4d234eaaba8c91c3d0 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 21 Oct 2024 12:19:20 +0200 Subject: [PATCH 182/217] fix: restore cursor --- db/routines/bs/procedures/clientNewBorn_recalc.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/routines/bs/procedures/clientNewBorn_recalc.sql b/db/routines/bs/procedures/clientNewBorn_recalc.sql index c56ffe49c..bb6b02aa7 100644 --- a/db/routines/bs/procedures/clientNewBorn_recalc.sql +++ b/db/routines/bs/procedures/clientNewBorn_recalc.sql @@ -6,7 +6,10 @@ BLOCK1: BEGIN DECLARE vShipped DATE; DECLARE vPreviousShipped DATE; DECLARE vDone boolean; - DECLARE cur cursor for + + DECLARE cur CURSOR FOR + SELECT clientFk, firstShipped + FROM bs.clientNewBorn; DECLARE continue HANDLER FOR NOT FOUND SET vDone = TRUE; SET vDone := FALSE; From 2b05e8c48e4c2dae7920fdbff21a178767d84f89 Mon Sep 17 00:00:00 2001 From: jgallego Date: Mon, 21 Oct 2024 13:29:33 +0200 Subject: [PATCH 183/217] feat: refs #7943 quitar lectura en metodos comunes --- db/routines/salix/triggers/ACL_beforeInsert.sql | 3 +++ db/versions/11314-redTulip/00-restrictedAsterisk.sql | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 db/versions/11314-redTulip/00-restrictedAsterisk.sql diff --git a/db/routines/salix/triggers/ACL_beforeInsert.sql b/db/routines/salix/triggers/ACL_beforeInsert.sql index 94fb51ada..cb0b5761b 100644 --- a/db/routines/salix/triggers/ACL_beforeInsert.sql +++ b/db/routines/salix/triggers/ACL_beforeInsert.sql @@ -4,5 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `salix`.`ACL_beforeInsert` FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); + IF NEW.`property` = '*' THEN + CALL util.throw('The property field cannot be *'); + END IF; END$$ DELIMITER ; diff --git a/db/versions/11314-redTulip/00-restrictedAsterisk.sql b/db/versions/11314-redTulip/00-restrictedAsterisk.sql new file mode 100644 index 000000000..20f1b4380 --- /dev/null +++ b/db/versions/11314-redTulip/00-restrictedAsterisk.sql @@ -0,0 +1,3 @@ +DELETE FROM `salix`.`ACL` +WHERE `model` = 'Worker' + AND `property` IN ('find', 'findById', 'findOne'); From 1efe258ea0b14c26a9035dc946d23ca394c182f6 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 21 Oct 2024 14:30:45 +0200 Subject: [PATCH 184/217] fix: refs #7524 filter by department --- .../vn/procedures/ticket_canAdvance.sql | 7 +++-- .../back/methods/ticket/getTicketsAdvance.js | 29 ++++--------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index 57c3f4235..e8fc70bba 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -51,7 +51,8 @@ BEGIN origin.companyFk futureCompanyFk, IFNULL(dest.nickname, origin.nickname) nickname, dest.landed, - dest.preparation + dest.preparation, + origin.departmentFk FROM ( SELECT s.ticketFk, c.salesPersonFk workerFk, @@ -71,9 +72,11 @@ BEGIN t.addressFk, t.warehouseFk, t.companyFk, - t.agencyModeFk + t.agencyModeFk, + wd.departmentFk FROM ticket t JOIN client c ON c.id = t.clientFk + JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk JOIN sale s ON s.ticketFk = t.id JOIN saleVolume sv ON sv.saleFk = s.id JOIN item i ON i.id = s.itemFk diff --git a/modules/ticket/back/methods/ticket/getTicketsAdvance.js b/modules/ticket/back/methods/ticket/getTicketsAdvance.js index 1088d357c..41f3ee79a 100644 --- a/modules/ticket/back/methods/ticket/getTicketsAdvance.js +++ b/modules/ticket/back/methods/ticket/getTicketsAdvance.js @@ -51,9 +51,9 @@ module.exports = Self => { description: 'True when lines and stock of origin are equal' }, { - arg: 'myTeam', - type: 'boolean', - description: `Whether to show only tickets for the current logged user team (currently user tickets)` + arg: 'departmentFk', + type: 'number', + description: 'Department identifier' }, { arg: 'filter', @@ -74,27 +74,11 @@ module.exports = Self => { Self.getTicketsAdvance = async(ctx, options) => { const args = ctx.args; const conn = Self.dataSource.connector; - const userId = ctx.req.accessToken.userId; const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); - const teamMembersId = []; - if (args.myTeam != null) { - const worker = await Self.app.models.Worker.findById(userId, { - include: { - relation: 'collegues' - } - }, myOptions); - const collegues = worker.collegues() || []; - for (let collegue of collegues) - teamMembersId.push(collegue.collegueFk); - - if (teamMembersId.length == 0) - teamMembersId.push(userId); - } - const where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'id': @@ -117,11 +101,8 @@ module.exports = Self => { }; case 'isFullMovable': return {'f.isFullMovable': value}; - case 'myTeam': - if (value) - return {'workerFk': {inq: teamMembersId}}; - else - return {'workerFk': {nin: teamMembersId}}; + case 'departmentFk': + return {'f.departmentFk': value}; } }); From bf2d7541a5c956ba48a7f9a8c31553f36ce74418 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 21 Oct 2024 14:57:55 +0200 Subject: [PATCH 185/217] feat: refs #7266 Item label QR --- db/dump/.dump/data.sql | 2 +- loopback/locale/es.json | 4 +- .../item/{labelPdf.js => itemLabelQr.js} | 27 ++--- modules/item/back/models/item.js | 2 +- .../assets/css/import.js | 0 .../item-label-qr/assets/css/style.css | 87 ++++++++++++++ .../reports/item-label-qr/item-label-qr.html | 112 ++++++++++++++++++ .../reports/item-label-qr/item-label-qr.js | 43 +++++++ .../reports/item-label-qr/locale/es.yml | 1 + .../options.json | 2 +- .../reports/item-label-qr/sql/item.sql | 42 +++++++ .../reports/item-label/assets/css/style.css | 37 ------ .../reports/item-label/item-label.html | 37 ------ .../reports/item-label/item-label.js | 58 --------- .../reports/item-label/locale/es.yml | 1 - .../templates/reports/item-label/sql/item.sql | 14 --- .../reports/item-label/sql/itemTags.sql | 4 - 17 files changed, 298 insertions(+), 175 deletions(-) rename modules/item/back/methods/item/{labelPdf.js => itemLabelQr.js} (62%) rename print/templates/reports/{item-label => item-label-qr}/assets/css/import.js (100%) create mode 100644 print/templates/reports/item-label-qr/assets/css/style.css create mode 100644 print/templates/reports/item-label-qr/item-label-qr.html create mode 100755 print/templates/reports/item-label-qr/item-label-qr.js create mode 100644 print/templates/reports/item-label-qr/locale/es.yml rename print/templates/reports/{item-label => item-label-qr}/options.json (86%) create mode 100644 print/templates/reports/item-label-qr/sql/item.sql delete mode 100644 print/templates/reports/item-label/assets/css/style.css delete mode 100644 print/templates/reports/item-label/item-label.html delete mode 100755 print/templates/reports/item-label/item-label.js delete mode 100644 print/templates/reports/item-label/locale/es.yml delete mode 100644 print/templates/reports/item-label/sql/item.sql delete mode 100644 print/templates/reports/item-label/sql/itemTags.sql diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index ca254055b..315bfe7c5 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -1723,7 +1723,7 @@ INSERT INTO `ACL` VALUES (378,'OsTicket','osTicketReportEmail','WRITE','ALLOW',' 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 (382,'Item','itemLabelQr','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); diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 6d50f634e..8e758d1ab 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -383,5 +383,5 @@ "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", - "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero" -} + "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero" +} \ No newline at end of file diff --git a/modules/item/back/methods/item/labelPdf.js b/modules/item/back/methods/item/itemLabelQr.js similarity index 62% rename from modules/item/back/methods/item/labelPdf.js rename to modules/item/back/methods/item/itemLabelQr.js index d7a50397e..8d92d51e8 100644 --- a/modules/item/back/methods/item/labelPdf.js +++ b/modules/item/back/methods/item/itemLabelQr.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('labelPdf', { + Self.remoteMethodCtx('itemLabelQr', { description: 'Returns the item label pdf', accessType: 'READ', accepts: [ @@ -11,26 +11,15 @@ module.exports = Self => { http: {source: 'path'} }, { - arg: 'recipientId', + arg: 'copies', type: 'number', - description: 'The recipient id', required: false - }, - { - arg: 'warehouseId', + }, { + arg: 'userId', type: 'number', - description: 'The warehouse id', + description: 'The user id from accessToken', + http: ctx => ctx.req.accessToken.userId, required: true - }, - { - arg: 'labelNumber', - type: 'number', - required: false - }, - { - arg: 'totalLabels', - type: 'number', - required: false } ], returns: [ @@ -49,11 +38,11 @@ module.exports = Self => { } ], http: { - path: '/:id/label-pdf', + path: '/:id/item-label-qr', verb: 'GET' }, accessScopes: ['DEFAULT', 'read:multimedia'] }); - Self.labelPdf = (ctx, id) => Self.printReport(ctx, id, 'item-label'); + Self.itemLabelQr = (ctx, id) => Self.printReport(ctx, id, 'item-label-qr'); }; diff --git a/modules/item/back/models/item.js b/modules/item/back/models/item.js index e715ab431..4fb9af8fa 100644 --- a/modules/item/back/models/item.js +++ b/modules/item/back/models/item.js @@ -15,7 +15,7 @@ module.exports = Self => { require('../methods/item/getWasteByItem')(Self); require('../methods/item/createIntrastat')(Self); require('../methods/item/buyerWasteEmail')(Self); - require('../methods/item/labelPdf')(Self); + require('../methods/item/itemLabelQr')(Self); require('../methods/item/setVisibleDiscard')(Self); require('../methods/item/get')(Self); diff --git a/print/templates/reports/item-label/assets/css/import.js b/print/templates/reports/item-label-qr/assets/css/import.js similarity index 100% rename from print/templates/reports/item-label/assets/css/import.js rename to print/templates/reports/item-label-qr/assets/css/import.js diff --git a/print/templates/reports/item-label-qr/assets/css/style.css b/print/templates/reports/item-label-qr/assets/css/style.css new file mode 100644 index 000000000..b868f3966 --- /dev/null +++ b/print/templates/reports/item-label-qr/assets/css/style.css @@ -0,0 +1,87 @@ +html { + font-family: "Roboto", "Helvetica", "Arial", sans-serif; + margin-top: -7px; +} +.leftTable { + width: 47%; + font-size: 12px; + float: left; + text-align: center; +} +.leftTable img { + width: 110px; +} +.rightTable { + width: 53%; + font-size: 14px; + float: right; +} +.rightTable td { + border: 3px solid white; +} +.center { + text-align: center; +} +.cursive { + font-style: italic; +} +.bold { + font-weight: bold; +} +.black-bg { + background-color: black; + color: white; +} +.md-txt { + font-size: 20px; +} +.xl-txt { + font-size: 36px; +} +.cell { + border: 2px solid black; + box-sizing: content-box; + width: 100%; + height: 30px; + display: flex; + justify-content: center; + align-items: center; +} +.padding { + padding: 7px; +} +.md-height { + height: 60px; + max-height: 60px; +} +.xs-width { + width: 60px; + max-width: 60px; +} +.sm-width { + width: 140px; + max-width: 140px; +} +.md-width { + width: 200px; + max-width: 200px; +} +.lg-width { + width: 270px; + max-width: 270px; +} +.overflow-multiline { + max-height: inherit; + display: -webkit-box; + overflow: hidden; + word-wrap: break-word; + line-clamp: 2; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; +} +.overflow-line { + width: inherit; + max-width: inherit; + overflow: hidden; + white-space: nowrap; +} \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/item-label-qr.html b/print/templates/reports/item-label-qr/item-label-qr.html new file mode 100644 index 000000000..3b61e1542 --- /dev/null +++ b/print/templates/reports/item-label-qr/item-label-qr.html @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + +
+ + + +
+ {{item.buyFk}} +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ {{item.itemFk}} +
+
+
+ {{item.item}} +
+
+
+ {{item.size}} +
+
+
+ Color: {{item.inkFk}} +
+
+
+ {{item.packing}} +
+
+
+ {{item.stems}} +
+
+
+ Origen: {{item.origin}} +
+
+
+ Productor: {{item.producer}} +
+
+
+ Comprador: {{item.buyerName}} +
+
+
+ F: {{date}} +
+
+
+ {{`${item.labelNum} / ${totalPages}`}} +
+
+
+ Entrada: {{item.entryFk}} +
+
+
+ {{item.comment}} +
+
+ + \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/item-label-qr.js b/print/templates/reports/item-label-qr/item-label-qr.js new file mode 100755 index 000000000..99744b0bd --- /dev/null +++ b/print/templates/reports/item-label-qr/item-label-qr.js @@ -0,0 +1,43 @@ +const UserError = require('vn-loopback/util/user-error'); +const moment = require('moment'); +const qrcode = require('qrcode'); + +module.exports = { + name: 'item-label-qr', + async serverPrefetch() { + this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.id]); + if (!this.items.length) throw new UserError(`Empty data source`); + this.qr = await this.getQr(this.items[0].buyFk); + this.vnDate = Date.vnNew(); + this.date = moment(this.vnDate).format('YY/DD'); + this.totalPages = this.items.length; + }, + methods: { + getQr(data) { + data = { + company: 'vnl', + user: this.userId, + created: this.vnDate, + table: 'buy', + id: data + }; + return qrcode.toDataURL(JSON.stringify(data), { + margin: 0, + errorCorrectionLevel: 'H' + }); + } + }, + props: { + id: { + type: Number, + required: true, + description: 'The item id' + }, + copies: { + type: Number + }, + userId: { + type: Number + } + } +}; diff --git a/print/templates/reports/item-label-qr/locale/es.yml b/print/templates/reports/item-label-qr/locale/es.yml new file mode 100644 index 000000000..81dbc1877 --- /dev/null +++ b/print/templates/reports/item-label-qr/locale/es.yml @@ -0,0 +1 @@ +reportName: Etiqueta de artículo QR \ No newline at end of file diff --git a/print/templates/reports/item-label/options.json b/print/templates/reports/item-label-qr/options.json similarity index 86% rename from print/templates/reports/item-label/options.json rename to print/templates/reports/item-label-qr/options.json index 98c5788b1..5a3c3b1eb 100644 --- a/print/templates/reports/item-label/options.json +++ b/print/templates/reports/item-label-qr/options.json @@ -2,7 +2,7 @@ "width": "10.4cm", "height": "4.8cm", "margin": { - "top": "0cm", + "top": "0.17cm", "right": "0cm", "bottom": "0cm", "left": "0cm" diff --git a/print/templates/reports/item-label-qr/sql/item.sql b/print/templates/reports/item-label-qr/sql/item.sql new file mode 100644 index 000000000..11ee60d1a --- /dev/null +++ b/print/templates/reports/item-label-qr/sql/item.sql @@ -0,0 +1,42 @@ +WITH RECURSIVE numbers AS ( + SELECT 1 n + UNION ALL + SELECT n + 1 + FROM numbers + WHERE n < ? +) +SELECT ROW_NUMBER() OVER() labelNum, + b.id buyFk, + b.itemFk, + b.quantity, + b.packing, + b.isPickedOff, + b.entryFk, + e.sub, + o.code origin, + COALESCE(p.`name`, p.id, '') producer, + i.name item, + i.`size`, + i.category, + i.stems, + i.inkFk, + IFNULL(CONCAT(ig.longName, ' ', ig.`size`, ' ', ig.subName), i.comment) comment, + i.typeFk, + i.isLaid, + w.code buyerName, + w.code, + s.company_name companyName, + t.shipped + FROM vn.buy b + JOIN vn.item i ON i.id = b.itemFk + LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk + LEFT JOIN edi.ekt e ON e.id = b.ektFk + JOIN vn.origin o ON o.id = i.originFk + LEFT JOIN vn.producer p ON p.id = i.producerFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.worker w ON w.id = it.workerFk + LEFT JOIN edi.supplier s ON s.supplier_id = e.pro + JOIN vn.entry e2 ON e2.id = b.entryFk + JOIN vn.travel t ON t.id = e2.travelFk + JOIN numbers num + WHERE b.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label/assets/css/style.css b/print/templates/reports/item-label/assets/css/style.css deleted file mode 100644 index 0dea5a9e4..000000000 --- a/print/templates/reports/item-label/assets/css/style.css +++ /dev/null @@ -1,37 +0,0 @@ -html { - font-family: "Roboto", "Helvetica", "Arial", sans-serif; - font-size: 12px; -} -table { - width: 50%; - font-size: 12px; - float: right; -} -td { - border: 3px solid white; -} -.center { - text-align: center; -} -.cursive { - font-style: italic; -} -.bold { - font-weight: bold; -} -.black { - background-color: black; - color: white; -} -.md { - font-size: 18px; -} -.xl { - font-size: 36px; -} -.border-black { - border: 2px solid #000000; -} -.regular-with { - width: 60px; -} \ No newline at end of file diff --git a/print/templates/reports/item-label/item-label.html b/print/templates/reports/item-label/item-label.html deleted file mode 100644 index e2526fc6b..000000000 --- a/print/templates/reports/item-label/item-label.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1
EUC Cinerea60
Color: LIV150
Origen: VCL
Productor: L'Arenal
Comprador: ATJF:42/11 / 50
Entrada: 358799
E622/2
- - \ No newline at end of file diff --git a/print/templates/reports/item-label/item-label.js b/print/templates/reports/item-label/item-label.js deleted file mode 100755 index c5b9cdfd7..000000000 --- a/print/templates/reports/item-label/item-label.js +++ /dev/null @@ -1,58 +0,0 @@ -const vnReport = require('../../../core/mixins/vn-report.js'); -const qrcode = require('qrcode'); - -module.exports = { - name: 'item-label', - mixins: [vnReport], - async serverPrefetch() { - this.item = await this.findOneFromDef('item', [this.id, this.warehouseId]); - this.checkMainEntity(this.item); - this.tags = await this.fetchItemTags(this.id); - this.barcode = await this.getBarcodeBase64(this.id); - }, - - computed: { - labelPage() { - const labelNumber = this.labelNumber ? this.labelNumber : 1; - const totalLabels = this.totalLabels ? this.totalLabels : 1; - - return `${labelNumber}/${totalLabels}`; - } - }, - methods: { - fetchItemTags(id) { - return this.rawSqlFromDef('itemTags', [id]).then(rows => { - const tags = {}; - rows.forEach(row => tags[row.code] = row.value); - - return tags; - }); - }, - getBarcodeBase64(id) { - const data = String(id); - - return qrcode.toDataURL(data, {margin: 0}); - }, - packing() { - const stems = this.item.stems ? this.item.stems : 1; - return `${this.item.packing}x${stems}`; - } - }, - props: { - id: { - type: Number, - required: true, - description: 'The item id' - }, - warehouseId: { - type: Number, - required: true - }, - labelNumber: { - type: Number - }, - totalLabels: { - type: Number - } - } -}; diff --git a/print/templates/reports/item-label/locale/es.yml b/print/templates/reports/item-label/locale/es.yml deleted file mode 100644 index 278946f3e..000000000 --- a/print/templates/reports/item-label/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -reportName: Etiqueta \ No newline at end of file diff --git a/print/templates/reports/item-label/sql/item.sql b/print/templates/reports/item-label/sql/item.sql deleted file mode 100644 index 46aacc2fa..000000000 --- a/print/templates/reports/item-label/sql/item.sql +++ /dev/null @@ -1,14 +0,0 @@ -SELECT - i.id, - i.name, - i.stems, - i.size, - b.packing, - p.name as 'producer' -FROM vn.item i - JOIN cache.last_buy clb ON clb.item_id = i.id - JOIN vn.buy b ON b.id = clb.buy_id - JOIN vn.entry e ON e.id = b.entryFk - JOIN vn.producer p ON p.id = i.producerFk - -WHERE i.id = ? AND clb.warehouse_id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label/sql/itemTags.sql b/print/templates/reports/item-label/sql/itemTags.sql deleted file mode 100644 index 3c20098a6..000000000 --- a/print/templates/reports/item-label/sql/itemTags.sql +++ /dev/null @@ -1,4 +0,0 @@ -SELECT t.code, t.name, it.value -FROM vn.itemTag it - JOIN vn.tag t ON t.id = it.tagFk -WHERE it.itemFk = ? \ No newline at end of file From 5162c2037b650d4c1b7dfef0d546286cbf5488e4 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 22 Oct 2024 08:41:46 +0200 Subject: [PATCH 186/217] feat: refs #8119 Requested changes --- db/routines/vn/procedures/itemCampaignQuantity_add.sql | 5 ++++- db/versions/11308-redCymbidium/00-firstScript.sql | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemCampaignQuantity_add.sql b/db/routines/vn/procedures/itemCampaignQuantity_add.sql index ca041d2d2..6edb97c08 100644 --- a/db/routines/vn/procedures/itemCampaignQuantity_add.sql +++ b/db/routines/vn/procedures/itemCampaignQuantity_add.sql @@ -65,12 +65,15 @@ proc: BEGIN SET vDateSumFrom = vDateSumTo - INTERVAL vScopeDays DAY; - REPLACE itemCampaignQuantity(dated, itemFk, quantity, campaign) + REPLACE itemCampaignQuantity(dated, itemFk, quantity, total, campaign) SELECT DATE(s.created), s.itemFk, SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo THEN s.quantity END) quantity, + SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo + THEN s.total + END) total, vCampaign FROM sale s JOIN ticket t ON t.id = s.ticketFk diff --git a/db/versions/11308-redCymbidium/00-firstScript.sql b/db/versions/11308-redCymbidium/00-firstScript.sql index d90cd1ae6..14fad3636 100644 --- a/db/versions/11308-redCymbidium/00-firstScript.sql +++ b/db/versions/11308-redCymbidium/00-firstScript.sql @@ -3,6 +3,7 @@ CREATE TABLE IF NOT EXISTS `vn`.`itemCampaignQuantity` ( dated date NOT NULL, itemFk int(11) NOT NULL, quantity decimal(10,2) NOT NULL, + total decimal(10,2) NOT NULL, campaign varchar(100) NOT NULL, UNIQUE KEY `itemCampaignQuantity_UNIQUE` (`dated`,`itemFk`), CONSTRAINT itemCampaignQuantity_item_FK FOREIGN KEY (itemFk) REFERENCES vn.item(id) ON DELETE RESTRICT ON UPDATE CASCADE From 6ef77604985c3ea38d9e3de0843b57ce28b5cb7e Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 22 Oct 2024 10:06:59 +0200 Subject: [PATCH 187/217] fix: refs #6861 fixTransactionCommit --- .../collection_addWithReservation.sql | 18 +++---- .../procedures/itemShelvingSale_addBySale.sql | 49 ++++++++++--------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/db/routines/vn/procedures/collection_addWithReservation.sql b/db/routines/vn/procedures/collection_addWithReservation.sql index cc0b7fd9b..bb6e94a63 100644 --- a/db/routines/vn/procedures/collection_addWithReservation.sql +++ b/db/routines/vn/procedures/collection_addWithReservation.sql @@ -37,23 +37,23 @@ BEGIN WHERE t.id = vTicketFk; CALL cache.available_refresh( - vCacheAvailableFk, + vCacheAvailableFk, FALSE, - vWarehouseFk, + vWarehouseFk, util.VN_CURDATE()); SELECT available INTO vAvailable FROM cache.available - WHERE calc_id = vCacheAvailableFk + 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) + CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name) INTO vItemName, vConcept - FROM item + FROM item WHERE id = vItemFk; START TRANSACTION; @@ -69,7 +69,7 @@ BEGIN 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; @@ -78,13 +78,13 @@ BEGIN 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/itemShelvingSale_addBySale.sql b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql index 6625e89b8..06736732a 100644 --- a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql +++ b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql @@ -18,8 +18,9 @@ proc: BEGIN DECLARE vReservedQuantity INT; DECLARE vOutStanding INT; DECLARE vUserFk INT; - DECLARE vTotalReservedQuantity INT; + DECLARE vTotalReservedQuantity INT; DECLARE vSaleQuantity INT; + DECLARE vIsRequiredTx BOOL DEFAULT NOT @@in_transaction; DECLARE vItemShelvingAvailable CURSOR FOR SELECT ish.id itemShelvingFk, @@ -29,7 +30,7 @@ proc: BEGIN 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 + JOIN productionConfig pc WHERE s.id = vSaleFk AND NOT sc.isHideForPickers AND (sc.id = vSectorFk OR vSectorFk IS NULL) @@ -44,15 +45,15 @@ proc: BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN - ROLLBACK; + CALL util.tx_rollback(vIsRequiredTx); RESIGNAL; END; - - START TRANSACTION; - + + CALL util.tx_start(vIsRequiredTx); + SELECT id INTO vSaleFk FROM sale - WHERE id = vSaleFk + WHERE id = vSaleFk FOR UPDATE; SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)), s.quantity @@ -65,7 +66,7 @@ proc: BEGIN WHERE s.id = vSaleFk; IF vOutStanding <= 0 THEN - COMMIT; + CALL util.tx_commit(vIsRequiredTx); LEAVE proc; END IF; @@ -85,7 +86,7 @@ proc: BEGIN 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; @@ -93,7 +94,7 @@ proc: BEGIN LEAVE l; END IF; - SELECT id INTO vItemShelvingFk + SELECT id INTO vItemShelvingFk FROM itemShelving WHERE id = vItemShelvingFk FOR UPDATE; @@ -102,19 +103,19 @@ proc: BEGIN 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; + 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 @@ -123,6 +124,6 @@ proc: BEGIN END IF; END LOOP; CLOSE vItemShelvingAvailable; - COMMIT; + CALL util.tx_commit(vIsRequiredTx); END$$ DELIMITER ; \ No newline at end of file From 0af58b20bea4025736feb55ac286ec441237691a Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 22 Oct 2024 12:02:04 +0200 Subject: [PATCH 188/217] feat: refs #7266 Item label QR finished --- db/routines/vn/functions/buy_getUltimate.sql | 31 +++++++++++++++++++ loopback/locale/es.json | 3 +- modules/item/back/methods/item/itemLabelQr.js | 11 +++++-- .../reports/item-label-qr/item-label-qr.html | 4 +-- .../reports/item-label-qr/item-label-qr.js | 28 ++++++++++++----- .../reports/item-label-qr/sql/company.sql | 6 ++++ .../reports/item-label-qr/sql/lastBuy.sql | 1 + 7 files changed, 72 insertions(+), 12 deletions(-) create mode 100644 db/routines/vn/functions/buy_getUltimate.sql create mode 100644 print/templates/reports/item-label-qr/sql/company.sql create mode 100644 print/templates/reports/item-label-qr/sql/lastBuy.sql diff --git a/db/routines/vn/functions/buy_getUltimate.sql b/db/routines/vn/functions/buy_getUltimate.sql new file mode 100644 index 000000000..173e6e01f --- /dev/null +++ b/db/routines/vn/functions/buy_getUltimate.sql @@ -0,0 +1,31 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getUltimate`( + vItemFk INT, + vWarehouseFk SMALLINT, + vDated DATE +) + RETURNS int(11) + DETERMINISTIC +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 Id de compra + */ + DECLARE vBuyFk INT; + + CALL buy_getUltimate(vItemFk, vWarehouseFk, vDated); + + SELECT buyFk INTO vBuyFk + FROM tmp.buyUltimate; + + DROP TEMPORARY TABLE IF EXISTS + tmp.buyUltimate, + tmp.buyUltimateFromInterval; + + RETURN vBuyFk; +END$$ +DELIMITER ; diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 8e758d1ab..8f0869eb5 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -383,5 +383,6 @@ "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", - "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero" + "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero", + "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén" } \ No newline at end of file diff --git a/modules/item/back/methods/item/itemLabelQr.js b/modules/item/back/methods/item/itemLabelQr.js index 8d92d51e8..88d8ce950 100644 --- a/modules/item/back/methods/item/itemLabelQr.js +++ b/modules/item/back/methods/item/itemLabelQr.js @@ -9,8 +9,15 @@ module.exports = Self => { required: true, description: 'The item id', http: {source: 'path'} - }, - { + }, { + arg: 'warehouseId', + type: 'number', + required: true + }, { + arg: 'packing', + type: 'number', + required: false + }, { arg: 'copies', type: 'number', required: false diff --git a/print/templates/reports/item-label-qr/item-label-qr.html b/print/templates/reports/item-label-qr/item-label-qr.html index 3b61e1542..2ece8943e 100644 --- a/print/templates/reports/item-label-qr/item-label-qr.html +++ b/print/templates/reports/item-label-qr/item-label-qr.html @@ -52,7 +52,7 @@
- {{item.packing}} + {{packing || item.packing}}
@@ -89,7 +89,7 @@
- {{`${item.labelNum} / ${totalPages}`}} + {{`${item.labelNum}/${item.quantity / (packing || item.packing)}`}}
diff --git a/print/templates/reports/item-label-qr/item-label-qr.js b/print/templates/reports/item-label-qr/item-label-qr.js index 99744b0bd..1a0ef767b 100755 --- a/print/templates/reports/item-label-qr/item-label-qr.js +++ b/print/templates/reports/item-label-qr/item-label-qr.js @@ -5,25 +5,33 @@ const qrcode = require('qrcode'); module.exports = { name: 'item-label-qr', async serverPrefetch() { - this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.id]); + this.company = await this.findOneFromDef('company', [this.warehouseId]); + if (!this.company) + throw new UserError(`There is no company associated with that warehouse`); + + this.date = Date.vnNew(); + this.lastBuy = await this.findOneFromDef('lastBuy', [ + this.id, + this.warehouseId, + this.date + ]); + this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy.id]); if (!this.items.length) throw new UserError(`Empty data source`); this.qr = await this.getQr(this.items[0].buyFk); - this.vnDate = Date.vnNew(); - this.date = moment(this.vnDate).format('YY/DD'); - this.totalPages = this.items.length; + this.date = moment(this.date).format('WW/E'); }, methods: { getQr(data) { data = { - company: 'vnl', + company: this.company, user: this.userId, - created: this.vnDate, + created: this.date, table: 'buy', id: data }; return qrcode.toDataURL(JSON.stringify(data), { margin: 0, - errorCorrectionLevel: 'H' + errorCorrectionLevel: 'L' }); } }, @@ -33,6 +41,12 @@ module.exports = { required: true, description: 'The item id' }, + warehouseId: { + type: Number + }, + packing: { + type: Number + }, copies: { type: Number }, diff --git a/print/templates/reports/item-label-qr/sql/company.sql b/print/templates/reports/item-label-qr/sql/company.sql new file mode 100644 index 000000000..e130b4033 --- /dev/null +++ b/print/templates/reports/item-label-qr/sql/company.sql @@ -0,0 +1,6 @@ +SELECT co.code + FROM warehouse w + JOIN address a ON a.id = w.addressFk + JOIN client c ON c.id = a.clientFk + JOIN company co ON co.clientFk = c.id + WHERE w.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/sql/lastBuy.sql b/print/templates/reports/item-label-qr/sql/lastBuy.sql new file mode 100644 index 000000000..d10339998 --- /dev/null +++ b/print/templates/reports/item-label-qr/sql/lastBuy.sql @@ -0,0 +1 @@ +SELECT buy_getUltimate(?, ?, ?) id \ No newline at end of file From ee0c0996f6e00507519e35368f279bee4b6b8e95 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 22 Oct 2024 12:16:26 +0200 Subject: [PATCH 189/217] feat: refs #7524 add e2e --- db/dump/fixtures.before.sql | 2 +- .../ticket/specs/getTicketsAdvance.spec.js | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 5076f9330..a667b6d27 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -403,7 +403,7 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city (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'); INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`) - SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), UPPER(CONCAT(name, 'Social')), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1 + SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), UPPER(CONCAT(name, 'Social')), CONCAT(name, 'Contact'), UPPER(CONCAT(name, 'Street')), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1 FROM `account`.`role` `r` WHERE `r`.`hasLogin` = 1; diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js index 488cd1fc2..a941013cd 100644 --- a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js @@ -6,6 +6,9 @@ describe('TicketFuture getTicketsAdvance()', () => { today.setHours(0, 0, 0, 0); let tomorrow = Date.vnNew(); tomorrow.setDate(today.getDate() + 1); + const salesDeptId = 43; + const spain1DeptId = 95; + beforeAll.mockLoopBackContext(); it('should return the tickets passing the required data', async() => { const tx = await models.Ticket.beginTransaction({}); @@ -129,4 +132,39 @@ describe('TicketFuture getTicketsAdvance()', () => { throw e; } }); + + it('should return the tickets matching the right department', async() => { + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + ctx.args = { + dateFuture: tomorrow, + dateToAdvance: today, + warehouseFk: 1, + }; + + await models.Ticket.updateAll({id: {inq: [12, 31]}}, {clientFk: 1}, options); + const client = await models.Client.findById(1, null, options); + await client.updateAttribute('salesPersonFk', 1, options); + const business = await models.Business.findById(1, null, options); + await business.updateAttributes({departmentFk: spain1DeptId}, options); + + const saleTickets = await models.Ticket.getTicketsAdvance(ctx, options); + const filteredSaleTickets = await models.Ticket.getTicketsAdvance( + {args: {...ctx.args, departmentFk: spain1DeptId}}, + options); + + expect(saleTickets.length).toBeGreaterThan(filteredSaleTickets.length); + expect(saleTickets.some(ticket => ticket.departmentFk === salesDeptId)).toBeTrue(); + expect(saleTickets.some(ticket => ticket.departmentFk === spain1DeptId)).toBeTrue(); + + expect(filteredSaleTickets.some(ticket => ticket.departmentFk === salesDeptId)).toBeFalse(); + expect(filteredSaleTickets.some(ticket => ticket.departmentFk === spain1DeptId)).toBeTrue(); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); From 1c5e4f40cec2c18cbf28e266bc37cd2e50fdf225 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 22 Oct 2024 12:39:51 +0200 Subject: [PATCH 190/217] feat: refs #8083 add prop --- modules/ticket/back/models/expedition.json | 117 +++++++++++---------- 1 file changed, 60 insertions(+), 57 deletions(-) diff --git a/modules/ticket/back/models/expedition.json b/modules/ticket/back/models/expedition.json index 2dcca1e87..f3f912ec3 100644 --- a/modules/ticket/back/models/expedition.json +++ b/modules/ticket/back/models/expedition.json @@ -1,63 +1,66 @@ { - "name": "Expedition", - "base": "VnModel", - "mixins": { - "Loggable": true + "name": "Expedition", + "base": "VnModel", + "mixins": { + "Loggable": true + }, + "options": { + "mysql": { + "table": "expedition" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "description": "Identifier" }, - "options": { - "mysql": { - "table": "expedition" - } + "freightItemFk": { + "type": "number" }, - "properties": { - "id": { - "id": true, - "type": "number", - "description": "Identifier" - }, - "freightItemFk": { - "type": "number" - }, - "created": { - "type": "date" - }, - "counter": { - "type": "number" - }, - "externalId": { - "type": "string" - } + "created": { + "type": "date" }, - "relations": { - "ticket": { - "type": "belongsTo", - "model": "Ticket", - "foreignKey": "ticketFk" - }, - "agencyMode": { - "type": "belongsTo", - "model": "AgencyMode", - "foreignKey": "agencyModeFk" - }, - "worker": { - "type": "belongsTo", - "model": "Worker", - "foreignKey": "workerFk" - }, - "packages": { - "type": "hasMany", - "model": "TicketPackaging", - "foreignKey": "ticketFk" - }, - "freightItem": { - "type": "belongsTo", - "model": "Item", - "foreignKey": "freightItemFk" - }, - "packaging": { - "type": "belongsTo", - "model": "Package", - "foreignKey": "packagingFk" - } + "counter": { + "type": "number" + }, + "externalId": { + "type": "string" + }, + "stateTypeFk": { + "type": "number" + } + }, + "relations": { + "ticket": { + "type": "belongsTo", + "model": "Ticket", + "foreignKey": "ticketFk" + }, + "agencyMode": { + "type": "belongsTo", + "model": "AgencyMode", + "foreignKey": "agencyModeFk" + }, + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "packages": { + "type": "hasMany", + "model": "TicketPackaging", + "foreignKey": "ticketFk" + }, + "freightItem": { + "type": "belongsTo", + "model": "Item", + "foreignKey": "freightItemFk" + }, + "packaging": { + "type": "belongsTo", + "model": "Package", + "foreignKey": "packagingFk" } } +} \ No newline at end of file From c3f8da52c61b7070ade2de36800d8c1c91f8f698 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 22 Oct 2024 13:43:54 +0200 Subject: [PATCH 191/217] feat: refs #7266 Item label barcode --- db/dump/.dump/data.sql | 1 - .../11315-grayCamellia/00-firstScript.sql | 3 + .../item/back/methods/item/labelBarcodePdf.js | 55 ++++++++++++ .../item/{itemLabelQr.js => labelQrPdf.js} | 8 +- modules/item/back/models/item.js | 3 +- .../item-label-barcode/assets/css/import.js | 12 +++ .../item-label-barcode/assets/css/style.css | 83 ++++++++++++++++++ .../item-label-barcode.html | 87 +++++++++++++++++++ .../item-label-barcode/item-label-barcode.js | 58 +++++++++++++ .../reports/item-label-barcode/locale/es.yml | 1 + .../reports/item-label-barcode/options.json | 11 +++ .../item-label-barcode/sql/company.sql | 6 ++ .../reports/item-label-barcode/sql/item.sql | 42 +++++++++ .../item-label-barcode/sql/lastBuy.sql | 1 + .../reports/item-label-qr/item-label-qr.html | 2 +- 15 files changed, 366 insertions(+), 7 deletions(-) create mode 100644 db/versions/11315-grayCamellia/00-firstScript.sql create mode 100644 modules/item/back/methods/item/labelBarcodePdf.js rename modules/item/back/methods/item/{itemLabelQr.js => labelQrPdf.js} (86%) create mode 100644 print/templates/reports/item-label-barcode/assets/css/import.js create mode 100644 print/templates/reports/item-label-barcode/assets/css/style.css create mode 100644 print/templates/reports/item-label-barcode/item-label-barcode.html create mode 100755 print/templates/reports/item-label-barcode/item-label-barcode.js create mode 100644 print/templates/reports/item-label-barcode/locale/es.yml create mode 100644 print/templates/reports/item-label-barcode/options.json create mode 100644 print/templates/reports/item-label-barcode/sql/company.sql create mode 100644 print/templates/reports/item-label-barcode/sql/item.sql create mode 100644 print/templates/reports/item-label-barcode/sql/lastBuy.sql diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index 315bfe7c5..5f464c5e2 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -1723,7 +1723,6 @@ INSERT INTO `ACL` VALUES (378,'OsTicket','osTicketReportEmail','WRITE','ALLOW',' 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','itemLabelQr','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); diff --git a/db/versions/11315-grayCamellia/00-firstScript.sql b/db/versions/11315-grayCamellia/00-firstScript.sql new file mode 100644 index 000000000..60eea0e01 --- /dev/null +++ b/db/versions/11315-grayCamellia/00-firstScript.sql @@ -0,0 +1,3 @@ +DELETE FROM salix.ACL + WHERE property = 'labelPdf' + AND model = 'Item'; diff --git a/modules/item/back/methods/item/labelBarcodePdf.js b/modules/item/back/methods/item/labelBarcodePdf.js new file mode 100644 index 000000000..3325e3da1 --- /dev/null +++ b/modules/item/back/methods/item/labelBarcodePdf.js @@ -0,0 +1,55 @@ +module.exports = Self => { + Self.remoteMethodCtx('labelBarcodePdf', { + description: 'Returns the item label pdf with barcode', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The item id', + http: {source: 'path'} + }, { + arg: 'warehouseId', + type: 'number', + required: true + }, { + arg: 'packing', + type: 'number', + required: false + }, { + arg: 'copies', + type: 'number', + required: false + }, { + arg: 'userId', + type: 'number', + description: 'The user id from accessToken', + http: ctx => ctx.req.accessToken.userId, + required: true + } + ], + 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/label-barcode-pdf', + verb: 'GET' + }, + accessScopes: ['DEFAULT', 'read:multimedia'] + }); + + Self.labelBarcodePdf = (ctx, id) => Self.printReport(ctx, id, 'item-label-barcode'); +}; diff --git a/modules/item/back/methods/item/itemLabelQr.js b/modules/item/back/methods/item/labelQrPdf.js similarity index 86% rename from modules/item/back/methods/item/itemLabelQr.js rename to modules/item/back/methods/item/labelQrPdf.js index 88d8ce950..4d0e34528 100644 --- a/modules/item/back/methods/item/itemLabelQr.js +++ b/modules/item/back/methods/item/labelQrPdf.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethodCtx('itemLabelQr', { - description: 'Returns the item label pdf', + Self.remoteMethodCtx('labelQrPdf', { + description: 'Returns the item label pdf with qr', accessType: 'READ', accepts: [ { @@ -45,11 +45,11 @@ module.exports = Self => { } ], http: { - path: '/:id/item-label-qr', + path: '/:id/label-qr-pdf', verb: 'GET' }, accessScopes: ['DEFAULT', 'read:multimedia'] }); - Self.itemLabelQr = (ctx, id) => Self.printReport(ctx, id, 'item-label-qr'); + Self.labelQrPdf = (ctx, id) => Self.printReport(ctx, id, 'item-label-qr'); }; diff --git a/modules/item/back/models/item.js b/modules/item/back/models/item.js index 4fb9af8fa..d39586a90 100644 --- a/modules/item/back/models/item.js +++ b/modules/item/back/models/item.js @@ -15,7 +15,8 @@ module.exports = Self => { require('../methods/item/getWasteByItem')(Self); require('../methods/item/createIntrastat')(Self); require('../methods/item/buyerWasteEmail')(Self); - require('../methods/item/itemLabelQr')(Self); + require('../methods/item/labelBarcodePdf')(Self); + require('../methods/item/labelQrPdf')(Self); require('../methods/item/setVisibleDiscard')(Self); require('../methods/item/get')(Self); diff --git a/print/templates/reports/item-label-barcode/assets/css/import.js b/print/templates/reports/item-label-barcode/assets/css/import.js new file mode 100644 index 000000000..37a98dfdd --- /dev/null +++ b/print/templates/reports/item-label-barcode/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/item-label-barcode/assets/css/style.css b/print/templates/reports/item-label-barcode/assets/css/style.css new file mode 100644 index 000000000..48b881986 --- /dev/null +++ b/print/templates/reports/item-label-barcode/assets/css/style.css @@ -0,0 +1,83 @@ +html { + font-family: "Roboto", "Helvetica", "Arial", sans-serif; + margin-top: -7px; +} +table { + width: 100%; + font-size: 14px; +} +td { + border: 6px solid white; +} +.center { + text-align: center; +} +.right { + text-align: right; +} +.cursive { + font-style: italic; +} +.bold { + font-weight: bold; +} +.black-bg { + background-color: black; + color: white; +} +.xs-txt { + font-size: 18px; +} +.md-txt { + font-size: 26px; +} +.xl-txt { + font-size: 50px; +} +.cell { + border: 2px solid black; + box-sizing: content-box; + width: 100%; + height: 30px; + display: flex; + justify-content: center; + align-items: center; +} +.padding { + padding: 7px; +} +.xs-height { + height: 50px; + max-height: 50px; +} +.md-height { + height: 60px; + max-height: 60px; +} +.sm-width { + width: 60px; + max-width: 60px; +} +.md-width { + width: 120px; + max-width: 120px; +} +.lg-width { + width: 400px; + max-width: 400px; +} +.overflow-multiline { + max-height: inherit; + display: -webkit-box; + overflow: hidden; + word-wrap: break-word; + line-clamp: 2; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; +} +.overflow-line { + width: inherit; + max-width: inherit; + overflow: hidden; + white-space: nowrap; +} \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.html b/print/templates/reports/item-label-barcode/item-label-barcode.html new file mode 100644 index 000000000..79de49411 --- /dev/null +++ b/print/templates/reports/item-label-barcode/item-label-barcode.html @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ {{item.item}} +
+
+
+ {{item.size}} +
+
+
+ {{item.comment}} +
+
+
+ {{item.producer}} +
+
+
+ {{item.inkFk}} +
+
+
+ {{item.itemFk}} +
+
+
+ {{`${(packing || item.packing)} x ${item.stems || ''}`}} +
+
+
+
+
+ {{item.entryFk}} +
+
+
+ {{item.buyerName}} +
+
+
+ {{item.origin}} +
+
+
+ {{item.buyFk}} +
+
+
+ {{date}} +
+
+
+ {{`${item.labelNum}/${item.quantity / (packing || item.packing)}`}} +
+
+ + \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.js b/print/templates/reports/item-label-barcode/item-label-barcode.js new file mode 100755 index 000000000..29a2b9ad5 --- /dev/null +++ b/print/templates/reports/item-label-barcode/item-label-barcode.js @@ -0,0 +1,58 @@ +const UserError = require('vn-loopback/util/user-error'); +const {DOMImplementation, XMLSerializer} = require('xmldom'); +const moment = require('moment'); +const jsbarcode = require('jsbarcode'); + +module.exports = { + name: 'item-label-qr', + async serverPrefetch() { + this.company = await this.findOneFromDef('company', [this.warehouseId]); + if (!this.company) + throw new UserError(`There is no company associated with that warehouse`); + + this.date = Date.vnNew(); + this.lastBuy = await this.findOneFromDef('lastBuy', [ + this.id, + this.warehouseId, + this.date + ]); + this.items = await this.rawSqlFromDef('item', [this.copies || 1, this.lastBuy.id]); + if (!this.items.length) throw new UserError(`Empty data source`); + this.date = moment(this.date).format('WW/E'); + }, + methods: { + getBarcode(data) { + 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, data, { + xmlDocument: document, + format: 'code128', + displayValue: false, + width: 3.9, + height: 85, + margin: 0 + }); + return new XMLSerializer().serializeToString(svgNode); + } + }, + props: { + id: { + type: Number, + required: true, + description: 'The item id' + }, + warehouseId: { + type: Number + }, + packing: { + type: Number + }, + copies: { + type: Number + }, + userId: { + type: Number + } + } +}; diff --git a/print/templates/reports/item-label-barcode/locale/es.yml b/print/templates/reports/item-label-barcode/locale/es.yml new file mode 100644 index 000000000..3cf8d2ce8 --- /dev/null +++ b/print/templates/reports/item-label-barcode/locale/es.yml @@ -0,0 +1 @@ +reportName: Etiqueta de artículo barcode \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/options.json b/print/templates/reports/item-label-barcode/options.json new file mode 100644 index 000000000..5a3c3b1eb --- /dev/null +++ b/print/templates/reports/item-label-barcode/options.json @@ -0,0 +1,11 @@ +{ + "width": "10.4cm", + "height": "4.8cm", + "margin": { + "top": "0.17cm", + "right": "0cm", + "bottom": "0cm", + "left": "0cm" + }, + "printBackground": true +} \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/sql/company.sql b/print/templates/reports/item-label-barcode/sql/company.sql new file mode 100644 index 000000000..e130b4033 --- /dev/null +++ b/print/templates/reports/item-label-barcode/sql/company.sql @@ -0,0 +1,6 @@ +SELECT co.code + FROM warehouse w + JOIN address a ON a.id = w.addressFk + JOIN client c ON c.id = a.clientFk + JOIN company co ON co.clientFk = c.id + WHERE w.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/sql/item.sql b/print/templates/reports/item-label-barcode/sql/item.sql new file mode 100644 index 000000000..11ee60d1a --- /dev/null +++ b/print/templates/reports/item-label-barcode/sql/item.sql @@ -0,0 +1,42 @@ +WITH RECURSIVE numbers AS ( + SELECT 1 n + UNION ALL + SELECT n + 1 + FROM numbers + WHERE n < ? +) +SELECT ROW_NUMBER() OVER() labelNum, + b.id buyFk, + b.itemFk, + b.quantity, + b.packing, + b.isPickedOff, + b.entryFk, + e.sub, + o.code origin, + COALESCE(p.`name`, p.id, '') producer, + i.name item, + i.`size`, + i.category, + i.stems, + i.inkFk, + IFNULL(CONCAT(ig.longName, ' ', ig.`size`, ' ', ig.subName), i.comment) comment, + i.typeFk, + i.isLaid, + w.code buyerName, + w.code, + s.company_name companyName, + t.shipped + FROM vn.buy b + JOIN vn.item i ON i.id = b.itemFk + LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk + LEFT JOIN edi.ekt e ON e.id = b.ektFk + JOIN vn.origin o ON o.id = i.originFk + LEFT JOIN vn.producer p ON p.id = i.producerFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.worker w ON w.id = it.workerFk + LEFT JOIN edi.supplier s ON s.supplier_id = e.pro + JOIN vn.entry e2 ON e2.id = b.entryFk + JOIN vn.travel t ON t.id = e2.travelFk + JOIN numbers num + WHERE b.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/sql/lastBuy.sql b/print/templates/reports/item-label-barcode/sql/lastBuy.sql new file mode 100644 index 000000000..d10339998 --- /dev/null +++ b/print/templates/reports/item-label-barcode/sql/lastBuy.sql @@ -0,0 +1 @@ +SELECT buy_getUltimate(?, ?, ?) id \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/item-label-qr.html b/print/templates/reports/item-label-qr/item-label-qr.html index 2ece8943e..231c94818 100644 --- a/print/templates/reports/item-label-qr/item-label-qr.html +++ b/print/templates/reports/item-label-qr/item-label-qr.html @@ -1,6 +1,6 @@ - + - @@ -103,7 +103,11 @@ diff --git a/print/templates/reports/item-label-qr/sql/company.sql b/print/templates/reports/item-label-qr/sql/company.sql index e130b4033..4047786a9 100644 --- a/print/templates/reports/item-label-qr/sql/company.sql +++ b/print/templates/reports/item-label-qr/sql/company.sql @@ -1,6 +1,5 @@ SELECT co.code FROM warehouse w JOIN address a ON a.id = w.addressFk - JOIN client c ON c.id = a.clientFk - JOIN company co ON co.clientFk = c.id + JOIN company co ON co.clientFk = a.clientFk WHERE w.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/sql/item.sql b/print/templates/reports/item-label-qr/sql/item.sql index 11ee60d1a..3cb42d139 100644 --- a/print/templates/reports/item-label-qr/sql/item.sql +++ b/print/templates/reports/item-label-qr/sql/item.sql @@ -6,37 +6,29 @@ WITH RECURSIVE numbers AS ( WHERE n < ? ) SELECT ROW_NUMBER() OVER() labelNum, - b.id buyFk, - b.itemFk, - b.quantity, - b.packing, - b.isPickedOff, - b.entryFk, - e.sub, - o.code origin, - COALESCE(p.`name`, p.id, '') producer, - i.name item, - i.`size`, - i.category, - i.stems, - i.inkFk, - IFNULL(CONCAT(ig.longName, ' ', ig.`size`, ' ', ig.subName), i.comment) comment, - i.typeFk, - i.isLaid, - w.code buyerName, - w.code, - s.company_name companyName, - t.shipped - FROM vn.buy b - JOIN vn.item i ON i.id = b.itemFk - LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk - LEFT JOIN edi.ekt e ON e.id = b.ektFk - JOIN vn.origin o ON o.id = i.originFk - LEFT JOIN vn.producer p ON p.id = i.producerFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.worker w ON w.id = it.workerFk - LEFT JOIN edi.supplier s ON s.supplier_id = e.pro - JOIN vn.entry e2 ON e2.id = b.entryFk - JOIN vn.travel t ON t.id = e2.travelFk - JOIN numbers num - WHERE b.id = ? \ No newline at end of file + b.itemFk, + i.name item, + b.id buyFk, + b.quantity, + b.packing, + b.entryFk, + o.code origin, + p.`name` producerName, + p.id producerFk, + i.`size`, + i.category, + i.stems, + i.inkFk, + ig.longName, + ig.subName, + i.comment, + w.code buyerName + FROM vn.buy b + JOIN vn.item i ON i.id = b.itemFk + LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk + JOIN vn.origin o ON o.id = i.originFk + LEFT JOIN vn.producer p ON p.id = i.producerFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.worker w ON w.id = it.workerFk + JOIN numbers num + WHERE b.id = ? \ No newline at end of file From 070a5640df8c40bba1b96fedc90440fcd8575576 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 24 Oct 2024 08:16:04 +0000 Subject: [PATCH 203/217] fix: recalculatePrice not working with all ids --- modules/ticket/back/methods/sale/recalculatePrice.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/sale/recalculatePrice.js b/modules/ticket/back/methods/sale/recalculatePrice.js index fd3d6aa9b..ea71032d0 100644 --- a/modules/ticket/back/methods/sale/recalculatePrice.js +++ b/modules/ticket/back/methods/sale/recalculatePrice.js @@ -48,7 +48,7 @@ module.exports = Self => { CALL vn.sale_recalcComponent(null); DROP TEMPORARY TABLE tmp.recalculateSales;`; - const recalculation = await Self.rawSql(query, salesIds, myOptions); + const recalculation = await Self.rawSql(query, [salesIds], myOptions); if (tx) await tx.commit(); From 8569bec34ac139a3846837e278009844ed6cbaac Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 24 Oct 2024 12:18:09 +0200 Subject: [PATCH 204/217] feat: refs #7266 Minor change --- db/versions/11321-wheatChrysanthemum/00-firstScript.sql | 3 +++ .../templates/reports/item-label-barcode/item-label-barcode.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 db/versions/11321-wheatChrysanthemum/00-firstScript.sql diff --git a/db/versions/11321-wheatChrysanthemum/00-firstScript.sql b/db/versions/11321-wheatChrysanthemum/00-firstScript.sql new file mode 100644 index 000000000..e3ba70e2c --- /dev/null +++ b/db/versions/11321-wheatChrysanthemum/00-firstScript.sql @@ -0,0 +1,3 @@ +INSERT INTO vn.report (name, `method`) + VALUES ('LabelItemBarcode','Items/{id}/label-barcode-pdf'), + ('LabelItemQr','Items/{id}/label-qr-pdf'); diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.js b/print/templates/reports/item-label-barcode/item-label-barcode.js index 8a294afc1..5f9a11ea1 100755 --- a/print/templates/reports/item-label-barcode/item-label-barcode.js +++ b/print/templates/reports/item-label-barcode/item-label-barcode.js @@ -4,7 +4,7 @@ const moment = require('moment'); const jsbarcode = require('jsbarcode'); module.exports = { - name: 'item-label-qr', + name: 'item-label-barcode', async serverPrefetch() { this.company = await this.findOneFromDef('company', [this.warehouseId]); if (!this.company) From 4da11c65bbe5de6e63ab3287dbcadea3938b23bd Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 24 Oct 2024 12:26:03 +0200 Subject: [PATCH 205/217] fix: refs #235425 sale priceFixed update --- modules/ticket/back/methods/sale/updatePrice.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/ticket/back/methods/sale/updatePrice.js b/modules/ticket/back/methods/sale/updatePrice.js index 191fd09e3..afb25c365 100644 --- a/modules/ticket/back/methods/sale/updatePrice.js +++ b/modules/ticket/back/methods/sale/updatePrice.js @@ -92,6 +92,19 @@ module.exports = Self => { }, myOptions); } await sale.updateAttributes({price: newPrice}, myOptions); + await Self.rawSql(` + UPDATE sale + SET priceFixed = ( + SELECT SUM(value) + 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.isBase + AND s.id = ? + ) + WHERE id = ? + `, [id, id], myOptions); await Self.rawSql('CALL vn.manaSpellersRequery(?)', [userId], myOptions); await Self.rawSql('CALL vn.ticket_recalc(?, NULL)', [sale.ticketFk], myOptions); From 111480f7b7f84c785cc1ceac8fef2d2eaad7c543 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 25 Oct 2024 07:22:36 +0200 Subject: [PATCH 206/217] fix: refs #235425 Requested changes --- .../ticket/back/methods/sale/updatePrice.js | 29 ++++++++++--------- modules/ticket/back/models/sale.json | 3 ++ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/modules/ticket/back/methods/sale/updatePrice.js b/modules/ticket/back/methods/sale/updatePrice.js index afb25c365..d4f128082 100644 --- a/modules/ticket/back/methods/sale/updatePrice.js +++ b/modules/ticket/back/methods/sale/updatePrice.js @@ -91,20 +91,21 @@ module.exports = Self => { value: componentValue }, myOptions); } - await sale.updateAttributes({price: newPrice}, myOptions); - await Self.rawSql(` - UPDATE sale - SET priceFixed = ( - SELECT SUM(value) - 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.isBase - AND s.id = ? - ) - WHERE id = ? - `, [id, id], myOptions); + + const [priceFixed] = await Self.rawSql(` + SELECT SUM(value) value + 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.isBase + AND s.id = ? + `, [id], myOptions); + + await sale.updateAttributes({ + price: newPrice, + priceFixed: priceFixed.value + }, myOptions); await Self.rawSql('CALL vn.manaSpellersRequery(?)', [userId], myOptions); await Self.rawSql('CALL vn.ticket_recalc(?, NULL)', [sale.ticketFk], myOptions); diff --git a/modules/ticket/back/models/sale.json b/modules/ticket/back/models/sale.json index 96a36bbc9..947115f5c 100644 --- a/modules/ticket/back/models/sale.json +++ b/modules/ticket/back/models/sale.json @@ -28,6 +28,9 @@ "discount": { "type": "number" }, + "priceFixed": { + "type": "number" + }, "reserved": { "type": "boolean" }, From 69e1df25042f03e5ae57f3a798dfdff6b2f8f3fc Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 25 Oct 2024 08:47:43 +0200 Subject: [PATCH 207/217] fix: refs #235425 Requested changes --- .../methods/sale/specs/updatePrice.spec.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js index 9d1403df0..100f74bf0 100644 --- a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js +++ b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js @@ -85,6 +85,25 @@ describe('sale updatePrice()', () => { } }); + it('should check if priceFixed has changed', async() => { + const tx = await models.Sale.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const price = 3; + const beforeUpdate = await models.Sale.findById(saleId, null, options); + await models.Sale.updatePrice(ctx, saleId, price, options); + const afterUpdate = await models.Sale.findById(saleId, null, options); + + expect(beforeUpdate.priceFixed).not.toEqual(afterUpdate.priceFixed); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + it('should set price as a decimal number and check the sale has the mana component changing the salesPersonMana', async() => { const tx = await models.Sale.beginTransaction({}); From 8f102607953ba587527a2122cb82537e3db0be6e Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 25 Oct 2024 11:37:45 +0200 Subject: [PATCH 208/217] feat: refs #7943 return just the required content --- modules/worker/back/models/worker.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index c334c0d05..53be3ebb7 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -204,6 +204,15 @@ ] }, "summary": { + "fields": [ + "id", + "firstName", + "lastName", + "bossFk", + "sex", + "phone", + "mobileExtension" + ], "include": [ { "relation": "user", From e775e561201d96604f0706b17948c3aeaa8af5b2 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 25 Oct 2024 13:48:27 +0200 Subject: [PATCH 209/217] feat: refs #7921 refs#7921 sendLostExpedition --- loopback/locale/en.json | 7 ++- loopback/locale/es.json | 3 +- loopback/locale/fr.json | 11 ++-- loopback/locale/pt.json | 9 +-- .../specs/addExpeditionState.spec.js | 1 + .../ticket/back/models/expedition-state.js | 62 +++++++++++++++++++ 6 files changed, 80 insertions(+), 13 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index a7e21960b..ed1f28a04 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -240,6 +240,7 @@ "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", - "There are tickets for this area, delete them first": "There are tickets for this area, delete them first" -} + "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line", + "There are tickets for this area, delete them first": "There are tickets for this area, delete them first", + "ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}" +} \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 9f01bd290..a31e0688b 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -385,5 +385,6 @@ "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", "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero", - "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén" + "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén", + "ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}" } \ No newline at end of file diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index 23bd5cc04..1c7923ab4 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -123,8 +123,8 @@ "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": " 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}}})", + "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", @@ -362,6 +362,7 @@ "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" -} + "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", + "ticketLostExpedition": "Le ticket [{{ticketId}}]({{{ticketUrl}}}) a l'expédition perdue suivante : {{expeditionId}}" +} \ No newline at end of file diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index f85afd607..689449163 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -124,7 +124,7 @@ "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 {{changes}} 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", @@ -361,7 +361,8 @@ "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", + "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" -} + "The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha", + "ticketLostExpedition": "O ticket [{{ticketId}}]({{{ticketUrl}}}) tem a seguinte expedição perdida: {{expeditionId}}" +} \ No newline at end of file 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 747352286..71bc453de 100644 --- a/modules/ticket/back/methods/expedition-state/specs/addExpeditionState.spec.js +++ b/modules/ticket/back/methods/expedition-state/specs/addExpeditionState.spec.js @@ -2,6 +2,7 @@ const models = require('vn-loopback/server/server').models; describe('expeditionState addExpeditionState()', () => { const ctx = beforeAll.getCtx(); + beforeAll.mockLoopBackContext(); it('should update the expedition states', async() => { const tx = await models.ExpeditionState.beginTransaction({}); try { diff --git a/modules/ticket/back/models/expedition-state.js b/modules/ticket/back/models/expedition-state.js index 496dd88d3..18bab580e 100644 --- a/modules/ticket/back/models/expedition-state.js +++ b/modules/ticket/back/models/expedition-state.js @@ -1,4 +1,66 @@ +const LoopBackContext = require('loopback-context'); + module.exports = function(Self) { require('../methods/expedition-state/filter')(Self); require('../methods/expedition-state/addExpeditionState')(Self); + + Self.observe('before save', async ctx => { + const models = Self.app.models; + const changes = ctx.data || ctx.instance; + const instance = ctx.currentInstance; + const loopBackContext = LoopBackContext.getCurrentContext(); + const httpCtx = {req: loopBackContext.active}; + const httpRequest = httpCtx.req.http.req; + const $t = httpRequest.__; + const myOptions = {}; + + if (ctx.options && ctx.options.transaction) + myOptions.transaction = ctx.options.transaction; + + const newStateType = changes?.typeFk; + if (newStateType == null) return; + + const expeditionId = changes?.expeditionFk || instance?.expeditionFk; + + const {code} = await models.ExpeditionStateType.findById( + newStateType, + { + fields: ['code'] + }, + myOptions); + + if (code !== 'LOST') return; + + const dataExpedition = await models.Expedition.findById( + expeditionId, { + fields: ['ticketFk'], + include: [{ + relation: 'ticket', + scope: { + fields: ['clientFk'], + include: [{ + relation: 'client', + scope: { + fields: ['name', 'salesPersonFk'] + } + }] + } + }], + + }, myOptions); + + const salesPersonFk = dataExpedition.toJSON().ticket?.client?.salesPersonFk; + + if (salesPersonFk) { + const url = await Self.app.models.Url.getUrl(); + const fullUrl = `${url}ticket/${dataExpedition.ticketFk}/expedition`; + const message = $t('ticketLostExpedition', { + ticketId: dataExpedition.ticketFk, + expeditionId: expeditionId, + url: fullUrl + }); + await models.Chat.sendCheckingPresence(httpCtx, salesPersonFk, message); + } + }); }; + From 80764b6495290a5e9090114956fc5260df53f42f Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 25 Oct 2024 14:17:57 +0200 Subject: [PATCH 210/217] feat: refs #7006 itemTypeLog --- db/versions/11297-graySalal/01-firstScript.sql | 3 +++ modules/item/back/models/item-type.json | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 db/versions/11297-graySalal/01-firstScript.sql diff --git a/db/versions/11297-graySalal/01-firstScript.sql b/db/versions/11297-graySalal/01-firstScript.sql new file mode 100644 index 000000000..78ce1a540 --- /dev/null +++ b/db/versions/11297-graySalal/01-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.itemType + ADD CONSTRAINT itemType_itemPackingType_FK FOREIGN KEY (itemPackingTypeFk) + REFERENCES vn.itemPackingType(code) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/modules/item/back/models/item-type.json b/modules/item/back/models/item-type.json index c5c920b2f..88f66899e 100644 --- a/modules/item/back/models/item-type.json +++ b/modules/item/back/models/item-type.json @@ -29,6 +29,12 @@ }, "isLaid": { "type": "boolean" + }, + "maxRefs": { + "type": "string" + }, + "isFragile": { + "type": "boolean" } }, "relations": { From 14d6eb722ee5087402b3d213a1d5f1b6399d53fe Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 25 Oct 2024 14:24:26 +0200 Subject: [PATCH 211/217] feat: refs #7006 Requested changes --- db/versions/11297-graySalal/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11297-graySalal/00-firstScript.sql b/db/versions/11297-graySalal/00-firstScript.sql index 372af804c..4d4711306 100644 --- a/db/versions/11297-graySalal/00-firstScript.sql +++ b/db/versions/11297-graySalal/00-firstScript.sql @@ -24,4 +24,4 @@ CREATE TABLE `vn`.`itemTypeLog` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; INSERT IGNORE INTO salix.ACL (model,property,principalId) - VALUES ('ItemTypeLog','*','employee'); + VALUES ('ItemTypeLog','find','employee'); From d8e241740f9e5df512c44c5fbc31ecdaa3f9f000 Mon Sep 17 00:00:00 2001 From: jorgep Date: Sun, 27 Oct 2024 13:47:52 +0100 Subject: [PATCH 212/217] feat: refs #7524 restrict fields --- modules/worker/back/models/worker.json | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 53be3ebb7..937df98c0 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -256,10 +256,21 @@ } }, { - "relation": "boss" + "relation": "boss", + "scope": { + "fields": [ + "id", + "name" + ] + } }, { - "relation": "client" + "relation": "client", + "scope": { + "fields": [ + "id" + ] + } }, { "relation": "sip", @@ -281,14 +292,16 @@ "fields": [ "id", "fiDueDate", - "sex", "seniority", "fi", "isFreelance", "isSsDiscounted", "hasMachineryAuthorized", "isDisable", - "birth" + "birth", + "educationLevelFk", + "originCountryFk", + "maritalStatus" ] } } From 869c7ab598ffa951a479987b6ba2946efd2aeb5a Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 28 Oct 2024 07:37:42 +0100 Subject: [PATCH 213/217] fix: refs #6644 email and translations --- loopback/locale/en.json | 9 ++++++--- loopback/locale/es.json | 5 +++-- loopback/locale/fr.json | 3 ++- loopback/locale/pt.json | 3 ++- modules/client/back/methods/client/createWithUser.js | 3 +++ 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index a7e21960b..8c1ee7bb9 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -240,6 +240,9 @@ "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", - "There are tickets for this area, delete them first": "There are tickets for this area, delete them first" -} + "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line", + "There are tickets for this area, delete them first": "There are tickets for this area, delete them first", + "null": "null", + "Invalid or expired verification code": "Invalid or expired verification code", + "Payment method is required": "Payment method is required" +} \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 9f01bd290..144046f56 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -385,5 +385,6 @@ "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", "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero", - "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén" -} \ No newline at end of file + "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén", + "The web user's email already exists": "El correo del usuario web ya existe" +} diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index 23bd5cc04..446c2ad0d 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -363,5 +363,6 @@ "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" + "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", + "The web user's email already exists": "L'email de l'internaute existe déjà" } diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index f85afd607..4f68dfa53 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -363,5 +363,6 @@ "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" + "The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha", + "The web user's email already exists": "O e-mail do utilizador da web já existe." } diff --git a/modules/client/back/methods/client/createWithUser.js b/modules/client/back/methods/client/createWithUser.js index c8cd282e1..1d5e71fca 100644 --- a/modules/client/back/methods/client/createWithUser.js +++ b/modules/client/back/methods/client/createWithUser.js @@ -1,3 +1,4 @@ +/* eslint max-len: ["error", { "code": 150 }]*/ const UserError = require('vn-loopback/util/user-error'); module.exports = function(Self) { @@ -98,6 +99,8 @@ module.exports = function(Self) { return client; } catch (e) { if (tx) await tx.rollback(); + if (e.message && e.message.includes(`Email already exists`)) throw new UserError(`The web user's email already exists`); + throw e; } }; From 6efc2c340c932b1437689cf5decb30bf8b7b7d3a Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 28 Oct 2024 08:57:22 +0100 Subject: [PATCH 214/217] feat: refs #7921 refs#7921 sendLostExpedition --- modules/ticket/back/models/expedition-state.js | 2 +- modules/ticket/back/models/expedition-state.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/models/expedition-state.js b/modules/ticket/back/models/expedition-state.js index 18bab580e..f819dc05c 100644 --- a/modules/ticket/back/models/expedition-state.js +++ b/modules/ticket/back/models/expedition-state.js @@ -49,7 +49,7 @@ module.exports = function(Self) { }, myOptions); - const salesPersonFk = dataExpedition.toJSON().ticket?.client?.salesPersonFk; + const salesPersonFk = dataExpedition.ticket()?.client()?.salesPersonFk; if (salesPersonFk) { const url = await Self.app.models.Url.getUrl(); diff --git a/modules/ticket/back/models/expedition-state.json b/modules/ticket/back/models/expedition-state.json index 159a9275e..522327031 100644 --- a/modules/ticket/back/models/expedition-state.json +++ b/modules/ticket/back/models/expedition-state.json @@ -19,7 +19,8 @@ "type": "number" }, "typeFk": { - "type": "number" + "type": "number", + "required": true }, "userFk": { "type": "number" From eb5f57285aaf242b1d54ce4a8bd881f4e69dea3b Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 28 Oct 2024 10:40:43 +0100 Subject: [PATCH 215/217] feat: refs #7193 added scope in parking model --- modules/shelving/back/models/parking.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/shelving/back/models/parking.json b/modules/shelving/back/models/parking.json index 47a3305ae..a9393fc6a 100644 --- a/modules/shelving/back/models/parking.json +++ b/modules/shelving/back/models/parking.json @@ -38,5 +38,13 @@ "model": "Sector", "foreignKey": "sectorFk" } + }, + "scope": { + "include": { + "relation": "sector", + "scope": { + "fields": ["id", "description"] + } + } } } From 0180998683ed40e951eb4a81671bcf411dc112c0 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 28 Oct 2024 13:08:27 +0100 Subject: [PATCH 216/217] fix: refs #7283 item filters --- modules/item/back/methods/item/filter.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/modules/item/back/methods/item/filter.js b/modules/item/back/methods/item/filter.js index 909b3dff8..54dd975a4 100644 --- a/modules/item/back/methods/item/filter.js +++ b/modules/item/back/methods/item/filter.js @@ -38,13 +38,23 @@ module.exports = Self => { type: 'integer', description: 'Type id', }, + { + arg: 'producerFk', + type: 'integer', + description: 'Producer id', + }, + { + arg: 'instrastatFk', + type: 'string', + description: 'intrastat id', + }, { arg: 'isActive', type: 'boolean', description: 'Whether the item is or not active', }, { - arg: 'buyerFk', + arg: 'workerFk', type: 'integer', description: 'The buyer of the item', }, @@ -126,14 +136,16 @@ module.exports = Self => { return {'i.stemMultiplier': value}; case 'categoryFk': return {'ic.id': value}; - case 'buyerFk': + case 'workerFk': return {'it.workerFk': value}; + case 'producerFk': + return {'pr.id': value}; case 'supplierFk': return {'s.id': value}; case 'origin': return {'ori.code': value}; - case 'intrastat': - return {'intr.description': value}; + case 'intrastatFk': + return {'i.intrastatFk': value}; case 'landed': return {'lb.landed': value}; } @@ -172,6 +184,7 @@ module.exports = Self => { u.name AS userName, ori.code AS origin, ic.name AS category, + i.intrastatFk, intr.description AS intrastat, b.grouping, b.packing, From 385279b39df4c829c99bf29913b233afa5644747 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 28 Oct 2024 13:15:40 +0100 Subject: [PATCH 217/217] fix: refs #7283 tback --- modules/item/back/methods/item/specs/filter.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/back/methods/item/specs/filter.spec.js b/modules/item/back/methods/item/specs/filter.spec.js index 14467d1d8..a8aaca786 100644 --- a/modules/item/back/methods/item/specs/filter.spec.js +++ b/modules/item/back/methods/item/specs/filter.spec.js @@ -86,7 +86,7 @@ describe('item filter()', () => { try { const filter = {}; - const ctx = {args: {filter: filter, buyerFk: 16}, req: {accessToken: {userId: 1}}}; + const ctx = {args: {filter: filter, workerFk: 16}, req: {accessToken: {userId: 1}}}; const result = await models.Item.filter(ctx, filter, options); expect(result.length).toEqual(2);
From 1afb33c3064739c0a032e7a7b09f581b7b20e602 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 22 Oct 2024 15:00:16 +0200 Subject: [PATCH 192/217] feat: refs #8119 Requested changes --- ...nQuantity_add.sql => itemCampaign_add.sql} | 4 +- .../procedures/itemCampaignQuantity_add.sql | 86 ------------------- .../vn/procedures/itemCampaign_add.sql | 58 +++++++++++++ .../11308-redCymbidium/00-firstScript.sql | 26 +++--- 4 files changed, 72 insertions(+), 102 deletions(-) rename db/routines/vn/events/{itemCampaignQuantity_add.sql => itemCampaign_add.sql} (72%) delete mode 100644 db/routines/vn/procedures/itemCampaignQuantity_add.sql create mode 100644 db/routines/vn/procedures/itemCampaign_add.sql diff --git a/db/routines/vn/events/itemCampaignQuantity_add.sql b/db/routines/vn/events/itemCampaign_add.sql similarity index 72% rename from db/routines/vn/events/itemCampaignQuantity_add.sql rename to db/routines/vn/events/itemCampaign_add.sql index 4deb2d556..efb2aeb11 100644 --- a/db/routines/vn/events/itemCampaignQuantity_add.sql +++ b/db/routines/vn/events/itemCampaign_add.sql @@ -1,8 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`itemCampaignQuantity_add` +CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`itemCampaig_add` ON SCHEDULE EVERY 1 DAY STARTS '2024-10-18 03:00:00.000' ON COMPLETION PRESERVE ENABLE -DO CALL itemCampaignQuantity_add(NULL, NULL, NULL)$$ +DO CALL itemCampaign_add()$$ DELIMITER ; diff --git a/db/routines/vn/procedures/itemCampaignQuantity_add.sql b/db/routines/vn/procedures/itemCampaignQuantity_add.sql deleted file mode 100644 index 6edb97c08..000000000 --- a/db/routines/vn/procedures/itemCampaignQuantity_add.sql +++ /dev/null @@ -1,86 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemCampaignQuantity_add`( - vDateFrom DATE, - vDateTo DATE, - vCampaign VARCHAR(100) -) -proc: BEGIN -/** - * Añade registros a tabla itemCampaignQuantity. - * - * @param vDateFrom Fecha desde - * @param vDateTo Fecha hasta - * @param vCampaign Código de la campaña - */ - DECLARE vCurdate DATE; - DECLARE vYesterday DATE; - DECLARE vDefaultCampaign VARCHAR(100); - DECLARE vPreviousDaysToInsert INT; - DECLARE vDateSumFrom DATE; - DECLARE vDateSumTo DATE; - DECLARE vScopeDays INT; - - SET vCurdate = util.VN_CURDATE(); - SET vYesterday = util.yesterday(); - - IF vDateFrom IS NULL THEN - SET vDateFrom = vYesterday; - END IF; - - IF vDateTo IS NULL THEN - SET vDateTo = vYesterday; - END IF; - - IF vDateFrom > vDateTo THEN - CALL util.throw('Start date cannot be later than end date'); - END IF; - - SELECT defaultCampaign, previousDaysToInsert - INTO vDefaultCampaign, vPreviousDaysToInsert - FROM itemCampaignQuantityConfig; - - IF vCampaign IS NULL THEN - SET vCampaign = vDefaultCampaign; - END IF; - - IF vCampaign IS NULL OR vPreviousDaysToInsert IS NULL THEN - CALL util.throw('Missing values in the configuration table'); - END IF; - - SELECT dated, scopeDays INTO vDateSumTo, vScopeDays - FROM campaign - WHERE dated > vCurdate - AND code = vCampaign - ORDER BY dated - LIMIT 1; - - IF vDateSumTo IS NULL OR vScopeDays IS NULL THEN - CALL util.throw('Missing data in campaign table'); - END IF; - - IF NOT vCurdate BETWEEN vDateSumTo - INTERVAL vPreviousDaysToInsert DAY - AND vDateSumTo THEN - LEAVE proc; - END IF; - - SET vDateSumFrom = vDateSumTo - INTERVAL vScopeDays DAY; - - REPLACE itemCampaignQuantity(dated, itemFk, quantity, total, campaign) - SELECT DATE(s.created), - s.itemFk, - SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo - THEN s.quantity - END) quantity, - SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo - THEN s.total - END) total, - vCampaign - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - JOIN client c ON c.id = t.clientFk - WHERE s.created BETWEEN vDateFrom AND util.dayEnd(vDateTo) - AND c.businessTypeFk <> 'worker' - GROUP BY DATE(s.created), s.itemFk - HAVING quantity; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/itemCampaign_add.sql b/db/routines/vn/procedures/itemCampaign_add.sql new file mode 100644 index 000000000..1e10bc619 --- /dev/null +++ b/db/routines/vn/procedures/itemCampaign_add.sql @@ -0,0 +1,58 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemCampaign_add`() +proc: BEGIN +/** + * Añade registros a tabla itemCampaign. + * + * @param vDateFrom Fecha desde + * @param vDateTo Fecha hasta + * @param vCampaign Código de la campaña + */ + DECLARE vCurdate DATE; + DECLARE vYesterday DATE; + DECLARE vCampaign VARCHAR(100); + DECLARE vPreviousDays INT; + DECLARE vDateSumFrom DATE; + DECLARE vDateSumTo DATE; + DECLARE vScopeDays INT; + + SET vCurdate = util.VN_CURDATE(); + + SELECT dated, code, scopeDays, previousDays + INTO vDateSumTo, vCampaign, vScopeDays, vPreviousDays + FROM campaign + WHERE dated > vCurdate + ORDER BY dated + LIMIT 1; + + IF vCampaign IS NULL THEN + CALL util.throw('Missing data in campaign table'); + END IF; + + IF NOT vCurdate BETWEEN vDateSumTo - INTERVAL vPreviousDays DAY + AND vDateSumTo THEN + LEAVE proc; + END IF; + + SET vDateSumFrom = vDateSumTo - INTERVAL vScopeDays DAY; + SET vYesterday = util.yesterday(); + + REPLACE itemCampaign(dated, itemFk, quantity, total, campaign) + SELECT DATE(s.created), + s.itemFk, + SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo + THEN s.quantity + END) quantity, + SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo + THEN (s.quantity * s.price) * (100 - s.discount) / 100 + END) total, + vCampaign + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN client c ON c.id = t.clientFk + WHERE s.created BETWEEN vYesterday AND util.dayEnd(vYesterday) + AND c.typeFk = 'normal' + GROUP BY DATE(s.created), s.itemFk + HAVING quantity; +END$$ +DELIMITER ; diff --git a/db/versions/11308-redCymbidium/00-firstScript.sql b/db/versions/11308-redCymbidium/00-firstScript.sql index 14fad3636..fe76cb600 100644 --- a/db/versions/11308-redCymbidium/00-firstScript.sql +++ b/db/versions/11308-redCymbidium/00-firstScript.sql @@ -1,27 +1,25 @@ -CREATE TABLE IF NOT EXISTS `vn`.`itemCampaignQuantity` ( +CREATE TABLE IF NOT EXISTS `vn`.`itemCampaign` ( `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, dated date NOT NULL, itemFk int(11) NOT NULL, quantity decimal(10,2) NOT NULL, total decimal(10,2) NOT NULL, campaign varchar(100) NOT NULL, - UNIQUE KEY `itemCampaignQuantity_UNIQUE` (`dated`,`itemFk`), - CONSTRAINT itemCampaignQuantity_item_FK FOREIGN KEY (itemFk) REFERENCES vn.item(id) ON DELETE RESTRICT ON UPDATE CASCADE + UNIQUE KEY `itemCampaign_UNIQUE` (`dated`,`itemFk`), + CONSTRAINT itemCampaign_item_FK FOREIGN KEY (itemFk) REFERENCES vn.item(id) ON DELETE RESTRICT ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tallos confirmados por día en los días de más producción de una campaña. La tabla está pensada para que sea una foto.'; -CREATE TABLE IF NOT EXISTS `vn`.`itemCampaignQuantityConfig` ( - id int(10) unsigned NOT NULL PRIMARY KEY, - defaultCampaign varchar(100) NOT NULL COMMENT 'Campaña por defecto si se le pasa NULL', - previousDaysToInsert int(10) unsigned NOT NULL COMMENT 'Días anteriores a la fecha de fin de campaña para insertar', - CONSTRAINT `itemCampaignQuantityConfig_check` CHECK (`id` = 1) -) -ENGINE=InnoDB -DEFAULT CHARSET=utf8mb3 -COLLATE=utf8mb3_unicode_ci; +ALTER TABLE vn.campaign + ADD previousDays int(10) unsigned DEFAULT 30 NOT NULL COMMENT 'Días previos para calcular e insertar en la tabla itemCampaign'; -INSERT IGNORE INTO `vn`.`itemCampaignQuantityConfig` (id, defaultCampaign, previousDaysToInsert) - VALUES (1, 'allSaints', 90); +UPDATE vn.campaign + SET previousDays = 90 + WHERE code = 'allSaints'; + +UPDATE vn.campaign + SET previousDays = 60 + WHERE code IN ('valentinesDay', 'mothersDay'); From fe3e7342bcea4693c40146076031b939a432f873 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 23 Oct 2024 07:14:07 +0200 Subject: [PATCH 193/217] fix: refs #7935 version --- .../{00-firstScript copy.sql => 00-firstScript2.sql} | 0 .../{00-firstScript copy 2.sql => 00-firstScript3.sql} | 0 .../{00-firstScript copy 3.sql => 00-firstScript4.sql} | 0 .../{00-firstScript copy 4.sql => 00-firstScript5.sql} | 0 .../{00-firstScript copy 5.sql => 00-firstScript6.sql} | 0 .../{00-firstScript copy 6.sql => 00-firstScript7.sql} | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename db/versions/11274-redGerbera/{00-firstScript copy.sql => 00-firstScript2.sql} (100%) rename db/versions/11274-redGerbera/{00-firstScript copy 2.sql => 00-firstScript3.sql} (100%) rename db/versions/11274-redGerbera/{00-firstScript copy 3.sql => 00-firstScript4.sql} (100%) rename db/versions/11274-redGerbera/{00-firstScript copy 4.sql => 00-firstScript5.sql} (100%) rename db/versions/11274-redGerbera/{00-firstScript copy 5.sql => 00-firstScript6.sql} (100%) rename db/versions/11274-redGerbera/{00-firstScript copy 6.sql => 00-firstScript7.sql} (100%) diff --git a/db/versions/11274-redGerbera/00-firstScript copy.sql b/db/versions/11274-redGerbera/00-firstScript2.sql similarity index 100% rename from db/versions/11274-redGerbera/00-firstScript copy.sql rename to db/versions/11274-redGerbera/00-firstScript2.sql diff --git a/db/versions/11274-redGerbera/00-firstScript copy 2.sql b/db/versions/11274-redGerbera/00-firstScript3.sql similarity index 100% rename from db/versions/11274-redGerbera/00-firstScript copy 2.sql rename to db/versions/11274-redGerbera/00-firstScript3.sql diff --git a/db/versions/11274-redGerbera/00-firstScript copy 3.sql b/db/versions/11274-redGerbera/00-firstScript4.sql similarity index 100% rename from db/versions/11274-redGerbera/00-firstScript copy 3.sql rename to db/versions/11274-redGerbera/00-firstScript4.sql diff --git a/db/versions/11274-redGerbera/00-firstScript copy 4.sql b/db/versions/11274-redGerbera/00-firstScript5.sql similarity index 100% rename from db/versions/11274-redGerbera/00-firstScript copy 4.sql rename to db/versions/11274-redGerbera/00-firstScript5.sql diff --git a/db/versions/11274-redGerbera/00-firstScript copy 5.sql b/db/versions/11274-redGerbera/00-firstScript6.sql similarity index 100% rename from db/versions/11274-redGerbera/00-firstScript copy 5.sql rename to db/versions/11274-redGerbera/00-firstScript6.sql diff --git a/db/versions/11274-redGerbera/00-firstScript copy 6.sql b/db/versions/11274-redGerbera/00-firstScript7.sql similarity index 100% rename from db/versions/11274-redGerbera/00-firstScript copy 6.sql rename to db/versions/11274-redGerbera/00-firstScript7.sql From 62f9f31279f829b204e55e4c52b2370c3a0b5244 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 23 Oct 2024 07:44:41 +0200 Subject: [PATCH 194/217] feat: refs #7943 usa back con permisos --- .../item/front/item-type/basic-data/index.html | 16 ++++++++-------- modules/item/front/item-type/create/index.html | 14 +++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/modules/item/front/item-type/basic-data/index.html b/modules/item/front/item-type/basic-data/index.html index 1417a05ab..c3f7a57f1 100644 --- a/modules/item/front/item-type/basic-data/index.html +++ b/modules/item/front/item-type/basic-data/index.html @@ -11,26 +11,26 @@ - \ No newline at end of file + diff --git a/modules/item/front/item-type/create/index.html b/modules/item/front/item-type/create/index.html index 44cb5183d..4a199a1b1 100644 --- a/modules/item/front/item-type/create/index.html +++ b/modules/item/front/item-type/create/index.html @@ -12,26 +12,26 @@ Date: Wed, 23 Oct 2024 08:23:28 +0200 Subject: [PATCH 195/217] feat: refs #8119 Requested changes --- .../vn/procedures/itemCampaign_add.sql | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/db/routines/vn/procedures/itemCampaign_add.sql b/db/routines/vn/procedures/itemCampaign_add.sql index 1e10bc619..6291d6895 100644 --- a/db/routines/vn/procedures/itemCampaign_add.sql +++ b/db/routines/vn/procedures/itemCampaign_add.sql @@ -8,20 +8,19 @@ proc: BEGIN * @param vDateTo Fecha hasta * @param vCampaign Código de la campaña */ - DECLARE vCurdate DATE; DECLARE vYesterday DATE; DECLARE vCampaign VARCHAR(100); + DECLARE vScopeDays INT; DECLARE vPreviousDays INT; DECLARE vDateSumFrom DATE; DECLARE vDateSumTo DATE; - DECLARE vScopeDays INT; - SET vCurdate = util.VN_CURDATE(); + SET vYesterday = util.yesterday(); SELECT dated, code, scopeDays, previousDays INTO vDateSumTo, vCampaign, vScopeDays, vPreviousDays FROM campaign - WHERE dated > vCurdate + WHERE dated >= vYesterday ORDER BY dated LIMIT 1; @@ -29,30 +28,26 @@ proc: BEGIN CALL util.throw('Missing data in campaign table'); END IF; - IF NOT vCurdate BETWEEN vDateSumTo - INTERVAL vPreviousDays DAY + IF NOT vYesterday BETWEEN vDateSumTo - INTERVAL vPreviousDays DAY AND vDateSumTo THEN LEAVE proc; END IF; SET vDateSumFrom = vDateSumTo - INTERVAL vScopeDays DAY; - SET vYesterday = util.yesterday(); - REPLACE itemCampaign(dated, itemFk, quantity, total, campaign) - SELECT DATE(s.created), + INSERT INTO itemCampaign(dated, itemFk, quantity, total, campaign) + SELECT vYesterday, s.itemFk, - SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo - THEN s.quantity - END) quantity, - SUM(CASE WHEN t.shipped BETWEEN vDateSumFrom AND vDateSumTo - THEN (s.quantity * s.price) * (100 - s.discount) / 100 - END) total, + SUM(s.quantity) quantity, + SUM((s.quantity * s.price) * (100 - s.discount) / 100) total, vCampaign FROM sale s JOIN ticket t ON t.id = s.ticketFk JOIN client c ON c.id = t.clientFk - WHERE s.created BETWEEN vYesterday AND util.dayEnd(vYesterday) + WHERE t.shipped BETWEEN vDateSumFrom AND vDateSumTo AND c.typeFk = 'normal' - GROUP BY DATE(s.created), s.itemFk + AND NOT t.isDeleted + GROUP BY s.itemFk HAVING quantity; END$$ DELIMITER ; From 37050361c23bc5f6b84807e674f1f5af937da43c Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 23 Oct 2024 08:26:36 +0200 Subject: [PATCH 196/217] feat: refs #8119 Requested changes --- db/routines/vn/procedures/itemCampaign_add.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemCampaign_add.sql b/db/routines/vn/procedures/itemCampaign_add.sql index 6291d6895..ff92f3b25 100644 --- a/db/routines/vn/procedures/itemCampaign_add.sql +++ b/db/routines/vn/procedures/itemCampaign_add.sql @@ -44,7 +44,7 @@ proc: BEGIN FROM sale s JOIN ticket t ON t.id = s.ticketFk JOIN client c ON c.id = t.clientFk - WHERE t.shipped BETWEEN vDateSumFrom AND vDateSumTo + WHERE t.shipped BETWEEN vDateSumFrom AND util.dayEnd(vDateSumTo) AND c.typeFk = 'normal' AND NOT t.isDeleted GROUP BY s.itemFk From 31c89538bc9d17d75b72975ecc1e3d87fcd2903e Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 23 Oct 2024 08:27:07 +0200 Subject: [PATCH 197/217] feat: refs #8119 Requested changes --- db/routines/vn/procedures/itemCampaign_add.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemCampaign_add.sql b/db/routines/vn/procedures/itemCampaign_add.sql index ff92f3b25..6291d6895 100644 --- a/db/routines/vn/procedures/itemCampaign_add.sql +++ b/db/routines/vn/procedures/itemCampaign_add.sql @@ -44,7 +44,7 @@ proc: BEGIN FROM sale s JOIN ticket t ON t.id = s.ticketFk JOIN client c ON c.id = t.clientFk - WHERE t.shipped BETWEEN vDateSumFrom AND util.dayEnd(vDateSumTo) + WHERE t.shipped BETWEEN vDateSumFrom AND vDateSumTo AND c.typeFk = 'normal' AND NOT t.isDeleted GROUP BY s.itemFk From 3cde6b6bc65136ebfa559af9269566ef9e718fac Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 23 Oct 2024 08:30:21 +0200 Subject: [PATCH 198/217] feat: refs #8119 Requested changes --- db/routines/vn/procedures/itemCampaign_add.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemCampaign_add.sql b/db/routines/vn/procedures/itemCampaign_add.sql index 6291d6895..8fb40df67 100644 --- a/db/routines/vn/procedures/itemCampaign_add.sql +++ b/db/routines/vn/procedures/itemCampaign_add.sql @@ -34,6 +34,7 @@ proc: BEGIN END IF; SET vDateSumFrom = vDateSumTo - INTERVAL vScopeDays DAY; + SET vDateSumTo = vDateSumTo - INTERVAL 1 DAY; INSERT INTO itemCampaign(dated, itemFk, quantity, total, campaign) SELECT vYesterday, @@ -44,7 +45,7 @@ proc: BEGIN FROM sale s JOIN ticket t ON t.id = s.ticketFk JOIN client c ON c.id = t.clientFk - WHERE t.shipped BETWEEN vDateSumFrom AND vDateSumTo + WHERE t.shipped BETWEEN vDateSumFrom AND util.dayEnd(vDateSumTo) AND c.typeFk = 'normal' AND NOT t.isDeleted GROUP BY s.itemFk From b1a295dca450d02b03c83f4be8f72d5fe557dd6b Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 23 Oct 2024 09:46:06 +0200 Subject: [PATCH 199/217] feat: refs #7266 Print corrections --- .../item-label-barcode/assets/css/style.css | 15 ++++++++------- .../item-label-barcode/item-label-barcode.html | 2 +- .../item-label-barcode/item-label-barcode.js | 2 +- .../reports/item-label-barcode/options.json | 4 ++-- .../reports/item-label-qr/assets/css/style.css | 18 ++++++++++-------- .../reports/item-label-qr/options.json | 4 ++-- 6 files changed, 24 insertions(+), 21 deletions(-) diff --git a/print/templates/reports/item-label-barcode/assets/css/style.css b/print/templates/reports/item-label-barcode/assets/css/style.css index 48b881986..884faef56 100644 --- a/print/templates/reports/item-label-barcode/assets/css/style.css +++ b/print/templates/reports/item-label-barcode/assets/css/style.css @@ -1,6 +1,7 @@ html { font-family: "Roboto", "Helvetica", "Arial", sans-serif; - margin-top: -7px; + margin-top: -9px; + margin-left: -6px; } table { width: 100%; @@ -51,20 +52,20 @@ td { max-height: 50px; } .md-height { - height: 60px; - max-height: 60px; + height: 75px; + max-height: 75px; } .sm-width { width: 60px; max-width: 60px; } .md-width { - width: 120px; - max-width: 120px; + width: 125px; + max-width: 125px; } .lg-width { - width: 400px; - max-width: 400px; + width: 380px; + max-width: 380px; } .overflow-multiline { max-height: inherit; diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.html b/print/templates/reports/item-label-barcode/item-label-barcode.html index 79de49411..224338c2f 100644 --- a/print/templates/reports/item-label-barcode/item-label-barcode.html +++ b/print/templates/reports/item-label-barcode/item-label-barcode.html @@ -8,7 +8,7 @@ {{item.item}} +
{{item.size}}
diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.js b/print/templates/reports/item-label-barcode/item-label-barcode.js index 29a2b9ad5..8a294afc1 100755 --- a/print/templates/reports/item-label-barcode/item-label-barcode.js +++ b/print/templates/reports/item-label-barcode/item-label-barcode.js @@ -29,7 +29,7 @@ module.exports = { xmlDocument: document, format: 'code128', displayValue: false, - width: 3.9, + width: 3.8, height: 85, margin: 0 }); diff --git a/print/templates/reports/item-label-barcode/options.json b/print/templates/reports/item-label-barcode/options.json index 5a3c3b1eb..1ae2630b0 100644 --- a/print/templates/reports/item-label-barcode/options.json +++ b/print/templates/reports/item-label-barcode/options.json @@ -1,9 +1,9 @@ { "width": "10.4cm", - "height": "4.8cm", + "height": "4.9cm", "margin": { "top": "0.17cm", - "right": "0cm", + "right": "0.745cm", "bottom": "0cm", "left": "0cm" }, diff --git a/print/templates/reports/item-label-qr/assets/css/style.css b/print/templates/reports/item-label-qr/assets/css/style.css index b868f3966..fe6668c9a 100644 --- a/print/templates/reports/item-label-qr/assets/css/style.css +++ b/print/templates/reports/item-label-qr/assets/css/style.css @@ -1,6 +1,7 @@ html { font-family: "Roboto", "Helvetica", "Arial", sans-serif; margin-top: -7px; + margin-left: -6px; } .leftTable { width: 47%; @@ -9,6 +10,7 @@ html { text-align: center; } .leftTable img { + margin-top: 3px; width: 110px; } .rightTable { @@ -51,24 +53,24 @@ html { padding: 7px; } .md-height { - height: 60px; - max-height: 60px; + height: 68px; + max-height: 68px; } .xs-width { width: 60px; max-width: 60px; } .sm-width { - width: 140px; - max-width: 140px; + width: 130px; + max-width: 130px; } .md-width { - width: 200px; - max-width: 200px; + width: 190px; + max-width: 190px; } .lg-width { - width: 270px; - max-width: 270px; + width: 240px; + max-width: 240px; } .overflow-multiline { max-height: inherit; diff --git a/print/templates/reports/item-label-qr/options.json b/print/templates/reports/item-label-qr/options.json index 5a3c3b1eb..c3c395040 100644 --- a/print/templates/reports/item-label-qr/options.json +++ b/print/templates/reports/item-label-qr/options.json @@ -1,9 +1,9 @@ { "width": "10.4cm", - "height": "4.8cm", + "height": "4.9cm", "margin": { "top": "0.17cm", - "right": "0cm", + "right": "0.6cm", "bottom": "0cm", "left": "0cm" }, From 3da08e3a23292353eca229b7c140898bec852cf3 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 23 Oct 2024 11:33:45 +0200 Subject: [PATCH 200/217] feat: refs #8020 machineWorkerDeprecated --- .../machine-worker/specs/updateInTime.spec.js | 132 ------------------ back/methods/machine-worker/updateInTime.js | 77 ---------- back/model-config.json | 6 - back/models/machine-worker-config.json | 18 --- back/models/machine-worker.js | 3 - back/models/machine-worker.json | 33 ----- db/dump/fixtures.before.sql | 11 -- .../workerMachinery_isRegistered.sql | 23 --- .../vn/procedures/machineWorker_add.sql | 22 --- .../machineWorker_getHistorical.sql | 21 --- .../vn/procedures/machineWorker_update.sql | 38 ----- .../vn/procedures/machine_getWorkerPlate.sql | 16 --- db/routines/vn/views/workerWithoutTractor.sql | 7 +- .../11317-silverCordyline/00-firstScript.sql | 9 ++ 14 files changed, 12 insertions(+), 404 deletions(-) delete mode 100644 back/methods/machine-worker/specs/updateInTime.spec.js delete mode 100644 back/methods/machine-worker/updateInTime.js delete mode 100644 back/models/machine-worker-config.json delete mode 100644 back/models/machine-worker.js delete mode 100644 back/models/machine-worker.json delete mode 100644 db/routines/vn/functions/workerMachinery_isRegistered.sql delete mode 100644 db/routines/vn/procedures/machineWorker_add.sql delete mode 100644 db/routines/vn/procedures/machineWorker_getHistorical.sql delete mode 100644 db/routines/vn/procedures/machineWorker_update.sql delete mode 100644 db/routines/vn/procedures/machine_getWorkerPlate.sql create mode 100644 db/versions/11317-silverCordyline/00-firstScript.sql diff --git a/back/methods/machine-worker/specs/updateInTime.spec.js b/back/methods/machine-worker/specs/updateInTime.spec.js deleted file mode 100644 index f166214b0..000000000 --- a/back/methods/machine-worker/specs/updateInTime.spec.js +++ /dev/null @@ -1,132 +0,0 @@ -const {models} = require('vn-loopback/server/server'); - -describe('machineWorker updateInTime()', () => { - const itBoss = 104; - const davidCharles = 1106; - - beforeAll(async() => { - ctx = { - req: { - accessToken: {}, - headers: {origin: 'http://localhost'}, - __: value => value - } - }; - }); - - it('should throw an error if the plate does not exist', async() => { - const tx = await models.MachineWorker.beginTransaction({}); - const options = {transaction: tx}; - const plate = 'RE-123'; - ctx.req.accessToken.userId = 1106; - try { - await models.MachineWorker.updateInTime(ctx, plate, options); - await tx.rollback(); - } catch (e) { - const error = e; - - expect(error.message).toContain('the plate does not exist'); - await tx.rollback(); - } - }); - - it('should grab a machine where is not in use', async() => { - const tx = await models.MachineWorker.beginTransaction({}); - const options = {transaction: tx}; - const plate = 'RE-003'; - ctx.req.accessToken.userId = 1107; - try { - const totalBefore = await models.MachineWorker.find(null, options); - await models.MachineWorker.updateInTime(ctx, plate, options); - const totalAfter = await models.MachineWorker.find(null, options); - - expect(totalAfter.length).toEqual(totalBefore.length + 1); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - } - }); - - describe('less than 12h', () => { - const plate = 'RE-001'; - it('should trow an error if it is not himself', async() => { - const tx = await models.MachineWorker.beginTransaction({}); - const options = {transaction: tx}; - ctx.req.accessToken.userId = davidCharles; - - try { - await models.MachineWorker.updateInTime(ctx, plate, options); - await tx.rollback(); - } catch (e) { - const error = e; - - expect(error.message).toContain('This machine is already in use'); - await tx.rollback(); - } - }); - - it('should throw an error if it is himself with a different machine', async() => { - const tx = await models.MachineWorker.beginTransaction({}); - const options = {transaction: tx}; - ctx.req.accessToken.userId = itBoss; - const plate = 'RE-003'; - try { - await models.MachineWorker.updateInTime(ctx, plate, options); - await tx.rollback(); - } catch (e) { - const error = e; - - expect(error.message).toEqual('You are already using a machine'); - await tx.rollback(); - } - }); - - it('should set the out time if it is himself', async() => { - const tx = await models.MachineWorker.beginTransaction({}); - const options = {transaction: tx}; - ctx.req.accessToken.userId = itBoss; - - try { - const isNotParked = await models.MachineWorker.findOne({ - where: {workerFk: itBoss} - }, options); - await models.MachineWorker.updateInTime(ctx, plate, options); - const isParked = await models.MachineWorker.findOne({ - where: {workerFk: itBoss} - }, options); - - expect(isNotParked.outTime).toBeNull(); - expect(isParked.outTime).toBeDefined(); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - } - }); - }); - - describe('equal or more than 12h', () => { - const plate = 'RE-002'; - it('should set the out time and grab the machine', async() => { - const tx = await models.MachineWorker.beginTransaction({}); - const options = {transaction: tx}; - ctx.req.accessToken.userId = davidCharles; - const filter = { - where: {workerFk: davidCharles, machineFk: 2} - }; - try { - const isNotParked = await models.MachineWorker.findOne(filter, options); - const totalBefore = await models.MachineWorker.find(null, options); - await models.MachineWorker.updateInTime(ctx, plate, options); - const isParked = await models.MachineWorker.findOne(filter, options); - const totalAfter = await models.MachineWorker.find(null, options); - - expect(isNotParked.outTime).toBeNull(); - expect(isParked.outTime).toBeDefined(); - expect(totalAfter.length).toEqual(totalBefore.length + 1); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - } - }); - }); -}); diff --git a/back/methods/machine-worker/updateInTime.js b/back/methods/machine-worker/updateInTime.js deleted file mode 100644 index 44fad2c05..000000000 --- a/back/methods/machine-worker/updateInTime.js +++ /dev/null @@ -1,77 +0,0 @@ -const UserError = require('vn-loopback/util/user-error'); -module.exports = Self => { - Self.remoteMethodCtx('updateInTime', { - description: 'Updates the corresponding registry if the worker has been registered in the last few hours', - accessType: 'WRITE', - accepts: [ - { - arg: 'plate', - type: 'string', - } - ], - http: { - path: `/updateInTime`, - verb: 'POST' - } - }); - - Self.updateInTime = async(ctx, plate, options) => { - const models = Self.app.models; - const userId = ctx.req.accessToken.userId; - const $t = ctx.req.__; - - let tx; - const myOptions = {}; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - - try { - const machine = await models.Machine.findOne({ - fields: ['id', 'plate'], - where: {plate} - }, myOptions); - - if (!machine) - throw new UserError($t('the plate does not exist', {plate})); - - const machineWorker = await Self.findOne({ - where: { - or: [{machineFk: machine.id}, {workerFk: userId}], - outTime: null, - } - }, myOptions); - - const {maxHours} = await models.MachineWorkerConfig.findOne({fields: ['maxHours']}, myOptions); - const hoursDifference = (Date.vnNow() - machineWorker?.inTime?.getTime() ?? 0) / (60 * 60 * 1000); - - if (machineWorker) { - const isHimself = userId == machineWorker.workerFk; - const isSameMachine = machine.id == machineWorker.machineFk; - - if (hoursDifference < maxHours && !isHimself) - throw new UserError($t('This machine is already in use.')); - - if (hoursDifference < maxHours && isHimself && !isSameMachine) - throw new UserError($t('You are already using a machine')); - - await machineWorker.updateAttributes({ - outTime: Date.vnNew() - }, myOptions); - } - - if (!machineWorker || hoursDifference >= maxHours) - await models.MachineWorker.create({machineFk: machine.id, workerFk: userId}, myOptions); - - if (tx) await tx.commit(); - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - }; -}; diff --git a/back/model-config.json b/back/model-config.json index b6d304675..5368769fd 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -88,12 +88,6 @@ "Machine": { "dataSource": "vn" }, - "MachineWorker": { - "dataSource": "vn" - }, - "MachineWorkerConfig": { - "dataSource": "vn" - }, "MobileAppVersionControl": { "dataSource": "vn" }, diff --git a/back/models/machine-worker-config.json b/back/models/machine-worker-config.json deleted file mode 100644 index dfb77124e..000000000 --- a/back/models/machine-worker-config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "MachineWorkerConfig", - "base": "VnModel", - "options": { - "mysql": { - "table": "vn.machineWorkerConfig" - } - }, - "properties": { - "id": { - "type": "number", - "id": true - }, - "maxHours": { - "type": "number" - } - } -} diff --git a/back/models/machine-worker.js b/back/models/machine-worker.js deleted file mode 100644 index cbc5fd53e..000000000 --- a/back/models/machine-worker.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = Self => { - require('../methods/machine-worker/updateInTime')(Self); -}; diff --git a/back/models/machine-worker.json b/back/models/machine-worker.json deleted file mode 100644 index 2244a533f..000000000 --- a/back/models/machine-worker.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "MachineWorker", - "base": "VnModel", - "options": { - "mysql": { - "table": "vn.machineWorker" - } - }, - "properties": { - "id": { - "type": "number", - "id": true - }, - "workerFk": { - "type": "number" - }, - "machineFk": { - "type": "number" - }, - "inTime": { - "type": "date", - "mysql": { - "columnName": "inTimed" - } - }, - "outTime": { - "type": "date", - "mysql": { - "columnName": "outTimed" - } - } - } -} diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index e93bb3b8e..4fbe16f33 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2842,12 +2842,6 @@ INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmen ('RE-001', 'STILL', 'LTX-20', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442), ('RE-002', 'STILL', 'LTX-20', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442); -INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`) - VALUES - (1106, 1, util.VN_CURDATE(), util.VN_CURDATE()), - (1106, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)), - (1106, 2, util.VN_CURDATE(), NULL), - (1106, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 DAY)); INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`) VALUES @@ -3831,8 +3825,6 @@ UPDATE vn.collection UPDATE vn.sale SET isPicked =FALSE; -INSERT INTO vn.machineWorkerConfig(id, maxHours) - VALUES(1, 12); INSERT INTO vn.workerAppTester(workerFk) VALUES(66); @@ -3840,9 +3832,6 @@ INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmen VALUES ('RE-003', 'IRON', 'JPH-24', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442); - -INSERT INTO vn.machineWorker(workerFk,machineFk,inTimed) VALUES (104,1,'2001-01-01 10:00:00.00.000'); - UPDATE vn.buy SET itemOriginalFk = 1 WHERE id = 1; UPDATE vn.saleTracking SET stateFk = 26 WHERE id = 5; diff --git a/db/routines/vn/functions/workerMachinery_isRegistered.sql b/db/routines/vn/functions/workerMachinery_isRegistered.sql deleted file mode 100644 index 60f458e9e..000000000 --- a/db/routines/vn/functions/workerMachinery_isRegistered.sql +++ /dev/null @@ -1,23 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`workerMachinery_isRegistered`(vWorkerFk VARCHAR(10)) - RETURNS tinyint(1) - NOT DETERMINISTIC - READS SQL DATA -BEGIN -/** - * Comprueba si existen registros en las últimas horas (maxHours de machineWorkerConfig) del trabajador vWorkerFk y si tiene a nulo la hora outTimed (indica la hora que deja el vehículo) - * - * @param vWorkerFk id del trabajador - * @return Devuelve TRUE/FALSE en caso de que haya o no registros - */ - IF (SELECT COUNT(*) - FROM machineWorker m - WHERE m.workerFk = vWorkerFk - AND m.inTimed >= TIMESTAMPADD(HOUR , -(SELECT maxHours from machineWorkerConfig), util.VN_NOW()) AND ISNULL(m.outTimed)) - THEN - RETURN TRUE; - ELSE - RETURN FALSE; - END IF; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/machineWorker_add.sql b/db/routines/vn/procedures/machineWorker_add.sql deleted file mode 100644 index 41000f556..000000000 --- a/db/routines/vn/procedures/machineWorker_add.sql +++ /dev/null @@ -1,22 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`machineWorker_add`(vPlate VARCHAR(10), vWorkerFk INT) -BEGIN - -/** - * Inserta registro si el vWorkerFk no ha registrado nada en las últimas 12 horas - * @param vPlate número de matrícula - * @param vWorkerFk id del worker - * -*/ - UPDATE vn.machineWorker mw - JOIN vn.machine m ON m.id = mw.machineFk - SET mw.outTimed = util.VN_NOW() - WHERE (mw.workerFk = vWorkerFk OR m.plate = vPlate) - AND ISNULL(mw.outTimed); - - INSERT INTO machineWorker (machineFk, workerFk) - SELECT m.id, vWorkerFk - FROM machine m - WHERE m.plate= vPlate; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/machineWorker_getHistorical.sql b/db/routines/vn/procedures/machineWorker_getHistorical.sql deleted file mode 100644 index 67b1971a2..000000000 --- a/db/routines/vn/procedures/machineWorker_getHistorical.sql +++ /dev/null @@ -1,21 +0,0 @@ -DELIMITER $$ -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, - * si es jefe de producción muestra el historial completo. - * - * @param vPlate número de matrícula - * @param vWorkerFk id del trabajador - * -*/ - DECLARE vWorkerName VARCHAR(255) DEFAULT account.user_getNameFromId(vWorkerFk); - - SELECT mw.inTimed,account.user_getNameFromId(mw.workerFk) as workerName, mw.outTimed - FROM machineWorker mw - JOIN machine m ON m.plate = vPlate - WHERE mw.machineFk = m.id - AND mw.workerFk = IF(account.user_hasRole(vWorkerName, 'coolerAssist'), mw.workerFk, vWorkerFk) - ORDER BY mw.inTimed DESC; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/machineWorker_update.sql b/db/routines/vn/procedures/machineWorker_update.sql deleted file mode 100644 index f1a6e40b5..000000000 --- a/db/routines/vn/procedures/machineWorker_update.sql +++ /dev/null @@ -1,38 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`machineWorker_update`(vPlate VARCHAR(10), vWorkerFk INT) -BEGIN - -/** - * Actualiza el registro correspondiente si el vWorkerFk se ha registrado en las últimas horas (campo maxHours de machineWorkerConfig) con vPlate, - * - * @param vPlate número de matrícula - * @param vWorkerFk id del trabajador - * -*/ - - DECLARE vMachineFk INT(10); - DECLARE vMaxHours INT(10); - - SELECT m.id INTO vMachineFk - FROM machine m - WHERE m.plate = vPlate; - - SELECT maxHours INTO vMaxHours - FROM machineWorkerConfig; - - IF (SELECT COUNT(*) - FROM machineWorker m - WHERE m.workerFk = vWorkerFk - AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, util.VN_NOW()) AND ISNULL(m.outTimed)) THEN - - UPDATE machineWorker m - SET m.outTimed = CURRENT_TIMESTAMP() - WHERE m.workerFk = vWorkerFk - AND m.inTimed >= TIMESTAMPADD(HOUR , -vMaxHours, util.VN_NOW()) - AND ISNULL(m.outTimed) - AND m.machineFk = vMachineFk; - - END IF; - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/machine_getWorkerPlate.sql b/db/routines/vn/procedures/machine_getWorkerPlate.sql deleted file mode 100644 index cbb71c4cf..000000000 --- a/db/routines/vn/procedures/machine_getWorkerPlate.sql +++ /dev/null @@ -1,16 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`machine_getWorkerPlate`(vWorkerFk INT) -BEGIN -/** - * Selecciona la matrícula del vehículo del workerfk - * - * @param vWorkerFk el id del trabajador - */ - SELECT m.plate - FROM machine m - JOIN machineWorker mw ON mw.machineFk = m.id - WHERE mw.inTimed >= TIMESTAMPADD(HOUR , -12,util.VN_NOW()) - AND ISNULL(mw.outTimed) - AND mw.workerFk = vWorkerFk; -END$$ -DELIMITER ; diff --git a/db/routines/vn/views/workerWithoutTractor.sql b/db/routines/vn/views/workerWithoutTractor.sql index 205c66599..15b62d4a9 100644 --- a/db/routines/vn/views/workerWithoutTractor.sql +++ b/db/routines/vn/views/workerWithoutTractor.sql @@ -10,11 +10,10 @@ FROM ( `vn`.`collection` `c` JOIN `vn`.`client` `cl` ON(`cl`.`id` = `c`.`workerFk`) ) - LEFT JOIN `vn`.`machineWorker` `mw` ON( - `mw`.`workerFk` = `c`.`workerFk` - AND `mw`.`inTimed` > `util`.`VN_CURDATE`() + JOIN `vn`.`operator` `o` ON( + `o`.`workerFk` = `c`.`workerFk` ) ) WHERE `c`.`created` > `util`.`VN_CURDATE`() - AND `mw`.`workerFk` IS NULL + AND `o`.`machineFk` IS NULL GROUP BY `c`.`workerFk` diff --git a/db/versions/11317-silverCordyline/00-firstScript.sql b/db/versions/11317-silverCordyline/00-firstScript.sql new file mode 100644 index 000000000..35dffcd64 --- /dev/null +++ b/db/versions/11317-silverCordyline/00-firstScript.sql @@ -0,0 +1,9 @@ + +USE vn; +RENAME TABLE machineWorker TO machineWorker__; +ALTER TABLE machineWorker__ COMMENT = '@deprecated 2024-10-23 not used'; + +RENAME TABLE machineWorkerConfig TO machineWorkerConfig__; +ALTER TABLE machineWorkerConfig__ COMMENT = '@deprecated 2024-10-23 not used'; + +DELETE FROM salix.ACL WHERE model = 'MachineWorker'; From 43f8b22593574c2908fabb66f2d158807e83afdc Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 23 Oct 2024 16:10:00 +0200 Subject: [PATCH 201/217] feat: refs #8083 add field --- modules/ticket/back/methods/expedition-state/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/expedition-state/filter.js b/modules/ticket/back/methods/expedition-state/filter.js index 1483780f7..3a4e7a87c 100644 --- a/modules/ticket/back/methods/expedition-state/filter.js +++ b/modules/ticket/back/methods/expedition-state/filter.js @@ -29,7 +29,7 @@ module.exports = Self => { Object.assign(myOptions, options); const stmt = new ParameterizedSQL( - `SELECT es.created, u.name, u.id workerFk, est.description state + `SELECT es.created, u.name, u.id workerFk, est.description state, es.isScanned FROM vn.expeditionState es JOIN vn.expeditionStateType est ON est.id = es.typeFk JOIN account.user u ON u.id = es.userFk From 4c529da620871d1c78f824aad3a781f7ea1fd0e8 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 24 Oct 2024 07:31:26 +0200 Subject: [PATCH 202/217] feat: refs #7266 Requested changes and query optimization --- db/routines/vn/functions/buy_getUltimate.sql | 2 +- db/routines/vn/procedures/buy_getUltimate.sql | 2 +- .../item-label-barcode.html | 8 ++- .../item-label-barcode/sql/company.sql | 3 +- .../reports/item-label-barcode/sql/item.sql | 60 ++++++++----------- .../reports/item-label-qr/item-label-qr.html | 8 ++- .../reports/item-label-qr/sql/company.sql | 3 +- .../reports/item-label-qr/sql/item.sql | 60 ++++++++----------- 8 files changed, 68 insertions(+), 78 deletions(-) diff --git a/db/routines/vn/functions/buy_getUltimate.sql b/db/routines/vn/functions/buy_getUltimate.sql index 173e6e01f..8f5e9ce59 100644 --- a/db/routines/vn/functions/buy_getUltimate.sql +++ b/db/routines/vn/functions/buy_getUltimate.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getUltimate`( vItemFk INT, - vWarehouseFk SMALLINT, + vWarehouseFk INT, vDated DATE ) RETURNS int(11) diff --git a/db/routines/vn/procedures/buy_getUltimate.sql b/db/routines/vn/procedures/buy_getUltimate.sql index 1532222ad..77e2029fc 100644 --- a/db/routines/vn/procedures/buy_getUltimate.sql +++ b/db/routines/vn/procedures/buy_getUltimate.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_getUltimate`( vItemFk INT, - vWarehouseFk SMALLINT, + vWarehouseFk INT, vDated DATE ) BEGIN diff --git a/print/templates/reports/item-label-barcode/item-label-barcode.html b/print/templates/reports/item-label-barcode/item-label-barcode.html index 224338c2f..929ce5fe2 100644 --- a/print/templates/reports/item-label-barcode/item-label-barcode.html +++ b/print/templates/reports/item-label-barcode/item-label-barcode.html @@ -17,12 +17,16 @@
- {{item.comment}} + {{ + (item.longName && item.size && item.subName) + ? `${item.longName} ${item.size} ${item.subName}` + : item.comment + }}
- {{item.producer}} + {{item.producerName || item.producerFk}}
diff --git a/print/templates/reports/item-label-barcode/sql/company.sql b/print/templates/reports/item-label-barcode/sql/company.sql index e130b4033..4047786a9 100644 --- a/print/templates/reports/item-label-barcode/sql/company.sql +++ b/print/templates/reports/item-label-barcode/sql/company.sql @@ -1,6 +1,5 @@ SELECT co.code FROM warehouse w JOIN address a ON a.id = w.addressFk - JOIN client c ON c.id = a.clientFk - JOIN company co ON co.clientFk = c.id + JOIN company co ON co.clientFk = a.clientFk WHERE w.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-barcode/sql/item.sql b/print/templates/reports/item-label-barcode/sql/item.sql index 11ee60d1a..3cb42d139 100644 --- a/print/templates/reports/item-label-barcode/sql/item.sql +++ b/print/templates/reports/item-label-barcode/sql/item.sql @@ -6,37 +6,29 @@ WITH RECURSIVE numbers AS ( WHERE n < ? ) SELECT ROW_NUMBER() OVER() labelNum, - b.id buyFk, - b.itemFk, - b.quantity, - b.packing, - b.isPickedOff, - b.entryFk, - e.sub, - o.code origin, - COALESCE(p.`name`, p.id, '') producer, - i.name item, - i.`size`, - i.category, - i.stems, - i.inkFk, - IFNULL(CONCAT(ig.longName, ' ', ig.`size`, ' ', ig.subName), i.comment) comment, - i.typeFk, - i.isLaid, - w.code buyerName, - w.code, - s.company_name companyName, - t.shipped - FROM vn.buy b - JOIN vn.item i ON i.id = b.itemFk - LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk - LEFT JOIN edi.ekt e ON e.id = b.ektFk - JOIN vn.origin o ON o.id = i.originFk - LEFT JOIN vn.producer p ON p.id = i.producerFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.worker w ON w.id = it.workerFk - LEFT JOIN edi.supplier s ON s.supplier_id = e.pro - JOIN vn.entry e2 ON e2.id = b.entryFk - JOIN vn.travel t ON t.id = e2.travelFk - JOIN numbers num - WHERE b.id = ? \ No newline at end of file + b.itemFk, + i.name item, + b.id buyFk, + b.quantity, + b.packing, + b.entryFk, + o.code origin, + p.`name` producerName, + p.id producerFk, + i.`size`, + i.category, + i.stems, + i.inkFk, + ig.longName, + ig.subName, + i.comment, + w.code buyerName + FROM vn.buy b + JOIN vn.item i ON i.id = b.itemFk + LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk + JOIN vn.origin o ON o.id = i.originFk + LEFT JOIN vn.producer p ON p.id = i.producerFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.worker w ON w.id = it.workerFk + JOIN numbers num + WHERE b.id = ? \ No newline at end of file diff --git a/print/templates/reports/item-label-qr/item-label-qr.html b/print/templates/reports/item-label-qr/item-label-qr.html index 231c94818..712bd6c7d 100644 --- a/print/templates/reports/item-label-qr/item-label-qr.html +++ b/print/templates/reports/item-label-qr/item-label-qr.html @@ -71,7 +71,7 @@
- Productor: {{item.producer}} + Productor: {{item.producerName || item.producerFk}}
- {{item.comment}} + {{ + (item.longName && item.size && item.subName) + ? `${item.longName} ${item.size} ${item.subName}` + : item.comment + }}