From 228239b0273158e86473eb7187553b9cc4742e63 Mon Sep 17 00:00:00 2001 From: Joan Date: Wed, 18 Apr 2018 09:47:05 +0200 Subject: [PATCH 1/6] Added step-control component and basic data step controllers --- client/core/src/components/index.js | 1 + .../components/step-control/step-control.html | 33 +++++++++ .../components/step-control/step-control.js | 71 ++++++++++++++++++ .../step-control/step-control.spec.js | 49 +++++++++++++ .../src/components/step-control/style.scss | 58 +++++++++++++++ client/core/src/locale/en.yml | 5 +- client/core/src/locale/es.yml | 5 +- client/ticket/src/data/step-one/step-one.html | 7 +- client/ticket/src/data/step-one/step-one.js | 13 +--- .../src/data/step-three/step-three.html | 8 ++ .../ticket/src/data/step-three/step-three.js | 15 ++++ client/ticket/src/data/step-two/step-two.html | 29 ++++++++ client/ticket/src/data/step-two/step-two.js | 28 +++++++ .../sale/{priceGap.js => price-gap.js} | 0 .../methods/sale/saleComponentFilter.js | 0 services/loopback/common/models/sale.js | 3 +- services/loopback/common/models/sale.json | 73 ++++++++++--------- services/ticket/common/methods/sale/filter.js | 39 ---------- services/ticket/common/models/sale.js | 4 - services/ticket/common/models/sale.json | 61 ---------------- services/ticket/server/model-config.json | 3 - 21 files changed, 347 insertions(+), 158 deletions(-) create mode 100644 client/core/src/components/step-control/step-control.html create mode 100644 client/core/src/components/step-control/step-control.js create mode 100644 client/core/src/components/step-control/step-control.spec.js create mode 100644 client/core/src/components/step-control/style.scss rename services/loopback/common/methods/sale/{priceGap.js => price-gap.js} (100%) rename services/{ticket => loopback}/common/methods/sale/saleComponentFilter.js (100%) delete mode 100644 services/ticket/common/methods/sale/filter.js delete mode 100644 services/ticket/common/models/sale.js delete mode 100644 services/ticket/common/models/sale.json diff --git a/client/core/src/components/index.js b/client/core/src/components/index.js index 315f449ed..2da08fd15 100644 --- a/client/core/src/components/index.js +++ b/client/core/src/components/index.js @@ -29,4 +29,5 @@ import './combo/combo'; import './card/card'; import './switch/switch'; import './float-button/float-button'; +import './step-control/step-control'; import './label-value/label-value'; diff --git a/client/core/src/components/step-control/step-control.html b/client/core/src/components/step-control/step-control.html new file mode 100644 index 000000000..fffdfe04d --- /dev/null +++ b/client/core/src/components/step-control/step-control.html @@ -0,0 +1,33 @@ +
+
+
+
+
+
+
+
+
+ + +
+
+ + + + +
+
+
\ No newline at end of file diff --git a/client/core/src/components/step-control/step-control.js b/client/core/src/components/step-control/step-control.js new file mode 100644 index 000000000..5510a7815 --- /dev/null +++ b/client/core/src/components/step-control/step-control.js @@ -0,0 +1,71 @@ +import ngModule from '../../module'; +import './style.scss'; + +export default class StepControl { + constructor($state) { + this.$state = $state; + } + + set currentState(state) { + let isAllowed = true; + + if (this.onStepChange) + isAllowed = this.onStepChange({state}); + + if (isAllowed) + this.$state.go(state); + } + + get totalSteps() { + return this.steps.length; + } + + get currentState() { + return this.$state.current.name; + } + + get currentStepIndex() { + for (let i = 0; i < this.steps.length; i++) { + if (this.steps[i].state == this.$state.current.name) + return i; + } + } + + onPreviousClick() { + let state = this.steps[this.currentStepIndex - 1].state; + + this.currentState = state; + } + + onNextClick() { + let state = this.steps[this.currentStepIndex + 1].state; + + this.currentState = state; + } + + canMovePrevious() { + return this.steps[0].state != this.currentState; + } + + canFinalize() { + let lastStep = this.steps[this.totalSteps - 1]; + return lastStep.state == this.currentState; + } + + canMoveNext() { + let lastStep = this.steps[this.totalSteps - 1]; + return lastStep.state != this.currentState; + } +} + +StepControl.$inject = ['$state']; + +ngModule.component('vnStepControl', { + template: require('./step-control.html'), + controller: StepControl, + bindings: { + steps: '<', + onStepChange: '&?', + onStepEnd: '&?' + } +}); diff --git a/client/core/src/components/step-control/step-control.spec.js b/client/core/src/components/step-control/step-control.spec.js new file mode 100644 index 000000000..63a4354db --- /dev/null +++ b/client/core/src/components/step-control/step-control.spec.js @@ -0,0 +1,49 @@ +import './step-control.js'; + +describe('Component vnStepControl', () => { + let $componentController; + let controller; + let $state; + + beforeEach(() => { + angular.mock.module('ticket'); + }); + + beforeEach(angular.mock.inject((_$componentController_, _$state_) => { + $componentController = _$componentController_; + $state = _$state_; + controller = $componentController('vnStepControl', {$state: $state}); + })); + + describe('currentState()', () => { + it(`should call the onStepChange method then return false and never call the go method`, () => { + controller.onStepChange = jasmine.createSpy(controller, 'onStepChange').and.returnValue(false); + spyOn(controller.$state, 'go'); + + controller.currentState = "something"; + + expect(controller.onStepChange).toHaveBeenCalledWith({state: 'something'}); + expect(controller.$state.go).not.toHaveBeenCalledWith("something"); + }); + + it(`should call the onStepChange method then return true and finally call the go method`, () => { + controller.onStepChange = jasmine.createSpy(controller, 'onStepChange').and.returnValue(true); + spyOn(controller.$state, 'go'); + + controller.currentState = "something"; + + expect(controller.onStepChange).toHaveBeenCalledWith({state: 'something'}); + expect(controller.$state.go).toHaveBeenCalledWith("something"); + }); + }); + + describe('currentStepIndex()', () => { + it('should get the current state index from an Array of states', () => { + controller.$state.current.name = 'iam_a_current_state'; + controller.steps = [{state: 'iam_not_current_state'}, {state: 'iam_a_current_state'}]; + + let result = controller.currentStepIndex; + expect(result).toEqual(1); + }); + }); +}); diff --git a/client/core/src/components/step-control/style.scss b/client/core/src/components/step-control/style.scss new file mode 100644 index 000000000..085801634 --- /dev/null +++ b/client/core/src/components/step-control/style.scss @@ -0,0 +1,58 @@ +vn-step-control { + display: flex; + justify-content: center; + + .step-control { + border-top: 2px solid rgb(255,152,0); + margin-bottom: 15px; + + & > .steps { + display: flex; + flex-direction: row + } + + & > .steps > .step { + justify-content: center; + min-width: 125px; + display: flex; + flex: auto + } + + & > .steps > .step .circle { + border: 2px solid rgb(255,152,0); + background-color: #FFF; + align-content: center; + margin-top: -9.5px; + -moz-border-radius: 50%; + -webkit-border-radius: 50%; + border-radius: 50%; + cursor: pointer; + height: 15px; + width: 15px + } + + & > .steps > .step .circle.active { + background-color: rgb(255,152,0); + } + + & > .buttons { + display: flex; + flex: auto; + flex-direction: row; + justify-content: space-between; + margin-top: 10px + } + + & > .buttons > .step { + display: flex + } + + & > .buttons > .step > .mdl-button { + line-height: 32px; + font-size: 12px; + padding: 0 12px; + height: 32px + } + } + +} \ No newline at end of file diff --git a/client/core/src/locale/en.yml b/client/core/src/locale/en.yml index a89a8ca8d..1c72342dd 100644 --- a/client/core/src/locale/en.yml +++ b/client/core/src/locale/en.yml @@ -7,4 +7,7 @@ Add: Add Search: Search Show More: Show More No more results: No more results -Hide: Hide \ No newline at end of file +Hide: Hide +Next: Next +Finalize: Finalize +Previous: Back \ No newline at end of file diff --git a/client/core/src/locale/es.yml b/client/core/src/locale/es.yml index 2b6386570..0f6d87d9f 100644 --- a/client/core/src/locale/es.yml +++ b/client/core/src/locale/es.yml @@ -7,4 +7,7 @@ Add: Añadir Search: Buscar Show More: Ver más No more results: No hay más resultados -Hide: Ocultar \ No newline at end of file +Hide: Ocultar +Next: Siguiente +Finalize: Finalizar +Previous: Anterior \ No newline at end of file diff --git a/client/ticket/src/data/step-one/step-one.html b/client/ticket/src/data/step-one/step-one.html index 9972c660b..9b07d94a5 100644 --- a/client/ticket/src/data/step-one/step-one.html +++ b/client/ticket/src/data/step-one/step-one.html @@ -1,4 +1,4 @@ -
+ Basic data @@ -19,7 +19,7 @@ initial-data="$ctrl.ticket.addressFk"> - - -
diff --git a/client/ticket/src/data/step-one/step-one.js b/client/ticket/src/data/step-one/step-one.js index 3db7aa4b0..87776169e 100644 --- a/client/ticket/src/data/step-one/step-one.js +++ b/client/ticket/src/data/step-one/step-one.js @@ -1,22 +1,17 @@ import ngModule from '../../module'; class Controller { - constructor($scope, $timeout, $state) { + constructor($scope) { this.$scope = $scope; - this.$timeout = $timeout; - this.$state = $state; - } - onSubmit() { - this.$state.go('ticket.card.data.stepTwo'); } } -Controller.$inject = ['$scope', '$timeout', '$state']; +Controller.$inject = ['$scope']; ngModule.component('vnTicketDataStepOne', { template: require('./step-one.html'), + controller: Controller, bindings: { ticket: '<' - }, - controller: Controller + } }); diff --git a/client/ticket/src/data/step-three/step-three.html b/client/ticket/src/data/step-three/step-three.html index e69de29bb..472bf468d 100644 --- a/client/ticket/src/data/step-three/step-three.html +++ b/client/ticket/src/data/step-three/step-three.html @@ -0,0 +1,8 @@ +
+ + Step tree + + Ticket id {{$ctrl.ticket.id}} + + +
diff --git a/client/ticket/src/data/step-three/step-three.js b/client/ticket/src/data/step-three/step-three.js index e69de29bb..2dde82cfe 100644 --- a/client/ticket/src/data/step-three/step-three.js +++ b/client/ticket/src/data/step-three/step-three.js @@ -0,0 +1,15 @@ +import ngModule from '../../module'; + +class Controller { + constructor($scope) { + this.$scope = $scope; + } +} + +ngModule.component('vnTicketDataStepThree', { + template: require('./step-three.html'), + controller: Controller, + bindings: { + ticket: '<' + } +}); diff --git a/client/ticket/src/data/step-two/step-two.html b/client/ticket/src/data/step-two/step-two.html index e69de29bb..a1c5d3c0d 100644 --- a/client/ticket/src/data/step-two/step-two.html +++ b/client/ticket/src/data/step-two/step-two.html @@ -0,0 +1,29 @@ +
+ + Price gap + + + + + + + + + + + + + + + + + + + + + + +
ItemDescriptionQuantityPriceNew pricePrice gap
{{("000000"+sale.itemFk).slice(-6)}}{{::sale.quantity}}{{::sale.price | currency:'€':2}}--
+
+
+
diff --git a/client/ticket/src/data/step-two/step-two.js b/client/ticket/src/data/step-two/step-two.js index e69de29bb..244828304 100644 --- a/client/ticket/src/data/step-two/step-two.js +++ b/client/ticket/src/data/step-two/step-two.js @@ -0,0 +1,28 @@ +import ngModule from '../../module'; + +class Controller { + constructor($http, $scope) { + this.$http = $http; + this.$scope = $scope; + } + + $onChanges(data) { + if (!this.ticket || !this.ticket.id) return; + + let query = `/ticket/api/sales/${this.ticket.id}/priceGap`; + this.$http.get(query).then(res => { + if (res.data) + this.ticket.sales = res.data; + }); + } +} + +Controller.$inject = ['$http', '$scope']; + +ngModule.component('vnTicketDataStepTwo', { + template: require('./step-two.html'), + controller: Controller, + bindings: { + ticket: '<' + } +}); diff --git a/services/loopback/common/methods/sale/priceGap.js b/services/loopback/common/methods/sale/price-gap.js similarity index 100% rename from services/loopback/common/methods/sale/priceGap.js rename to services/loopback/common/methods/sale/price-gap.js diff --git a/services/ticket/common/methods/sale/saleComponentFilter.js b/services/loopback/common/methods/sale/saleComponentFilter.js similarity index 100% rename from services/ticket/common/methods/sale/saleComponentFilter.js rename to services/loopback/common/methods/sale/saleComponentFilter.js diff --git a/services/loopback/common/models/sale.js b/services/loopback/common/models/sale.js index a5189ea26..5d452295d 100644 --- a/services/loopback/common/models/sale.js +++ b/services/loopback/common/models/sale.js @@ -1,4 +1,5 @@ module.exports = function(Self) { require('../methods/sale/filter')(Self); - require('../methods/sale/priceGap')(Self); + require('../methods/sale/saleComponentFilter.js')(Self); + require('../methods/sale/price-gap')(Self); }; diff --git a/services/loopback/common/models/sale.json b/services/loopback/common/models/sale.json index fec1f2dd9..9466549da 100644 --- a/services/loopback/common/models/sale.json +++ b/services/loopback/common/models/sale.json @@ -1,38 +1,38 @@ { - "name": "Sale", - "base": "VnModel", - "options": { - "mysql": { - "table": "sale" - } + "name": "Sale", + "base": "VnModel", + "options": { + "mysql": { + "table": "sale" + } + }, + "properties": { + "id": { + "id": true, + "type": "Number", + "description": "Identifier" }, - "properties": { - "id": { - "id": true, - "type": "Number", - "description": "Identifier" - }, - "concept": { - "type": "String" - }, - "quantity": { - "type": "Number" - }, - "price": { - "type": "Number" - }, - "discount": { - "type": "Number" - }, - "reserved": { - "type": "Number" - }, - "isPicked": { - "type": "Number" - }, - "created": { - "type": "date" - } + "concept": { + "type": "String" + }, + "quantity": { + "type": "Number" + }, + "price": { + "type": "Number" + }, + "discount": { + "type": "Number" + }, + "reserved": { + "type": "Number" + }, + "isPicked": { + "type": "Number" + }, + "created": { + "type": "date" + } }, "relations": { "item": { @@ -51,6 +51,11 @@ "type": "hasOne", "model": "SaleChecked", "foreignKey": "saleFk" - } + }, + "components": { + "type": "hasMany", + "model": "SaleComponent", + "foreignKey": "saleFk" + } } } diff --git a/services/ticket/common/methods/sale/filter.js b/services/ticket/common/methods/sale/filter.js deleted file mode 100644 index f9b6304f6..000000000 --- a/services/ticket/common/methods/sale/filter.js +++ /dev/null @@ -1,39 +0,0 @@ -module.exports = Self => { - Self.installMethod('filter', filterParams); - - function filterParams(params) { - return { - where: { - ticketFk: params.ticketFk - }, - skip: (params.page - 1) * params.size, - limit: params.size, - order: params.order || 'concept ASC', - include: [{ - relation: "item", - scope: { - include: { - relation: "itemTag", - scope: { - fields: ["tagFk", "value"], - include: { - relation: "tag", - scope: { - fields: ["name"] - } - }, - limit: 6 - } - }, - fields: ["itemFk", "name"] - } - }, - { - relation: "isChecked", - scope: { - fields: ["isChecked"] - } - }] - }; - } -}; diff --git a/services/ticket/common/models/sale.js b/services/ticket/common/models/sale.js deleted file mode 100644 index c8afd2123..000000000 --- a/services/ticket/common/models/sale.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = function(Self) { - require('../methods/sale/filter.js')(Self); - require('../methods/sale/saleComponentFilter.js')(Self); -}; diff --git a/services/ticket/common/models/sale.json b/services/ticket/common/models/sale.json deleted file mode 100644 index 529329613..000000000 --- a/services/ticket/common/models/sale.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "Sale", - "base": "VnModel", - "options": { - "mysql": { - "table": "sale" - } - }, - "properties": { - "id": { - "id": true, - "type": "Number", - "description": "Identifier" - }, - "concept": { - "type": "String" - }, - "quantity": { - "type": "Number" - }, - "price": { - "type": "Number" - }, - "discount": { - "type": "Number" - }, - "reserved": { - "type": "Number" - }, - "isPicked": { - "type": "Number" - }, - "created": { - "type": "date" - } - }, - "relations": { - "item": { - "type": "belongsTo", - "model": "Item", - "foreignKey": "itemFk", - "required": true - }, - "ticket": { - "type": "belongsTo", - "model": "Ticket", - "foreignKey": "ticketFk", - "required": true - }, - "isChecked": { - "type": "hasOne", - "model": "SaleChecked", - "foreignKey": "saleFk" - }, - "components": { - "type": "hasMany", - "model": "SaleComponent", - "foreignKey": "saleFk" - } - } -} diff --git a/services/ticket/server/model-config.json b/services/ticket/server/model-config.json index bb5715e73..eccd5dae5 100644 --- a/services/ticket/server/model-config.json +++ b/services/ticket/server/model-config.json @@ -5,9 +5,6 @@ "ObservationType": { "dataSource": "vn" }, - "Sale": { - "dataSource": "vn" - }, "TicketTracking": { "dataSource": "vn" }, From 78b79b6fde4826a048db6b8061f3073f8c8329e4 Mon Sep 17 00:00:00 2001 From: Bernat Date: Wed, 18 Apr 2018 13:40:09 +0200 Subject: [PATCH 2/6] update fixtures and refactor ticketVolume and backend test --- services/db/04-fixtures.sql | 9 +++++- services/db/changes/1.0.3/01-ticketVolume.sql | 29 +++++++++++++++++++ .../client/specs/getAverageInvoiced.spec.js | 2 +- .../methods/client/specs/getMana.spec.js | 2 +- 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 services/db/changes/1.0.3/01-ticketVolume.sql diff --git a/services/db/04-fixtures.sql b/services/db/04-fixtures.sql index 039b879bb..83662e7d0 100644 --- a/services/db/04-fixtures.sql +++ b/services/db/04-fixtures.sql @@ -151,6 +151,13 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city (109, 'Bruce Banner', '16104829E', 'Hulk', 'Black widow', 'Somewhere in New York', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'BruceBanner@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 0, 1, NULL, 0, 0, 19, 0, 1), (110, 'Jessica Jones', '58282869H', 'Jessica Jones', 'Luke Cage', 'NYCC 2015 Poster', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'JessicaJones@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 0, 1, NULL, 0, 0, NULL, 0, 1); +INSERT INTO `vn`.`clientManaCache`(`clientFk`, `mana`, `dated`) + VALUES + ( 101, 50, CURDATE()), + ( 102, 100, CURDATE()), + ( 103, 0, CURDATE()), + ( 104, -30, CURDATE()); + INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `isDefaultAddress`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`) VALUES (101, '01', 'Somewhere in Thailand', 'Silla', 46460, 1, NULL, NULL, 1, 0, 109, 2, NULL, NULL, 0), @@ -537,7 +544,7 @@ INSERT INTO `bi`.`rotacion`(`Id_Article`, `warehouse_id`, `total`, `rotacion`, ` INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`) VALUES - ( 101, 0), + ( 101, 1500), ( 102, 100), ( 103, 1000), ( 104, 500), diff --git a/services/db/changes/1.0.3/01-ticketVolume.sql b/services/db/changes/1.0.3/01-ticketVolume.sql new file mode 100644 index 000000000..89cebb67e --- /dev/null +++ b/services/db/changes/1.0.3/01-ticketVolume.sql @@ -0,0 +1,29 @@ +USE `vn`; +DROP procedure IF EXISTS `ticketVolume`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `ticketVolume`(IN vTicketId INT) +BEGIN + DECLARE vWarehouseId INTEGER; + DECLARE vShippedDate DATE; + + DROP TEMPORARY TABLE IF EXISTS ticketVolume; + SELECT warehouseFk, shipped INTO vWarehouseId,vShippedDate FROM vn.ticket WHERE id = vTicketId; + + CREATE TEMPORARY TABLE IF NOT EXISTS ticketVolume ENGINE MEMORY + + SELECT itemFk, saleFk, quantity, concept, VolUd as m3_uni, volume as m3, volume * quantity as volumeTimesQuantity, @m3:= @m3 + ifnull(volume,0) as m3_total + FROM + ( + SELECT round(r.cm3 / 1000000,3) as VolUd ,s.quantity, round(r.cm3 * s.quantity / 1000000,3) as volume, + s.itemFk, s.id AS saleFk, s.concept, @m3:= 0, @vol:=0, t.agencyModeFk + FROM sale s + JOIN vn.ticket t on t.id = s.ticketFk + JOIN bi.rotacion r ON r.Id_Article = s.itemFk AND r.warehouse_id = t.warehouseFk + WHERE s.ticketFk = vTicketId + ) sub; +END$$ + +DELIMITER ; + diff --git a/services/loopback/common/methods/client/specs/getAverageInvoiced.spec.js b/services/loopback/common/methods/client/specs/getAverageInvoiced.spec.js index 0775423e0..a27e9a848 100644 --- a/services/loopback/common/methods/client/specs/getAverageInvoiced.spec.js +++ b/services/loopback/common/methods/client/specs/getAverageInvoiced.spec.js @@ -11,7 +11,7 @@ describe('client getAverageInvoiced()', () => { it('should call the getAverageInvoiced method', done => { model.getAverageInvoiced(101) .then(response => { - expect(response.invoiced).toEqual(0); + expect(response.invoiced).toEqual(1500); done(); }); }); diff --git a/services/loopback/common/methods/client/specs/getMana.spec.js b/services/loopback/common/methods/client/specs/getMana.spec.js index 942eaaca0..731c7a021 100644 --- a/services/loopback/common/methods/client/specs/getMana.spec.js +++ b/services/loopback/common/methods/client/specs/getMana.spec.js @@ -11,7 +11,7 @@ describe('client getMana()', () => { it('should call the getMana method', done => { model.getMana(101) .then(response => { - expect(response.mana).toEqual(0); + expect(response.mana).toEqual(30.02); done(); }); }); From f5014b7824bf48df3c70b853c50cdf6d13635a81 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 18 Apr 2018 13:47:45 +0200 Subject: [PATCH 3/6] # 186 CANCEL button en secciones pertinentes CR juan --- .../src/components/main-menu/main-menu.html | 8 + .../salix/src/components/main-menu/style.scss | 2 +- client/salix/src/locale/es.yml | 45 ++--- services/salix/client/version-notes.html | 160 ++++++++++++++++++ 4 files changed, 192 insertions(+), 23 deletions(-) create mode 100644 services/salix/client/version-notes.html diff --git a/client/salix/src/components/main-menu/main-menu.html b/client/salix/src/components/main-menu/main-menu.html index 33703f371..0a7947705 100644 --- a/client/salix/src/components/main-menu/main-menu.html +++ b/client/salix/src/components/main-menu/main-menu.html @@ -3,6 +3,14 @@ id="user">
{{currentUserName}}
+ + + + div > vn-icon { + & > div > vn-icon, & > div > a > vn-icon { font-size: 2.2em; cursor: pointer; diff --git a/client/salix/src/locale/es.yml b/client/salix/src/locale/es.yml index e1ba19aa9..f5767b4a2 100644 --- a/client/salix/src/locale/es.yml +++ b/client/salix/src/locale/es.yml @@ -1,26 +1,27 @@ Applications: Aplicaciones -Home: Inicio -Notifications: Notificaciones -Logout: Cerrar sesión -Change language: Cambiar idioma -Profile: Perfil -Data saved!: ¡Datos guardados! Can't contact with server: No se pudo contactar con el servidor -Push on applications menu: Para abrir un módulo pulsa en el menú de aplicaciones -Clients: Clientes -Routes : Rutas -Production : Producción -Modules access : Acceso a módulos -Locator: Localizador -Items: Artículos -name: Nombre -credit: Crédito -phone: Teléfono -creditInsurance: Crédito Asegurado -Return to module index: Volver a la página principal del módulo -Preview: Vista previa -Client has debt: Cliente con riesgo -Web Account inactive: Sin acceso Web +Change language: Cambiar idioma Client Frozen: Cliente congelado +Client has debt: Cliente con riesgo Client inactive: Cliente inactivo -Client not checked: Cliente no comprobado \ No newline at end of file +Client not checked: Cliente no comprobado +Clients: Clientes +credit: Crédito +creditInsurance: Crédito Asegurado +Data saved!: ¡Datos guardados! +Home: Inicio +Items: Artículos +Locator: Localizador +Logout: Cerrar sesión +Modules access : Acceso a módulos +Notifications: Notificaciones +name: Nombre +phone: Teléfono +Preview: Vista previa +Production : Producción +Profile: Perfil +Push on applications menu: Para abrir un módulo pulsa en el menú de aplicaciones +Return to module index: Volver a la página principal del módulo +Routes: Rutas +What is new: Novedades de la versión +Web Account inactive: Sin acceso Web diff --git a/services/salix/client/version-notes.html b/services/salix/client/version-notes.html new file mode 100644 index 000000000..3e0cbb774 --- /dev/null +++ b/services/salix/client/version-notes.html @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#EstadoAsunto
166In Progressrefactorizar buscador avanzado de articulos
171In ProgressAñadir revision
211In ProgressForzar a ciertos tags
213In ProgressSumario Tickets
216In ProgressSeccion Configuracion paso 2
124Resolvedaddress observations validations
199ResolvedAñadir manejador de cliente que no existe
138ResolvedRefactorización Popover
172ResolvedE2E revision
175ResolvedE2E embalajes
177ResolvedListar modelo saleChecked
182ResolvedListar volumen del ticket
196ResolvedE2E listar lineas ticket
198Resolvedrefactorizar tag con nuevo + -
201ResolvedListar Mana del cliente
202ResolvedAñadir a Sumario Cliente una seccion financia
209ResolvedContratos de credito
210Resolveditem tags
212ResolvedMostrar solo las agencias con el campo isActive(tpv) en TRUE
215ResolvedSeccion Configuracion paso 1
220ResolvedAl crear un consignatario mirar RE
222Resolvednuevo dni españa
223ResolvedManejador de errores global
227Resolvedtraducciones pendientes
219FeedbackPair programming
+ + + + From f3eecf53b7fc525af5bfc97f6e0c14ee1b93db32 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Wed, 18 Apr 2018 14:37:17 +0200 Subject: [PATCH 4/6] #192 refactor on back end unit test helpers to ready loopback methods extensions CR Joan --- .../client/specs/getAverageInvoiced.spec.js | 5 ++- .../methods/client/specs/getMana.spec.js | 5 ++- .../loopback/common/methods/item/clone.js | 2 +- .../common/methods/item/specs/clone.spec.js | 20 ++++++++++ .../common/methods/item/updateTaxes.js | 2 +- .../methods/ticket/specs/get-taxes.spec.js | 5 ++- .../methods/ticket/specs/get-total.spec.js | 5 ++- .../methods/ticket/specs/get-volume.spec.js | 7 ++-- .../loopback/common/test-helpers/loopback.js | 39 +++++++++++++++++++ .../loopback/common/test-helpers/rawSql.js | 14 ------- 10 files changed, 77 insertions(+), 27 deletions(-) create mode 100644 services/loopback/common/methods/item/specs/clone.spec.js create mode 100644 services/loopback/common/test-helpers/loopback.js delete mode 100644 services/loopback/common/test-helpers/rawSql.js diff --git a/services/loopback/common/methods/client/specs/getAverageInvoiced.spec.js b/services/loopback/common/methods/client/specs/getAverageInvoiced.spec.js index 0775423e0..2493c17b0 100644 --- a/services/loopback/common/methods/client/specs/getAverageInvoiced.spec.js +++ b/services/loopback/common/methods/client/specs/getAverageInvoiced.spec.js @@ -1,10 +1,11 @@ const getAverageInvoiced = require('../getAverageInvoiced'); -const {rawSql} = require('../../../test-helpers/rawSql'); const model = { remoteMethod: () => {} }; +let Loopback = require('../../../test-helpers/loopback'); +Loopback.init(model); -rawSql(model); +Loopback.rawSql(model); getAverageInvoiced(model); describe('client getAverageInvoiced()', () => { diff --git a/services/loopback/common/methods/client/specs/getMana.spec.js b/services/loopback/common/methods/client/specs/getMana.spec.js index 942eaaca0..940930eb5 100644 --- a/services/loopback/common/methods/client/specs/getMana.spec.js +++ b/services/loopback/common/methods/client/specs/getMana.spec.js @@ -1,10 +1,11 @@ const getMana = require('../getMana'); -const {rawSql} = require('../../../test-helpers/rawSql'); const model = { remoteMethod: () => {} }; +let Loopback = require('../../../test-helpers/loopback'); +Loopback.init(model); -rawSql(model); +Loopback.rawSql(model); getMana(model); describe('client getMana()', () => { diff --git a/services/loopback/common/methods/item/clone.js b/services/loopback/common/methods/item/clone.js index a3e9e38fc..f0a66d0d9 100644 --- a/services/loopback/common/methods/item/clone.js +++ b/services/loopback/common/methods/item/clone.js @@ -1,4 +1,4 @@ -var UserError = require('../../helpers').UserError; +let UserError = require('../../helpers').UserError; module.exports = Self => { Self.remoteMethod('clone', { diff --git a/services/loopback/common/methods/item/specs/clone.spec.js b/services/loopback/common/methods/item/specs/clone.spec.js new file mode 100644 index 000000000..345b7f7e5 --- /dev/null +++ b/services/loopback/common/methods/item/specs/clone.spec.js @@ -0,0 +1,20 @@ +const clone = require('../clone'); +const model = { + remoteMethod: () => {} +}; +let Loopback = require('../../../test-helpers/loopback'); +Loopback.init(model); + +Loopback.rawSql(model); +clone(model); + +describe('item clone()', () => { + it('should', () => { + let itemFk = 1; + model.clone(itemFk) + .then(response => { + expect(response).toEqual('whatever'); + done(); + }); + }); +}); diff --git a/services/loopback/common/methods/item/updateTaxes.js b/services/loopback/common/methods/item/updateTaxes.js index 70a2511bc..e70af8ca2 100644 --- a/services/loopback/common/methods/item/updateTaxes.js +++ b/services/loopback/common/methods/item/updateTaxes.js @@ -25,7 +25,7 @@ module.exports = Self => { } }); - Self.updateTaxes = async (id, taxes) => { + Self.updateTaxes = async(id, taxes) => { let promises = []; for (let tax of taxes) { if (!tax.taxClassFk) diff --git a/services/loopback/common/methods/ticket/specs/get-taxes.spec.js b/services/loopback/common/methods/ticket/specs/get-taxes.spec.js index f7a4fbb70..179b8907c 100644 --- a/services/loopback/common/methods/ticket/specs/get-taxes.spec.js +++ b/services/loopback/common/methods/ticket/specs/get-taxes.spec.js @@ -1,10 +1,11 @@ const getTaxes = require('../get-taxes'); -const {rawSql} = require('../../../test-helpers/rawSql'); const model = { remoteMethod: () => {} }; +let Loopback = require('../../../test-helpers/loopback'); +Loopback.init(model); -rawSql(model); +Loopback.rawSql(model); getTaxes(model); describe('ticket getTaxes()', () => { diff --git a/services/loopback/common/methods/ticket/specs/get-total.spec.js b/services/loopback/common/methods/ticket/specs/get-total.spec.js index 73adcb87e..a42234194 100644 --- a/services/loopback/common/methods/ticket/specs/get-total.spec.js +++ b/services/loopback/common/methods/ticket/specs/get-total.spec.js @@ -1,10 +1,11 @@ const getTotal = require('../get-total'); -const {rawSql} = require('../../../test-helpers/rawSql'); const model = { remoteMethod: () => {} }; +let Loopback = require('../../../test-helpers/loopback'); +Loopback.init(model); -rawSql(model); +Loopback.rawSql(model); getTotal(model); describe('ticket getTotal()', () => { diff --git a/services/loopback/common/methods/ticket/specs/get-volume.spec.js b/services/loopback/common/methods/ticket/specs/get-volume.spec.js index dcb01ac7f..99e1d4a63 100644 --- a/services/loopback/common/methods/ticket/specs/get-volume.spec.js +++ b/services/loopback/common/methods/ticket/specs/get-volume.spec.js @@ -1,10 +1,11 @@ const getVolume = require('../get-volume'); -const {rawSql} = require('../../../test-helpers/rawSql'); const model = { remoteMethod: () => {} }; +let Loopback = require('../../../test-helpers/loopback'); +Loopback.init(model); -rawSql(model); +Loopback.rawSql(model); getVolume(model); describe('ticket getVolume()', () => { @@ -16,4 +17,4 @@ describe('ticket getVolume()', () => { done(); }); }); -}); \ No newline at end of file +}); diff --git a/services/loopback/common/test-helpers/loopback.js b/services/loopback/common/test-helpers/loopback.js new file mode 100644 index 000000000..c6a11cb6d --- /dev/null +++ b/services/loopback/common/test-helpers/loopback.js @@ -0,0 +1,39 @@ +module.exports = { + importLoopbackModules: function() { + this.rawSqlModule = require('../methods/vnModel/rawSql.js'); + this.findOneModule = require('../methods/vnModel/rawSql.js'); + }, + + /** + * Initializes DataSource once + * @param {Object} Self - Model + */ + init: function(Self) { + if (!this.dataSource) + this.connect(); + + Self.dataSource = this.dataSource; + + this.importLoopbackModules(); + }, + + /** + * Instantiate Loopback DataSource + */ + connect: function() { + let DataSource = require('loopback-datasource-juggler').DataSource; + let dataSourceConfig = { + connector: 'mysql', + host: 'localhost', + user: 'root', + password: 'root', + database: 'salix' + }; + + this.dataSource = new DataSource(dataSourceConfig); + }, + + rawSql: function(Self) { + this.rawSqlModule(Self); + } +}; diff --git a/services/loopback/common/test-helpers/rawSql.js b/services/loopback/common/test-helpers/rawSql.js deleted file mode 100644 index 880520321..000000000 --- a/services/loopback/common/test-helpers/rawSql.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports.rawSql = Self => { - const DataSource = require('loopback-datasource-juggler').DataSource; - const rawSql = require('../methods/vnModel/rawSql.js'); - const dataSourceConfig = { - connector: 'mysql', - host: 'localhost', - user: 'root', - password: 'root', - database: 'salix' - }; - const dataSource = new DataSource(dataSourceConfig); - Self.dataSource = dataSource; - rawSql(Self); -}; From bf66dcbf1096b9538af128c0aa6b5f0dd1efcd6c Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Wed, 18 Apr 2018 14:42:30 +0200 Subject: [PATCH 5/6] disabled clone spec while investigating how to extend loopback methods --- .../common/methods/item/specs/clone.spec.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/services/loopback/common/methods/item/specs/clone.spec.js b/services/loopback/common/methods/item/specs/clone.spec.js index 345b7f7e5..f91f1b1e3 100644 --- a/services/loopback/common/methods/item/specs/clone.spec.js +++ b/services/loopback/common/methods/item/specs/clone.spec.js @@ -8,13 +8,15 @@ Loopback.init(model); Loopback.rawSql(model); clone(model); +// disabled test while loopback findOne method isnt extended to model yet. describe('item clone()', () => { it('should', () => { - let itemFk = 1; - model.clone(itemFk) - .then(response => { - expect(response).toEqual('whatever'); - done(); - }); + + // let itemFk = 1; + // model.clone(itemFk) + // .then(response => { + // expect(response).toEqual('whatever'); + // done(); + // }); }); }); From ded1ab5d937485afd36091f612ddcdefa8d311a1 Mon Sep 17 00:00:00 2001 From: Joan Date: Wed, 18 Apr 2018 15:11:05 +0200 Subject: [PATCH 6/6] Sql messageSend() and messageSendWithUser() --- services/db/changes/1.0.3/02-messageSend.sql | 17 ++++++ .../changes/1.0.3/03-messageSendWithUser.sql | 57 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 services/db/changes/1.0.3/02-messageSend.sql create mode 100644 services/db/changes/1.0.3/03-messageSendWithUser.sql diff --git a/services/db/changes/1.0.3/02-messageSend.sql b/services/db/changes/1.0.3/02-messageSend.sql new file mode 100644 index 000000000..cb099222c --- /dev/null +++ b/services/db/changes/1.0.3/02-messageSend.sql @@ -0,0 +1,17 @@ +USE `vn`; +DROP function IF EXISTS `messageSend`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` FUNCTION `messageSend`(vRecipient VARCHAR(255) CHARSET utf8, vMessage TEXT CHARSET utf8) RETURNS int(11) +BEGIN + DECLARE result INT; + DECLARE vSenderFk INT; + + SELECT id INTO vSenderFk + FROM account.user WHERE `name` = account.userGetName(); + + RETURN (SELECT messageSendWithUser(vSenderFk, vRecipient, vMessage)); +END$$ + +DELIMITER ; diff --git a/services/db/changes/1.0.3/03-messageSendWithUser.sql b/services/db/changes/1.0.3/03-messageSendWithUser.sql new file mode 100644 index 000000000..c5b83f77f --- /dev/null +++ b/services/db/changes/1.0.3/03-messageSendWithUser.sql @@ -0,0 +1,57 @@ +USE `vn`; +DROP function IF EXISTS `messageSendWithUser`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` FUNCTION `messageSendWithUser`(vSenderFK INT, vRecipient VARCHAR(255) CHARSET utf8, vMessage TEXT CHARSET utf8) RETURNS int(11) +BEGIN + + DECLARE vCount INT; + DECLARE vUuid VARCHAR(255); + DECLARE vSendDate DATETIME DEFAULT NOW(); + DECLARE vSender VARCHAR(255) CHARSET utf8; + + SELECT `name` INTO vSender + FROM account.user WHERE id = vSenderFK; + + SET vRecipient = LOWER(vRecipient); + + DROP TEMPORARY TABLE IF EXISTS tRecipients; + CREATE TEMPORARY TABLE tRecipients + SELECT u.name finalRecipient + FROM account.mailAlias a + JOIN account.mailAliasAccount aa ON aa.mailAlias = a.id + JOIN account.user u ON u.id = aa.account + WHERE a.alias = vRecipient COLLATE utf8_unicode_ci + AND u.name != vSender + AND u.active + UNION + SELECT u.name FROM account.user u + WHERE u.name = vRecipient + AND u.active; + + SELECT COUNT(*) INTO vCount FROM tRecipients; + + IF vCount = 0 THEN + RETURN vCount; + END IF; + + SET vUuid = UUID(); + + INSERT INTO message + SET uuid = vUuid, + sender = vSender, + recipient = vRecipient, + message = vMessage, + sendDate = vSendDate; + + INSERT INTO messageInbox (uuid, sender, recipient, finalRecipient, message, sendDate) + SELECT vUuid, vSender, vRecipient, finalRecipient, vMessage, vSendDate + FROM tRecipients; + + DROP TEMPORARY TABLE tRecipients; + RETURN vCount; +END$$ + +DELIMITER ; +