From fac93bd74ce1213a2471d1b1a47a8cb64047c153 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Tue, 4 Feb 2020 09:34:31 +0100 Subject: [PATCH 01/10] summary --- modules/entry/front/index.js | 5 +- modules/entry/front/routes.json | 8 ++ modules/entry/front/summary/index.html | 140 ++++++++++++++++++++++ modules/entry/front/summary/index.js | 56 +++++++++ modules/entry/front/summary/index.spec.js | 108 +++++++++++++++++ modules/entry/front/summary/locale/es.yml | 0 modules/entry/front/summary/style.scss | 10 ++ 7 files changed, 323 insertions(+), 4 deletions(-) create mode 100644 modules/entry/front/summary/index.html create mode 100644 modules/entry/front/summary/index.js create mode 100644 modules/entry/front/summary/index.spec.js create mode 100644 modules/entry/front/summary/locale/es.yml create mode 100644 modules/entry/front/summary/style.scss diff --git a/modules/entry/front/index.js b/modules/entry/front/index.js index a0272fccf1..25e054a717 100644 --- a/modules/entry/front/index.js +++ b/modules/entry/front/index.js @@ -5,7 +5,4 @@ import './index/'; import './search-panel'; import './descriptor'; import './card'; -// import './summary'; -// import './basic-data'; -// import './log'; -// import './create'; +import './summary'; diff --git a/modules/entry/front/routes.json b/modules/entry/front/routes.json index f23ff02bfb..ee4853eab9 100644 --- a/modules/entry/front/routes.json +++ b/modules/entry/front/routes.json @@ -27,6 +27,14 @@ "state": "entry.card", "abstract": true, "component": "vn-entry-card" + }, { + "url": "/summary", + "state": "entry.card.summary", + "component": "vn-entry-summary", + "description": "Summary", + "params": { + "entry": "$ctrl.entry" + } } ] } \ No newline at end of file diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html new file mode 100644 index 0000000000..5397c72ca2 --- /dev/null +++ b/modules/entry/front/summary/index.html @@ -0,0 +1,140 @@ + +
{{$ctrl.travelData.id}} - {{$ctrl.travelData.ref}}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Entries

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

Thermographs

+ + + + Code + Temperature + State + Destination + Created + + + + + {{thermograph.thermographFk}} + {{thermograph.temperature}} + {{thermograph.result}} + {{thermograph.warehouse.name}} + {{thermograph.created | date: 'dd/MM/yyyy'}} + + + +
+
+
+ + + + \ No newline at end of file diff --git a/modules/entry/front/summary/index.js b/modules/entry/front/summary/index.js new file mode 100644 index 0000000000..be17feb29b --- /dev/null +++ b/modules/entry/front/summary/index.js @@ -0,0 +1,56 @@ +import ngModule from '../module'; +import './style.scss'; +import Component from 'core/lib/component'; + +class Controller extends Component { + constructor($element, $, $httpParamSerializer) { + super($element, $); + this.entries = []; + this.$httpParamSerializer = $httpParamSerializer; + } + + get entry() { + return this._entry; + } + + set entry(value) { + this._entry = value; + + // if (value && value.id) { + // this.getTravel(); + // this.getEntries(); + // this.getThermographs(); + // } + } + + // getTravel() { + // return this.$http.get(`/api/Travels/${this.travel.id}/getTravel`).then(response => { + // this.travelData = response.data; + // }); + // } + + // getEntries() { + // return this.$http.get(`/api/Travels/${this.travel.id}/getEntries`).then(response => { + // this.entries = response.data; + // }); + // } + + // total(field) { + // let total = 0; + + // for (let entry of this.entries) + // total += entry[field]; + + // return total; + // } +} + +Controller.$inject = ['$element', '$scope', '$httpParamSerializer']; + +ngModule.component('vnEntrySummary', { + template: require('./index.html'), + controller: Controller, + bindings: { + entry: '<' + } +}); diff --git a/modules/entry/front/summary/index.spec.js b/modules/entry/front/summary/index.spec.js new file mode 100644 index 0000000000..5411d8a0d3 --- /dev/null +++ b/modules/entry/front/summary/index.spec.js @@ -0,0 +1,108 @@ +import './index'; + +describe('component vnTravelSummary', () => { + let controller; + let $httpBackend; + let $scope; + let $element; + let $httpParamSerializer; + + beforeEach(angular.mock.module('travel', $translateProvider => { + $translateProvider.translations('en', {}); + })); + + beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { + $httpBackend = _$httpBackend_; + $httpParamSerializer = _$httpParamSerializer_; + $scope = $rootScope.$new(); + $element = angular.element(``); + controller = $componentController('vnTravelSummary', {$element, $scope}); + })); + + describe('travel setter/getter', () => { + it('should return the travel', () => { + controller.travel = {id: null}; + + expect(controller.travel).toEqual(jasmine.any(Object)); + }); + + it('should return the travel and then call both getTravel() and getEntries()', () => { + spyOn(controller, 'getTravel'); + spyOn(controller, 'getEntries'); + spyOn(controller, 'getThermographs'); + controller.travel = {id: 99}; + + + expect(controller._travel.id).toEqual(99); + expect(controller.getTravel).toHaveBeenCalledWith(); + expect(controller.getEntries).toHaveBeenCalledWith(); + expect(controller.getThermographs).toHaveBeenCalledWith(); + }); + }); + + describe('getTravel()', () => { + it('should perform a get and then store data on the controller', () => { + controller._travel = {id: 999}; + + const query = `/api/Travels/${controller._travel.id}/getTravel`; + $httpBackend.expectGET(query).respond('I am the travelData'); + controller.getTravel(); + $httpBackend.flush(); + + expect(controller.travelData).toEqual('I am the travelData'); + }); + }); + + describe('getEntries()', () => { + it('should call the getEntries method to get the entries data', () => { + controller._travel = {id: 999}; + + const query = `/api/Travels/${controller._travel.id}/getEntries`; + $httpBackend.expectGET(query).respond('I am the entries'); + controller.getEntries(); + $httpBackend.flush(); + + expect(controller.entries).toEqual('I am the entries'); + }); + }); + + describe('getThermographs()', () => { + it('should call the getThermographs method to get the thermographs', () => { + controller._travel = {id: 2}; + const params = { + filter: { + include: { + relation: 'warehouse', + scope: { + fields: ['id', 'name'] + } + }, + where: { + travelFk: controller._travel.id + } + } + }; + const serializedParams = $httpParamSerializer(params); + const query = `TravelThermographs?${serializedParams}`; + $httpBackend.expectGET(query).respond('I am the thermographs'); + controller.getThermographs(); + $httpBackend.flush(); + + expect(controller.travelThermographs).toEqual('I am the thermographs'); + }); + }); + + describe('total()', () => { + it('should calculate the total amount of a given property for every row', () => { + controller.entries = [ + {id: 1, freightValue: 1, packageValue: 2, cc: 0.01}, + {id: 2, freightValue: 1, packageValue: 2, cc: 0.01}, + {id: 3, freightValue: 1, packageValue: 2, cc: 0.01} + ]; + + expect(controller.total('freightValue')).toEqual(3); + expect(controller.total('packageValue')).toEqual(6); + expect(controller.total('cc')).toEqual(0.03); + }); + }); +}); diff --git a/modules/entry/front/summary/locale/es.yml b/modules/entry/front/summary/locale/es.yml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/modules/entry/front/summary/style.scss b/modules/entry/front/summary/style.scss new file mode 100644 index 0000000000..922b36ad8f --- /dev/null +++ b/modules/entry/front/summary/style.scss @@ -0,0 +1,10 @@ +@import "variables"; + + +vn-travel-summary .summary { + max-width: $width-lg; + + vn-icon[icon=insert_drive_file]{ + color: $color-font-secondary; + } +} \ No newline at end of file From d018d9d536e886993ac26808d6ead66b1fe5d1bd Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Fri, 21 Feb 2020 07:44:20 +0100 Subject: [PATCH 02/10] fonts --- front/core/styles/icons/salixfont.css | 6 ++++++ front/core/styles/icons/salixfont.svg | 2 ++ front/core/styles/icons/salixfont.ttf | Bin 27668 -> 29868 bytes front/core/styles/icons/salixfont.woff | Bin 27744 -> 29944 bytes 4 files changed, 8 insertions(+) diff --git a/front/core/styles/icons/salixfont.css b/front/core/styles/icons/salixfont.css index 64f2776ea0..505fb8520e 100644 --- a/front/core/styles/icons/salixfont.css +++ b/front/core/styles/icons/salixfont.css @@ -23,6 +23,12 @@ -moz-osx-font-smoothing: grayscale; } +.icon-net:before { + content: "\e95b"; +} +.icon-anonymous:before { + content: "\e95c"; +} .icon-buyrequest:before { content: "\e914"; } diff --git a/front/core/styles/icons/salixfont.svg b/front/core/styles/icons/salixfont.svg index 2c13f601bd..7cd1af528d 100644 --- a/front/core/styles/icons/salixfont.svg +++ b/front/core/styles/icons/salixfont.svg @@ -98,4 +98,6 @@ + + \ No newline at end of file diff --git a/front/core/styles/icons/salixfont.ttf b/front/core/styles/icons/salixfont.ttf index 7a6ad2721937d8b4c55af2aab19a3dfa22ba4c22..08a36a48ba00ae23f523cc473aff246dd4a0c945 100644 GIT binary patch delta 2547 zcmZ8jOKcm*8J^i$&TyAI(nw3~niL-^Qsjz^sI0`7s|t>4)l!_;sRbK#4v8BzvHXZ1 zYOORj;9!j+=*c~_X$|y}OOMSVfO{|s19g!Ay%Z?WQ<9?SAwYowMIR`F^k7T-?u zE{D4_^FQYQzwhV2{K-f3y}#0!P(nzK+#!ra-#GpB!ss}UvGWk$S6;okvE_gB51$f3 zOIV+|uyJDxPldI9W-na1wfXxejXz?2laOogUp&9@+M&$#e-W}Z1Nq=0HpB;J1?yL^ zp1yc>`{u15Y`pv0uf9#lce7CV@ao3REfO2w!}@nv2iG>Po3pt!d0{^-FPed)*adHT}*6LftuF6=(ueZ(HKhvb*!x8zUcGn%Cp zx=2sbO&Zgm(qGWu&`;<;4a=w*vqs-IYCLb8FlAxdk1Qd`Y?<++VHr*WMR-fLXnBilpf%a7>J0^4?MrojC=@_Gen;205B4O z{4w4POL3B9h3+Ld3qmU%1=NKt!V!=yy4NGK&uv_E=@A>&Ln6k~}a+gw^>w*L6GDYzKpD)gSa9hg*5w)5t4&r($d1oTawdJIG^7mAOcQ1R4Mz>F$%cw~Ogxsd$ zx$soA&YTpwoU~P(yRsZ=8$`NJ=*yk z8G0ShiRDA-V4{L68W)2B4tLhOy(gCIGH~7UCS`3(b@W0%FVO?)_JkD*&n2?}QWI5>k2k0wE>2tf_ zWKbc&3z126Eo8Z0Q!MiZmo+7L>#K{=3jr70l}MY930th|f>M_4m{LxFZi9&+T*gmG z*S#3`ft9Q{V#Mmy#Pt|NYl;J@g6E)-QoMv+6`a)tg8jR?7}^C#mj`GAL`ZbMY)A&L zwXR9nIWj}elkbqX$j=FJlNO8q*F_)kbeq8YeBtMKTPNM1Ht*J z`@K6ve*wZV5@wcN8kDdoc8i6>1(1xwLyxh>#j|VA{%~z|?bE{3Mb2edC@+?ZGs+!j zq8Wsj>Oq+a4s?XUxgB`z*Xu!*&9+-Fw$Ord;$F1!OcbrKqjWR+`ZG~y^#~Pr?%dfW zxPhABYxQE>Ew0>MZJ%zH`(+H(c8zoO)oGk(p=asehR{DrL)4E2IGp0z`I#`e!HW%B zW^7(@i;L6EMYq6%;&PK`wFwhw5MEQ3GJ3Cb%=dU1d<$0|KH5oRN}rw8_;v2+Tyd8; z2^HvYF>bRlOaEQbf3onMK5^^M-x^)|jO0wcOFp?V@$3C3{=VEdP4)rSSz_p2T(Dt} zb{`R9638E$X5uLk?cFv~PvrjYg*RwctLcq*wl6($23LkJCi)x3_Wh;HAJP8;ISE%x delta 308 zcmZ4Ul5xrn#(D-u1_lOhh6V;^1_S?KeItG$wpyUb9w1Ig&P^;354-e`fq_v5$PY1DmajvSW&=G%XpZ9A(F05!}j$S*DdIur=9zf9cW&KNa`(VH=9vkzlnnkvX2KpempoVcWN6`TRuv|RjK?Yf{9Mj~9CBmEE I7wu&P0PHkRK>z>% diff --git a/front/core/styles/icons/salixfont.woff b/front/core/styles/icons/salixfont.woff index 0e6d9a21a9ba5a148f072d8a8888067e0cc5f283..325a1bc2d042d645d6fe16c72087b875f3117e4e 100644 GIT binary patch delta 2544 zcmZ8jOKcm*8Q$4h&TyAI^hitYiWDC!QskPnsIJ79p&E)R#ZsKuiG>(-4v7mju`D}& zwNmRCP_RZ(6g{Mez^Kt)a_O--6mSngVW2KzAjcLxIVpk^2vDGxK2QYlL6-W>uB4!XouU}icscB>bq;qO}-~RLG zm)15F?E#+C`&(YRdV3wTN1As1H){X!Y2z;&7uVj~r(2KT-Fb<;diOMWfxLSE7i4ukD(vm-J)}GIf%aSNBkfb| z3z8-kGDpskbrO-ElV6iRkWa|JbW^YCQ+i)t)L+og>96Tm^i54mwMqR1>Gzt!G~qSI zvxHBRV4e);Nq+!ZpcwT;XpVHTW(VL6q0npAm1snU72;vJiqVHLEXb8e9xLa1u42v( z6FnT^B1`ftR`F(CWfOvMffYyKK?w_@VJ@EpqykaFDU-7&dk>{iXfQkg-J;L!9l%%Mup@j0Kow+d6r=6di)^M1aIIv6S^Lf9ezF8 z1noFkuYsTvi``yqv7#UeR2&geKq`=Nn7st zC<~UEGgD``L*hag`A|C8C>U_yOa9Nfu4SZe)14T8?(Vgj;chS$0a8W591BAWs6HQ(YE;0~M0mEO*S?JtHfE z>dcmG)RL1bjP^LW4sqyPS!QLZA%U$)A92gf3%g)iVBDqM65IGibWd!H>M~GU1UKRJ8vXuS;DkaCoQn#E^ zJwQ1J3|3AwgWzPjG#b~J(E6nnry-4$Dr=gVM=VEDYjFu3qri-i2UUf)9J5g@j+1QC zCuxR)p(T#CTc<145d*D4X!!?A(BT;>T$>mGhmEkDq~^(mxR#Po@}Dp|g8+@rYh{*U zdR!bkZ;HbImGGcK5h`f7FHc#H1=CM&xl@jz)7CVjmOwU!+54(xI$c%Dy6S7cW6Lzx zd*~XsfiZ1m;+y?(!J5*Tpn-z^ROHj%MO32d;<@_hgR}jKu zR>4l8L;M#*gQ#9eGp{CT>Z@ATBxkK}&V?`fj59|dZ8pL!zN#8ZnwD({kw>|8%Kcyg zKOxokeAEM0qGI!`*{Sgx5eltJ>c2v8leNTH^`<13S@rcFz>tc?$YD}xasD@%Z#XyWFU9BEL(wiOhV*xez z@ovB{!U)CC!R&0-)O#ZrzuIEr5EBfu4w9I1<-@k(OHy|7#VQN~XK?x7VZn1E@fFh&uFk{S7{@luQKU-N|`MmIrB4Z*bl;=vt zqtY3ryy*v*>wcMX26VX2nB}|eH|u_tPPJRFv@n7){9d^9Oc*ZFMY0|~`%Ktbo+tdy zojZFPE+~!vt$H!)7MI>xZok|r_sdwa?dTWk%aibDVrHq|23J2xo!3wLa8B^q{UtY; z&Wa67q%2l(igT0AIj6w<;zE<9l?vq;5N=bHQi|3&>A9?odUHn{U+g3?CHKzq;+xD? zx#B9|2_0xNK5Ees6J?G6e&H|J%#w-i~1; of7fD>6ORizd5Q}Jpcdz delta 332 zcmezIlJUU}MzL~#H#Y`G1|Y~uVBiMRA`Fa^AC`zs)Df<)P0md$U|?X(07`^_uz1*| zhv|vMAhA6_J_i&Fq~}zo0mY6mFr=w~a7A%dVMc0V3Ijv>3!oY^5Eh^Pa%TomkbxmX z0muicV^Co~!XlHATT%fOa{=nF0pY?{?%bUGWS}~`%mYA0V4VJ=nJYK30%&no15iu> zjB6PW=OyN*0>u^pHO>R!xbU0q1^LA#K>s*Q{Nv9UHQ9&Jn=xwh4937TRggb{IFNth z)p&lJuMFHQKmi7ZTeg=L!|4BiC(kO77ytYJ4+{$ From 773963e7abab876e31b39cce4ba53875e015792f Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Fri, 21 Feb 2020 10:03:08 +0100 Subject: [PATCH 03/10] update entry filter --- modules/entry/back/methods/entry/filter.js | 12 ++++++++++++ modules/entry/front/search-panel/index.html | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/modules/entry/back/methods/entry/filter.js b/modules/entry/back/methods/entry/filter.js index 93e9558a96..ba9b021f50 100644 --- a/modules/entry/back/methods/entry/filter.js +++ b/modules/entry/back/methods/entry/filter.js @@ -68,6 +68,14 @@ module.exports = Self => { type: 'Number', description: 'The currency id to filter', http: {source: 'query'} + }, { + arg: 'from', + type: 'Date', + description: `The from date filter` + }, { + arg: 'to', + type: 'Date', + description: `The to date filter` } ], returns: { @@ -91,6 +99,10 @@ module.exports = Self => { return {[param]: {like: `%${value}%`}}; case 'created': return {'e.created': {gte: value}}; + case 'from': + return {'t.landed': {gte: value}}; + case 'to': + return {'t.landed': {lte: value}}; case 'id': case 'isBooked': case 'isConfirmed': diff --git a/modules/entry/front/search-panel/index.html b/modules/entry/front/search-panel/index.html index d648edcddc..a3daa8f0f7 100644 --- a/modules/entry/front/search-panel/index.html +++ b/modules/entry/front/search-panel/index.html @@ -54,6 +54,18 @@ ng-model="filter.created"> + + + + + + Date: Fri, 21 Feb 2020 12:48:34 +0100 Subject: [PATCH 04/10] entry summary and descriptor --- db/dump/fixtures.sql | 8 +- modules/entry/back/methods/entry/getEntry.js | 76 ++++++++ .../back/methods/entry/specs/getEntry.spec.js | 31 ++++ modules/entry/back/models/entry.js | 1 + modules/entry/back/models/entry.json | 3 + modules/entry/front/card/index.js | 29 ++- modules/entry/front/descriptor/index.html | 16 +- modules/entry/front/descriptor/index.js | 42 +++++ modules/entry/front/descriptor/locale/es.yml | 2 + modules/entry/front/index/index.html | 8 +- modules/entry/front/summary/index.html | 174 +++++------------- modules/entry/front/summary/index.js | 33 +--- modules/entry/front/summary/index.spec.js | 98 ++-------- modules/entry/front/summary/locale/es.yml | 2 + modules/entry/front/summary/style.scss | 2 +- 15 files changed, 283 insertions(+), 242 deletions(-) create mode 100644 modules/entry/back/methods/entry/getEntry.js create mode 100644 modules/entry/back/methods/entry/specs/getEntry.spec.js diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index f7d5d94f1c..5d2eb871d2 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1101,11 +1101,11 @@ INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`) (104, 500), (105, 5000); -INSERT INTO `vn`.`supplier`(`id`, `name`,`account`,`countryFk`,`nif`,`isFarmer`,`retAccount`,`commission`, `created`, `postcodeFk`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`) +INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`retAccount`,`commission`, `created`, `postcodeFk`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`) VALUES - (1, 'Plants SL', 4000000001, 1, 'A11111111', 0, NULL, 0, CURDATE(), 1111, 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1), - (2, 'Flower King', 4000000002, 1, 'B22222222', 0, NULL, 0, CURDATE(), 2222, 1, 'supplier address 2', 'LONDON', 2, 45671, 1, 2), - (442, 'Verdnatura Levante SL', 4000000442, 1, 'C33333333', 0, NULL, 0, CURDATE(), 3333, 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2); + (1, 'Plants SL', 'Plants nick', 4000000001, 1, 'A11111111', 0, NULL, 0, CURDATE(), 1111, 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1), + (2, 'Flower King', 'The king', 4000000002, 1, 'B22222222', 0, NULL, 0, CURDATE(), 2222, 1, 'supplier address 2', 'LONDON', 2, 45671, 1, 2), + (442, 'Verdnatura Levante SL', 'Verdnatura', 4000000442, 1, 'C33333333', 0, NULL, 0, CURDATE(), 3333, 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2); INSERT INTO `cache`.`cache_calc`(`id`, `cache_id`, `cacheName`, `params`, `last_refresh`, `expires`, `created`, `connection_id`) VALUES diff --git a/modules/entry/back/methods/entry/getEntry.js b/modules/entry/back/methods/entry/getEntry.js new file mode 100644 index 0000000000..008ee8148f --- /dev/null +++ b/modules/entry/back/methods/entry/getEntry.js @@ -0,0 +1,76 @@ +module.exports = Self => { + Self.remoteMethod('getEntry', { + description: 'Returns an entry', + accessType: 'READ', + accepts: { + arg: 'id', + type: 'number', + required: true, + description: 'The entry id', + http: {source: 'path'} + }, + returns: { + type: 'object', + root: true + }, + http: { + path: `/:id/getEntry`, + verb: 'GET' + } + }); + + Self.getEntry = async id => { + let filter = { + where: {id: id}, + include: [ + { + relation: 'supplier', + scope: { + fields: ['id', 'nickname'] + } + }, + { + relation: 'travel', + scope: { + fields: ['id', 'name', 'shipped', 'landed', 'agencyFk', 'warehouseOutFk', 'warehouseInFk'], + include: [ + { + relation: 'agency', + scope: { + fields: ['name'] + } + }, + { + relation: 'warehouseOut', + scope: { + fields: ['name'] + } + }, + { + relation: 'warehouseIn', + scope: { + fields: ['name'] + } + } + ] + } + }, + { + relation: 'currency', + scope: { + fields: ['id', 'name'] + } + }, + { + relation: 'company', + scope: { + fields: ['id', 'code'] + } + } + ], + }; + + let entry = await Self.app.models.Entry.findOne(filter); + return entry; + }; +}; diff --git a/modules/entry/back/methods/entry/specs/getEntry.spec.js b/modules/entry/back/methods/entry/specs/getEntry.spec.js new file mode 100644 index 0000000000..4baf64543f --- /dev/null +++ b/modules/entry/back/methods/entry/specs/getEntry.spec.js @@ -0,0 +1,31 @@ +const app = require('vn-loopback/server/server'); + +describe('travel getEntry()', () => { + const entryId = 1; + it('should check the entry contains the id', async() => { + const entry = await app.models.Entry.getEntry(entryId); + + expect(entry.id).toEqual(1); + }); + + it('should check the entry contains the supplier name', async() => { + const entry = await app.models.Entry.getEntry(entryId); + const supplierName = entry.supplier().nickname; + + expect(supplierName).toEqual('Plants nick'); + }); + + it('should check the entry contains the receiver warehouse name', async() => { + const entry = await app.models.Entry.getEntry(entryId); + const receiverWarehouseName = entry.travel().warehouseIn().name; + + expect(receiverWarehouseName).toEqual('Warehouse One'); + }); + + it('should check the entry contains the company code', async() => { + const entry = await app.models.Entry.getEntry(entryId); + const companyCode = entry.company().code; + + expect(companyCode).toEqual('VNL'); + }); +}); diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 4034b7e0aa..b1f71b4bd3 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -1,4 +1,5 @@ module.exports = Self => { require('../methods/entry/filter')(Self); + require('../methods/entry/getEntry')(Self); }; diff --git a/modules/entry/back/models/entry.json b/modules/entry/back/models/entry.json index a2eef4cd22..c2a7d7c42f 100644 --- a/modules/entry/back/models/entry.json +++ b/modules/entry/back/models/entry.json @@ -39,6 +39,9 @@ "commission": { "type": "Number" }, + "isOrdered": { + "type": "Boolean" + }, "created": { "type": "date" }, diff --git a/modules/entry/front/card/index.js b/modules/entry/front/card/index.js index 62fed7db04..83f47c83d9 100644 --- a/modules/entry/front/card/index.js +++ b/modules/entry/front/card/index.js @@ -11,11 +11,34 @@ class Controller extends ModuleCard { fields: ['id', 'code'] } }, { - relation: 'travel' + relation: 'travel', + scope: { + fields: ['id', 'landed', 'agencyFk', 'warehouseOutFk'], + include: [ + { + relation: 'agency', + scope: { + fields: ['name'] + } + }, + { + relation: 'warehouseOut', + scope: { + fields: ['name'] + } + }, + { + relation: 'warehouseIn', + scope: { + fields: ['name'] + } + } + ] + } }, { relation: 'supplier', scope: { - fields: ['id', 'name'] + fields: ['id', 'nickname'] } }, { relation: 'currency' @@ -27,7 +50,7 @@ class Controller extends ModuleCard { } } -ngModule.component('vnEntry Card', { +ngModule.component('vnEntryCard', { template: require('./index.html'), controller: Controller }); diff --git a/modules/entry/front/descriptor/index.html b/modules/entry/front/descriptor/index.html index 372479c799..5cb655dc3f 100644 --- a/modules/entry/front/descriptor/index.html +++ b/modules/entry/front/descriptor/index.html @@ -13,9 +13,21 @@ - + + + + + + + + + diff --git a/modules/entry/front/descriptor/index.js b/modules/entry/front/descriptor/index.js index a9f5cd6796..e3c00f9ad4 100644 --- a/modules/entry/front/descriptor/index.js +++ b/modules/entry/front/descriptor/index.js @@ -4,6 +4,48 @@ class Controller { constructor($scope) { this.$ = $scope; } + get entry() { + return this._entry; + } + + set entry(value) { + this._entry = value; + if (!value) return; + + const date = value.travel.landed; + let to = new Date(date); + let from = new Date(date); + to.setDate(to.getDate() + 10); + + to.setHours(0, 0, 0, 0); + + from.setDate(from.getDate() - 10); + from.setHours(0, 0, 0, 0); + + let links = { + btnOne: { + icon: 'local_airport', + state: `travel.index({q: '{"agencyFk": ${value.travel.agencyFk}}'})`, + tooltip: 'All travels with current agency' + }}; + + links.btnTwo = { + icon: 'icon-entry', + state: `entry.index({q: '{"supplierFk": ${value.supplierFk}, "to": "${to}", "from": "${from}"}'})`, + tooltip: 'All entries with current supplier' + }; + + + this._quicklinks = links; + } + + get quicklinks() { + return this._quicklinks; + } + + set quicklinks(value = {}) { + this._quicklinks = Object.assign(value, this._quicklinks); + } } Controller.$inject = ['$scope']; diff --git a/modules/entry/front/descriptor/locale/es.yml b/modules/entry/front/descriptor/locale/es.yml index e5b926f1df..6789a1281f 100644 --- a/modules/entry/front/descriptor/locale/es.yml +++ b/modules/entry/front/descriptor/locale/es.yml @@ -1 +1,3 @@ Reference: Referencia +All travels with current agency: Todos los envios con la agencia actual +All entries with current supplier: Todas las entradas con el proveedor actual \ No newline at end of file diff --git a/modules/entry/front/index/index.html b/modules/entry/front/index/index.html index f0f5404899..60bbe46d54 100644 --- a/modules/entry/front/index/index.html +++ b/modules/entry/front/index/index.html @@ -16,7 +16,7 @@ - + Id Landed Reference @@ -33,18 +33,18 @@ - + + icon="icon-anonymous"> + icon="icon-net"> {{::entry.id}} diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html index 5397c72ca2..771eaaf7ab 100644 --- a/modules/entry/front/summary/index.html +++ b/modules/entry/front/summary/index.html @@ -1,140 +1,68 @@ -
{{$ctrl.travelData.id}} - {{$ctrl.travelData.ref}}
+
Entrada #{{$ctrl.entryData.id}} - {{$ctrl.entryData.supplier.nickname}}
- + - + - - - - - + - + - - + + + value="{{$ctrl.entryData.travel.agency.name}}"> - + - + - + + + - -

Entries

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

Thermographs

- - - - Code - Temperature - State - Destination - Created - - - - - {{thermograph.thermographFk}} - {{thermograph.temperature}} - {{thermograph.result}} - {{thermograph.warehouse.name}} - {{thermograph.created | date: 'dd/MM/yyyy'}} - - - -
+ + + + + + + + + + + + + +
- - - - \ No newline at end of file diff --git a/modules/entry/front/summary/index.js b/modules/entry/front/summary/index.js index be17feb29b..260715490f 100644 --- a/modules/entry/front/summary/index.js +++ b/modules/entry/front/summary/index.js @@ -5,7 +5,6 @@ import Component from 'core/lib/component'; class Controller extends Component { constructor($element, $, $httpParamSerializer) { super($element, $); - this.entries = []; this.$httpParamSerializer = $httpParamSerializer; } @@ -16,33 +15,15 @@ class Controller extends Component { set entry(value) { this._entry = value; - // if (value && value.id) { - // this.getTravel(); - // this.getEntries(); - // this.getThermographs(); - // } + if (value && value.id) + this.getEntry(); } - // getTravel() { - // return this.$http.get(`/api/Travels/${this.travel.id}/getTravel`).then(response => { - // this.travelData = response.data; - // }); - // } - - // getEntries() { - // return this.$http.get(`/api/Travels/${this.travel.id}/getEntries`).then(response => { - // this.entries = response.data; - // }); - // } - - // total(field) { - // let total = 0; - - // for (let entry of this.entries) - // total += entry[field]; - - // return total; - // } + getEntry() { + return this.$http.get(`/api/Entries/${this.entry.id}/getEntry`).then(response => { + this.entryData = response.data; + }); + } } Controller.$inject = ['$element', '$scope', '$httpParamSerializer']; diff --git a/modules/entry/front/summary/index.spec.js b/modules/entry/front/summary/index.spec.js index 5411d8a0d3..9a8971b52f 100644 --- a/modules/entry/front/summary/index.spec.js +++ b/modules/entry/front/summary/index.spec.js @@ -1,108 +1,48 @@ import './index'; -describe('component vnTravelSummary', () => { +describe('component vnEntrySummary', () => { let controller; let $httpBackend; let $scope; let $element; - let $httpParamSerializer; - beforeEach(angular.mock.module('travel', $translateProvider => { + beforeEach(angular.mock.module('entry', $translateProvider => { $translateProvider.translations('en', {}); })); beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; $scope = $rootScope.$new(); - $element = angular.element(``); - controller = $componentController('vnTravelSummary', {$element, $scope}); + $element = angular.element(``); + controller = $componentController('vnEntrySummary', {$element, $scope}); })); - describe('travel setter/getter', () => { - it('should return the travel', () => { - controller.travel = {id: null}; + describe('entry setter/getter', () => { + it('should return the entry', () => { + controller.entry = {id: 1}; - expect(controller.travel).toEqual(jasmine.any(Object)); + expect(controller.entry).toEqual(jasmine.any(Object)); }); - it('should return the travel and then call both getTravel() and getEntries()', () => { - spyOn(controller, 'getTravel'); - spyOn(controller, 'getEntries'); - spyOn(controller, 'getThermographs'); - controller.travel = {id: 99}; + it('should return the entry and then call getEntry()', () => { + spyOn(controller, 'getEntry'); + controller.entry = {id: 99}; - - expect(controller._travel.id).toEqual(99); - expect(controller.getTravel).toHaveBeenCalledWith(); - expect(controller.getEntries).toHaveBeenCalledWith(); - expect(controller.getThermographs).toHaveBeenCalledWith(); + expect(controller._entry.id).toEqual(99); + expect(controller.getEntry).toHaveBeenCalledWith(); }); }); - describe('getTravel()', () => { + describe('getEntry()', () => { it('should perform a get and then store data on the controller', () => { - controller._travel = {id: 999}; + controller._entry = {id: 999}; - const query = `/api/Travels/${controller._travel.id}/getTravel`; - $httpBackend.expectGET(query).respond('I am the travelData'); - controller.getTravel(); + const query = `/api/Entries/${controller._entry.id}/getEntry`; + $httpBackend.expectGET(query).respond('I am the entryData'); + controller.getEntry(); $httpBackend.flush(); - expect(controller.travelData).toEqual('I am the travelData'); - }); - }); - - describe('getEntries()', () => { - it('should call the getEntries method to get the entries data', () => { - controller._travel = {id: 999}; - - const query = `/api/Travels/${controller._travel.id}/getEntries`; - $httpBackend.expectGET(query).respond('I am the entries'); - controller.getEntries(); - $httpBackend.flush(); - - expect(controller.entries).toEqual('I am the entries'); - }); - }); - - describe('getThermographs()', () => { - it('should call the getThermographs method to get the thermographs', () => { - controller._travel = {id: 2}; - const params = { - filter: { - include: { - relation: 'warehouse', - scope: { - fields: ['id', 'name'] - } - }, - where: { - travelFk: controller._travel.id - } - } - }; - const serializedParams = $httpParamSerializer(params); - const query = `TravelThermographs?${serializedParams}`; - $httpBackend.expectGET(query).respond('I am the thermographs'); - controller.getThermographs(); - $httpBackend.flush(); - - expect(controller.travelThermographs).toEqual('I am the thermographs'); - }); - }); - - describe('total()', () => { - it('should calculate the total amount of a given property for every row', () => { - controller.entries = [ - {id: 1, freightValue: 1, packageValue: 2, cc: 0.01}, - {id: 2, freightValue: 1, packageValue: 2, cc: 0.01}, - {id: 3, freightValue: 1, packageValue: 2, cc: 0.01} - ]; - - expect(controller.total('freightValue')).toEqual(3); - expect(controller.total('packageValue')).toEqual(6); - expect(controller.total('cc')).toEqual(0.03); + expect(controller.entryData).toEqual('I am the entryData'); }); }); }); diff --git a/modules/entry/front/summary/locale/es.yml b/modules/entry/front/summary/locale/es.yml index e69de29bb2..528c388303 100644 --- a/modules/entry/front/summary/locale/es.yml +++ b/modules/entry/front/summary/locale/es.yml @@ -0,0 +1,2 @@ +Inventory: Inventario +Virtual: Redada \ No newline at end of file diff --git a/modules/entry/front/summary/style.scss b/modules/entry/front/summary/style.scss index 922b36ad8f..8887e15b92 100644 --- a/modules/entry/front/summary/style.scss +++ b/modules/entry/front/summary/style.scss @@ -1,7 +1,7 @@ @import "variables"; -vn-travel-summary .summary { +vn-entry-summary .summary { max-width: $width-lg; vn-icon[icon=insert_drive_file]{ From 0a4adedcdb123cf84c932acfe6388102093b5f15 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Mon, 24 Feb 2020 09:47:26 +0100 Subject: [PATCH 05/10] client descriptor translates --- modules/client/front/descriptor/index.html | 4 ++-- modules/client/front/descriptor/locale/es.yml | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html index 30777bcda1..b5673b7832 100644 --- a/modules/client/front/descriptor/index.html +++ b/modules/client/front/descriptor/index.html @@ -83,7 +83,7 @@ vn-id="from" vn-one ng-model="$ctrl.from" - label="From hour" + label="date" vn-focus>
@@ -93,7 +93,7 @@ vn-id="to" vn-one ng-model="$ctrl.to" - label="To date"> + label="date"> diff --git a/modules/client/front/descriptor/locale/es.yml b/modules/client/front/descriptor/locale/es.yml index 293191ec59..cf8d32b1a4 100644 --- a/modules/client/front/descriptor/locale/es.yml +++ b/modules/client/front/descriptor/locale/es.yml @@ -1,2 +1,5 @@ Simple ticket: Ticket simple -Send consumer report: Enviar informe de consumo \ No newline at end of file +Send consumer report: Enviar informe de consumo +From date: Fecha desde +To date: Fecha hasta +date: fecha \ No newline at end of file From 832089de790ff1f753fbc2e905bab456731e12fb Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Mon, 24 Feb 2020 12:20:53 +0100 Subject: [PATCH 06/10] entry descriptor, add more options to view entry report --- modules/entry/front/descriptor/index.html | 11 +++++- modules/entry/front/descriptor/index.js | 30 ++++++++++++++--- modules/entry/front/descriptor/index.spec.js | 35 ++++++++++++++++++++ modules/entry/front/descriptor/locale/es.yml | 3 +- 4 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 modules/entry/front/descriptor/index.spec.js diff --git a/modules/entry/front/descriptor/index.html b/modules/entry/front/descriptor/index.html index 5cb655dc3f..cd4057c43a 100644 --- a/modules/entry/front/descriptor/index.html +++ b/modules/entry/front/descriptor/index.html @@ -6,7 +6,16 @@ - + +
diff --git a/modules/entry/front/descriptor/index.js b/modules/entry/front/descriptor/index.js index e3c00f9ad4..2c8ec9adeb 100644 --- a/modules/entry/front/descriptor/index.js +++ b/modules/entry/front/descriptor/index.js @@ -1,9 +1,20 @@ import ngModule from '../module'; +import Component from 'core/lib/component'; -class Controller { - constructor($scope) { - this.$ = $scope; +class Controller extends Component { + constructor($element, $, $httpParamSerializer, vnConfig) { + super($element, $); + this.vnConfig = vnConfig; + this.$httpParamSerializer = $httpParamSerializer; + this.moreOptions = [ + {name: 'Show entry report', callback: this.showEntryReport} + ]; } + + onMoreChange(callback) { + callback.call(this); + } + get entry() { return this._entry; } @@ -35,7 +46,6 @@ class Controller { tooltip: 'All entries with current supplier' }; - this._quicklinks = links; } @@ -46,9 +56,19 @@ class Controller { set quicklinks(value = {}) { this._quicklinks = Object.assign(value, this._quicklinks); } + + showEntryReport() { + const params = { + clientId: this.vnConfig.storage.currentUserWorkerId, + entryId: this.entry.id + }; + const serializedParams = this.$httpParamSerializer(params); + let url = `api/report/entry-order?${serializedParams}`; + window.open(url); + } } -Controller.$inject = ['$scope']; +Controller.$inject = ['$element', '$scope', '$httpParamSerializer', 'vnConfig']; ngModule.component('vnEntryDescriptor', { template: require('./index.html'), diff --git a/modules/entry/front/descriptor/index.spec.js b/modules/entry/front/descriptor/index.spec.js new file mode 100644 index 0000000000..a63abc0f1b --- /dev/null +++ b/modules/entry/front/descriptor/index.spec.js @@ -0,0 +1,35 @@ +import './index.js'; + +describe('Entry Component vnEntryDescriptor', () => { + let $httpParamSerializer; + let controller; + let $element; + + beforeEach(ngModule('entry')); + + beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope, _$httpParamSerializer_) => { + $httpParamSerializer = _$httpParamSerializer_; + $element = angular.element(``); + controller = $componentController('vnEntryDescriptor', {$element}); + controller._entry = {id: 2}; + controller.vnConfig.storage = {currentUserWorkerId: 9}; + controller.cardReload = ()=> { + return true; + }; + })); + + describe('showEntryReport()', () => { + it('should open a new window showing a delivery note PDF document', () => { + const params = { + clientId: controller.vnConfig.storage.currentUserWorkerId, + entryId: controller.entry.id + }; + const serializedParams = $httpParamSerializer(params); + let expectedPath = `api/report/entry-order?${serializedParams}`; + spyOn(window, 'open'); + controller.showEntryReport(); + + expect(window.open).toHaveBeenCalledWith(expectedPath); + }); + }); +}); diff --git a/modules/entry/front/descriptor/locale/es.yml b/modules/entry/front/descriptor/locale/es.yml index 6789a1281f..5e1eb25c2d 100644 --- a/modules/entry/front/descriptor/locale/es.yml +++ b/modules/entry/front/descriptor/locale/es.yml @@ -1,3 +1,4 @@ Reference: Referencia All travels with current agency: Todos los envios con la agencia actual -All entries with current supplier: Todas las entradas con el proveedor actual \ No newline at end of file +All entries with current supplier: Todas las entradas con el proveedor actual +Show entry report: Ver informe del pedido \ No newline at end of file From 843f13276a820cd01a5a9db9e75ac794f77659bb Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Mon, 24 Feb 2020 14:34:36 +0100 Subject: [PATCH 07/10] entry summary e2e --- e2e/helpers/selectors.js | 5 ++++ e2e/paths/12-entry/01_summary.spec.js | 43 +++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 e2e/paths/12-entry/01_summary.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 873e7c0b5d..0e36fbcb66 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -799,5 +799,10 @@ export default { inflation: 'vn-zone-basic-data vn-input-number[ng-model="$ctrl.zone.inflation"]', volumetric: 'vn-zone-basic-data vn-check[ng-model="$ctrl.zone.isVolumetric"]', saveButton: 'vn-zone-basic-data vn-submit > button', + }, + entrySummary: { + header: 'vn-entry-summary > vn-card > h5', + reference: 'vn-entry-summary vn-label-value[label="Reference"]', + confirmed: 'vn-entry-summary vn-check[label="Confirmed"]', } }; diff --git a/e2e/paths/12-entry/01_summary.spec.js b/e2e/paths/12-entry/01_summary.spec.js new file mode 100644 index 0000000000..39b12b8402 --- /dev/null +++ b/e2e/paths/12-entry/01_summary.spec.js @@ -0,0 +1,43 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Entry summary path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('buyer', 'entry'); + await page.waitToClick('vn-entry-index vn-tbody > a:nth-child(2)'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the second entry summary section', async() => { + let url = await page.expectURL('#!/entry/2/summary'); + + expect(url).toBe(true); + }); + + it(`should display details from the entry on the header`, async() => { + await page.waitForTextInElement(selectors.entrySummary.header, 'The king'); + const result = await page.waitToGetProperty(selectors.entrySummary.header, 'innerText'); + + expect(result).toContain('The king'); + }); + + it('should display some entry details like the reference', async() => { + const result = await page.waitToGetProperty(selectors.entrySummary.reference, 'innerText'); + + expect(result).toContain('Movement 2'); + }); + + it('should display other entry details like the confirmed', async() => { + const result = await page.checkboxState(selectors.entrySummary.confirmed, 'innerText'); + + expect(result).toContain('unchecked'); + }); +}); From e7cdc58fad540f107f8cadc7be405dd8cd2a6e12 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Tue, 25 Feb 2020 07:51:16 +0100 Subject: [PATCH 08/10] translates --- modules/client/front/descriptor/index.html | 9 +++------ modules/client/front/descriptor/locale/es.yml | 3 +-- modules/entry/front/descriptor/index.js | 3 ++- modules/entry/front/summary/index.html | 2 +- modules/entry/front/summary/locale/es.yml | 3 ++- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html index b5673b7832..d8e035942e 100644 --- a/modules/client/front/descriptor/index.html +++ b/modules/client/front/descriptor/index.html @@ -77,23 +77,20 @@
- From date + Send consumer report
-
- To date -
+ label="To date">
diff --git a/modules/client/front/descriptor/locale/es.yml b/modules/client/front/descriptor/locale/es.yml index cf8d32b1a4..88720ab444 100644 --- a/modules/client/front/descriptor/locale/es.yml +++ b/modules/client/front/descriptor/locale/es.yml @@ -1,5 +1,4 @@ Simple ticket: Ticket simple Send consumer report: Enviar informe de consumo From date: Fecha desde -To date: Fecha hasta -date: fecha \ No newline at end of file +To date: Fecha hasta \ No newline at end of file diff --git a/modules/entry/front/descriptor/index.js b/modules/entry/front/descriptor/index.js index 2c8ec9adeb..8f51308f29 100644 --- a/modules/entry/front/descriptor/index.js +++ b/modules/entry/front/descriptor/index.js @@ -73,7 +73,8 @@ Controller.$inject = ['$element', '$scope', '$httpParamSerializer', 'vnConfig']; ngModule.component('vnEntryDescriptor', { template: require('./index.html'), bindings: { - entry: '<' + entry: '<', + quicklinks: '<' }, require: { card: '^?vnEntryCard' diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html index 771eaaf7ab..af9eae30cf 100644 --- a/modules/entry/front/summary/index.html +++ b/modules/entry/front/summary/index.html @@ -1,5 +1,5 @@ -
Entrada #{{$ctrl.entryData.id}} - {{$ctrl.entryData.supplier.nickname}}
+
Entry #{{$ctrl.entryData.id}} - {{$ctrl.entryData.supplier.nickname}}
Date: Tue, 25 Feb 2020 10:39:21 +0100 Subject: [PATCH 09/10] fix test --- modules/client/front/balance/index/index.spec.js | 6 ------ .../back/methods/entry/specs/getEntry.spec.js | 2 +- modules/entry/front/summary/index.js | 4 ++-- modules/entry/front/summary/index.spec.js | 16 +++++++++------- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/modules/client/front/balance/index/index.spec.js b/modules/client/front/balance/index/index.spec.js index e10f903d03..e044b7979e 100644 --- a/modules/client/front/balance/index/index.spec.js +++ b/modules/client/front/balance/index/index.spec.js @@ -44,12 +44,6 @@ describe('Client', () => { }); describe('company setter/getter', () => { - it('should return the company', () => { - controller.companyId = null; - - expect(controller._companyId).toEqual(jasmine.any(Object)); - }); - it('should return the company and then call getData()', () => { spyOn(controller, 'getData'); controller.companyId = 442; diff --git a/modules/entry/back/methods/entry/specs/getEntry.spec.js b/modules/entry/back/methods/entry/specs/getEntry.spec.js index 4baf64543f..3791a3703d 100644 --- a/modules/entry/back/methods/entry/specs/getEntry.spec.js +++ b/modules/entry/back/methods/entry/specs/getEntry.spec.js @@ -5,7 +5,7 @@ describe('travel getEntry()', () => { it('should check the entry contains the id', async() => { const entry = await app.models.Entry.getEntry(entryId); - expect(entry.id).toEqual(1); + expect(entry.id).toEqual(entryId); }); it('should check the entry contains the supplier name', async() => { diff --git a/modules/entry/front/summary/index.js b/modules/entry/front/summary/index.js index 260715490f..3b26907d71 100644 --- a/modules/entry/front/summary/index.js +++ b/modules/entry/front/summary/index.js @@ -16,10 +16,10 @@ class Controller extends Component { this._entry = value; if (value && value.id) - this.getEntry(); + this.getEntryData(); } - getEntry() { + getEntryData() { return this.$http.get(`/api/Entries/${this.entry.id}/getEntry`).then(response => { this.entryData = response.data; }); diff --git a/modules/entry/front/summary/index.spec.js b/modules/entry/front/summary/index.spec.js index 9a8971b52f..ea4a5a7c11 100644 --- a/modules/entry/front/summary/index.spec.js +++ b/modules/entry/front/summary/index.spec.js @@ -18,28 +18,30 @@ describe('component vnEntrySummary', () => { })); describe('entry setter/getter', () => { - it('should return the entry', () => { + it('should check if value.id is defined', () => { + spyOn(controller, 'getEntryData'); + controller.entry = {id: 1}; - expect(controller.entry).toEqual(jasmine.any(Object)); + expect(controller.getEntryData).toHaveBeenCalledWith(); }); - it('should return the entry and then call getEntry()', () => { - spyOn(controller, 'getEntry'); + it('should return the entry and then call getEntryData()', () => { + spyOn(controller, 'getEntryData'); controller.entry = {id: 99}; expect(controller._entry.id).toEqual(99); - expect(controller.getEntry).toHaveBeenCalledWith(); + expect(controller.getEntryData).toHaveBeenCalledWith(); }); }); - describe('getEntry()', () => { + describe('getEntryData()', () => { it('should perform a get and then store data on the controller', () => { controller._entry = {id: 999}; const query = `/api/Entries/${controller._entry.id}/getEntry`; $httpBackend.expectGET(query).respond('I am the entryData'); - controller.getEntry(); + controller.getEntryData(); $httpBackend.flush(); expect(controller.entryData).toEqual('I am the entryData'); From bbba294b7976bb5fe04864925b6e4b0c6f6548bb Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Tue, 25 Feb 2020 11:44:46 +0100 Subject: [PATCH 10/10] fix test --- modules/travel/front/summary/index.spec.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/modules/travel/front/summary/index.spec.js b/modules/travel/front/summary/index.spec.js index 5411d8a0d3..593d2cfcc7 100644 --- a/modules/travel/front/summary/index.spec.js +++ b/modules/travel/front/summary/index.spec.js @@ -20,12 +20,6 @@ describe('component vnTravelSummary', () => { })); describe('travel setter/getter', () => { - it('should return the travel', () => { - controller.travel = {id: null}; - - expect(controller.travel).toEqual(jasmine.any(Object)); - }); - it('should return the travel and then call both getTravel() and getEntries()', () => { spyOn(controller, 'getTravel'); spyOn(controller, 'getEntries');