From 0d85069e0fc50f636c9a80f412afedcb79eeccaa Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 1 Jun 2023 15:01:38 +0200 Subject: [PATCH 01/24] refs #5561 feat: permite colorear --- .../back/methods/sale-tracking/delete.js | 53 ++++++++++++++ .../back/methods/sale-tracking/replace.js | 69 +++++++++++++++++++ modules/ticket/back/models/sale-tracking.js | 2 + modules/ticket/front/sale-tracking/index.html | 69 ++++++++++--------- modules/ticket/front/sale-tracking/index.js | 47 ++++++++++--- 5 files changed, 200 insertions(+), 40 deletions(-) create mode 100644 modules/ticket/back/methods/sale-tracking/delete.js create mode 100644 modules/ticket/back/methods/sale-tracking/replace.js diff --git a/modules/ticket/back/methods/sale-tracking/delete.js b/modules/ticket/back/methods/sale-tracking/delete.js new file mode 100644 index 000000000..50f7ff396 --- /dev/null +++ b/modules/ticket/back/methods/sale-tracking/delete.js @@ -0,0 +1,53 @@ + +module.exports = Self => { + Self.remoteMethod('delete', { + description: 'Elimina el registro (si se cumple la condición) y inserta uno nuevo', + accessType: 'READ', + accepts: [ + { + arg: 'saleFk', + type: 'number', + description: 'The sale id' + }, + { + arg: 'stateCode', + type: 'string' + } + ], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/delete`, + verb: 'POST' + } + }); + + Self.delete = async(saleFk, stateCode, options) => { + const models = Self.app.models; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + // const [itemShelvingSale] = await models.ItemShelvingSale.find({saleFk: saleFk}, myOptions); + // if (itemShelvingSale) await itemShelvingSale.destroy(myOptions); + + // const filter = { + // where: { + // saleFk: saleFk, + // code: stateCode + // } + // }; + // const [saleTracking] = await models.SaleTracking.find(filter, myOptions); + // return saleTracking.destroy(myOptions); + + query = `CALL vn.saleTracking_del(?, ?)`; + return Self.rawSql(query, + [ + saleFk, + stateCode, + ], myOptions); + }; +}; diff --git a/modules/ticket/back/methods/sale-tracking/replace.js b/modules/ticket/back/methods/sale-tracking/replace.js new file mode 100644 index 000000000..886ca4bfa --- /dev/null +++ b/modules/ticket/back/methods/sale-tracking/replace.js @@ -0,0 +1,69 @@ + +module.exports = Self => { + Self.remoteMethodCtx('replace', { + description: 'Remplaza el registro o lo crea si no existe', + accessType: 'READ', + accepts: [ + { + arg: 'saleFk', + type: 'number', + description: 'The sale id' + }, + { + arg: 'isChecked', + type: 'boolean' + }, + { + arg: 'quantity', + type: 'number' + }, + { + arg: 'stateCode', + type: 'string' + } + ], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/replace`, + verb: 'POST' + } + }); + + Self.replace = async(ctx, saleFk, isChecked, quantity, stateCode, options) => { + const models = Self.app.models; + const myOptions = {}; + const userId = ctx.req.accessToken.userId; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + // const state = await models.State.findOne({ + // where: {code: stateCode} + // }, myOptions); + + // if (!state) return; + + // const data = { + // saleFk: saleFk, + // isChecked: isChecked, + // originalQuantity: quantity, + // workerFk: userId, + // stateFk: state.id + // }; + // return models.SaleTracking.replaceOrCreate(data, myOptions); + + query = `CALL vn.saleTracking_new(?, ?, ?, ?, ?, ?)`; + return Self.rawSql(query, + [ + saleFk, + isChecked, + quantity, + userId, + stateCode, + null + ], myOptions); + }; +}; diff --git a/modules/ticket/back/models/sale-tracking.js b/modules/ticket/back/models/sale-tracking.js index 4a46dd6b7..446bdf37b 100644 --- a/modules/ticket/back/models/sale-tracking.js +++ b/modules/ticket/back/models/sale-tracking.js @@ -1,3 +1,5 @@ module.exports = Self => { require('../methods/sale-tracking/listSaleTracking')(Self); + require('../methods/sale-tracking/replace')(Self); + require('../methods/sale-tracking/delete')(Self); }; diff --git a/modules/ticket/front/sale-tracking/index.html b/modules/ticket/front/sale-tracking/index.html index 0309dde13..8d3fa65af 100644 --- a/modules/ticket/front/sale-tracking/index.html +++ b/modules/ticket/front/sale-tracking/index.html @@ -1,6 +1,6 @@ - + - + - + - + - + { - this.salePreparingList = res.data; - for (const salePreparing of this.salePreparingList) { - for (const sale of this.sales) { - if (salePreparing.saleFk == sale.id) - sale.preparingList = salePreparing; - } - } + res.data.forEach(salePreparing => { + const sale = this.sales.find(sale => salePreparing.saleFk === sale.id); + if (sale) sale.preparingList = salePreparing; + }); }); } } @@ -83,12 +80,46 @@ class Controller extends Section { this.saleId = sale.id; this.$.itemShelvingSale.show(); } + + clickPreviousSelected(index) { + const sale = this.sales[index]; + if (!sale.preparingList.isPreviousSelected) { + this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', false); + sale.preparingList.isPreviousSelected = true; + } else { + this.saleTrackingDel(sale, 'PREVIOUS_PREPARATION'); + sale.preparingList.isPreviousSelected = false; + } + } + + saleTrackingNew(sale, stateCode, isChecked) { + const params = { + saleFk: sale.id, + isChecked: isChecked, + quantity: sale.quantity, + stateCode: stateCode + }; + this.$http.post(`SaleTrackings/replace`, params).then(() => { + this.vnApp.showSuccess(this.$t('Data saved!')); + }); + } + + saleTrackingDel(sale, stateCode) { + const params = { + saleFk: sale.id, + stateCode: stateCode + }; + this.$http.post(`SaleTrackings/delete`, params).then(() => { + this.vnApp.showSuccess(this.$t('Data saved!')); + }); + } } ngModule.vnComponent('vnTicketSaleTracking', { template: require('./index.html'), controller: Controller, bindings: { - ticket: '<' + ticket: '<', + model: ' Date: Thu, 1 Jun 2023 15:31:16 +0200 Subject: [PATCH 02/24] refs # 5561 feat: cambiar url del crud-model --- .../back/methods/sale-tracking/delete.js | 34 ++++--- .../back/methods/sale-tracking/replace.js | 45 ++++----- .../sale-tracking/salePreparingList.js | 99 +++++++++++++++++++ .../back/methods/sale/salePreparingList.js | 33 ------- modules/ticket/back/models/sale-tracking.js | 1 + modules/ticket/back/models/sale.js | 1 - modules/ticket/front/sale-tracking/index.html | 38 ++++--- modules/ticket/front/sale-tracking/index.js | 32 ++---- 8 files changed, 166 insertions(+), 117 deletions(-) create mode 100644 modules/ticket/back/methods/sale-tracking/salePreparingList.js delete mode 100644 modules/ticket/back/methods/sale/salePreparingList.js diff --git a/modules/ticket/back/methods/sale-tracking/delete.js b/modules/ticket/back/methods/sale-tracking/delete.js index 50f7ff396..e2869c89a 100644 --- a/modules/ticket/back/methods/sale-tracking/delete.js +++ b/modules/ticket/back/methods/sale-tracking/delete.js @@ -31,23 +31,25 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - // const [itemShelvingSale] = await models.ItemShelvingSale.find({saleFk: saleFk}, myOptions); - // if (itemShelvingSale) await itemShelvingSale.destroy(myOptions); + const itemShelvingSales = await models.ItemShelvingSale.find({saleFk: saleFk}, myOptions); + for (let itemShelvingSale of itemShelvingSales) + await itemShelvingSale.destroy(myOptions); - // const filter = { - // where: { - // saleFk: saleFk, - // code: stateCode - // } - // }; - // const [saleTracking] = await models.SaleTracking.find(filter, myOptions); - // return saleTracking.destroy(myOptions); + const filter = { + where: { + saleFk: saleFk, + code: stateCode + } + }; + const saleTrackings = await models.SaleTracking.find(filter, myOptions); + for (let saleTracking of saleTrackings) + await saleTracking.destroy(myOptions); - query = `CALL vn.saleTracking_del(?, ?)`; - return Self.rawSql(query, - [ - saleFk, - stateCode, - ], myOptions); + // query = `CALL vn.saleTracking_del(?, ?)`; + // return Self.rawSql(query, + // [ + // saleFk, + // stateCode, + // ], myOptions); }; }; diff --git a/modules/ticket/back/methods/sale-tracking/replace.js b/modules/ticket/back/methods/sale-tracking/replace.js index 886ca4bfa..a2f9d6c08 100644 --- a/modules/ticket/back/methods/sale-tracking/replace.js +++ b/modules/ticket/back/methods/sale-tracking/replace.js @@ -40,30 +40,31 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - // const state = await models.State.findOne({ - // where: {code: stateCode} - // }, myOptions); + const state = await models.State.findOne({ + where: {code: stateCode} + }, myOptions); - // if (!state) return; + if (!state) return; - // const data = { - // saleFk: saleFk, - // isChecked: isChecked, - // originalQuantity: quantity, - // workerFk: userId, - // stateFk: state.id - // }; - // return models.SaleTracking.replaceOrCreate(data, myOptions); + const data = { + saleFk: saleFk, + isChecked: isChecked, + originalQuantity: quantity, + workerFk: userId, + stateFk: state.id + }; + return models.SaleTracking.replaceOrCreate(data, myOptions); - query = `CALL vn.saleTracking_new(?, ?, ?, ?, ?, ?)`; - return Self.rawSql(query, - [ - saleFk, - isChecked, - quantity, - userId, - stateCode, - null - ], myOptions); + // query = `CALL vn.saleTracking_new(?, ?, ?, ?, ?, ?, ?)`; + // return Self.rawSql(query, + // [ + // saleFk, + // isChecked, + // quantity, + // userId, + // stateCode, + // 'parameterToDelete', + // null + // ], myOptions); }; }; diff --git a/modules/ticket/back/methods/sale-tracking/salePreparingList.js b/modules/ticket/back/methods/sale-tracking/salePreparingList.js new file mode 100644 index 000000000..063730fde --- /dev/null +++ b/modules/ticket/back/methods/sale-tracking/salePreparingList.js @@ -0,0 +1,99 @@ + +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; + +module.exports = Self => { + Self.remoteMethod('salePreparingList', { + description: 'Returns a list with the lines of a ticket and its different states of preparation', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The ticket id', + http: {source: 'path'} + }, + { + arg: 'filter', + type: 'object', + description: 'Filter defining where and paginated data' + } + ], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/:id/salePreparingList`, + verb: 'GET' + } + }); + + Self.salePreparingList = async(id, filter, options) => { + const conn = Self.dataSource.connector; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const stmts = []; + let stmt; + + stmts.push('CALL cache.last_buy_refresh(FALSE)'); + + stmt = new ParameterizedSQL( + `SELECT t.clientFk, + t.shipped, + a.nickname, + s.ticketFk, + s.itemFk, + s.quantity, + s.concept, + s.reserved, + s.id saleFk, + i.size, + i.inkFk, + i.stems, + i.image, + i.subName, + b.grouping, + IF(stPrevious.saleFk,TRUE,FALSE) as isPreviousSelected, + stPrevious.isChecked as isPrevious, + stPrepared.isChecked as isPrepared, + stControled.isChecked as isControled, + ib.code as barcode, + (MAX(sgd.id) IS NOT NULL) AS hasSaleGroupDetail, + p.code AS parkingCode, + i.value5, + i.value6, + i.value7, + i.value8, + i.value9, + i.value10 + FROM vn.ticket t + JOIN vn.address a ON a.id = t.addressFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = t.warehouseFk + LEFT JOIN vn.buy b ON b.id = lb.buy_id + LEFT JOIN vn.saleTracking stPrevious ON stPrevious.saleFk = s.id AND stPrevious.stateFk = 26 + LEFT JOIN vn.saleTracking stPrepared ON stPrepared.saleFk = s.id AND stPrepared.stateFk = 14 + LEFT JOIN vn.saleTracking stControled ON stControled.saleFk = s.id AND stControled.stateFk = 8 + LEFT JOIN vn.itemBarcode ib ON ib.itemFk = i.id + LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id + LEFT JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk + LEFT JOIN vn.parking p ON p.id = sg.parkingFk + WHERE t.id = ? + GROUP BY s.id`, [id]); + + stmts.push(stmt); + + stmt.merge(Self.makeSuffix(filter)); + + const index = stmts.push(stmt) - 1; + const sql = ParameterizedSQL.join(stmts, ';'); + const result = await conn.executeStmt(sql, myOptions); + + return result[index]; + }; +}; diff --git a/modules/ticket/back/methods/sale/salePreparingList.js b/modules/ticket/back/methods/sale/salePreparingList.js deleted file mode 100644 index e6e7d5164..000000000 --- a/modules/ticket/back/methods/sale/salePreparingList.js +++ /dev/null @@ -1,33 +0,0 @@ -module.exports = Self => { - Self.remoteMethodCtx('salePreparingList', { - description: 'Returns a list with the lines of a ticket and its different states of preparation', - accessType: 'READ', - accepts: [{ - arg: 'id', - type: 'number', - required: true, - description: 'The ticket id', - http: {source: 'path'} - }], - returns: { - type: ['object'], - root: true - }, - http: { - path: `/:id/salePreparingList`, - verb: 'GET' - } - }); - - Self.salePreparingList = async(ctx, id, options) => { - const myOptions = {}; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - query = `CALL vn.salePreparingList(?)`; - const [sales] = await Self.rawSql(query, [id], myOptions); - - return sales; - }; -}; diff --git a/modules/ticket/back/models/sale-tracking.js b/modules/ticket/back/models/sale-tracking.js index 446bdf37b..76efff4c7 100644 --- a/modules/ticket/back/models/sale-tracking.js +++ b/modules/ticket/back/models/sale-tracking.js @@ -1,4 +1,5 @@ module.exports = Self => { + require('../methods/sale-tracking/salePreparingList')(Self); require('../methods/sale-tracking/listSaleTracking')(Self); require('../methods/sale-tracking/replace')(Self); require('../methods/sale-tracking/delete')(Self); diff --git a/modules/ticket/back/models/sale.js b/modules/ticket/back/models/sale.js index bab201fdd..ae247fc24 100644 --- a/modules/ticket/back/models/sale.js +++ b/modules/ticket/back/models/sale.js @@ -1,6 +1,5 @@ module.exports = Self => { require('../methods/sale/getClaimableFromTicket')(Self); - require('../methods/sale/salePreparingList')(Self); require('../methods/sale/reserve')(Self); require('../methods/sale/deleteSales')(Self); require('../methods/sale/updatePrice')(Self); diff --git a/modules/ticket/front/sale-tracking/index.html b/modules/ticket/front/sale-tracking/index.html index 8d3fa65af..193f87622 100644 --- a/modules/ticket/front/sale-tracking/index.html +++ b/modules/ticket/front/sale-tracking/index.html @@ -1,8 +1,6 @@ @@ -69,26 +67,26 @@ - {{::sale.item.id}} + {{::sale.itemFk}}
- {{::sale.item.name}} - -

{{::sale.item.subName}}

+ {{::sale.concept}} + +

{{::sale.subName}}

{{::sale.quantity}} - {{::sale.saleGroupDetail.saleGroup.parking.code | dashIfEmpty}} + {{::sale.parkingCode | dashIfEmpty}} { - res.data.forEach(salePreparing => { - const sale = this.sales.find(sale => salePreparing.saleFk === sale.id); - if (sale) sale.preparingList = salePreparing; - }); - }); - } - } - showItemDescriptor(event, sale) { this.quicklinks = { btnThree: { @@ -72,29 +54,29 @@ class Controller extends Section { } showSaleTracking(sale) { - this.saleId = sale.id; + this.saleId = sale.saleFk; this.$.saleTracking.show(); } showItemShelvingSale(sale) { - this.saleId = sale.id; + this.saleId = sale.saleFk; this.$.itemShelvingSale.show(); } clickPreviousSelected(index) { const sale = this.sales[index]; - if (!sale.preparingList.isPreviousSelected) { + if (!sale.isPreviousSelected) { this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', false); - sale.preparingList.isPreviousSelected = true; + sale.isPreviousSelected = true; } else { this.saleTrackingDel(sale, 'PREVIOUS_PREPARATION'); - sale.preparingList.isPreviousSelected = false; + sale.isPreviousSelected = false; } } saleTrackingNew(sale, stateCode, isChecked) { const params = { - saleFk: sale.id, + saleFk: sale.saleFk, isChecked: isChecked, quantity: sale.quantity, stateCode: stateCode @@ -106,7 +88,7 @@ class Controller extends Section { saleTrackingDel(sale, stateCode) { const params = { - saleFk: sale.id, + saleFk: sale.saleFk, stateCode: stateCode }; this.$http.post(`SaleTrackings/delete`, params).then(() => { From cf2bf0a17ba611e2d19e4e3f38dfc7f9364b0275 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 2 Jun 2023 08:23:44 +0200 Subject: [PATCH 03/24] refs #5561 delete: codigo obsoleto --- modules/ticket/front/sale-tracking/index.js | 35 --------------------- 1 file changed, 35 deletions(-) diff --git a/modules/ticket/front/sale-tracking/index.js b/modules/ticket/front/sale-tracking/index.js index c40892a52..62174860b 100644 --- a/modules/ticket/front/sale-tracking/index.js +++ b/modules/ticket/front/sale-tracking/index.js @@ -3,41 +3,6 @@ import Section from 'salix/components/section'; import './style.scss'; class Controller extends Section { - constructor($element, $) { - super($element, $); - this.filter = { - include: [ - { - relation: 'item' - }, - { - relation: 'saleTracking', - scope: { - fields: ['isChecked'] - } - }, - { - relation: 'saleGroupDetail', - scope: { - fields: ['saleGroupFk'], - include: { - relation: 'saleGroup', - scope: { - fields: ['parkingFk'], - include: { - relation: 'parking', - scope: { - fields: ['code'] - } - } - } - } - } - } - ] - }; - } - showItemDescriptor(event, sale) { this.quicklinks = { btnThree: { From 02d2afcb8ba9724eb30e3c4e8527651c3b6171cb Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 2 Jun 2023 10:57:28 +0200 Subject: [PATCH 04/24] refs #5561 feat: permite coloear todos los circulos --- .../back/methods/sale-tracking/delete.js | 36 +++++++-------- .../back/methods/sale-tracking/replace.js | 46 +++++++++---------- modules/ticket/front/sale-tracking/index.html | 11 +++-- modules/ticket/front/sale-tracking/index.js | 39 +++++++++++++++- 4 files changed, 85 insertions(+), 47 deletions(-) diff --git a/modules/ticket/back/methods/sale-tracking/delete.js b/modules/ticket/back/methods/sale-tracking/delete.js index e2869c89a..23fc9f01d 100644 --- a/modules/ticket/back/methods/sale-tracking/delete.js +++ b/modules/ticket/back/methods/sale-tracking/delete.js @@ -31,25 +31,25 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const itemShelvingSales = await models.ItemShelvingSale.find({saleFk: saleFk}, myOptions); - for (let itemShelvingSale of itemShelvingSales) - await itemShelvingSale.destroy(myOptions); + // const itemShelvingSales = await models.ItemShelvingSale.find({where: {saleFk: saleFk}}, myOptions); + // for (let itemShelvingSale of itemShelvingSales) + // await itemShelvingSale.destroy(myOptions); - const filter = { - where: { - saleFk: saleFk, - code: stateCode - } - }; - const saleTrackings = await models.SaleTracking.find(filter, myOptions); - for (let saleTracking of saleTrackings) - await saleTracking.destroy(myOptions); + // const filter = { + // where: { + // saleFk: saleFk, + // code: stateCode + // } + // }; + // const saleTrackings = await models.SaleTracking.find(filter, myOptions); + // for (let saleTracking of saleTrackings) + // await saleTracking.destroy(myOptions); - // query = `CALL vn.saleTracking_del(?, ?)`; - // return Self.rawSql(query, - // [ - // saleFk, - // stateCode, - // ], myOptions); + query = `CALL vn.saleTracking_del(?, ?)`; + return Self.rawSql(query, + [ + saleFk, + stateCode, + ], myOptions); }; }; diff --git a/modules/ticket/back/methods/sale-tracking/replace.js b/modules/ticket/back/methods/sale-tracking/replace.js index a2f9d6c08..140d0fc00 100644 --- a/modules/ticket/back/methods/sale-tracking/replace.js +++ b/modules/ticket/back/methods/sale-tracking/replace.js @@ -40,31 +40,31 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const state = await models.State.findOne({ - where: {code: stateCode} - }, myOptions); + // const state = await models.State.findOne({ + // where: {code: stateCode} + // }, myOptions); - if (!state) return; + // if (!state) return; - const data = { - saleFk: saleFk, - isChecked: isChecked, - originalQuantity: quantity, - workerFk: userId, - stateFk: state.id - }; - return models.SaleTracking.replaceOrCreate(data, myOptions); + // const data = { + // saleFk: saleFk, + // isChecked: isChecked, + // originalQuantity: quantity, + // workerFk: userId, + // stateFk: state.id + // }; + // return models.SaleTracking.replaceOrCreate(data, myOptions); - // query = `CALL vn.saleTracking_new(?, ?, ?, ?, ?, ?, ?)`; - // return Self.rawSql(query, - // [ - // saleFk, - // isChecked, - // quantity, - // userId, - // stateCode, - // 'parameterToDelete', - // null - // ], myOptions); + query = `CALL vn.saleTracking_new(?, ?, ?, ?, ?, ?, ?)`; + return Self.rawSql(query, + [ + saleFk, + isChecked, + quantity, + userId, + 'parameterToDelete', + stateCode, + null + ], myOptions); }; }; diff --git a/modules/ticket/front/sale-tracking/index.html b/modules/ticket/front/sale-tracking/index.html index 193f87622..1bd79642f 100644 --- a/modules/ticket/front/sale-tracking/index.html +++ b/modules/ticket/front/sale-tracking/index.html @@ -3,7 +3,7 @@ url="SaleTrackings/{{$ctrl.$params.id}}/salePreparingList" limit="20" data="$ctrl.sales" - order="concept ASC" + order="concept ASC, quantity DESC" auto-load="true">
@@ -46,7 +46,8 @@ 'none': !sale.isPrevious, }" class="circleState" - vn-tooltip="is previous"> + vn-tooltip="is previous" + vn-click-stop="$ctrl.clickPrevious($index)"> + vn-tooltip="is prepared" + vn-click-stop="$ctrl.clickPrepared($index)"> + vn-tooltip="is controled" + vn-click-stop="$ctrl.clickControled($index)"> diff --git a/modules/ticket/front/sale-tracking/index.js b/modules/ticket/front/sale-tracking/index.js index 62174860b..3016043d6 100644 --- a/modules/ticket/front/sale-tracking/index.js +++ b/modules/ticket/front/sale-tracking/index.js @@ -31,11 +31,46 @@ class Controller extends Section { clickPreviousSelected(index) { const sale = this.sales[index]; if (!sale.isPreviousSelected) { - this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', false); sale.isPreviousSelected = true; + this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', false); } else { - this.saleTrackingDel(sale, 'PREVIOUS_PREPARATION'); sale.isPreviousSelected = false; + sale.isPrevious = false; + this.saleTrackingDel(sale, 'PREVIOUS_PREPARATION'); + } + } + + clickPrevious(index) { + const sale = this.sales[index]; + if (!sale.isPrevious) { + sale.isPrevious = true; + sale.isPreviousSelected = true; + this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', true); + } else { + sale.isPrevious = false; + this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', false); + } + } + + clickPrepared(index) { + const sale = this.sales[index]; + if (!sale.isPrepared) { + sale.isPrepared = true; + this.saleTrackingNew(sale, 'PREPARED', true); + } else { + sale.isPrepared = false; + this.saleTrackingDel(sale, 'PREPARED'); + } + } + + clickControled(index) { + const sale = this.sales[index]; + if (!sale.isControled) { + sale.isControled = true; + this.saleTrackingNew(sale, 'CHECKED', true); + } else { + sale.isControled = false; + this.saleTrackingDel(sale, 'CHECKED'); } } From ba64dbbe46699b3a69b6fce6c85f60814b815aed Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 2 Jun 2023 12:20:29 +0200 Subject: [PATCH 05/24] refs #5561 refactor: actualizados nombres --- .../{salePreparingList.js => filter.js} | 16 +++------------- modules/ticket/back/models/sale-tracking.js | 2 +- modules/ticket/front/sale-tracking/index.html | 16 ++++++++-------- modules/ticket/front/sale-tracking/locale/es.yml | 13 +++++++------ 4 files changed, 19 insertions(+), 28 deletions(-) rename modules/ticket/back/methods/sale-tracking/{salePreparingList.js => filter.js} (84%) diff --git a/modules/ticket/back/methods/sale-tracking/salePreparingList.js b/modules/ticket/back/methods/sale-tracking/filter.js similarity index 84% rename from modules/ticket/back/methods/sale-tracking/salePreparingList.js rename to modules/ticket/back/methods/sale-tracking/filter.js index 063730fde..ee074a852 100644 --- a/modules/ticket/back/methods/sale-tracking/salePreparingList.js +++ b/modules/ticket/back/methods/sale-tracking/filter.js @@ -2,7 +2,7 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; module.exports = Self => { - Self.remoteMethod('salePreparingList', { + Self.remoteMethod('filter', { description: 'Returns a list with the lines of a ticket and its different states of preparation', accessType: 'READ', accepts: [ @@ -24,12 +24,12 @@ module.exports = Self => { root: true }, http: { - path: `/:id/salePreparingList`, + path: `/:id/filter`, verb: 'GET' } }); - Self.salePreparingList = async(id, filter, options) => { + Self.filter = async(id, filter, options) => { const conn = Self.dataSource.connector; const myOptions = {}; @@ -44,24 +44,17 @@ module.exports = Self => { stmt = new ParameterizedSQL( `SELECT t.clientFk, t.shipped, - a.nickname, s.ticketFk, s.itemFk, s.quantity, s.concept, - s.reserved, s.id saleFk, - i.size, - i.inkFk, - i.stems, i.image, i.subName, - b.grouping, IF(stPrevious.saleFk,TRUE,FALSE) as isPreviousSelected, stPrevious.isChecked as isPrevious, stPrepared.isChecked as isPrepared, stControled.isChecked as isControled, - ib.code as barcode, (MAX(sgd.id) IS NOT NULL) AS hasSaleGroupDetail, p.code AS parkingCode, i.value5, @@ -71,15 +64,12 @@ module.exports = Self => { i.value9, i.value10 FROM vn.ticket t - JOIN vn.address a ON a.id = t.addressFk JOIN vn.sale s ON s.ticketFk = t.id JOIN vn.item i ON i.id = s.itemFk LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = t.warehouseFk - LEFT JOIN vn.buy b ON b.id = lb.buy_id LEFT JOIN vn.saleTracking stPrevious ON stPrevious.saleFk = s.id AND stPrevious.stateFk = 26 LEFT JOIN vn.saleTracking stPrepared ON stPrepared.saleFk = s.id AND stPrepared.stateFk = 14 LEFT JOIN vn.saleTracking stControled ON stControled.saleFk = s.id AND stControled.stateFk = 8 - LEFT JOIN vn.itemBarcode ib ON ib.itemFk = i.id LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id LEFT JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk LEFT JOIN vn.parking p ON p.id = sg.parkingFk diff --git a/modules/ticket/back/models/sale-tracking.js b/modules/ticket/back/models/sale-tracking.js index 76efff4c7..86a5ea4ca 100644 --- a/modules/ticket/back/models/sale-tracking.js +++ b/modules/ticket/back/models/sale-tracking.js @@ -1,5 +1,5 @@ module.exports = Self => { - require('../methods/sale-tracking/salePreparingList')(Self); + require('../methods/sale-tracking/filter')(Self); require('../methods/sale-tracking/listSaleTracking')(Self); require('../methods/sale-tracking/replace')(Self); require('../methods/sale-tracking/delete')(Self); diff --git a/modules/ticket/front/sale-tracking/index.html b/modules/ticket/front/sale-tracking/index.html index 1bd79642f..76b178c26 100644 --- a/modules/ticket/front/sale-tracking/index.html +++ b/modules/ticket/front/sale-tracking/index.html @@ -1,6 +1,6 @@ @@ -93,12 +93,12 @@ diff --git a/modules/ticket/front/sale-tracking/locale/es.yml b/modules/ticket/front/sale-tracking/locale/es.yml index eabc0a04d..559321dd6 100644 --- a/modules/ticket/front/sale-tracking/locale/es.yml +++ b/modules/ticket/front/sale-tracking/locale/es.yml @@ -1,6 +1,7 @@ -ItemShelvings sale: Carros línea -has saleGroupDetail: tiene detalle grupo lineas -is previousSelected: es previa seleccionada -is previous: es previa -is prepared: esta preparado -is controled: esta controlado +Shelvings sale: Carros línea +Log states: Historial estados +sale group detail: detalle grupo lineas +previous selected: previa seleccionado +previous: previa +prepared: preparado +checked: revisado From 67413360c654794bf519e4fca07a42cf51340a9a Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 2 Jun 2023 13:31:41 +0200 Subject: [PATCH 06/24] =?UTF-8?q?refs=20#5561=20feat:=20utilizar=20m=C3=A9?= =?UTF-8?q?todos=20bd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/changes/232401/00-saleTracking_new.sql | 38 +++++++++++++++++++ .../back/methods/sale-tracking/delete.js | 15 -------- .../sale-tracking/{replace.js => new.js} | 23 ++--------- modules/ticket/back/models/sale-tracking.js | 2 +- 4 files changed, 42 insertions(+), 36 deletions(-) create mode 100644 db/changes/232401/00-saleTracking_new.sql rename modules/ticket/back/methods/sale-tracking/{replace.js => new.js} (63%) diff --git a/db/changes/232401/00-saleTracking_new.sql b/db/changes/232401/00-saleTracking_new.sql new file mode 100644 index 000000000..d5fa569fd --- /dev/null +++ b/db/changes/232401/00-saleTracking_new.sql @@ -0,0 +1,38 @@ +DELIMITER $$ +$$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`saleTracking_new`( + vSaleFK INT, + vIsChecked BOOLEAN, + vOriginalQuantity INT, + vWorkerFk INT, + vState VARCHAR(50), + vIsScanned BOOLEAN) +BEGIN +/** + * Modifica registro de saleTracking + * + * @param vSaleFK Identificador del registro a modificar + * @param vIsChecked Indica si la línea ha sido pulsada + * @param vOriginalQuantity Cantidad original + * @param vWorkerFk Identificador del trabajador + * @param vAction Identificador de la acción realizada + * @param vState Identificador del estado a modificar + * @param vIsScanned Identificador si se ha escaneado automáticamente o manual + */ + + REPLACE vn.saleTracking(saleFk, + isChecked, + originalQuantity, + workerFk, + stateFk, + isScanned) + SELECT vSaleFK, + vIsChecked, + vOriginalQuantity, + IFNULL(vWorkerFk, vn.getUser()), + s.id, + vIsScanned + FROM vn.state s + WHERE s.code = vState COLLATE utf8_unicode_ci; +END$$ +DELIMITER ; diff --git a/modules/ticket/back/methods/sale-tracking/delete.js b/modules/ticket/back/methods/sale-tracking/delete.js index 23fc9f01d..68b8b8ddc 100644 --- a/modules/ticket/back/methods/sale-tracking/delete.js +++ b/modules/ticket/back/methods/sale-tracking/delete.js @@ -25,26 +25,11 @@ module.exports = Self => { }); Self.delete = async(saleFk, stateCode, options) => { - const models = Self.app.models; const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); - // const itemShelvingSales = await models.ItemShelvingSale.find({where: {saleFk: saleFk}}, myOptions); - // for (let itemShelvingSale of itemShelvingSales) - // await itemShelvingSale.destroy(myOptions); - - // const filter = { - // where: { - // saleFk: saleFk, - // code: stateCode - // } - // }; - // const saleTrackings = await models.SaleTracking.find(filter, myOptions); - // for (let saleTracking of saleTrackings) - // await saleTracking.destroy(myOptions); - query = `CALL vn.saleTracking_del(?, ?)`; return Self.rawSql(query, [ diff --git a/modules/ticket/back/methods/sale-tracking/replace.js b/modules/ticket/back/methods/sale-tracking/new.js similarity index 63% rename from modules/ticket/back/methods/sale-tracking/replace.js rename to modules/ticket/back/methods/sale-tracking/new.js index 140d0fc00..d946fc40c 100644 --- a/modules/ticket/back/methods/sale-tracking/replace.js +++ b/modules/ticket/back/methods/sale-tracking/new.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethodCtx('replace', { + Self.remoteMethodCtx('new', { description: 'Remplaza el registro o lo crea si no existe', accessType: 'READ', accepts: [ @@ -27,34 +27,18 @@ module.exports = Self => { root: true }, http: { - path: `/replace`, + path: `/new`, verb: 'POST' } }); - Self.replace = async(ctx, saleFk, isChecked, quantity, stateCode, options) => { - const models = Self.app.models; + Self.new = async(ctx, saleFk, isChecked, quantity, stateCode, options) => { const myOptions = {}; const userId = ctx.req.accessToken.userId; if (typeof options == 'object') Object.assign(myOptions, options); - // const state = await models.State.findOne({ - // where: {code: stateCode} - // }, myOptions); - - // if (!state) return; - - // const data = { - // saleFk: saleFk, - // isChecked: isChecked, - // originalQuantity: quantity, - // workerFk: userId, - // stateFk: state.id - // }; - // return models.SaleTracking.replaceOrCreate(data, myOptions); - query = `CALL vn.saleTracking_new(?, ?, ?, ?, ?, ?, ?)`; return Self.rawSql(query, [ @@ -62,7 +46,6 @@ module.exports = Self => { isChecked, quantity, userId, - 'parameterToDelete', stateCode, null ], myOptions); diff --git a/modules/ticket/back/models/sale-tracking.js b/modules/ticket/back/models/sale-tracking.js index 86a5ea4ca..54a2b5a1a 100644 --- a/modules/ticket/back/models/sale-tracking.js +++ b/modules/ticket/back/models/sale-tracking.js @@ -1,6 +1,6 @@ module.exports = Self => { require('../methods/sale-tracking/filter')(Self); require('../methods/sale-tracking/listSaleTracking')(Self); - require('../methods/sale-tracking/replace')(Self); + require('../methods/sale-tracking/new')(Self); require('../methods/sale-tracking/delete')(Self); }; From 5eac9d20dcc9d6047f96aed759e3ca46662a7c61 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 5 Jun 2023 09:43:39 +0200 Subject: [PATCH 07/24] a --- modules/ticket/front/sale-tracking/index.html | 79 +++++++++++++++++-- 1 file changed, 74 insertions(+), 5 deletions(-) diff --git a/modules/ticket/front/sale-tracking/index.html b/modules/ticket/front/sale-tracking/index.html index 76b178c26..e51bc7499 100644 --- a/modules/ticket/front/sale-tracking/index.html +++ b/modules/ticket/front/sale-tracking/index.html @@ -158,7 +158,8 @@ - + + - - - + + Quantity @@ -181,7 +181,15 @@ - {{::itemShelvingSale.quantity}} + + {{itemShelvingSale.quantity}} + + + + + + + + From 024cb1e3f4ec1f02b20e52101d4fe17c33cb3807 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 6 Jun 2023 11:56:14 +0200 Subject: [PATCH 08/24] refs #5561 feat: permite modificar registros --- db/changes/232401/00-aclSaleTracking.sql | 3 + .../back/methods/item-shelving-sale/filter.js | 6 +- modules/item/back/models/item-shelving.json | 5 - modules/monitor/front/index/orders/index.html | 22 ++-- .../back/methods/sale-tracking/delete.js | 26 ++++- .../sale-tracking/deleteSaleGroupDetail.js | 49 ++++++++ .../ticket/back/methods/sale-tracking/new.js | 35 ++++-- modules/ticket/back/models/sale-tracking.js | 1 + modules/ticket/front/sale-tracking/index.html | 106 ++++++------------ modules/ticket/front/sale-tracking/index.js | 80 +++++++++++-- modules/ticket/front/sale-tracking/style.scss | 9 -- 11 files changed, 219 insertions(+), 123 deletions(-) create mode 100644 db/changes/232401/00-aclSaleTracking.sql create mode 100644 modules/ticket/back/methods/sale-tracking/deleteSaleGroupDetail.js diff --git a/db/changes/232401/00-aclSaleTracking.sql b/db/changes/232401/00-aclSaleTracking.sql new file mode 100644 index 000000000..441945fe2 --- /dev/null +++ b/db/changes/232401/00-aclSaleTracking.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) + VALUES + ('SaleTracking', 'deleteSaleGroupDetail', 'WRITE', 'ALLOW', 'ROLE', 'employee'); diff --git a/modules/item/back/methods/item-shelving-sale/filter.js b/modules/item/back/methods/item-shelving-sale/filter.js index 12029d33d..01a9f1856 100644 --- a/modules/item/back/methods/item-shelving-sale/filter.js +++ b/modules/item/back/methods/item-shelving-sale/filter.js @@ -28,11 +28,15 @@ module.exports = Self => { Object.assign(myOptions, options); const stmt = new ParameterizedSQL(` - SELECT iss.created, + SELECT + iss.id, + iss.created, iss.saleFk, iss.quantity, iss.userFk, + ish.id itemShelvingFk, ish.shelvingFk, + s.parkingFk, p.code, u.name FROM itemShelvingSale iss diff --git a/modules/item/back/models/item-shelving.json b/modules/item/back/models/item-shelving.json index 49bebcb6b..0b1d0eceb 100644 --- a/modules/item/back/models/item-shelving.json +++ b/modules/item/back/models/item-shelving.json @@ -35,11 +35,6 @@ "type": "belongsTo", "model": "VnUser", "foreignKey": "userFk" - }, - "shelving": { - "type": "belongsTo", - "model": "Shelving", - "foreignKey": "shelvingFk" } } } diff --git a/modules/monitor/front/index/orders/index.html b/modules/monitor/front/index/orders/index.html index 74e80e40e..4d1171185 100644 --- a/modules/monitor/front/index/orders/index.html +++ b/modules/monitor/front/index/orders/index.html @@ -32,7 +32,7 @@ - @@ -46,7 +46,7 @@ ui-sref="order.card.summary({id: {{::order.id}}})" target="_blank"> - @@ -98,7 +98,7 @@ scroll-offset="100"> - Filter by selection - Exclude selection - Remove filter - Remove all filters - Copy value @@ -138,4 +138,4 @@ on-accept="$ctrl.onDelete()" question="All the selected elements will be deleted. Are you sure you want to continue?" message="Delete selected elements"> - \ No newline at end of file + diff --git a/modules/ticket/back/methods/sale-tracking/delete.js b/modules/ticket/back/methods/sale-tracking/delete.js index 68b8b8ddc..000c52621 100644 --- a/modules/ticket/back/methods/sale-tracking/delete.js +++ b/modules/ticket/back/methods/sale-tracking/delete.js @@ -26,15 +26,29 @@ module.exports = Self => { Self.delete = async(saleFk, stateCode, options) => { const myOptions = {}; + let tx; if (typeof options == 'object') Object.assign(myOptions, options); - query = `CALL vn.saleTracking_del(?, ?)`; - return Self.rawSql(query, - [ - saleFk, - stateCode, - ], myOptions); + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const result = await Self.rawSql(`CALL vn.saleTracking_del(?, ?)`, + [ + saleFk, + stateCode, + ], myOptions); + + if (tx) await tx.commit(); + + return result; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } }; }; diff --git a/modules/ticket/back/methods/sale-tracking/deleteSaleGroupDetail.js b/modules/ticket/back/methods/sale-tracking/deleteSaleGroupDetail.js new file mode 100644 index 000000000..13806edf0 --- /dev/null +++ b/modules/ticket/back/methods/sale-tracking/deleteSaleGroupDetail.js @@ -0,0 +1,49 @@ + +module.exports = Self => { + Self.remoteMethod('deleteSaleGroupDetail', { + description: 'Elimina los registros de saleGroupDetail', + accessType: 'WRITE', + accepts: [ + { + arg: 'saleFk', + type: 'number', + description: 'The sale id' + } + ], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/deleteSaleGroupDetail`, + verb: 'POST' + } + }); + + Self.deleteSaleGroupDetail = async(saleFk, options) => { + const models = Self.app.models; + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const deletes = await models.SaleGroupDetail.destroyAll({ + saleFk: saleFk + }, myOptions); + + if (tx) await tx.commit(); + + return deletes; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/ticket/back/methods/sale-tracking/new.js b/modules/ticket/back/methods/sale-tracking/new.js index d946fc40c..ec5951d7d 100644 --- a/modules/ticket/back/methods/sale-tracking/new.js +++ b/modules/ticket/back/methods/sale-tracking/new.js @@ -33,21 +33,34 @@ module.exports = Self => { }); Self.new = async(ctx, saleFk, isChecked, quantity, stateCode, options) => { - const myOptions = {}; const userId = ctx.req.accessToken.userId; + const myOptions = {}; + let tx; if (typeof options == 'object') Object.assign(myOptions, options); - query = `CALL vn.saleTracking_new(?, ?, ?, ?, ?, ?, ?)`; - return Self.rawSql(query, - [ - saleFk, - isChecked, - quantity, - userId, - stateCode, - null - ], myOptions); + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + try { + const result = await Self.rawSql(`CALL vn.saleTracking_new(?, ?, ?, ?, ?, ?)`, + [ + saleFk, + isChecked, + quantity, + userId, + stateCode, + null + ], myOptions); + + if (tx) await tx.commit(); + + return result; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } }; }; diff --git a/modules/ticket/back/models/sale-tracking.js b/modules/ticket/back/models/sale-tracking.js index 54a2b5a1a..38de256be 100644 --- a/modules/ticket/back/models/sale-tracking.js +++ b/modules/ticket/back/models/sale-tracking.js @@ -3,4 +3,5 @@ module.exports = Self => { require('../methods/sale-tracking/listSaleTracking')(Self); require('../methods/sale-tracking/new')(Self); require('../methods/sale-tracking/delete')(Self); + require('../methods/sale-tracking/deleteSaleGroupDetail')(Self); }; diff --git a/modules/ticket/front/sale-tracking/index.html b/modules/ticket/front/sale-tracking/index.html index e51bc7499..1ae845a74 100644 --- a/modules/ticket/front/sale-tracking/index.html +++ b/modules/ticket/front/sale-tracking/index.html @@ -6,6 +6,16 @@ order="concept ASC, quantity DESC" auto-load="true"> + + + + @@ -29,7 +39,7 @@ }" class="circleState" vn-tooltip="sale group detail" - > + vn-click-stop="$ctrl.clickSaleGroupDetail($index)"> + - + Quantity Worker - Shelving - Parking + Shelving + Parking Created @@ -186,7 +195,7 @@ + on-change="$ctrl.updateQuantity(itemShelvingSale)"> @@ -197,8 +206,24 @@ {{::itemShelvingSale.name | dashIfEmpty}} - {{::itemShelvingSale.shelvingFk}} - {{::itemShelvingSale.code}} + + + + + + + + {{::itemShelvingSale.created | date: 'dd/MM/yyyy HH:mm'}} @@ -209,64 +234,3 @@ vn-id="worker-descriptor"> - - - diff --git a/modules/ticket/front/sale-tracking/index.js b/modules/ticket/front/sale-tracking/index.js index 3016043d6..8521a03af 100644 --- a/modules/ticket/front/sale-tracking/index.js +++ b/modules/ticket/front/sale-tracking/index.js @@ -28,49 +28,61 @@ class Controller extends Section { this.$.itemShelvingSale.show(); } + clickSaleGroupDetail(index) { + const sale = this.sales[index]; + const params = { + saleFk: sale.saleFk + }; + return this.$http.post('SaleTrackings/deleteSaleGroupDetail', params) + .then(() => { + sale.hasSaleGroupDetail = false; + this.vnApp.showSuccess(this.$t('Data saved!')); + }); + } + clickPreviousSelected(index) { const sale = this.sales[index]; if (!sale.isPreviousSelected) { - sale.isPreviousSelected = true; this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', false); + sale.isPreviousSelected = true; } else { + this.saleTrackingDel(sale, 'PREVIOUS_PREPARATION'); sale.isPreviousSelected = false; sale.isPrevious = false; - this.saleTrackingDel(sale, 'PREVIOUS_PREPARATION'); } } clickPrevious(index) { const sale = this.sales[index]; if (!sale.isPrevious) { + this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', true); sale.isPrevious = true; sale.isPreviousSelected = true; - this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', true); } else { - sale.isPrevious = false; this.saleTrackingNew(sale, 'PREVIOUS_PREPARATION', false); + sale.isPrevious = false; } } clickPrepared(index) { const sale = this.sales[index]; if (!sale.isPrepared) { - sale.isPrepared = true; this.saleTrackingNew(sale, 'PREPARED', true); + sale.isPrepared = true; } else { - sale.isPrepared = false; this.saleTrackingDel(sale, 'PREPARED'); + sale.isPrepared = false; } } clickControled(index) { const sale = this.sales[index]; if (!sale.isControled) { - sale.isControled = true; this.saleTrackingNew(sale, 'CHECKED', true); + sale.isControled = true; } else { - sale.isControled = false; this.saleTrackingDel(sale, 'CHECKED'); + sale.isControled = false; } } @@ -81,7 +93,7 @@ class Controller extends Section { quantity: sale.quantity, stateCode: stateCode }; - this.$http.post(`SaleTrackings/replace`, params).then(() => { + this.$http.post(`SaleTrackings/new`, params).then(() => { this.vnApp.showSuccess(this.$t('Data saved!')); }); } @@ -95,6 +107,56 @@ class Controller extends Section { this.vnApp.showSuccess(this.$t('Data saved!')); }); } + + updateQuantity(itemShelvingSale) { + const params = { + quantity: itemShelvingSale.quantity + }; + this.$http.patch(`ItemShelvingSales/${itemShelvingSale.id}`, params) + .then(() => { + this.vnApp.showSuccess(this.$t('Data saved!')); + }); + } + + updateShelving(itemShelvingSale) { + const params = { + shelvingFk: itemShelvingSale.shelvingFk + }; + this.$http.patch(`ItemShelvings/${itemShelvingSale.itemShelvingFk}`, params) + .then(res => { + const filter = { + fields: ['parkingFk'], + where: { + code: res.data.shelvingFk + } + }; + this.$http.get(`Shelvings/findOne`, {filter}) + .then(res => { + itemShelvingSale.parkingFk = res.data.parkingFk; + }); + + this.vnApp.showSuccess(this.$t('Data saved!')); + }); + } + + updateParking(itemShelvingSale) { + const filter = { + fields: ['id'], + where: { + code: itemShelvingSale.shelvingFk + } + }; + this.$http.get(`Shelvings/findOne`, {filter}) + .then(res => { + const params = { + parkingFk: itemShelvingSale.parkingFk + }; + this.$http.patch(`Shelvings/${res.data.id}`, params) + .then(() => { + this.vnApp.showSuccess(this.$t('Data saved!')); + }); + }); + } } ngModule.vnComponent('vnTicketSaleTracking', { diff --git a/modules/ticket/front/sale-tracking/style.scss b/modules/ticket/front/sale-tracking/style.scss index 78a0bda1d..f0807d75d 100644 --- a/modules/ticket/front/sale-tracking/style.scss +++ b/modules/ticket/front/sale-tracking/style.scss @@ -1,14 +1,5 @@ @import "variables"; -vn-sale-tracking { - .chip { - display: inline-block; - min-width: 15px; - min-height: 25px; - } - -} - .circleState { display: inline-block; justify-content: center; From 391dba6d2cb92614b11cc6ac581a379c8fc06ccc Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 6 Jun 2023 12:15:39 +0200 Subject: [PATCH 09/24] refs #5561 feat: add async functions --- modules/ticket/front/sale-tracking/index.html | 4 +- modules/ticket/front/sale-tracking/index.js | 43 ++++++++----------- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/modules/ticket/front/sale-tracking/index.html b/modules/ticket/front/sale-tracking/index.html index 1ae845a74..f05cf15fb 100644 --- a/modules/ticket/front/sale-tracking/index.html +++ b/modules/ticket/front/sale-tracking/index.html @@ -21,7 +21,7 @@ - Is checked + Is checked Item Description Quantity @@ -31,7 +31,7 @@ - + {{invoice.name}}
{{invoice.postalAddress}}
{{invoice.postcodeCity}}
+
{{invoice.postCode}}, {{invoice.city}}, ({{invoice.province}})
{{$t('fiscalId')}}: {{invoice.nif}}
{{$t('phone')}}: {{invoice.phone}}
diff --git a/print/templates/reports/invoiceIn/sql/invoice.sql b/print/templates/reports/invoiceIn/sql/invoice.sql index dae979011..82eeebce0 100644 --- a/print/templates/reports/invoiceIn/sql/invoice.sql +++ b/print/templates/reports/invoiceIn/sql/invoice.sql @@ -4,6 +4,9 @@ SELECT i.issued, s.name, s.street AS postalAddress, + s.city, + s.postCode, + pr.name province, s.nif, s.phone, p.name payMethod @@ -11,4 +14,5 @@ SELECT JOIN supplier s ON s.id = i.supplierFk JOIN company c ON c.id = i.companyFk JOIN payMethod p ON p.id = s.payMethodFk + LEFT JOIN province pr ON pr.id = s.provinceFk WHERE i.id = ? From 36623c1cae948bfd88c456aea6459a35166b240a Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 21 Aug 2023 13:48:51 +0200 Subject: [PATCH 18/24] refs #5941 fix(sendToSupport): fix email from --- back/methods/osticket/sendToSupport.js | 2 ++ print/core/smtp.js | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/back/methods/osticket/sendToSupport.js b/back/methods/osticket/sendToSupport.js index 320691e23..a9fcf28a9 100644 --- a/back/methods/osticket/sendToSupport.js +++ b/back/methods/osticket/sendToSupport.js @@ -33,6 +33,7 @@ module.exports = Self => { await Self.app.models.EmailUser.findById(ctx.req.accessToken.userId, {fields: ['email']}); let html = `Motivo:
${reason}
`; + html += `Usuario:
${ctx.req.accessToken.userId} ${emailUser.email}
`; for (const data in additionalData) html += `${data}:
${tryParse(additionalData[data])}
`; @@ -40,6 +41,7 @@ module.exports = Self => { const subjectReason = JSON.parse(additionalData?.httpRequest)?.data?.error; smtp.send({ to: config.app.reportEmail, + from: emailUser.email, replyTo: emailUser.email, subject: '[Support-Salix] ' + diff --git a/print/core/smtp.js b/print/core/smtp.js index 8c07e7eca..01d66b6f0 100644 --- a/print/core/smtp.js +++ b/print/core/smtp.js @@ -9,7 +9,7 @@ module.exports = { }, async send(options) { - options.from = `${config.app.senderName} <${config.app.senderEmail}>`; + options.from = options.from ?? `${config.app.senderName} <${config.app.senderEmail}>`; const env = process.env.NODE_ENV; const canSend = env === 'production' || !env || options.force; @@ -19,8 +19,10 @@ module.exports = { return Promise.resolve(true); } - if (!env) + if (!env) { options.to = config.app.senderEmail; + options.from = `${config.app.senderName} <${config.app.senderEmail}>`; + } let res; let error; From 14d4de0e1f4d4ac35bddb828d14c9d038f17979d Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 21 Aug 2023 14:48:05 +0200 Subject: [PATCH 19/24] refs #5941 fix(sendToSupport): add as a collaborator --- back/methods/osticket/sendToSupport.js | 4 +--- print/core/smtp.js | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/back/methods/osticket/sendToSupport.js b/back/methods/osticket/sendToSupport.js index a9fcf28a9..5b9ebb4e3 100644 --- a/back/methods/osticket/sendToSupport.js +++ b/back/methods/osticket/sendToSupport.js @@ -40,9 +40,7 @@ module.exports = Self => { const subjectReason = JSON.parse(additionalData?.httpRequest)?.data?.error; smtp.send({ - to: config.app.reportEmail, - from: emailUser.email, - replyTo: emailUser.email, + to: `${config.app.reportEmail}, ${emailUser.email}`, subject: '[Support-Salix] ' + additionalData?.frontPath + ' ' + diff --git a/print/core/smtp.js b/print/core/smtp.js index 01d66b6f0..8c07e7eca 100644 --- a/print/core/smtp.js +++ b/print/core/smtp.js @@ -9,7 +9,7 @@ module.exports = { }, async send(options) { - options.from = options.from ?? `${config.app.senderName} <${config.app.senderEmail}>`; + options.from = `${config.app.senderName} <${config.app.senderEmail}>`; const env = process.env.NODE_ENV; const canSend = env === 'production' || !env || options.force; @@ -19,10 +19,8 @@ module.exports = { return Promise.resolve(true); } - if (!env) { + if (!env) options.to = config.app.senderEmail; - options.from = `${config.app.senderName} <${config.app.senderEmail}>`; - } let res; let error; From a26652045c46efa6303c48f6db8c3c63b1454a6c Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 22 Aug 2023 10:17:46 +0200 Subject: [PATCH 20/24] refs #5712 hotFix(docuware): tickets. hotFix(catalog): search_panel --- back/methods/docuware/checkFile.js | 7 +++---- back/methods/docuware/deliveryNoteEmail.js | 2 +- back/methods/docuware/specs/checkFile.spec.js | 16 +++------------- back/methods/docuware/upload.js | 2 +- .../order/front/catalog-search-panel/index.js | 4 ---- modules/order/front/catalog/index.js | 2 +- modules/order/front/catalog/index.spec.js | 4 ++-- .../back/methods/ticket/docuwareDownload.js | 10 +++++++++- modules/ticket/back/models/ticket-methods.js | 1 + modules/ticket/front/descriptor-menu/index.js | 7 ++++--- 10 files changed, 25 insertions(+), 30 deletions(-) diff --git a/back/methods/docuware/checkFile.js b/back/methods/docuware/checkFile.js index 19224057c..76789649f 100644 --- a/back/methods/docuware/checkFile.js +++ b/back/methods/docuware/checkFile.js @@ -71,11 +71,10 @@ module.exports = Self => { } try { - const response = await Self.get(fileCabinet, filter); - const [documents] = response.Items; - if (!documents) return false; + const [response] = await Self.get(fileCabinet, filter); + if (!response) return false; - return {id: documents.Id}; + return {id: response['Document ID']}; } catch (error) { return false; } diff --git a/back/methods/docuware/deliveryNoteEmail.js b/back/methods/docuware/deliveryNoteEmail.js index 1557a3a87..a654eb262 100644 --- a/back/methods/docuware/deliveryNoteEmail.js +++ b/back/methods/docuware/deliveryNoteEmail.js @@ -65,7 +65,7 @@ module.exports = Self => { const email = new Email('delivery-note', params); - const docuwareFile = await models.Docuware.download(ctx, id, 'deliveryNote'); + const docuwareFile = await models.Docuware.download(id, 'deliveryNote'); return email.send({ overrideAttachments: true, diff --git a/back/methods/docuware/specs/checkFile.spec.js b/back/methods/docuware/specs/checkFile.spec.js index 8460bb561..c60809e85 100644 --- a/back/methods/docuware/specs/checkFile.spec.js +++ b/back/methods/docuware/specs/checkFile.spec.js @@ -16,19 +16,9 @@ describe('docuware download()', () => { it('should return the document data', async() => { const docuwareId = 1; - const response = { - Items: [ - { - Id: docuwareId, - Fields: [ - { - FieldName: 'ESTADO', - Item: 'Firmado' - } - ] - } - ] - }; + const response = [{ + 'Document ID': docuwareId + }]; spyOn(docuwareModel, 'get').and.returnValue((new Promise(resolve => resolve(response)))); const result = await models.Docuware.checkFile(ticketId, fileCabinetName, null, true); diff --git a/back/methods/docuware/upload.js b/back/methods/docuware/upload.js index 096301e56..7055bf8d5 100644 --- a/back/methods/docuware/upload.js +++ b/back/methods/docuware/upload.js @@ -111,7 +111,7 @@ module.exports = Self => { throw new UserError('Action not allowed on the test environment'); // delete old - const docuwareFile = await models.Docuware.checkFile(ctx, id, fileCabinet, false); + const docuwareFile = await models.Docuware.checkFile(id, fileCabinet, false); if (docuwareFile) { const deleteJson = { 'Field': [{'FieldName': 'ESTADO', 'Item': 'Pendiente eliminar', 'ItemElementName': 'String'}] diff --git a/modules/order/front/catalog-search-panel/index.js b/modules/order/front/catalog-search-panel/index.js index 21c0c50fa..b84243ca7 100644 --- a/modules/order/front/catalog-search-panel/index.js +++ b/modules/order/front/catalog-search-panel/index.js @@ -25,10 +25,6 @@ class Controller extends SearchPanel { this.filter.values.push({}); setTimeout(() => this.parentPopover.relocate()); } - - changeTag() { - - } } ngModule.vnComponent('vnOrderCatalogSearchPanel', { diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js index c0777ebc9..f25c4a35e 100644 --- a/modules/order/front/catalog/index.js +++ b/modules/order/front/catalog/index.js @@ -236,7 +236,7 @@ class Controller extends Section { tagGroups: this.tagGroups, }; - return model.applyFilter({where: newFilter}, newParams); + return model.addFilter({where: newFilter}, newParams); } openPanel(event) { diff --git a/modules/order/front/catalog/index.spec.js b/modules/order/front/catalog/index.spec.js index 03d7c41ba..ef96e1ed0 100644 --- a/modules/order/front/catalog/index.spec.js +++ b/modules/order/front/catalog/index.spec.js @@ -191,14 +191,14 @@ describe('Order', () => { describe('applyFilters()', () => { it(`should call model applyFilter() method with a new filter`, () => { - jest.spyOn(controller.$.model, 'applyFilter'); + jest.spyOn(controller.$.model, 'addFilter'); controller._categoryId = 2; controller._typeId = 4; controller.applyFilters(); - expect(controller.$.model.applyFilter).toHaveBeenCalledWith( + expect(controller.$.model.addFilter).toHaveBeenCalledWith( {where: {categoryFk: 2, typeFk: 4}}, {orderFk: 4, orderBy: controller.getOrderBy(), tagGroups: []}); }); diff --git a/modules/ticket/back/methods/ticket/docuwareDownload.js b/modules/ticket/back/methods/ticket/docuwareDownload.js index e9b74b1a9..7084bbdd4 100644 --- a/modules/ticket/back/methods/ticket/docuwareDownload.js +++ b/modules/ticket/back/methods/ticket/docuwareDownload.js @@ -32,6 +32,14 @@ module.exports = Self => { }); Self.docuwareDownload = async id => { + const models = Self.app.models; + const docuwareInfo = await models.Docuware.findOne({ + where: { + code: 'deliveryNote', + action: 'find' + } + }); + const filter = { condition: [ { @@ -50,6 +58,6 @@ module.exports = Self => { } ] }; - return Self.app.models.Docuware.download(id, 'deliveryNote', filter); + return models.Docuware.download(id, 'deliveryNote', filter); }; }; diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index c37337253..14cb104be 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -42,4 +42,5 @@ module.exports = function(Self) { require('../methods/ticket/expeditionPalletLabel')(Self); require('../methods/ticket/saveSign')(Self); require('../methods/ticket/invoiceTickets')(Self); + require('../methods/ticket/docuwareDownload')(Self); }; diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index 360d93564..d1f39fd19 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -3,10 +3,11 @@ import Section from 'salix/components/section'; import './style.scss'; class Controller extends Section { - constructor($element, $, vnReport, vnEmail) { + constructor($element, $, vnReport, vnEmail, vnFile) { super($element, $); this.vnReport = vnReport; this.vnEmail = vnEmail; + this.vnFile = vnFile; } get ticketId() { @@ -322,7 +323,7 @@ class Controller extends Section { } docuwareDownload() { - this.vnFile.download(`api/Ticket/${this.ticket.id}/docuwareDownload`); + this.vnFile.download(`api/Tickets/${this.ticket.id}/docuwareDownload`); } setTicketWeight(weight) { @@ -335,7 +336,7 @@ class Controller extends Section { } } -Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail']; +Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail', 'vnFile']; ngModule.vnComponent('vnTicketDescriptorMenu', { template: require('./index.html'), From cb8ed437d99acc7ca361dfc6ad8bb52ede9f2b00 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 22 Aug 2023 13:21:17 +0200 Subject: [PATCH 21/24] refs #6140 fix: el valor de ttl ya no es undefined --- front/core/services/token.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/core/services/token.js b/front/core/services/token.js index c16cc3c4f..426fe2b73 100644 --- a/front/core/services/token.js +++ b/front/core/services/token.js @@ -60,7 +60,7 @@ export default class Token { if (!this.token) return; const created = storage.getItem('vnTokenCreated'); this.created = created && new Date(created); - this.renewPeriod = storage.getItem('vnTokenRenewPeriod'); + this.ttl = storage.getItem('vnTokenTtl'); } setStorage(storage, token, created, ttl) { From 5a5e3ebddb40382eef2cd6c117312adddd77ad15 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 22 Aug 2023 13:39:57 +0200 Subject: [PATCH 22/24] refs #5712 hotFix(catalog): undo last fix search_panel --- modules/order/front/catalog/index.js | 2 +- modules/order/front/catalog/index.spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js index f25c4a35e..c0777ebc9 100644 --- a/modules/order/front/catalog/index.js +++ b/modules/order/front/catalog/index.js @@ -236,7 +236,7 @@ class Controller extends Section { tagGroups: this.tagGroups, }; - return model.addFilter({where: newFilter}, newParams); + return model.applyFilter({where: newFilter}, newParams); } openPanel(event) { diff --git a/modules/order/front/catalog/index.spec.js b/modules/order/front/catalog/index.spec.js index ef96e1ed0..03d7c41ba 100644 --- a/modules/order/front/catalog/index.spec.js +++ b/modules/order/front/catalog/index.spec.js @@ -191,14 +191,14 @@ describe('Order', () => { describe('applyFilters()', () => { it(`should call model applyFilter() method with a new filter`, () => { - jest.spyOn(controller.$.model, 'addFilter'); + jest.spyOn(controller.$.model, 'applyFilter'); controller._categoryId = 2; controller._typeId = 4; controller.applyFilters(); - expect(controller.$.model.addFilter).toHaveBeenCalledWith( + expect(controller.$.model.applyFilter).toHaveBeenCalledWith( {where: {categoryFk: 2, typeFk: 4}}, {orderFk: 4, orderBy: controller.getOrderBy(), tagGroups: []}); }); From 7349d4496f8ed79ec44a5f3f56bb922d18be3298 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 23 Aug 2023 07:34:01 +0200 Subject: [PATCH 23/24] refs #5351 hotFix(worker_sip): use worker.id not worker.userFk --- modules/worker/front/pbx/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/front/pbx/index.js b/modules/worker/front/pbx/index.js index d37f6f7d8..3b6443d3c 100644 --- a/modules/worker/front/pbx/index.js +++ b/modules/worker/front/pbx/index.js @@ -5,7 +5,7 @@ class Controller extends Section { onSubmit() { const sip = this.worker.sip; const params = { - userFk: this.worker.userFk, + userFk: this.worker.id, extension: sip.extension }; this.$.watcher.check(); From 8454d208e16c7be5999d3fe5b55102bdea881ac7 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 23 Aug 2023 12:02:52 +0200 Subject: [PATCH 24/24] hotFix(route_tickets): orderBy nickname --- modules/route/front/tickets/index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html index ea6755cca..46b62c5ba 100644 --- a/modules/route/front/tickets/index.html +++ b/modules/route/front/tickets/index.html @@ -58,7 +58,7 @@ Street City PC - Client + Client Warehouse Packages @@ -100,9 +100,9 @@ {{::ticket.street}} -